/* =========================================================================
   amishow — design system
   Plain CSS, no build step. Internal ops/telephony control panel.
   ========================================================================= */

:root {
  /* Palette: neutral gray/white base + one primary accent + status colors */
  --color-bg: #f3f4f6;
  --color-surface: #ffffff;
  --color-surface-alt: #f9fafb;
  --color-border: #e3e5ea;
  --color-border-strong: #d1d5db;

  --color-text: #1f2430;
  --color-text-muted: #6b7280;
  --color-text-faint: #9ca3af;

  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-bg: #eff6ff;
  --color-primary-border: #bfdbfe;

  --color-success: #16a34a;
  --color-success-hover: #15803d;
  --color-success-bg: #f0fdf4;
  --color-success-border: #bbf7d0;

  --color-danger: #dc2626;
  --color-danger-hover: #b91c1c;
  --color-danger-bg: #fef2f2;
  --color-danger-border: #fecaca;

  --color-warning: #b45309;
  --color-warning-bg: #fffbeb;
  --color-warning-border: #fde68a;

  --color-muted-bg: #f3f4f6;
  --color-muted-border: #e5e7eb;

  --color-gw-a-tint: #f7faff;
  --color-gw-b-tint: #fdf9f2;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, .08);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0 0 var(--space-2); font-weight: 600; color: var(--color-text); }
h1 { font-size: 1.375rem; }
h2 { font-size: 1.0625rem; }
h3 { font-size: 0.9375rem; }

p { margin: 0 0 var(--space-3); color: var(--color-text-muted); }

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
  background: var(--color-muted-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
  font-size: 0.85em;
}

/* ---- Top navigation ---------------------------------------------------- */

.topbar {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--space-5);
  height: 56px;
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

.brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--color-text);
  letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }

.topnav {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: 1;
  min-width: 0; /* let this flex item shrink below its content's natural width so
                   .topnav-links (not the whole page) becomes the scroll container */
}

/* Primary nav links live in their own scrollable strip so that on narrow
   viewports (where Dashboard + ANI Table + Gateways don't all fit) THIS
   scrolls horizontally instead of the page. Logout stays outside of it so
   it's always reachable without scrolling the nav. */
.topnav-links {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.topnav a {
  color: var(--color-text-muted);
  font-weight: 500;
  font-size: 0.875rem;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  flex: 0 0 auto;
}

.topnav a:hover {
  background: var(--color-surface-alt);
  text-decoration: none;
  color: var(--color-text);
}

.topnav a.is-active {
  background: var(--color-primary-bg);
  color: var(--color-primary);
}

.topnav-logout {
  margin-left: auto;
}

/* Logout is a POST form (CSRF-protected); make its button read as a nav link. */
.topnav-logout-form {
  margin: 0;
  display: inline-flex;
}
button.topnav-logout {
  color: var(--color-text-muted);
  font-weight: 500;
  font-size: 0.875rem;
  padding: var(--space-2) var(--space-3);
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  cursor: pointer;
  font-family: inherit;
}
button.topnav-logout:hover {
  background: var(--color-surface-alt);
  color: var(--color-text);
}

/* ---- Page layout -------------------------------------------------------- */

.page {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-5);
}

.page-narrow {
  max-width: 720px;
  margin: 0 auto;
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
}

.card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.card-header h2 { margin: 0; }

.section-hint {
  color: var(--color-text-muted);
  font-size: 0.8125rem;
  margin: 0 0 var(--space-3);
}

hr.divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-5) 0;
}

