/* =====================================================================
   License Lab — Admin UI
   Modern dashboard: dark sidebar, light/dark content, glassy cards.
   ===================================================================== */

:root {
  --bg:        #eef1f7;
  --surface:   #ffffff;
  --surface-2: #f6f8fc;
  --border:    #e2e7f0;
  --border-2:  #d7deeb;
  --text:      #1b2233;
  --text-2:    #5b6678;
  --text-3:    #8a93a6;
  --primary:   #5b5ef0;
  --primary-2: #7c5cf5;
  --primary-d: #4d50e6;
  --ring:      rgba(91, 94, 240, .35);

  --green:  #16a34a;  --green-bg:  #e7f6ec;  --green-bd:  #b9e6c6;
  --red:    #dc2626;  --red-bg:    #fdeaea;  --red-bd:    #f3c4c4;
  --amber:  #c2710c;  --amber-bg:  #fdf1dc;  --amber-bd:  #f4dcab;
  --violet: #7c3aed;  --violet-bg: #f1ebfe;  --violet-bd: #ddccfb;
  --blue:   #2563eb;  --blue-bg:   #e7effe;  --blue-bd:   #c4d8fb;
  --slate:  #64748b;  --slate-bg:  #eef1f6;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow:    0 6px 22px rgba(16, 24, 40, .08);
  --shadow-lg: 0 24px 60px rgba(16, 24, 40, .22);

  --radius:    14px;
  --radius-sm: 9px;
  --sidebar-w: 252px;

  --sb-bg:    #14161f;
  --sb-bg-2:  #1b1e2a;
  --sb-text:  #aab2c5;
  --sb-text-2:#6b7488;
  --sb-active:#ffffff;
  --sb-hover: rgba(255, 255, 255, .06);
}

:root[data-theme="dark"] {
  --bg:        #0d0f15;
  --surface:   #161922;
  --surface-2: #1c2029;
  --border:    #262b37;
  --border-2:  #313845;
  --text:      #e7eaf2;
  --text-2:    #a3acbe;
  --text-3:    #7b8497;
  --ring:      rgba(124, 92, 245, .45);

  --green-bg:  rgba(22,163,74,.16);  --green-bd:  rgba(22,163,74,.4);
  --red-bg:    rgba(220,38,38,.16);  --red-bd:    rgba(220,38,38,.4);
  --amber-bg:  rgba(217,119,6,.18);  --amber-bd:  rgba(217,119,6,.42);
  --violet-bg: rgba(124,58,237,.18); --violet-bd: rgba(124,58,237,.42);
  --blue-bg:   rgba(37,99,235,.18);  --blue-bd:   rgba(37,99,235,.42);
  --slate-bg:  rgba(100,116,139,.18);

  --shadow:    0 6px 22px rgba(0, 0, 0, .4);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }

/* The `hidden` attribute must always win over any display:flex/grid rules
   (e.g. .auth-body form, .bulkbar) or toggling tab forms / bars does nothing. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: "JetBrains Mono", "SF Mono", Consolas, monospace; font-size: .86em; }
.mono { font-family: "JetBrains Mono", "SF Mono", Consolas, monospace; }
.break { word-break: break-all; }
.nowrap { white-space: nowrap; }
.muted { color: var(--text-3); }
.ta-r { text-align: right; }
.pad { padding: 18px 4px; }

.ic { width: 18px; height: 18px; flex: none; }

/* ---------------------------------------------------------------- Layout */

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--sb-bg);
  color: var(--sb-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid rgba(255, 255, 255, .05);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 18px;
}
.brand-mark {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  box-shadow: 0 6px 16px rgba(91, 94, 240, .45);
}
.brand-mark .ic { width: 22px; height: 22px; }
.brand-mark.lg { width: 56px; height: 56px; border-radius: 16px; }
.brand-mark.lg .ic { width: 30px; height: 30px; }
.brand-text strong { display: block; color: #fff; font-size: 15px; letter-spacing: .2px; }
.brand-text small { color: var(--sb-text-2); font-size: 11.5px; text-transform: uppercase; letter-spacing: 1px; }

.nav { padding: 8px 12px; display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--sb-text);
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--sb-hover); color: #fff; text-decoration: none; }
.nav-item.active {
  background: linear-gradient(135deg, rgba(91,94,240,.22), rgba(124,92,245,.12));
  color: var(--sb-active);
  box-shadow: inset 0 0 0 1px rgba(124,92,245,.3);
}
.nav-item.active .ic { color: var(--primary-2); }

