:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #6d778a;
  --line: #e5e9f1;
  --brand: #152d4f;
  --brand-soft: #eaf0f8;
  --success: #157347;
  --warning: #9a6700;
  --danger: #b42318;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(23, 32, 51, .07);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); background: var(--bg); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.app-shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar { background: #101d31; color: white; padding: 22px 16px; display: flex; flex-direction: column; gap: 28px; }
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark { width: 44px; height: 44px; border-radius: 12px; background: white; color: #101d31; display: grid; place-items: center; font-weight: 800; letter-spacing: -.5px; }
.brand strong { display:block; font-size: 14px; line-height: 1.25; }
.brand span { display:block; color:#aab7cb; font-size: 12px; margin-top:3px; }
.side-nav { display:flex; flex-direction:column; gap:6px; }
.side-nav button { border:0; background:transparent; color:#c3cde0; text-align:left; padding:12px 14px; border-radius:10px; }
.side-nav button:hover, .side-nav button.active { background:rgba(255,255,255,.1); color:white; }
.sidebar-footer { margin-top:auto; display:flex; flex-direction:column; gap:10px; color:#8fa0ba; }
.sidebar-footer .ghost { color:#d6deea; border-color:rgba(255,255,255,.2); }
.main-area { min-width:0; }
.topbar { height:88px; background:rgba(255,255,255,.94); border-bottom:1px solid var(--line); display:flex; align-items:center; justify-content:space-between; padding:0 28px; position:sticky; top:0; z-index:20; backdrop-filter: blur(10px); }
.topbar h1 { margin:0; font-size:22px; }
.topbar p { margin:4px 0 0; color:var(--muted); font-size:13px; }
.content { padding:26px 28px 90px; max-width:1500px; margin:auto; }
.primary, .secondary, .ghost, .danger-btn { border-radius:10px; padding:10px 14px; border:1px solid transparent; font-weight:650; }
.primary { background:var(--brand); color:white; }
.secondary { background:var(--brand-soft); color:var(--brand); }
.ghost { background:transparent; border-color:var(--line); color:var(--ink); }
.danger-btn { background:#fff0ee; color:var(--danger); }
.icon-btn { border:0; background:transparent; font-size:24px; }
.grid { display:grid; gap:16px; }
.metrics { grid-template-columns:repeat(4,minmax(0,1fr)); }
.metric, .card { background:var(--panel); border:1px solid var(--line); border-radius:var(--radius); box-shadow:var(--shadow); }
.metric { padding:18px; }
.metric .label { color:var(--muted); font-size:13px; }
.metric .value { font-weight:800; font-size:26px; margin-top:7px; }
.metric .hint { font-size:12px; color:var(--muted); margin-top:4px; }
.card { padding:20px; }
.card h2 { font-size:17px; margin:0 0 16px; }
.two-col { grid-template-columns:minmax(0,1.4fr) minmax(300px,.8fr); margin-top:16px; }
.section-head { display:flex; justify-content:space-between; align-items:center; gap:12px; margin-bottom:14px; }
.section-head h2 { margin:0; font-size:18px; }
.table-wrap { overflow:auto; }
table { width:100%; border-collapse:collapse; font-size:14px; }
th { color:var(--muted); font-weight:650; text-align:left; padding:10px 12px; border-bottom:1px solid var(--line); white-space:nowrap; }
td { padding:12px; border-bottom:1px solid var(--line); vertical-align:middle; }
tr:last-child td { border-bottom:0; }
.badge { display:inline-flex; align-items:center; padding:5px 8px; border-radius:999px; font-size:12px; font-weight:700; background:#eef2f7; }
.badge.success { background:#e9f7ef; color:var(--success); }
.badge.warning { background:#fff6dc; color:var(--warning); }
.badge.danger { background:#fff0ee; color:var(--danger); }
.list { display:flex; flex-direction:column; gap:10px; }
.list-item { border:1px solid var(--line); border-radius:12px; padding:13px; display:flex; justify-content:space-between; align-items:center; gap:12px; }
.list-item strong { display:block; }
.list-item small { color:var(--muted); display:block; margin-top:3px; }
.alert { border-radius:12px; padding:12px 14px; background:#fff8e8; border:1px solid #f4dfad; color:#725400; font-size:13px; }
.empty { padding:28px; text-align:center; color:var(--muted); border:1px dashed var(--line); border-radius:12px; }
.toolbar { display:flex; flex-wrap:wrap; gap:10px; margin-bottom:16px; }
.toolbar input, .toolbar select { min-width:180px; }
input, select, textarea { width:100%; padding:11px 12px; border:1px solid #d9dfE8; border-radius:10px; background:white; color:var(--ink); outline:none; }
input:focus, select:focus, textarea:focus { border-color:#8ba3c4; box-shadow:0 0 0 3px rgba(21,45,79,.08); }
label { font-size:13px; font-weight:650; display:block; margin-bottom:6px; }
.form-grid { display:grid; grid-template-columns:1fr 1fr; gap:14px; }
.form-group.full { grid-column:1/-1; }
.form-actions { display:flex; justify-content:flex-end; gap:10px; margin-top:18px; }
.modal-backdrop { position:fixed; inset:0; background:rgba(10,18,32,.58); display:grid; place-items:center; padding:20px; z-index:100; }
.modal-backdrop.hidden { display:none; }
.modal { width:min(720px,100%); max-height:90vh; overflow:auto; background:white; border-radius:18px; box-shadow:0 30px 80px rgba(0,0,0,.25); padding:22px; }
.modal h2 { margin:0 0 6px; }
.modal .sub { color:var(--muted); margin:0 0 18px; font-size:13px; }
.duration-options { display:grid; grid-template-columns:repeat(5,1fr); gap:8px; }
.duration-options button { padding:12px 8px; border:1px solid var(--line); border-radius:10px; background:white; }
.duration-options button.selected { background:var(--brand); color:white; border-color:var(--brand); }
.summary-box { background:#f7f9fc; border:1px solid var(--line); border-radius:12px; padding:13px; margin-top:12px; font-size:13px; }
.summary-box strong { font-size:15px; }
.detail-header { display:flex; justify-content:space-between; gap:12px; align-items:flex-start; margin-bottom:16px; }
.detail-header h2 { margin:0; }
.detail-header p { color:var(--muted); margin:5px 0 0; }
.stats-row { display:grid; grid-template-columns:repeat(3,1fr); gap:12px; margin:16px 0; }
.stat-mini { border:1px solid var(--line); border-radius:12px; padding:13px; }
.stat-mini span { display:block; color:var(--muted); font-size:12px; }
.stat-mini strong { display:block; font-size:19px; margin-top:4px; }
.product-card { border:1px solid var(--line); border-radius:14px; padding:16px; }
.product-card h3 { margin:0 0 6px; font-size:16px; }
.product-card p { margin:0; color:var(--muted); font-size:13px; }
.product-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:14px; }
.toast { position:fixed; right:24px; bottom:24px; background:#101d31; color:white; padding:12px 16px; border-radius:10px; box-shadow:var(--shadow); z-index:200; max-width:360px; }
.toast.hidden { display:none; }
.mobile-nav, .mobile-only { display:none; }
.link-btn { border:0; background:none; color:var(--brand); padding:0; font-weight:700; }
.money { font-variant-numeric:tabular-nums; }
@media (max-width: 980px) {
  .metrics { grid-template-columns:repeat(2,1fr); }
  .two-col { grid-template-columns:1fr; }
  .product-grid { grid-template-columns:repeat(2,1fr); }
}
@media (max-width: 720px) {
  .app-shell { grid-template-columns:1fr; }
  .sidebar { position:fixed; inset:0 auto 0 0; width:260px; transform:translateX(-105%); transition:.2s; z-index:150; box-shadow:20px 0 60px rgba(0,0,0,.25); }
  .sidebar.open { transform:translateX(0); }
  .mobile-only { display:block; }
  .topbar { height:76px; padding:0 16px; }
  .topbar h1 { font-size:19px; }
  .topbar-actions .primary { display:none; }
  .content { padding:16px 14px 92px; }
  .metrics { grid-template-columns:1fr 1fr; gap:10px; }
  .metric { padding:14px; }
  .metric .value { font-size:21px; }
  .product-grid { grid-template-columns:1fr; }
  .form-grid { grid-template-columns:1fr; }
  .form-group.full { grid-column:auto; }
  .duration-options { grid-template-columns:repeat(3,1fr); }
  .stats-row { grid-template-columns:1fr; }
  .mobile-nav { position:fixed; display:grid; grid-template-columns:repeat(5,1fr); left:0; right:0; bottom:0; height:68px; border-top:1px solid var(--line); background:white; z-index:90; box-shadow:0 -8px 24px rgba(0,0,0,.06); }
  .mobile-nav button { border:0; background:white; color:var(--muted); font-size:12px; }
  .mobile-nav .mobile-add { width:52px; height:52px; border-radius:50%; background:var(--brand); color:white; font-size:28px; align-self:center; justify-self:center; margin-top:-20px; box-shadow:0 8px 20px rgba(21,45,79,.3); }
  .modal-backdrop { padding:8px; align-items:end; }
  .modal { width:100%; max-height:92vh; border-radius:20px 20px 0 0; padding:18px; }
}

.hidden { display: none !important; }
.connection-pill { display:inline-flex; align-items:center; padding:6px 9px; border-radius:999px; font-size:12px; font-weight:750; background:#eef2f7; color:var(--muted); margin-right:8px; }
.connection-pill.live { background:#e9f7ef; color:var(--success); }
.connection-pill.syncing { background:#fff6dc; color:var(--warning); }
.auth-gate { min-height:100vh; display:grid; place-items:center; padding:24px; background:var(--bg); }
.auth-card { width:min(440px,100%); background:white; border:1px solid var(--line); border-radius:20px; box-shadow:var(--shadow); padding:26px; }
.auth-logo { width:54px; height:54px; border-radius:14px; display:grid; place-items:center; background:#101d31; color:white; font-weight:800; margin-bottom:18px; }
.auth-card h1 { font-size:22px; margin:0 0 6px; }
.auth-card p { color:var(--muted); margin:0 0 20px; font-size:14px; line-height:1.5; }
.auth-card .form-group { margin-bottom:14px; }
.auth-card .primary { width:100%; margin-top:4px; }
.auth-error { color:var(--danger); font-size:13px; margin-top:12px; min-height:19px; }
.setup-note { background:#fff8e8; border:1px solid #f4dfad; color:#725400; border-radius:12px; padding:12px; font-size:13px; line-height:1.45; }
.sync-note { font-size:12px; color:var(--muted); margin-top:8px; }
@media (max-width:720px) { .connection-pill { display:none; } }