/* ---- Buttons -------------------------------------------------------------
   Restrained palette: primary (blue) for default actions, success (green)
   for Call, danger (red) for Hangup/destructive actions, ghost for neutral.
   ---------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.2;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color .12s ease, border-color .12s ease, box-shadow .12s ease;
  white-space: nowrap;
}

.btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}
.btn-primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); }

.btn-success {
  background: var(--color-success);
  border-color: var(--color-success);
  color: #fff;
}
.btn-success:hover { background: var(--color-success-hover); border-color: var(--color-success-hover); }

.btn-danger {
  background: #fff;
  border-color: var(--color-danger-border);
  color: var(--color-danger);
}
.btn-danger:hover { background: var(--color-danger); border-color: var(--color-danger); color: #fff; }

.btn-ghost {
  background: var(--color-surface);
  border-color: var(--color-border-strong);
  color: var(--color-text);
}
.btn-ghost:hover { background: var(--color-surface-alt); }

.btn-sm { padding: 5px 10px; font-size: 0.75rem; }
.btn-block { width: 100%; }

/* ---- Form controls -------------------------------------------------------- */

label {
  display: inline-block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-1);
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="file"],
select,
textarea {
  font-family: inherit;
  font-size: 0.8125rem;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  padding: 7px 9px;
  transition: border-color .12s ease, box-shadow .12s ease;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-bg);
}

input::placeholder { color: var(--color-text-faint); }

textarea { font-family: "SFMono-Regular", Consolas, Menlo, monospace; resize: vertical; }

.field-row {
  display: flex;
  align-items: flex-end;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-3);
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

/* ---- Login page ---------------------------------------------------------- */

body.login-body .page {
  padding: 0;
}

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #eef1f6 0%, #f3f4f6 100%);
  padding: var(--space-5);
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-6) var(--space-5);
}

.login-brand {
  text-align: center;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--color-text);
  margin-bottom: var(--space-1);
}

.login-subtitle {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.8125rem;
  margin-bottom: var(--space-5);
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.login-error {
  background: var(--color-danger-bg);
  border: 1px solid var(--color-danger-border);
  color: var(--color-danger);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  font-size: 0.8125rem;
  margin-bottom: var(--space-3);
}

/* ---- Status summary strip ------------------------------------------------- */

.stat-strip {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  flex-wrap: wrap;
}

.stat-tile {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-tile .stat-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--color-text-faint);
}

.stat-tile .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text);
}

