:root {
  color-scheme: light;
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: #172033;
  --muted: #697386;
  --line: #e3e8f0;
  --navy: #10182a;
  --navy-soft: #18233b;
  --blue: #3567f0;
  --blue-dark: #234ed0;
  --green: #178b63;
  --amber: #b96f12;
  --red: #c5364f;
  --violet: #7654d8;
  --shadow: 0 18px 45px rgba(18, 31, 53, .08);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--ink); }
body { margin: 0; min-height: 100vh; }
button, input, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.skip-link { position: fixed; left: 12px; top: -80px; z-index: 100; padding: 10px 14px; background: var(--surface); color: var(--ink); border-radius: 8px; }
.skip-link:focus { top: 12px; }
.eyebrow { margin: 0 0 7px; color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.muted { color: var(--muted); line-height: 1.55; }

.auth-layout { min-height: 100vh; display: grid; grid-template-columns: minmax(380px, .9fr) minmax(460px, 1.1fr); }
.auth-visual { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; padding: clamp(36px, 6vw, 86px); color: #fff; background: linear-gradient(145deg, #0d1526 0%, #182b55 54%, #234ed0 145%); }
.auth-visual::before, .auth-visual::after { content: ""; position: absolute; border-radius: 50%; border: 1px solid rgba(255,255,255,.12); }
.auth-visual::before { width: 520px; height: 520px; right: -260px; top: -130px; }
.auth-visual::after { width: 760px; height: 760px; right: -430px; top: -250px; }
.auth-visual > * { position: relative; z-index: 1; }
.auth-visual h1 { margin: 0 0 14px; max-width: 520px; font-size: clamp(42px, 6vw, 78px); letter-spacing: -.055em; line-height: .98; }
.auth-visual p:not(.eyebrow) { max-width: 520px; color: #bec9df; font-size: 17px; line-height: 1.65; }
.auth-visual .eyebrow { color: #91aaff; }
.brand-mark { display: grid; place-items: center; width: 58px; height: 58px; color: white; background: linear-gradient(145deg, #6f8cff, #315ce8); border: 1px solid rgba(255,255,255,.2); border-radius: 18px; font-size: 26px; font-weight: 900; box-shadow: 0 16px 42px rgba(15,44,129,.35); }
.brand-mark.small { width: 40px; height: 40px; border-radius: 12px; font-size: 18px; flex: 0 0 auto; }
.auth-panel { display: grid; place-items: center; padding: 40px; }
.auth-card { width: min(430px, 100%); padding: 42px; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); }
.auth-card h2 { margin: 0; font-size: 30px; letter-spacing: -.035em; }
.auth-card label, .form-grid label { display: grid; gap: 8px; margin-top: 20px; color: #303a4e; font-size: 13px; font-weight: 750; }
.auth-card input, .form-grid input, .form-grid select, .table-toolbar input { width: 100%; padding: 12px 14px; color: var(--ink); background: var(--surface); border: 1px solid #d7deea; border-radius: 10px; outline: none; transition: .2s ease; }
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(53,103,240,.12); }
.password-field { position: relative; }
.password-field input { padding-right: 72px; }
.password-field .icon-button { position: absolute; right: 6px; top: 6px; }
.security-note { margin: 18px 0 0; color: #8790a1; font-size: 12px; line-height: 1.5; text-align: center; }
.brand-mobile { display: none; align-items: center; gap: 10px; margin-bottom: 28px; font-weight: 800; }

.button, .icon-button { border: 0; border-radius: 10px; font-weight: 750; transition: transform .15s ease, background .15s ease, box-shadow .15s ease; }
.button { min-height: 40px; padding: 10px 16px; }
.button:hover, .icon-button:hover { transform: translateY(-1px); }
.button.primary { color: white; background: var(--blue); box-shadow: 0 8px 20px rgba(53,103,240,.2); }
.button.primary:hover { background: var(--blue-dark); }
.button.secondary { color: #2d426f; background: #eaf0ff; }
.button.ghost, .icon-button { color: #596579; background: #eef2f7; }
.button.full { width: 100%; margin-top: 24px; }
.icon-button { min-height: 34px; padding: 7px 10px; font-size: 12px; }

.alert { margin-bottom: 20px; padding: 12px 15px; border: 1px solid #cbd7f8; border-radius: 10px; color: #26417d; background: #edf3ff; }
.alert.error { color: #8c2134; border-color: #f2c3cc; background: #fff1f3; }
.alert.success { color: #17684d; border-color: #bce2d4; background: #edfbf5; }

.app-layout { min-height: 100vh; display: grid; grid-template-columns: 258px minmax(0, 1fr); }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; width: 258px; display: flex; flex-direction: column; padding: 28px 18px 22px; color: #dfe6f5; background: var(--navy); }
.brand { display: flex; align-items: center; gap: 12px; margin: 0 10px 32px; color: white; text-decoration: none; }
.brand span:last-child { display: grid; }
.brand strong { letter-spacing: .06em; }
.brand small, .sidebar-footer small, .admin-identity small { color: #8793ab; }
.sidebar nav { display: grid; gap: 5px; }
.nav-item { width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 13px; color: #abb6ca; background: transparent; border: 0; border-radius: 10px; text-align: left; font-weight: 680; }
.nav-item span { color: #65728a; font-size: 10px; font-weight: 800; }
.nav-item:hover { color: white; background: #151f35; }
.nav-item.active { color: white; background: var(--navy-soft); box-shadow: inset 3px 0 var(--blue); }
.nav-item.active span { color: #88a5ff; }
.sidebar-footer { display: flex; align-items: center; gap: 10px; margin-top: auto; padding: 14px 12px; border-top: 1px solid #24304a; font-size: 12px; }
.sidebar-footer span:last-child { display: grid; gap: 2px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #3dd598; box-shadow: 0 0 0 5px rgba(61,213,152,.12); }
.app-content { grid-column: 2; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 92px; padding: 18px clamp(24px, 4vw, 56px); background: rgba(243,246,251,.88); border-bottom: 1px solid rgba(217,225,236,.8); backdrop-filter: blur(18px); }
.topbar h1 { margin: 0; font-size: 25px; letter-spacing: -.03em; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.admin-identity { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.admin-identity span:last-child { display: grid; gap: 1px; font-size: 12px; }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; color: #fff; background: #263b6a; border-radius: 50%; font-size: 11px; font-weight: 800; }
main { padding: 32px clamp(24px, 4vw, 56px) 64px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.metric-card { position: relative; overflow: hidden; display: grid; min-height: 156px; padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(28,45,75,.045); }
.metric-card::before { content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 4px; background: var(--accent); }
.metric-card span { color: var(--muted); font-size: 13px; font-weight: 700; }
.metric-card strong { align-self: center; font-size: 38px; letter-spacing: -.045em; }
.metric-card small { color: #929bab; }
.accent-blue { --accent: var(--blue); }.accent-green { --accent: var(--green); }.accent-amber { --accent: var(--amber); }.accent-violet { --accent: var(--violet); }

.content-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-top: 20px; }
.span-2 { grid-column: span 2; }
.panel { padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(28,45,75,.04); }
.panel h2, .panel h3 { margin: 0; letter-spacing: -.025em; }
.panel-heading, .section-heading, .table-toolbar, .form-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.section-heading { margin-bottom: 18px; }
.section-heading h2 { margin: 0; font-size: 25px; }
.health-list { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin-top: 22px; overflow: hidden; background: var(--line); border: 1px solid var(--line); border-radius: 12px; }
.health-list div { display: grid; gap: 5px; padding: 17px; background: var(--surface-soft); }
.health-list span { color: var(--muted); font-size: 12px; }
.health-list strong { color: var(--green); font-size: 14px; }
.badge { display: inline-flex; align-items: center; justify-content: center; min-height: 26px; padding: 4px 9px; color: #536077; background: #eef2f7; border-radius: 999px; font-size: 11px; font-weight: 800; text-transform: capitalize; }
.badge.success, .badge.active, .badge.completed { color: #147250; background: #def6ec; }
.badge.failed, .badge.blocked, .badge.suspended { color: #a62a40; background: #ffe4e8; }
.badge.pending, .badge.retry_waiting, .badge.claimed, .badge.processing, .badge.grace { color: #925a0d; background: #fff0cf; }

.form-panel { margin-bottom: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.form-actions { justify-content: flex-end; margin-top: 22px; }
.table-panel { padding: 0; overflow: hidden; }
.table-toolbar { padding: 18px 20px; border-bottom: 1px solid var(--line); }
.table-toolbar input { max-width: 420px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 18px; border-bottom: 1px solid #edf0f5; text-align: left; white-space: nowrap; }
th { color: #737e91; background: #fafbfd; font-size: 10px; letter-spacing: .09em; text-transform: uppercase; }
td { color: #394459; font-size: 13px; }
tbody tr:hover { background: #fbfcff; }
.primary-cell { display: grid; gap: 3px; }
.primary-cell small { color: var(--muted); }
.empty-cell { padding: 40px; color: var(--muted); text-align: center; }

.plans-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.plan-card { position: relative; overflow: hidden; }
.plan-card::before { content: ""; position: absolute; width: 180px; height: 180px; right: -80px; top: -90px; background: radial-gradient(circle, rgba(53,103,240,.18), transparent 70%); }
.plan-card h3 { font-size: 24px; }
.plan-limits { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 22px 0; }
.plan-limits div { padding: 12px; background: var(--surface-soft); border-radius: 10px; }
.plan-limits span { display: block; color: var(--muted); font-size: 11px; }
.plan-limits strong { display: block; margin-top: 4px; }
.feature-list, .check-list { display: grid; gap: 10px; padding: 0; list-style: none; }
.feature-list li, .check-list li { position: relative; padding-left: 22px; color: #536077; font-size: 13px; }
.feature-list li::before, .check-list li::before { content: "✓"; position: absolute; left: 0; color: var(--green); font-weight: 900; }
.mobile-only { display: none; }

@media (max-width: 1080px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .content-grid { grid-template-columns: 1fr 1fr; }
  .span-2 { grid-column: span 1; }
}

@media (max-width: 820px) {
  .auth-layout { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
  .auth-panel { min-height: 100vh; padding: 22px; }
  .brand-mobile { display: flex; }
  .app-layout { display: block; }
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .app-content { display: block; }
  .mobile-only { display: inline-flex; }
  .admin-identity { display: none; }
  .topbar { padding: 16px 20px; }
  main { padding: 24px 18px 50px; }
  .plans-grid, .content-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .auth-card { padding: 28px 22px; }
  .metric-grid { grid-template-columns: 1fr; }
  .form-grid, .health-list { grid-template-columns: 1fr; }
  .top-actions .secondary { display: none; }
  .section-heading { align-items: flex-start; }
}