.nav-foot { margin-top: auto; padding: 14px 12px; border-top: 1px solid rgba(255,255,255,.06); }
.nav-stat {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; margin-bottom: 8px;
  background: var(--sb-bg-2); border-radius: 10px;
}
.nav-stat span { color: var(--sb-text-2); font-size: 12px; }
.nav-stat strong { color: #fff; }
.nav-item.logout:hover { background: rgba(220,38,38,.16); color: #ff8f8f; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---------------------------------------------------------------- Topbar */

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 22px;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.page-title { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -.2px; }

.topsearch {
  margin-left: 8px;
  flex: 1; max-width: 440px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-3);
}
.topsearch:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.topsearch input { border: 0; background: transparent; outline: none; height: 38px; flex: 1; color: var(--text); font: inherit; }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* ---------------------------------------------------------------- Buttons */

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 38px; padding: 0 14px;
  border: 1px solid var(--border-2);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit; font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s, box-shadow .15s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn .ic { width: 16px; height: 16px; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 9px; }
.btn-xs { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; justify-content: center; height: 44px; }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  border-color: transparent; color: #fff;
  box-shadow: 0 6px 16px rgba(91, 94, 240, .32);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--primary-d), var(--primary)); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-ok { color: #fff; background: var(--green); border-color: transparent; }
.btn-danger { color: #fff; background: var(--red); border-color: transparent; }
.btn .danger, button.danger { color: var(--red); }
.btn-danger.danger, .btn-ok { color: #fff; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 9px; }
.icon-btn.disabled { opacity: .4; pointer-events: none; }

#themeToggle .i-sun { display: none; }
:root[data-theme="dark"] #themeToggle .i-moon { display: none; }
:root[data-theme="dark"] #themeToggle .i-sun { display: inline; }

/* ---------------------------------------------------------------- Content */

.content { padding: 22px; max-width: 1480px; width: 100%; margin: 0 auto; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px;
  margin-bottom: 18px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.panel-head h2 .ic { color: var(--primary); width: 18px; height: 18px; }
.count {
  font-size: 12px; font-weight: 700; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 1px 8px; border-radius: 999px;
}
.link { font-weight: 600; font-size: 13px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

/* ---------------------------------------------------------------- Stat cards */

.cards { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; margin-bottom: 18px; }
.card {
  display: flex; align-items: center; gap: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden;
}
.card::after {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 4px;
  background: var(--primary);
}
.card-ic {
  width: 44px; height: 44px; flex: none;
  display: grid; place-items: center;
  border-radius: 12px;
  background: var(--primary-bg, var(--surface-2));
  color: var(--primary);
}
.card-ic .ic { width: 22px; height: 22px; }
.card-body { min-width: 0; }
.card-body span { display: block; color: var(--text-3); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.card-body strong { display: block; font-size: 26px; font-weight: 800; letter-spacing: -.5px; margin-top: 2px; }

.tone-accent { --primary-bg: var(--violet-bg); }
.tone-accent::after { background: var(--primary); }
.tone-accent .card-ic { color: var(--primary); background: var(--violet-bg); background: color-mix(in srgb, var(--primary) 14%, transparent); }
.tone-green::after { background: var(--green); } .tone-green .card-ic { color: var(--green); background: var(--green-bg); }
.tone-red::after { background: var(--red); }     .tone-red .card-ic { color: var(--red); background: var(--red-bg); }
.tone-amber::after { background: var(--amber); } .tone-amber .card-ic { color: var(--amber); background: var(--amber-bg); }
.tone-violet::after { background: var(--violet); } .tone-violet .card-ic { color: var(--violet); background: var(--violet-bg); }

/* ---------------------------------------------------------------- Badges / pills */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .2px;
  border: 1px solid transparent;
}
.st-active  { background: var(--green-bg);  color: var(--green);  border-color: var(--green-bd); }
.st-revoked { background: var(--red-bg);    color: var(--red);    border-color: var(--red-bd); }
.st-expired { background: var(--amber-bg);  color: var(--amber);  border-color: var(--amber-bd); }
.ed-lite       { background: var(--blue-bg);   color: var(--blue);   border-color: var(--blue-bd); }
.ed-pro        { background: var(--violet-bg); color: var(--violet); border-color: var(--violet-bd); }
.ed-enterprise { background: var(--amber-bg);  color: var(--amber);  border-color: var(--amber-bd); }

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700;
  background: var(--slate-bg); color: var(--slate);
}
.pill .ic { width: 12px; height: 12px; }
.pill.ok     { background: var(--green-bg); color: var(--green); }
.pill.soon   { background: var(--blue-bg);  color: var(--blue); }
.pill.warn   { background: var(--amber-bg); color: var(--amber); }
.pill.danger { background: var(--red-bg);   color: var(--red); }

.tag {
  display: inline-block; padding: 0 6px; border-radius: 5px;
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  background: var(--slate-bg); color: var(--slate);
}

/* ---------------------------------------------------------------- Tables */

.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-3);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  white-space: nowrap;
  position: sticky; top: 0;
}
table.data td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr { transition: background .12s; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tr:last-child td { border-bottom: 0; }
.cb { width: 36px; }
.sub { font-size: 11.5px; margin-top: 3px; }
.sub.danger { color: var(--red); font-weight: 600; }

.key-cell { min-width: 190px; }
.keyline { display: inline-flex; align-items: center; gap: 6px; }
.keyline code {
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 3px 8px; border-radius: 7px; font-weight: 600;
}
.keyline.lg code { font-size: 16px; padding: 6px 12px; }
.copy {
  display: inline-grid; place-items: center;
  width: 26px; height: 26px; flex: none;
  border: 1px solid var(--border); border-radius: 7px;
  background: var(--surface); color: var(--text-3); cursor: pointer;
  transition: all .15s;
}
.copy:hover { color: var(--primary); border-color: var(--primary); }
.copy .ic { width: 14px; height: 14px; }
.copy.copied { color: var(--green); border-color: var(--green-bd); background: var(--green-bg); }

.org-name { font-weight: 600; }

.mach-cell { min-width: 150px; }
.mach-top { font-size: 13px; }
.mini-track { height: 6px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; margin: 5px 0; max-width: 120px; }
.mini-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-2)); border-radius: 999px; }
.mini-fill.full { background: linear-gradient(90deg, var(--amber), var(--red)); }

.row-actions { display: inline-flex; gap: 5px; justify-content: flex-end; }

.empty { text-align: center; color: var(--text-3); padding: 44px 16px !important; }
.empty .ic { width: 40px; height: 40px; opacity: .35; margin-bottom: 6px; }
.empty p { margin: 6px 0 14px; }

/* ---------------------------------------------------------------- Toolbar / filters */

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar-right { display: flex; align-items: center; gap: 8px; }
.search-box {
  display: flex; align-items: center; gap: 8px; padding: 0 11px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; color: var(--text-3);
}
.search-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.search-box input { border: 0; background: transparent; outline: none; height: 36px; width: 230px; color: var(--text); font: inherit; }

select, input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="search"], input[type="datetime-local"], textarea {
  height: 38px; padding: 0 11px;
  border: 1px solid var(--border-2); border-radius: 10px;
  background: var(--surface); color: var(--text);
  font: inherit; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; padding: 9px 11px; resize: vertical; }
select { padding-right: 28px; cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238a93a6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
}
/* Multi-select must be a real multi-line list, not a 38px one-row box. */
select[multiple] {
  height: auto; min-height: 110px;
  padding: 8px 10px;
  background-image: none;
  cursor: default;
}
select[multiple] option { padding: 5px 8px; border-radius: 6px; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
input, select, textarea { max-width: 100%; }
.fld input, .fld select, .fld textarea { width: 100%; }

/* ---------------------------------------------------------------- Bulk bar */

.bulkbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; margin-bottom: 12px;
  background: color-mix(in srgb, var(--primary) 8%, var(--surface));
  border: 1px solid var(--primary); border-radius: 10px;
}
.bulkbar select { height: 34px; }

/* ---------------------------------------------------------------- Pager */

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 14px; margin-top: 4px; }
.pager-btns { display: flex; align-items: center; gap: 8px; }
.pager-pos { font-size: 13px; font-weight: 600; color: var(--text-2); }

/* ---------------------------------------------------------------- Dropdown */

.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; z-index: 50; top: calc(100% + 6px); left: 0;
  min-width: 210px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: none;
}
.dropdown-menu.right { left: auto; right: 0; }
.dropdown.open .dropdown-menu { display: block; animation: pop .12s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.dropdown-menu form { display: contents; }
.dropdown-menu button, .dropdown-menu a {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 10px; border: 0; border-radius: 8px;
  background: transparent; color: var(--text); font: inherit; font-weight: 500; text-align: left;
  cursor: pointer;
}
.dropdown-menu button:hover, .dropdown-menu a:hover { background: var(--surface-2); text-decoration: none; }
.dropdown-menu .ic { width: 16px; height: 16px; color: var(--text-3); }
.dropdown-menu button.danger { color: var(--red); }
.dropdown-menu button.danger .ic { color: var(--red); }
.dd-sep { height: 1px; background: var(--border); margin: 5px 2px; }

/* ---------------------------------------------------------------- Dashboard widgets */

.bars { display: flex; flex-direction: column; gap: 13px; }
.bar-row { display: grid; grid-template-columns: 96px 1fr 36px; align-items: center; gap: 12px; }
.bar-label { display: flex; }
.bar-track { height: 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; transition: width .4s ease; }
.bar-fill.ed-lite { background: var(--blue); }
.bar-fill.ed-pro { background: var(--violet); }
.bar-fill.ed-enterprise { background: var(--amber); }
.bar-val { text-align: right; font-weight: 700; }

.inline-note { display: flex; align-items: center; gap: 10px; margin-top: 16px; padding: 10px 12px; border-radius: 10px; font-size: 13px; }
.inline-note.warn { background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber-bd); }
.inline-note .ic { width: 18px; height: 18px; flex: none; }
.inline-note form { margin-left: auto; }
.inline-note .btn { background: var(--surface); }

.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { display: flex; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.mini-list li:last-child { border-bottom: 0; }
.mini-list code { background: var(--surface-2); border: 1px solid var(--border); padding: 2px 7px; border-radius: 6px; }
.mini-list .muted { margin-left: auto; font-size: 12px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 12px; padding: 9px 0; }
.timeline .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; flex: none; background: var(--slate); }
.timeline .dot.ok { background: var(--green); } .timeline .dot.warn { background: var(--amber); }
.timeline .dot.danger { background: var(--red); } .timeline .dot.neutral { background: var(--slate); }
.tl-body { min-width: 0; }
.tl-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tl-top .ev { font-weight: 600; }
code.tiny { font-size: 11.5px; background: var(--surface-2); border: 1px solid var(--border); padding: 1px 6px; border-radius: 5px; }

/* ---------------------------------------------------------------- Events pills */

.evpill, .ev {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; white-space: nowrap;
}
.evpill.ok { background: var(--green-bg); color: var(--green); }
.evpill.warn { background: var(--amber-bg); color: var(--amber); }
.evpill.danger { background: var(--red-bg); color: var(--red); }
.evpill.neutral { background: var(--slate-bg); color: var(--slate); }

/* ---------------------------------------------------------------- Detail page */

.crumbs { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; font-size: 13px; color: var(--text-3); }
.crumbs a { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; }
.crumbs .ic { width: 15px; height: 15px; }

.detail-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.detail-badges { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.detail-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.detail-actions form { display: inline; }

.kv { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.kv > div { padding: 11px 4px; border-bottom: 1px solid var(--border); }
.kv > div:nth-last-child(-n+2):not(.kv-wide) { }
.kv .kv-wide { grid-column: 1 / -1; }
.kv dt { font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--text-3); font-weight: 600; margin-bottom: 3px; }
.kv dd { margin: 0; font-weight: 500; }

/* ---------------------------------------------------------------- Modal */

.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: start center; padding: 6vh 16px; overflow: auto; }
.modal[hidden] { display: none; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 12, 20, .55); backdrop-filter: blur(3px); animation: fade .15s; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  position: relative; width: min(760px, 100%);
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: 18px; box-shadow: var(--shadow-lg);
  animation: rise .18s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 17px; display: flex; align-items: center; gap: 9px; }
