/* License Manager — panel styles. Matches the approved UI reference.
   Mobile-first; the sidebar becomes a slide-in drawer under 960px. */

:root {
  --ink: #0F172A;
  --ink-2: #334155;
  --muted: #475569;
  --muted-2: #64748B;
  --line: #E5E7EB;
  --line-2: #EEF0F3;
  --bg: #F5F6F8;
  --card: #FFFFFF;
  --soft: #F8FAFC;
  --nav: #0F172A;
  --nav-2: #1E293B;
  --nav-ink: #CBD5E1;
  --nav-muted: #94A3B8;
  --accent: #4F46E5;
  --accent-ink: #3730A3;
  --accent-soft: #EEF2FF;
  --green: #166534; --green-bg: #DCFCE7;
  --amber: #92400E; --amber-bg: #FEF3C7; --amber-line: #FDE68A;
  --red: #991B1B; --red-bg: #FEE2E2; --red-line: #FECACA;
  --radius: 12px;
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.45; color: var(--ink); background: var(--bg); }
a { color: #4338CA; text-decoration: none; }
a:hover { color: #312E81; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
p { margin: 0; }
code, .mono { font-family: var(--mono); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex: none; background: var(--nav); color: var(--nav-ink);
  padding: 22px 14px; display: flex; flex-direction: column; gap: 26px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand-mark { width: 32px; height: 32px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; color: #fff; flex: none; }
.brand-name { font-weight: 700; color: #fff; font-size: 15px; display: block; }
.brand-sub { font-size: 12px; color: var(--nav-muted); display: block; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--nav-muted); padding: 0 12px 6px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; color: var(--nav-ink); font-size: 14px; min-height: 40px; }
.nav-link:hover { background: var(--nav-2); color: #fff; }
.nav-link.active { background: var(--nav-2); color: #fff; font-weight: 500; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--nav-2); padding-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px 8px; }
.avatar { width: 34px; height: 34px; border-radius: 999px; background: #E0E7FF; color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.user-chip .who { min-width: 0; }
.user-chip .who b { display: block; color: #fff; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .who span { display: block; color: var(--nav-muted); font-size: 12px; }
.nav-btn { width: 100%; background: transparent; border: 0; font: inherit; cursor: pointer; text-align: left; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 16px;
  padding: 18px 32px; background: var(--card); border-bottom: 1px solid var(--line);
}
.topbar-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-title .sub { font-size: 13px; color: var(--muted); display: block; margin-top: 2px; }
.topbar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.btn.menu-btn { display: none; }
.content { padding: 24px 32px 48px; display: flex; flex-direction: column; gap: 20px; width: 100%; max-width: 1320px; }
.crumbs { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; margin-bottom: 4px; }
.crumbs a { color: var(--muted); }

/* ---------- Building blocks ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.card-pad { padding: 20px 24px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 18px 24px; }
.card-head .sub { font-size: 13px; color: var(--muted); display: block; margin-top: 2px; }
.card-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; padding: 14px 24px; border-top: 1px solid var(--line-2); font-size: 13px; color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.col-main { flex: 3 1 560px; min-width: 0; }
.col-side { flex: 1 1 320px; min-width: 0; }
.col-half { flex: 1 1 380px; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.grow { flex: 1; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.kpi { padding: 20px; display: flex; flex-direction: column; gap: 8px; }
.kpi .label { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi .value { font-size: 30px; font-weight: 700; letter-spacing: -.02em; }
.kpi .note { font-size: 12px; font-weight: 500; color: var(--muted); }
.kpi .note.up { color: var(--green); }
.kpi .note.warn { color: var(--amber); }

/* Bar chart */
.chart { display: flex; align-items: flex-end; gap: 8px; height: 190px; border-bottom: 1px solid var(--line); padding-top: 8px; }
.chart .bar-col { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; height: 100%; min-width: 0; }
.chart .bar { width: 100%; max-width: 36px; background: #C7D2FE; border-radius: 6px 6px 0 0; min-height: 2px; }
.chart .bar.now { background: var(--accent); }
.chart .val { font-size: 11px; color: var(--muted); }
.chart-x { display: flex; gap: 8px; }
.chart-x span { flex: 1 1 0; text-align: center; font-size: 11px; color: var(--muted-2); min-width: 0; overflow: hidden; }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { background: var(--soft); color: var(--muted); text-align: left; font-weight: 600; padding: 10px 12px; white-space: nowrap; }
.table td { padding: 12px; border-top: 1px solid var(--line-2); vertical-align: middle; }
.table th:first-child, .table td:first-child { padding-left: 24px; }
.table th:last-child, .table td:last-child { padding-right: 24px; }
.table tbody tr:hover { background: #FAFBFF; }
.table .two { display: flex; flex-direction: column; gap: 2px; }
.table .two .sub { color: var(--muted); font-size: 12px; }
.table .key { font-family: var(--mono); font-size: 12px; font-weight: 600; }
.table .right { text-align: right; }
.table .nowrap { white-space: nowrap; }
.row-link { color: inherit; display: block; }
.row-link:hover { color: inherit; }
.empty { padding: 48px 24px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 12px; }

/* Mobile cards instead of tables */
@media (max-width: 720px) {
  table.table.responsive thead { display: none; }
  table.table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td { display: block; width: 100%; }
  .table.responsive tr { padding: 12px 16px; border-top: 1px solid var(--line-2); }
  .table.responsive td { border: 0; padding: 3px 0 !important; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .table.responsive td::before { content: attr(data-label); color: var(--muted); font-size: 12px; text-align: left; flex: none; }
  .table.responsive td:first-child { display: block; text-align: left; padding-bottom: 6px !important; }
  .table.responsive td:first-child::before { content: none; }
}

/* Badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-indigo { background: #E0E7FF; color: var(--accent-ink); }
.badge-slate { background: #F1F5F9; color: var(--muted); }
.count-pill { background: var(--accent); color: #fff; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; margin-left: auto; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink-2);
  font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--soft); color: var(--ink); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { background: #4338CA; color: #fff; }
.btn-warn { background: #FFFBEB; border-color: var(--amber-line); color: var(--amber); font-weight: 600; }
.btn-warn:hover { background: var(--amber-bg); color: var(--amber); }
.btn-danger { background: #FEF2F2; border-color: var(--red-line); color: var(--red); font-weight: 600; }
.btn-danger:hover { background: var(--red-bg); color: var(--red); }
.btn-link { border: 0; background: none; color: #4338CA; padding: 0; height: auto; font-weight: 600; font-size: 13px; }
.btn-link.danger { color: var(--red); }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; }
.btn-lg { height: 46px; padding: 0 20px; }
.btn-block { width: 100%; }
.icon-btn { width: 40px; height: 40px; padding: 0; }
.actions-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.actions-grid form { display: contents; }
.actions-grid .btn { width: 100%; }

/* Forms */
.form { display: flex; flex-direction: column; gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: 13px; font-weight: 500; color: var(--ink); }
.hint { font-size: 12px; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; height: 42px; padding: 0 12px; border: 1px solid #CBD5E1; border-radius: 8px; background: #fff;
  font: inherit; font-size: 14px; color: var(--ink);
}
textarea.input { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; }
.input:focus { border-color: var(--accent); outline: 3px solid #E0E7FF; outline-offset: 0; }
.field.has-error .input { border-color: #DC2626; }
.error-text { font-size: 12px; color: #B91C1C; }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.search { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--soft); color: var(--muted-2); min-width: 240px; }
.search input { border: 0; background: transparent; outline: none; font: inherit; color: var(--ink); width: 100%; }
.filters { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--line-2); }
.filters .selects { display: flex; gap: 8px; flex-wrap: wrap; }
.filters select.input { height: 36px; width: auto; font-size: 13px; padding: 0 10px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab { padding: 8px 12px; border-radius: 8px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.tab:hover { background: var(--soft); color: var(--ink); }
.tab.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }

/* Alerts */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; font-size: 13px; border: 1px solid; }
.alert svg { flex: none; margin-top: 1px; }
.alert-success { background: #F0FDF4; border-color: #BBF7D0; color: var(--green); }
.alert-error { background: #FEF2F2; border-color: var(--red-line); color: var(--red); }
.alert-warn { background: #FFFBEB; border-color: var(--amber-line); color: #78350F; }
.alert-info { background: var(--accent-soft); border-color: #C7D2FE; color: var(--accent-ink); }

/* Key box & definition lists */
.keybox { display: flex; align-items: center; gap: 8px; background: var(--soft); border: 1px solid var(--line); border-radius: 8px; padding: 8px 8px 8px 12px; }
.keybox code { flex: 1; font-size: 13px; font-weight: 600; word-break: break-all; }
.dl { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.dl dt { color: var(--muted); font-size: 12px; }
.dl dd { margin: 2px 0 0; font-weight: 500; }
.section { padding: 16px 20px; border-top: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 10px; }
.list-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.list-item .two { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.list-item .two b { font-weight: 500; font-size: 13px; word-break: break-all; }
.list-item .two span { font-size: 12px; color: var(--muted); }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; font-size: 13px; }
.timeline li { display: flex; gap: 10px; }
.timeline .dot { width: 8px; height: 8px; border-radius: 999px; background: #94A3B8; margin-top: 6px; flex: none; }
.timeline li:first-child .dot { background: var(--accent); }
.mini-list .item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.mini-list .item:last-child { border-bottom: 0; }
pre.code { background: #0F172A; color: #E2E8F0; padding: 14px 16px; border-radius: 10px; font-size: 12px; overflow-x: auto; margin: 0; line-height: 1.55; }

/* Pagination */
.pager { display: flex; gap: 8px; }

/* ---------- Auth pages ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-side { background: var(--nav); color: var(--nav-ink); padding: 48px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; }
.auth-side h2 { color: #fff; font-size: 28px; font-weight: 700; letter-spacing: -.01em; max-width: 440px; }
.auth-side p { color: var(--nav-muted); max-width: 440px; margin-top: 12px; font-size: 15px; }
.auth-points { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 14px; }
.auth-points li { display: flex; gap: 10px; align-items: flex-start; color: var(--nav-ink); }
.auth-points svg { color: #A5B4FC; flex: none; margin-top: 2px; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--card); }
.auth-card { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 22px; }
.auth-card.wide { max-width: 640px; }
.auth-card h1 { font-size: 26px; }
.auth-foot { font-size: 12px; color: var(--muted-2); }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 50; transform: translateX(-100%);
    transition: transform .2s ease; box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0); width: 272px;
  }
  .nav-open .sidebar { transform: none; box-shadow: 0 0 0 9999px rgba(15, 23, 42, .45); }
  .btn.menu-btn { display: inline-flex; }
  .topbar { padding: 14px 16px; position: sticky; top: 0; z-index: 20; }
  .content { padding: 16px 16px 40px; gap: 16px; }
  .card-head, .card-pad { padding-left: 16px; padding-right: 16px; }
  .table th:first-child, .table td:first-child { padding-left: 16px; }
  .table th:last-child, .table td:last-child { padding-right: 16px; }
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
}
@media (max-width: 600px) {
  h1 { font-size: 19px; }
  .form-grid, .dl { grid-template-columns: 1fr; }
  .search { min-width: 0; width: 100%; }
  .topbar-actions { width: 100%; }
  .topbar-actions .btn-primary { flex: 1; }
  .kpi .value { font-size: 26px; }
  .chart { gap: 4px; }
  .chart .val { display: none; }
  .hide-sm { display: none !important; }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }
