/* Bingkapa License Server — admin panel styles */

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e3e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #4f46e5;
  --primary-600: #4338ca;
  --primary-soft: #eef2ff;
  --sidebar: #0f172a;
  --sidebar-text: #cbd5e1;
  --sidebar-active: #1e293b;
  --green: #059669; --green-soft: #ecfdf5;
  --red: #dc2626; --red-soft: #fef2f2;
  --amber: #b45309; --amber-soft: #fffbeb;
  --orange: #c2410c; --orange-soft: #fff7ed;
  --blue: #2563eb; --blue-soft: #eff6ff;
  --gray-soft: #f1f5f9;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
  --radius: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120; --surface: #111827; --surface-2: #0f172a; --border: #1f2a3c;
    --text: #e5e7eb; --muted: #94a3b8; --primary: #818cf8; --primary-600: #6366f1; --primary-soft: #1e1b4b;
    --sidebar: #060b16; --sidebar-active: #111c33;
    --green: #34d399; --green-soft: #052e22; --red: #f87171; --red-soft: #3b0d0d;
    --amber: #fbbf24; --amber-soft: #3a2a05; --orange: #fb923c; --orange-soft: #3b1906;
    --blue: #60a5fa; --blue-soft: #0b2447; --gray-soft: #1e293b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0b1120; --surface: #111827; --surface-2: #0f172a; --border: #1f2a3c;
  --text: #e5e7eb; --muted: #94a3b8; --primary: #818cf8; --primary-600: #6366f1; --primary-soft: #1e1b4b;
  --sidebar: #060b16; --sidebar-active: #111c33;
  --green: #34d399; --green-soft: #052e22; --red: #f87171; --red-soft: #3b0d0d;
  --amber: #fbbf24; --amber-soft: #3a2a05; --orange: #fb923c; --orange-soft: #3b1906;
  --blue: #60a5fa; --blue-soft: #0b2447; --gray-soft: #1e293b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; font-size: 13px; }
.icon { width: 18px; height: 18px; flex: none; }

/* Layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex: none; background: var(--sidebar); color: var(--sidebar-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(135deg, #6366f1, #22d3ee); color: #fff; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { color: #fff; font-size: 15px; }
.brand-text small { color: #94a3b8; font-size: 12px; }
.nav { padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-section { margin: 14px 10px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #64748b; }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 8px; color: var(--sidebar-text); font-weight: 500; }
.nav-link:hover { background: var(--sidebar-active); color: #fff; text-decoration: none; }
.nav-link.is-active { background: var(--sidebar-active); color: #fff; box-shadow: inset 3px 0 0 #818cf8; }
.sidebar-foot { padding: 14px 18px; font-size: 12px; color: #64748b; }
.sidebar-backdrop { display: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 64px; display: flex; align-items: center; gap: 12px; padding: 0 24px;
  background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
}
.top-search { flex: 1; max-width: 460px; display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 0 12px; color: var(--muted); }
.top-search input { border: 0; background: transparent; height: 38px; flex: 1; color: var(--text); font: inherit; outline: none; min-width: 0; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); }
.only-mobile { display: none; }

.user-menu { position: relative; }
.user-menu summary { list-style: none; display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 4px 8px; border-radius: 10px; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover { background: var(--surface-2); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 13px; }
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-meta small { color: var(--muted); font-size: 12px; }
.user-dropdown { position: absolute; right: 0; top: calc(100% + 6px); min-width: 190px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 30px rgba(15, 23, 42, .15); padding: 6px; z-index: 30; }
.user-dropdown a, .user-dropdown button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 8px; color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; text-align: left; }
.user-dropdown a:hover, .user-dropdown button:hover { background: var(--surface-2); text-decoration: none; }
.user-dropdown form { margin: 0; }

.content { padding: 24px; max-width: 1400px; width: 100%; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; font-weight: 700; }
.page-sub { margin: 4px 0 0; color: var(--muted); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Cards & grid */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card, .card + .grid, .grid + .card, .grid + .grid { margin-top: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head h2 { font-size: 15px; font-weight: 650; }
.card-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.card-body { padding: 20px; }
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }

.stat { display: flex; gap: 14px; align-items: center; padding: 16px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--text); }
a.stat:hover { text-decoration: none; border-color: var(--primary); }
.stat-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; }
.stat-icon .icon { width: 20px; height: 20px; }
.stat-body { display: flex; flex-direction: column; min-width: 0; }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { font-size: 24px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-hint { color: var(--muted); font-size: 12px; }
.stat-indigo .stat-icon { background: var(--primary-soft); color: var(--primary); }
.stat-green .stat-icon { background: var(--green-soft); color: var(--green); }
.stat-red .stat-icon { background: var(--red-soft); color: var(--red); }
.stat-amber .stat-icon { background: var(--amber-soft); color: var(--amber); }
.stat-blue .stat-icon { background: var(--blue-soft); color: var(--blue); }

/* Tables */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-main { font-weight: 600; color: var(--text); }
.cell-sub { color: var(--muted); font-size: 12px; }
.nowrap { white-space: nowrap; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-orange { background: var(--orange-soft); color: var(--orange); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-gray { background: var(--gray-soft); color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; background: var(--muted); }
.dot-green { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: 9px; border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none !important; }
.btn .icon { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger-soft { background: var(--red-soft); color: var(--red); }
.btn-success-soft { background: var(--green-soft); color: var(--green); }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form { display: inline; margin: 0; }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
label { font-weight: 600; font-size: 13px; }
.hint { color: var(--muted); font-size: 12px; font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=search], select, textarea {
  width: 100%; height: 40px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit;
}
textarea { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; padding: 14px 20px; border-bottom: 1px solid var(--border); align-items: center; }
.filters input, .filters select { width: auto; min-width: 150px; height: 36px; }
.filters input[type=search] { min-width: 240px; flex: 1; }
.checkbox { display: flex; align-items: center; gap: 8px; font-weight: 500; }

/* Alerts */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; border: 1px solid transparent; }
.alert-success { background: var(--green-soft); color: var(--green); }
.alert-error { background: var(--red-soft); color: var(--red); }
.alert-warning { background: var(--amber-soft); color: var(--amber); }
.alert-info { background: var(--blue-soft); color: var(--blue); }
.alert .icon { margin-top: 1px; }

/* Detail lists */
.details { display: grid; grid-template-columns: 170px 1fr; gap: 10px 16px; margin: 0; }
.details dt { color: var(--muted); }
.details dd { margin: 0; font-weight: 500; word-break: break-word; }

.code-box { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--surface-2); border: 1px dashed var(--border); border-radius: 10px; font-family: ui-monospace, Consolas, monospace; font-size: 15px; font-weight: 600; word-break: break-all; }
.code-box button { margin-left: auto; }

.expiry-hero { display: flex; align-items: center; gap: 16px; padding: 18px 20px; border-radius: var(--radius); margin-bottom: 20px; border: 1px solid var(--border); background: var(--surface); }
.expiry-hero .big { font-size: 28px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.expiry-hero.tone-green { border-left: 5px solid var(--green); }
.expiry-hero.tone-amber { border-left: 5px solid var(--amber); background: var(--amber-soft); }
.expiry-hero.tone-orange { border-left: 5px solid var(--orange); background: var(--orange-soft); }
.expiry-hero.tone-red { border-left: 5px solid var(--red); background: var(--red-soft); }
.expiry-hero.tone-blue { border-left: 5px solid var(--blue); }

.quick-extend { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* Lists */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.feed li:last-child { border-bottom: 0; }
.feed .feed-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); flex: none; }
.feed .feed-icon .icon { width: 15px; height: 15px; }
.feed .feed-main { min-width: 0; flex: 1; }
.feed .feed-time { color: var(--muted); font-size: 12px; white-space: nowrap; }

/* Bar chart */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 160px; padding: 10px 0 0; }
.bar { flex: 1; background: var(--primary-soft); border-radius: 4px 4px 0 0; position: relative; min-height: 2px; }
.bar > span { position: absolute; inset: auto 0 0 0; background: var(--primary); border-radius: 4px 4px 0 0; }
.bar:hover::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: var(--text); color: var(--surface); font-size: 12px; padding: 3px 8px; border-radius: 6px; white-space: nowrap; z-index: 2; }
.bars-legend { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-top: 6px; }

/* Empty, pagination */
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state .icon { width: 36px; height: 36px; color: var(--muted); margin-bottom: 8px; }
.empty-state h2 { font-size: 16px; color: var(--text); margin-bottom: 6px; }
.empty-state p { margin: 0 0 14px; }
.pagination { display: flex; gap: 6px; padding: 14px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.page-link { min-width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--border); color: var(--text); padding: 0 8px; }
.page-link.is-current { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-gap { align-self: center; color: var(--muted); }
.table-foot { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 13px; }
.table-foot .count { padding: 14px 20px; }

/* Auth pages */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 10% -10%, rgba(99, 102, 241, .18), transparent), var(--bg); }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 32px; box-shadow: 0 20px 50px rgba(15, 23, 42, .12); }
.auth-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.auth-title { font-size: 22px; margin-bottom: 6px; }
.auth-text { color: var(--muted); margin: 0 0 22px; }
.auth-card .form-group { margin-bottom: 14px; }
.auth-foot { margin-top: 18px; text-align: center; color: var(--muted); font-size: 12px; }

.muted { color: var(--muted); }
.text-red { color: var(--red); }
.text-green { color: var(--green); }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.danger-zone { border-color: var(--red-soft); }
.danger-zone .card-head h2 { color: var(--red); }

/* Responsive */
@media (max-width: 1100px) {
  .grid-main, .grid-3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s ease; }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 40; }
  .only-mobile { display: grid; }
  .topbar { padding: 0 16px; }
  .content { padding: 16px; }
  .grid-2, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .user-meta { display: none; }
  .details { grid-template-columns: 1fr; gap: 2px 0; }
  .details dd { margin-bottom: 10px; }
  .filters input[type=search] { min-width: 0; width: 100%; }
  .filters select { flex: 1; }
}