.modal-head h2 .ic { color: var(--primary); }
.modal-body { padding: 20px; }
/* When .modal-body classes are reused on an inline panel form, drop the double padding. */
form.modal-body { padding: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.fld { display: flex; flex-direction: column; gap: 6px; }
.fld > span { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.fld.span2 { grid-column: 1 / -1; }
.key-input { display: flex; gap: 8px; }
.key-input input { flex: 1; }

/* ---------------------------------------------------------------- Toasts */

.toasts { position: fixed; top: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 10px; max-width: 380px; }
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border-2);
  box-shadow: var(--shadow-lg);
  animation: toastIn .25s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
.toast.success { border-left: 4px solid var(--green); }
.toast.error { border-left: 4px solid var(--red); }
.toast .ic { width: 18px; height: 18px; flex: none; }
.toast.success > .ic { color: var(--green); }
.toast.error > .ic { color: var(--red); }
.toast span { flex: 1; font-size: 13.5px; }
.toast-x { border: 0; background: transparent; color: var(--text-3); cursor: pointer; padding: 2px; display: grid; }
.toast.fade-out { opacity: 0; transform: translateX(20px); transition: all .3s; }

/* ---------------------------------------------------------------- Auth */

body.auth {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 24px 16px;
  background:
    radial-gradient(900px 520px at 88% -12%, rgba(124, 92, 245, .30), transparent 60%),
    radial-gradient(760px 460px at -8% 108%, rgba(91, 94, 240, .22), transparent 55%),
    var(--bg);
}
.auth-card {
  width: min(420px, 94vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: authIn .3s ease;
}
@keyframes authIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

.auth-hero {
  position: relative;
  padding: 40px 30px 28px;
  text-align: center;
  background:
    radial-gradient(420px 200px at 50% -30%, rgba(124, 92, 245, .35), transparent 70%),
    linear-gradient(165deg, rgba(91, 94, 240, .13), transparent 62%);
  border-bottom: 1px solid var(--border);
}
.auth-hero .brand-mark {
  margin: 0 auto 18px;
  width: 64px; height: 64px; border-radius: 18px;
  box-shadow: 0 14px 34px rgba(91, 94, 240, .5);
}
.auth-hero .brand-mark .ic { width: 34px; height: 34px; }
.auth-hero h1 { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.auth-hero h1 em {
  font-style: normal;
  background: linear-gradient(120deg, var(--primary), var(--primary-2));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.auth-hero p { margin: 7px 0 0; color: var(--text-3); font-size: 13.5px; }

.auth-body { padding: 26px 30px 4px; }
.auth-body form { display: flex; flex-direction: column; gap: 15px; }
/* Login tab forms: off-state is a dedicated class (not the `hidden` attribute)
   so it can never be overridden by display:flex above, and stays visually
   distinct from other hidden fields. */
.auth-mode-form.is-auth-off { display: none !important; }
.auth-card .fld { gap: 7px; }
.auth-card .fld > span { font-size: 12.5px; font-weight: 600; color: var(--text-2); letter-spacing: .2px; }

.ipt { position: relative; display: flex; align-items: center; }
.ipt .ic {
  position: absolute; left: 13px; width: 17px; height: 17px;
  color: var(--text-3); pointer-events: none; transition: color .15s;
}
.ipt input {
  width: 100%; height: 46px;
  padding: 0 14px 0 39px;
  border: 1px solid var(--border-2); border-radius: 12px;
  background: var(--surface-2); color: var(--text);
  font: inherit; outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.ipt input::placeholder { color: var(--text-3); }
.ipt:focus-within input { border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 3px var(--ring); }
.ipt:focus-within .ic { color: var(--primary); }

.auth-card .pin-input {
  width: 100%; height: 46px;
  padding: 0 14px; text-align: center;
  letter-spacing: 10px; font-size: 20px; font-weight: 700;
  border: 1px solid var(--border-2); border-radius: 12px;
  background: var(--surface-2); color: var(--text);
  font: inherit; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.auth-card .pin-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }

.auth-card .btn-block { height: 46px; border-radius: 12px; box-shadow: 0 10px 22px rgba(91, 94, 240, .32); }

.auth-error { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; padding: 11px 13px; border-radius: 11px;
  background: var(--red-bg); color: var(--red); border: 1px solid var(--red-bd); font-size: 13px; }
.auth-error .ic { width: 17px; height: 17px; flex: none; }

.auth-hint { margin: 0; text-align: center; color: var(--text-3); font-size: 12px; }
.auth-foot { text-align: center; margin: 22px 0 0; padding: 0 30px 26px; color: var(--text-3); font-size: 12px; }

/* Login tabs */
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; margin-bottom: 18px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 13px; }
.auth-tab {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 0; background: transparent; color: var(--text-2); font: inherit;
  font-size: 13.5px; font-weight: 600; padding: 10px 12px; border-radius: 9px;
  cursor: pointer; transition: all .15s;
}
.auth-tab .ic { width: 16px; height: 16px; }
.auth-tab:hover { color: var(--text); }
.auth-tab.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }

/* Back link on the PIN step */
.auth-back { display: inline-flex; align-items: center; gap: 5px; justify-content: center;
  color: var(--text-3); font-size: 13px; text-decoration: none; margin-top: -4px; }
.auth-back:hover { color: var(--primary); }

/* Honeypot field — invisible to humans, tempting to bots */
.hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px;
  overflow: hidden; opacity: 0; pointer-events: none; }

/* PIN control layout */
.inline-form { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.inline-form .fld.inline { flex-direction: row; align-items: flex-end; gap: 10px; }
.inline-form .fld.inline span { margin-bottom: 8px; }
.pad-t { margin-top: 14px; }
.detail-key { min-width: 0; }
.small { font-size: 12.5px; }

/* PIN badge tone */
.st-warn { background: var(--violet-bg); color: var(--violet); border-color: var(--violet-bd); }

/* ---------------------------------------------------------------- Responsive */

@media (max-width: 1280px) {
  .cards { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 1100px) {
  .cards { grid-template-columns: repeat(3, 1fr); }
  .content { padding: 18px; }
}
@media (max-width: 920px) {
  .grid-2 { grid-template-columns: 1fr; }
  .layout { flex-direction: column; }
  .sidebar { width: 100%; position: static; height: auto; border-right: 0; border-bottom: 1px solid rgba(255,255,255,.06); }
  .topsearch { display: none; }
  .modal { padding: 4vh 12px; }
}
@media (max-width: 720px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 14px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-right, .filters { justify-content: flex-start; }
  .search-box input { width: 100%; }
  .pager { flex-direction: column; align-items: flex-start; gap: 8px; }
  .bar-row { grid-template-columns: 78px 1fr 34px; gap: 8px; }
  .kv { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .modal-card { width: 100%; max-height: none; }
  .modal-head, .modal-body, .modal-foot { padding-left: 16px; padding-right: 16px; }
  .detail-actions { width: 100%; justify-content: flex-start; }
  .inline-form { align-items: stretch; flex-direction: column; }
  .inline-form .fld.inline { flex-direction: column; align-items: stretch; }
  .inline-form .fld.inline span { margin-bottom: 0; }
  .topbar { padding: 10px 14px; }
  .table-wrap { -webkit-overflow-scrolling: touch; }
  .brand { padding: 14px 16px 8px; }
  .nav { flex-direction: row; overflow-x: auto; padding: 8px 12px 12px; gap: 6px; }
  .nav-item { padding: 8px 12px; white-space: nowrap; }
  .nav-foot { border-top: 0; padding: 0 12px 12px; }
  .nav-foot .nav-stat { display: none; }
  .nav-item.logout { margin-left: auto; }
}
@media (max-width: 480px) {
  .cards { grid-template-columns: 1fr; }
  .content { padding: 12px; }
  .card-body strong { font-size: 22px; }
  .modal { padding: 2vh 8px; }
  .modal-head h2 { font-size: 15px; }
  .row-actions { flex-wrap: wrap; }
  .bar-row { grid-template-columns: 1fr; gap: 4px; }
  .bar-val { text-align: left; }
  .crumbs { flex-wrap: wrap; }
  .pill, .badge { white-space: nowrap; }
}
