:root {
  color-scheme: dark;
  --bg: #090f1e;
  --panel: #151e2e;
  --border: #32435b;
  --text: #f3f7ff;
  --muted: #9eafc4;
  --accent: #63cbff;
  --green: #22c55e;
  --yellow: #f0c638;
  --red: #ef5350;
  --blocked: #8d95a6;
}
* { box-sizing: border-box; }
body {
  margin: 0; font: 14px/1.45 system-ui, Arial, sans-serif;
  background: var(--bg); color: var(--text);
}
header {
  background: var(--panel); padding: 13px 3%;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
a { color: var(--accent); }
main { max-width: 1650px; margin: 22px auto; padding: 0 16px; }
h1 { font-size: 23px; margin: 0 0 16px; }
h2 { font-size: 18px; margin: 0 0 12px; }
.panel {
  padding: 16px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 11px; margin: 16px 0;
}
.stats { display: flex; flex-wrap: wrap; gap: 10px; }
.stats > div {
  min-width: 130px; padding: 12px 15px; border: 1px solid var(--border);
  border-radius: 9px; background: var(--panel);
}
.stats b { display: block; color: var(--accent); font-size: 27px; line-height: 1.3; }
.credit { border-color: #527d68 !important; }
.credit b { color: #80e5ad !important; }
small { display: block; color: var(--muted); margin-top: 7px; font-size: 12px; }
input, select {
  min-width: 0; border: 1px solid var(--border); border-radius: 7px;
  background: #0c1524; color: var(--text); font: inherit; padding: 8px 9px;
}
input[type=number] { min-width: 75px; }
button {
  font: inherit; border: 1px solid #388bb9; border-radius: 7px;
  color: white; background: #145982; padding: 8px 11px; cursor: pointer;
}
button:hover, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid #7be0ff; outline-offset: 1px;
}
.inline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0; }
.inline > input { min-width: 190px; flex: 1; }
.panel .inline label { display: flex; flex-direction: column; gap: 5px; flex: 1; }
.panel .inline label input { width: 100%; min-width: 180px; }
label { display: block; margin: 8px 0; }
.notice {
  background: #51391f; padding: 11px; border: 1px solid #795a2d;
  border-radius: 7px;
}
.action { display: inline-flex; align-items: center; margin: 3px 3px 3px 0; }
.action button { font-size: 12px; padding: 6px 9px; }
.table-wrap { width: 100%; overflow-x: auto; overflow-y: hidden; scrollbar-color: #42556a #101929; }
table { width: 100%; border-collapse: collapse; min-width: 1080px; }
td, th {
  padding: 10px 9px; border-bottom: 1px solid var(--border);
  text-align: left; vertical-align: middle;
}
th { color: #c8d7ea; font-size: 12px; font-weight: 650; white-space: nowrap; }
td { font-size: 13px; }
td input { width: 190px; }
td form button { margin: 0; }
table.compact { min-width: 680px; }
.login { max-width: 420px; margin: 9vh auto; }
.login input, .login button { width: 100%; margin-bottom: 13px; }

.panel-heading {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 12px; margin-bottom: 8px;
}
.panel-heading h2 { margin: 0; }
.status-legend { display: flex; align-items: center; flex-wrap: wrap; gap: 13px; }
.status-legend > span {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--muted); font-size: 11px;
}
.status-dot {
  display: inline-block; flex-shrink: 0; width: 10px; height: 10px;
  border-radius: 50%; background: var(--muted);
}
.status-dot.active { background: var(--green); box-shadow: 0 0 0 2px #22c55e20; }
.status-dot.trial { background: var(--yellow); }
.status-dot.expired { background: var(--red); }
.status-dot.blocked { background: var(--blocked); }
.device-panel { padding: 14px; }
.device-search { margin: 8px 0 11px; }
.device-search input { flex: 0 1 360px; }
.text-link { font-size: 12px; white-space: nowrap; }

.device-table { min-width: 1180px; font-variant-numeric: tabular-nums; table-layout: auto; }
.device-table th { padding: 9px 7px; }
.device-table td { padding: 7px; white-space: nowrap; }
.device-table tbody tr:hover { background: #1b2a40; }
.device-table tbody tr:last-child td { border-bottom: 0; }
.device-table .status-head { width: 28px; text-align: center; font-size: 14px; }
.device-table .status-column { width: 28px; text-align: center; }
.device-table .head-unit { color: var(--muted); font-weight: 400; }
.device-table time { color: #b7c7d9; font-size: 12px; }
.code-column { white-space: nowrap; }
.device-code { color: #eff7ff; font-size: 12px; letter-spacing: .1px; }
.device-id { color: var(--muted); font-size: 10px; margin-left: 5px; }
.status-name { font-size: 12px; }
.owner-column, .license-column, .portal-column, .purchase-column { white-space: nowrap; }
.cell-actions { display: flex; align-items: center; gap: 5px; flex-wrap: nowrap; margin: 0; }
.cell-form { display: inline-flex; align-items: center; margin: 0; }
.cell-actions select { width: 115px; height: 30px; padding: 3px 5px; font-size: 12px; }
.cell-actions input {
  width: 170px; max-width: none; height: 30px;
  padding: 4px 7px; font-size: 12px;
}
.btn-compact {
  display: inline-flex; align-items: center; justify-content: center;
  height: 30px; min-width: 0; padding: 0 8px;
  white-space: nowrap; font-size: 11px; line-height: 1;
}
.btn-positive { background: #176a46; border-color: #389866; }
.btn-warn { background: #6a3030; border-color: #a25656; }
.btn-muted { background: #26344a; border-color: #44556b; }
.purchase-done { color: #86dfab; font-size: 12px; }
.muted { color: var(--muted); font-size: 12px; }
.empty-table { text-align: center; color: var(--muted); padding: 24px !important; }
@media (max-width: 650px) {
  header { padding: 12px; }
  main { padding: 0 10px; }
  .panel { padding: 12px; }
  .stats > div { min-width: 112px; padding: 10px; }
  .status-legend { gap: 8px; }
  .device-panel { padding: 10px; }
}


/* Compact single-row device actions and reseller credit management, revision 2. */
.device-panel .table-wrap,
.reseller-panel .table-wrap { overflow-x: auto; overflow-y: hidden; }
.device-table td,
.reseller-table td { vertical-align: middle; white-space: nowrap; padding: 7px 6px; }
.device-table th,
.reseller-table th { padding: 8px 6px; white-space: nowrap; }
.device-table tbody tr, .reseller-table tbody tr { height: 43px; }
.device-table .cell-actions,
.device-table .cell-form,
.device-table form.owner-form,
.device-table form.portal-form,
.reseller-table .reseller-actions,
.reseller-table .compact-form {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 5px;
  flex-wrap: nowrap;
  vertical-align: middle;
  margin: 0;
  white-space: nowrap;
}
.device-table .cell-actions,
.reseller-table .reseller-actions { display: flex; }
.device-table .cell-form,
.reseller-table .compact-form { flex: 0 0 auto; }
.device-table .owner-form select { height: 29px; width: 106px; padding: 3px 5px; font-size: 11px; }
.device-table .portal-form input { width: 142px; height: 29px; padding: 3px 6px; }
.device-table .btn-compact,
.reseller-table .btn-compact { height: 29px; padding: 0 8px; font-size: 11px; line-height: 1; }
.device-table .device-code { font-size: 12px; }
.device-table .code-column { min-width: 126px; }
.device-table .device-id { font-size: 10px; }
.device-table .license-column { min-width: 78px; }
.device-table .portal-column { min-width: 215px; }
.device-table .owner-column { min-width: 172px; }
.device-table .status-column { width: 24px; }
.device-table .status-head { width: 24px; }
.device-table .status-dot { width: 9px; height: 9px; }
.device-table .status-name { font-size: 11px; }

.reseller-panel { padding: 14px; }
.reseller-panel .panel-heading small { margin: 0; }
.reseller-table { min-width: 980px; width: 100%; table-layout: fixed; font-variant-numeric: tabular-nums; }
.reseller-table col.r-name { width: 18%; }
.reseller-table col.r-count { width: 6.5%; }
.reseller-table col.r-credit { width: 8%; }
.reseller-table col.r-topup { width: 18%; }
.reseller-table col.r-access { width: 43%; }
.reseller-table td { padding-top: 8px; padding-bottom: 8px; }
.reseller-table .reseller-name-cell { overflow: hidden; text-overflow: ellipsis; }
.reseller-table .reseller-name-cell strong { display: block; font-weight: 650; overflow: hidden; text-overflow: ellipsis; }
.reseller-table .reseller-name-cell small { margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reseller-table .cell-number { font-weight: 600; }
.reseller-table .credit-number { color: #80e5ad; font-size: 16px; font-weight: 750; }
.reseller-table .credit-form input[type=number] {
  width: 58px;
  min-width: 58px;
  height: 29px;
  padding: 3px 5px;
  font-size: 12px;
}
.reseller-table .reseller-actions { gap: 8px; width: 100%; }
.reseller-table .account-state {
  display: inline-flex;
  flex: 0 0 75px;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  white-space: nowrap;
}
.reseller-table .account-state .status-dot { width: 9px; height: 9px; }
.reseller-table .password-form { flex: 1 1 auto; min-width: 0; }
.reseller-table .password-form input {
  width: 120px;
  min-width: 100px;
  max-width: 175px;
  height: 29px;
  padding: 3px 7px;
  font-size: 11px;
}
.reseller-table tbody tr:hover { background: #1b2a40; }
.reseller-table tbody tr:last-child td { border-bottom: 0; }
@media(max-width:1150px) {
  .reseller-table { min-width: 1080px; }
}

/* Admin-only device deletion: deliberately separate from routine licence controls. */
.device-table .device-delete { position: relative; display: inline-block; flex: 0 0 auto; }
.device-table .device-delete > summary {
  display: inline-flex; align-items: center; justify-content: center;
  list-style: none; cursor: pointer; user-select: none;
  border: 1px solid #aa5562; color: #ffe5e7; background: #55222b;
}
.device-delete > summary::-webkit-details-marker { display: none; }
.device-delete[open] > summary { border-color: #f19aa7; }
.device-table .delete-device-form {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 10;
  width: 275px; padding: 13px; display: flex; flex-direction: column;
  gap: 8px; border: 1px solid #ab5968; border-radius: 9px;
  background: #18263b; white-space: normal;
  box-shadow: 0 10px 30px #0008;
}
.device-table .delete-device-form label { display: grid; gap: 6px; color: #fff; }
.device-table .delete-device-form input {
  width: 100%; height: 34px; padding: 6px 8px; font-family: monospace;
  letter-spacing: .07em; text-transform: uppercase;
}
.device-table .delete-device-form small {
  display: block; color: #ffd4d8; font-size: 11px; line-height: 1.4; white-space: normal;
}
.device-table .delete-device-form .btn-danger { height: 36px; }
.device-table .btn-danger:hover, .device-table .btn-danger:focus-visible {
  outline: 2px solid #ffc5ca; outline-offset: 2px; background: #833443;
}
