/* ==========================================================
   limaPOS Licensing — Deep Navy admin theme
   Mirrors the desktop app's PyQt6 colour system so brand
   identity stays consistent across surfaces.
   ========================================================== */

/* Secret-field with show/hide toggle (used in admin Settings → M-Pesa).
   The reveal button sits inside the same flex row as the input. */
.field.secret-field {
  position: relative;
}
.field.secret-field input {
  padding-right: 70px;
}
.field.secret-field .reveal-btn {
  position: absolute;
  right: 8px;
  top: calc(50% + 6px);
  transform: translateY(-50%);
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #1e293b;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.field.secret-field .reveal-btn:hover {
  background: #e2e8f0;
}

:root {
  --brand-blue:     #3b82f6;
  --brand-blue-dk:  #1d4ed8;
  --blue-light:     #dbeafe;
  --deep-navy:      #1e3a5f;
  --deep-navy-dk:   #142640;
  --emerald:        #10b981;
  --emerald-dk:     #059669;
  --emerald-light:  #d1fae5;
  --emerald-text:   #065f46;
  --amber:          #f59e0b;
  --amber-light:    #fef3c7;
  --amber-text:     #92400e;
  --red:            #ef4444;
  --red-dk:         #dc2626;
  --red-light:      #fee2e2;
  --red-text:       #991b1b;
  --violet:         #8b5cf6;
  --violet-light:   #ede9fe;
  --violet-text:    #5b21b6;
  --card:           #ffffff;
  --surface:        #f8fafc;
  --border:         #e2e8f0;
  --text-primary:   #1e293b;
  --text-muted:     #64748b;
  --text-soft:      #94a3b8;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               'Helvetica Neue', Arial, sans-serif;
  background: var(--surface);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.45;
}
a { color: var(--brand-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- App shell ----------------------------------------------- */
.app {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--deep-navy);
  color: rgba(255, 255, 255, 0.65);
  padding: 0;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar-logo .dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--brand-blue);
}
.sidebar-logo .wordmark {
  display: flex; flex-direction: column;
}
.sidebar-logo .wordmark .title {
  color: #fff;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.2px;
}
.sidebar-logo .wordmark .subtitle {
  color: rgba(255, 255, 255, 0.45);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.sidebar nav {
  padding: 12px 8px;
  display: flex; flex-direction: column; gap: 2px;
}
.sidebar nav a {
  color: #cfd6e4;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.sidebar nav a.active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-left-color: var(--brand-blue);
}
.sidebar nav .nav-icon {
  width: 18px; height: 18px;
  display: inline-block;
  fill: none; stroke: currentColor;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}

.content {
  display: flex; flex-direction: column;
  overflow-x: hidden;
}

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex; align-items: center; gap: 16px;
}
.topbar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}
.topbar .grow { flex: 1; }
.topbar .user-pill {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9999px;
  padding: 6px 14px;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-muted);
}
.topbar .logout {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 14px;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-primary);
  cursor: pointer;
}
.topbar .logout:hover { background: var(--surface); }

.page {
  padding: 24px 28px;
  display: flex; flex-direction: column; gap: 20px;
}

/* --- Cards / metric tiles ----------------------------------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 22px;
}
.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.2px;
  margin-bottom: 10px;
}
.card .muted {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 4px;
}

.metrics-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
@media (max-width: 1100px) { .metrics-row { grid-template-columns: repeat(2, 1fr); } }
.metric {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.metric .label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  text-transform: uppercase;
}
.metric .value {
  margin-top: 6px;
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
}
.metric .delta {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
}
.metric .strip {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--brand-blue);
}
.metric.emerald .strip  { background: var(--emerald); }
.metric.amber   .strip  { background: var(--amber); }
.metric.red     .strip  { background: var(--red); }
.metric.violet  .strip  { background: var(--violet); }

/* --- Tables ------------------------------------------------- */
.table-card { padding: 0; overflow: hidden; }
.table-head {
  display: flex; align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.table-head .grow { flex: 1; }
.table-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data thead th {
  text-align: left;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface);
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
}
table.data tbody td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: #fafbfc; }
table.data td.right, table.data th.right { text-align: right; }
table.data td.center, table.data th.center { text-align: center; }

/* Editable tables (Plans & Pricing).
   .content hides horizontal overflow, so a table wider than the card is
   clipped with no way to reach the far columns — the scroller has to live
   on a wrapper inside the card. Columns are sized in percentages so the
   table fits without scrolling on a normal desktop. */