.stat-tile .stat-sub {
  font-size: 0.6875rem;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

/* Gateway link status dot (dashboard). */
.gw-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
  background: var(--color-text-faint);
}
.gw-dot-ok  { background: var(--color-success, #1a7f3c); box-shadow: 0 0 0 3px var(--color-success-bg, #e6f7ec); }
.gw-dot-bad { background: var(--color-danger,  #c0392b); box-shadow: 0 0 0 3px var(--color-danger-bg,  #fdecea); }
.gw-dot-amber { background: var(--color-warning, #b45309); box-shadow: 0 0 0 3px var(--color-warning-bg, #fffbeb); }
.gw-dot-unknown { background: var(--color-text-faint); }

/* Security tile label links through to the audit log. */
.stat-link { color: inherit; }
.stat-link:hover { color: var(--color-primary); }
.stat-tile .stat-value:has(.gw-dot) { font-size: 1.05rem; display: flex; align-items: center; }

/* ---- Generic data table (active calls, etc.) ------------------------------ */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

table.data-table th,
table.data-table td {
  padding: var(--space-2) var(--space-3);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

table.data-table th {
  background: var(--color-surface-alt);
  font-weight: 600;
  color: var(--color-text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}

table.data-table tbody tr:last-child td { border-bottom: none; }
table.data-table tbody tr:hover { background: var(--color-surface-alt); }

.empty-state {
  color: var(--color-text-faint);
  font-size: 0.8125rem;
  padding: var(--space-3);
  text-align: center;
}

/* ---- Audit log table ------------------------------------------------------ */
td.audit-time {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--color-text-muted);
}
.audit-event {
  font-weight: 600;
  font-size: 0.75rem;
}
td.audit-detail {
  font-family: "SFMono-Regular", Consolas, Menlo, monospace;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  white-space: normal;      /* let long detail wrap instead of forcing scroll */
  word-break: break-word;
  max-width: 640px;
}
.audit-toolbar { align-items: flex-end; }
.audit-count {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}
/* Severity tint: blocked attempts amber, errors/auth-failures red. Set on the
   cells directly so it survives the row-hover background. */
table.data-table tbody tr.audit-warn td { background: var(--color-warning-bg); }
table.data-table tbody tr.audit-danger td { background: var(--color-danger-bg); }

/* ---- Dial panel (64-row manual dial table) -------------------------------- */

.dial-table-wrap {
  /* Any non-visible overflow value on EITHER axis makes an element a "scroll
     container" and thus the containing block for position:sticky descendants
     — overflow-x: auto alone was already enough to make this wrapper (not
     the page) the sticky context for thead th below, so its `top: 56px`
     (meant to clear the page's fixed navbar) instead measured 56px from this
     wrapper's own top edge, landing the header on top of the section-divider
     row and row 1. Fix: lean into it — make this a proper bounded,
     internally-scrolling table (same pattern as .ani-grid-wrap) so the
     sticky header is relative to *this* box on purpose, top: 0. */
  overflow: auto;
  max-height: 70vh;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

table.dial-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

table.dial-table thead th {
  position: sticky;
  top: 0;
  background: var(--color-surface-alt);
  border-bottom: 1px solid var(--color-border-strong);
  color: var(--color-text-muted);
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: var(--space-2) var(--space-3);
  text-align: left;
  white-space: nowrap;
  z-index: 5;
}

/* This table already lives inside .dial-table-wrap (overflow-x: auto), so it's
   free to be wider than its container and scroll — that's the intended
   pattern. Without nowrap, narrow columns (e.g. Aktif ANI) wrap their text
   instead of the table growing, producing uneven, jagged row heights. */
table.dial-table tbody td {
  padding: 5px var(--space-3);
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
  white-space: nowrap;
}

table.dial-table tbody tr:hover td {
  background: var(--color-primary-bg);
}

table.dial-table .port-label {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--color-text-muted);
  width: 44px;
}

table.dial-table input[type="text"],
table.dial-table select.row-number {
  width: 200px;
  max-width: 100%;
}

/* Rows whose dropdown is showing their active SIM's own DNIS (not the global
   fallback) get a quiet left accent so the operator can tell at a glance. */
table.dial-table select.row-number.row-number-dnis {
  border-left: 3px solid var(--color-success, #1a7f3c);
}

table.dial-table input[type="number"] {
  width: 88px;
}

/* Saved-numbers editor grows to fill the row; the Save button sits beside it. */
.saved-numbers-field {
  flex: 1 1 260px;
  min-width: 220px;
}
.saved-numbers-field textarea {
  width: 100%;
}

table.dial-table .cell-actions {
  display: flex;
  gap: var(--space-2);
  white-space: nowrap;
}

/* Section tint: rows 1-32 = Gateway A (live ANI resolution), rows 33-64 =
   Gateway B (no ANI resolution yet). Subtle background tint keeps the whole
   table scannable without hard borders. */
tr.row-gw-a { background: var(--color-gw-a-tint); }
tr.row-gw-a:hover td { background: var(--color-primary-bg); }

tr.row-gw-b { background: var(--color-gw-b-tint); }
tr.row-gw-b:hover td { background: #fdf2e3; }

tr.section-divider td {
  background: var(--color-surface-alt);
  border-top: 2px solid var(--color-border-strong);
  border-bottom: 1px solid var(--color-border-strong);
  padding: var(--space-2) var(--space-3);
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--color-text-muted);
}

/* ANI status text — color-coded by state (set via JS classList in
   fetchPortStatusSummary): muted gray = no SIM, amber = SIM but no ANI
   mapped, green = a real resolved number. */
.ani-status {
  display: inline-block;
  font-weight: 600;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--color-muted-bg);
  color: var(--color-text-faint);
  white-space: nowrap;
}

.ani-status.ani-ok {
  background: var(--color-success-bg);
  color: var(--color-success-hover);
}

.ani-status.ani-warn {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.ani-status.ani-muted {
  background: var(--color-muted-bg);
  color: var(--color-text-faint);
}

.countdown {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--color-text-muted);
  font-size: 0.8125rem;
}

/* ---- ANI table (32 x 16 grid) ---------------------------------------------- */

.ani-grid-wrap {
  overflow: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  max-height: 78vh;
}

table.ani-grid {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.75rem;
}

table.ani-grid th,
table.ani-grid td {
  border-right: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  padding: 2px;
  text-align: center;
  white-space: nowrap;
}

table.ani-grid thead th {
  position: sticky;
  top: 0;
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
  font-weight: 700;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  padding: var(--space-2) 6px;
  z-index: 3;
}

table.ani-grid th.portcol,
table.ani-grid td.portcol {
  position: sticky;
  left: 0;
  background: var(--color-surface-alt);
  font-weight: 700;
  color: var(--color-text);
  z-index: 2;
  min-width: 48px;
}

table.ani-grid thead th.portcol {
  z-index: 4;
}

table.ani-grid tbody tr:nth-child(even) td:not(.portcol) {
  background: var(--color-surface-alt);
}

table.ani-grid tbody tr:hover td {
  background: var(--color-primary-bg);
}

/* Read-only number cells (live mirror of the gateway's SIM Number Settings). */
table.ani-grid td:not(.portcol) {
  font-variant-numeric: tabular-nums;
  font-size: 0.75rem;
  color: var(--color-text);
  min-width: 92px;
}

/* The SIM slot that is currently active for a port. */
table.ani-grid td.ani-cell-active {
  background: var(--color-success-bg, #e6f7ec) !important;
  color: var(--color-success, #1a7f3c);
  font-weight: 700;
  box-shadow: inset 0 0 0 2px var(--color-success, #1a7f3c);
}

table.ani-grid tbody tr:hover td.portcol {
  background: var(--color-primary-bg);
}

table.ani-grid input[type="text"] {
  /* Sized so 16 slot columns + the port column fit within a ~1200px+ card
     without horizontal scroll on typical desktop widths (was 100px, which
     forced a ~1760px-wide grid and made scrolling unavoidable even on
     desktop). Mobile/narrow viewports still scroll within .ani-grid-wrap —
     that part is fine, this only removes the *unnecessary* desktop scroll. */
  width: 62px;
  padding: 3px 4px;
  font-size: 0.75rem;
  border-color: var(--color-border);
  text-align: center;
}

/* ---- DNIS table (per-SIM destination numbers) ------------------------------ */
/* Reuses .ani-grid-wrap for the sticky-header internal scroll. One row per SIM,
   with the port/slot/ANI pinned on the left and the 10 DNIS inputs wrapping in
   a flex grid so they stay usable at any width. */
.dnis-controls {
  align-items: flex-end;
  gap: var(--space-3);
}

table.dnis-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 0.8125rem;
}

table.dnis-table th,
table.dnis-table td {
  border-right: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-2) 6px;
  text-align: left;
  vertical-align: middle;
}

table.dnis-table thead th {
  position: sticky;
  top: 0;
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
  font-weight: 700;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  z-index: 3;
  white-space: nowrap;
}

table.dnis-table td.portcol {
  font-weight: 700;
  color: var(--color-text);
  text-align: center;
  min-width: 44px;
  font-variant-numeric: tabular-nums;
}

table.dnis-table td.dnis-ani {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
  min-width: 96px;
}

table.dnis-table tbody tr:nth-child(even) td {
  background: var(--color-surface-alt);
}

table.dnis-table tbody tr:hover td {
  background: var(--color-primary-bg);
}

/* The row whose SIM slot is currently the active one for its port. */
table.dnis-table tbody tr.ani-cell-active td.portcol {
  background: var(--color-success-bg, #e6f7ec);
  color: var(--color-success, #1a7f3c);
  box-shadow: inset 2px 0 0 var(--color-success, #1a7f3c);
}

td.dnis-cells {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 320px;
}

input.dnis-in {
  width: 92px;
  padding: 3px 5px;
  font-size: 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm, 4px);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

input.dnis-in:focus {
  outline: none;
  border-color: var(--color-primary, #2563eb);
  box-shadow: 0 0 0 2px var(--color-primary-bg, #e6efff);
}

/* ---- Uploads list ---------------------------------------------------------- */

.file-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.file-list li {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  font-size: 0.8125rem;
}

.file-list li:last-child { border-bottom: none; }
.file-list li:hover { background: var(--color-surface-alt); }

.back-link {
  display: inline-block;
  margin-top: var(--space-4);
  font-size: 0.8125rem;
}

/* ---- Responsive ------------------------------------------------------------
   Fluid widths, flex-wrap on .field-row/.stat-strip, max-width containers,
   and the overflow-x:auto data wrappers (.dial-table-wrap, .ani-grid-wrap,
   .table-wrap) already carry most of the responsive behavior at every width.
   This tightens outer spacing on phones so cards and the scrollable
   tables/grid get a bit more usable width instead of losing it to padding.
   ---------------------------------------------------------------------- */

@media (max-width: 480px) {
  .topbar-inner {
    padding: 0 var(--space-4);
    gap: var(--space-3);
  }

  .page {
    padding: var(--space-4);
  }

  .card {
    padding: var(--space-4);
    margin-bottom: var(--space-4);
  }

  .login-card {
    padding: var(--space-5) var(--space-4);
  }
}

/* ---- Language switch (TR | EN) ----------------------------------------- */
.topnav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}
.topnav-right .topnav-logout {
  margin-left: 0;
}
.lang-switch {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.lang-switch .lang-opt {
  padding: 4px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--color-text-muted);
  border-radius: 0;
}
.lang-switch .lang-opt:hover {
  background: var(--color-surface-alt);
  color: var(--color-text);
}
.lang-switch .lang-opt.is-active {
  background: var(--color-primary);
  color: #fff;
}
.lang-switch .lang-opt.is-active:hover {
  background: var(--color-primary-hover);
  color: #fff;
}
/* login sayfasindaki dil anahtari */
.login-lang {
  display: flex;
  justify-content: center;
  margin-bottom: var(--space-4);
}

/* === Device tabs (dashboard / ANI / DNIS per-gateway panels) === */
.gwtabs { margin-top: 4px; }
.gwtab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: 12px;
}
.gwtab {
  appearance: none;
  border: 1px solid transparent;
  border-bottom: none;
  background: transparent;
  color: var(--color-text-muted);
  font: inherit;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  cursor: pointer;
  margin-bottom: -2px;
  white-space: nowrap;
}
.gwtab:hover { color: var(--color-text); background: var(--color-surface-alt); }
.gwtab.is-active {
  color: var(--color-primary);
  background: var(--color-surface);
  border-color: var(--color-border);
  border-bottom: 2px solid var(--color-surface);
}
.gwtab-panel { display: none; }
.gwtab-panel.is-active { display: block; }

/* === USSD panel === */
.ussd-in { width: 100%; min-width: 120px; }
.ussd-resp { white-space: pre-wrap; word-break: break-word; font-size: 0.9em; display: block; max-width: 48ch; max-height: 7.5em; overflow-y: auto; }
.ussd-line { padding: 1px 0; }
.ussd-line.ussd-sent { color: var(--color-primary); font-weight: 600; }
.ussd-line.ussd-resp { color: var(--color-text); border-bottom: 1px solid var(--color-border); padding-bottom: 3px; margin-bottom: 3px; }
/* A reply whose text changed since the page opened — the answer to a command
   just sent — is highlighted so it stands out from pre-existing stored balances.
   Semi-transparent green works over either theme's background. */
.ussd-line.ussd-fresh { font-weight: 600; background: rgba(34, 197, 94, 0.15); border-left: 3px solid #22c55e; padding-left: 6px; border-radius: 3px; }
/* USSD inline in the dashboard's manual-call rows: keep input + Send on one line
   and cap the reply cell so 32 rows stay scannable (the wrap scrolls sideways). */
.dial-table .cell-ussd { white-space: nowrap; }
.dial-table .cell-ussd .ussd-in { width: 120px; min-width: 100px; display: inline-block; vertical-align: middle; margin-right: 4px; }
.dial-table .ussd-resp { max-width: 36ch; max-height: 5em; }