.table-scroll { overflow-x: auto; }
table.data.editable { min-width: 880px; }
table.data.editable thead th,
table.data.editable tbody td { padding: 10px 12px; }
table.data.editable input:not([type]),
table.data.editable input[type="text"],
table.data.editable input[type="number"] {
  width: 100%;
  font-family: inherit;
  font-size: 13px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  color: var(--text-primary);
}
table.data.editable input:focus {
  outline: none;
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
table.data.editable td.right input { text-align: right; }
table.data.editable input[type="checkbox"] { width: 16px; height: 16px; }

/* A deactivated plan is still editable — it is kept because live licences
   reference its plan_code — but it must not read as part of the live
   ladder. Dimmed, not hidden. */
table.data.editable tbody tr.inactive td { color: var(--text-soft); }
table.data.editable tbody tr.inactive,
table.data.editable tbody tr.inactive:hover { background: #fbfcfe; }
table.data.editable tbody tr.inactive input:not([type="checkbox"]) {
  background: var(--surface);
  color: var(--text-muted);
}
.pill.off {
  background: #f1f5f9;
  color: var(--text-muted);
  font-size: 10px;
  padding: 2px 8px;
  vertical-align: middle;
}
.empty {
  padding: 36px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* --- Pills / badges ----------------------------------------- */
.pill {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

/* --- Forms --------------------------------------------------- */
form .field {
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: 14px;
}
form .field label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.1px;
}
form .field input,
form .field select,
form .field textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text-primary);
}
form .field input:focus,
form .field select:focus,
form .field textarea:focus {
  outline: none;
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
form .field .hint {
  font-size: 11px;
  color: var(--text-muted);
}
form .row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
form .actions {
  display: flex; gap: 10px;
  justify-content: flex-end;
  margin-top: 14px;
}

/* --- Buttons ------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center; gap: 8px;
  padding: 9px 16px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .12s ease, border-color .12s ease;
  text-decoration: none;
}
.btn.primary {
  background: var(--brand-blue);
  color: #fff;
}
.btn.primary:hover { background: var(--brand-blue-dk); text-decoration: none; }
.btn.secondary {
  background: var(--surface);
  color: var(--deep-navy);
  border-color: var(--border);
}
.btn.secondary:hover { background: var(--blue-light); }
.btn.ghost {
  background: transparent;
  color: var(--brand-blue);
  border-color: var(--brand-blue);
}
.btn.ghost:hover { background: var(--blue-light); }
.btn.danger {
  background: var(--red);
  color: #fff;
}
.btn.danger:hover { background: var(--red-dk); }
.btn.small { padding: 5px 10px; font-size: 12px; }

/* --- Filters strip ------------------------------------------ */
.filters {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
}
.filters label { font-size: 12px; color: var(--text-muted); font-weight: 700; }
.filters input[type="search"],
.filters select {
  font-family: inherit; font-size: 13px;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

/* --- Flash messages ----------------------------------------- */
.flash {
  border-radius: 10px;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 13px;
}
.flash.success { background: var(--emerald-light); color: var(--emerald-text); }
.flash.error   { background: var(--red-light);     color: var(--red-text); }
.flash.info    { background: var(--blue-light);    color: var(--brand-blue-dk); }
.flash.warn    { background: var(--amber-light);   color: var(--amber-text); }

/* --- Login page --------------------------------------------- */
.login-host {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(135deg, var(--deep-navy) 0%, var(--deep-navy-dk) 100%);
}
.login-card {
  width: 380px;
  background: #fff;
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: 0 10px 40px rgba(15, 23, 42, 0.25);
}
.login-card .brand {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 6px;
}
.login-card .brand .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--brand-blue);
}
.login-card .brand .name {
  font-size: 18px;
  font-weight: 800;
  color: var(--deep-navy);
}
.login-card .sub {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 22px;
}

/* --- Layout helpers ----------------------------------------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 18px; }
@media (max-width: 980px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .app { grid-template-columns: 64px 1fr; }
  .sidebar nav a span.label { display: none; }
  .sidebar-logo .wordmark { display: none; }
}

/* --- Code blocks / monospace -------------------------------- */
code, pre {
  font-family: 'SF Mono', Consolas, Menlo, monospace;
  font-size: 12.5px;
}
.codebox {
  background: #0f172a;
  color: #cbd5e1;
  padding: 14px 16px;
  border-radius: 10px;
  overflow-x: auto;
}

/* --- Modal / dialog ------------------------------------------ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}
.modal {
  width: 520px; max-width: 92%;
  background: #fff;
  border-radius: 14px;
  padding: 22px 24px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.35);
}
.modal h3 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
}
