/* Realign Control Center™ — app styles */
:root {
  --bg: #f1f5f9; --panel: #ffffff; --ink: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --brand: #2563eb; --brand-2: #0ea5e9; --safe: #16a34a; --warn: #f59e0b; --crit: #dc2626;
  --sidebar: #0b1220; --sidebar-ink: #cbd5e1; --sidebar-active: #1e293b;
  --radius: 12px; --shadow: 0 1px 2px rgba(15,23,42,.06), 0 8px 24px rgba(15,23,42,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif; background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
button { font: inherit; cursor: pointer; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1200px 600px at 70% -10%, #1e3a8a 0%, #0b1220 55%); padding: 24px; }
.login-card { width: 100%; max-width: 400px; background: var(--panel); border-radius: 16px; box-shadow: var(--shadow); padding: 32px; }
.login-card .logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; margin-bottom: 4px; }
.login-card p.sub { color: var(--muted); margin: 0 0 22px; font-size: 14px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field input, .field select { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; font-size: 14px; background: #fff; }
.field input:focus, .field select:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: 9px; border: 1px solid var(--line); background: #fff; font-weight: 600; font-size: 14px; color: var(--ink); }
.btn:hover { background: #f8fafc; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #1d4ed8; }
.btn.block { width: 100%; }
.btn.sm { padding: 6px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.danger { color: var(--crit); border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }
.mfa-note { font-size: 12px; color: var(--muted); margin-top: 14px; text-align: center; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px; color: #fff; font-weight: 800; font-size: 15px; border-bottom: 1px solid rgba(255,255,255,.06); }
.sidebar .brand .mark { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); display: grid; place-items: center; font-size: 16px; }
.nav { padding: 10px; overflow-y: auto; flex: 1; }
.nav .group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: #64748b; padding: 14px 12px 6px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 9px; color: var(--sidebar-ink); font-size: 14px; font-weight: 500; margin-bottom: 2px; }
.nav a .ico { width: 18px; text-align: center; opacity: .9; }
.nav a:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav a.active { background: var(--sidebar-active); color: #fff; box-shadow: inset 3px 0 0 var(--brand-2); }
.nav a .badge { margin-left: auto; background: var(--crit); color: #fff; font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 20px; }
.sidebar .foot { padding: 12px 14px; border-top: 1px solid rgba(255,255,255,.06); font-size: 12px; color: #64748b; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 14px 26px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar h1 { font-size: 18px; margin: 0; font-weight: 700; }
.topbar .spacer { flex: 1; }
.tenant-select { display: flex; align-items: center; gap: 8px; }
.tenant-select select { padding: 8px 12px; border-radius: 9px; border: 1px solid var(--line); font-size: 13.5px; font-weight: 600; background: #fff; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.content { padding: 26px; max-width: 1280px; width: 100%; margin: 0 auto; }
.page-intro { color: var(--muted); margin: -6px 0 20px; font-size: 14px; }

/* ---------- Cards / KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi .label { font-size: 12.5px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.kpi .value { font-size: 28px; font-weight: 800; margin-top: 8px; letter-spacing: -.02em; }
.kpi .delta { font-size: 12px; margin-top: 4px; font-weight: 600; }
.kpi .delta.up { color: var(--safe); } .kpi .delta.down { color: var(--crit); }
.kpi .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: 1.6fr 1fr; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card .hd { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.card .hd h3 { margin: 0; font-size: 15px; font-weight: 700; }
.card .hd .spacer { flex: 1; }
.card .bd { padding: 16px 18px; }
.card .bd.tight { padding: 0; }
canvas { display: block; width: 100%; }

/* ---------- Table ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input[type=search] { padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; font-size: 13.5px; min-width: 240px; background: #fff; }
.toolbar select { padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; font-size: 13.5px; background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th { text-align: left; padding: 11px 14px; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: none; }
.cell-main { font-weight: 600; }
.cell-sub { color: var(--muted); font-size: 12px; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.pill .d { width: 7px; height: 7px; border-radius: 50%; }
.pill.green { background: #dcfce7; color: #166534; } .pill.green .d { background: var(--safe); }
.pill.red { background: #fee2e2; color: #991b1b; } .pill.red .d { background: var(--crit); }
.pill.amber { background: #fef3c7; color: #92400e; } .pill.amber .d { background: var(--warn); }
.pill.gray { background: #e2e8f0; color: #475569; } .pill.gray .d { background: #94a3b8; }
.pill.blue { background: #dbeafe; color: #1e40af; } .pill.blue .d { background: var(--brand); }
.tag { font-size: 11.5px; padding: 2px 8px; border-radius: 6px; background: #eef2ff; color: #3730a3; font-weight: 600; }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.muted { color: var(--muted); }
.bar { height: 7px; border-radius: 6px; background: #e2e8f0; overflow: hidden; min-width: 70px; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }

/* ---------- Profiles / generic grids ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.tile .emoji { font-size: 30px; }
.tile h4 { margin: 10px 0 4px; font-size: 15px; }
.tile p { margin: 0 0 12px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.tile .meta { display: flex; gap: 8px; flex-wrap: wrap; }

.plan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px,1fr)); gap: 16px; }
.plan { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); position: relative; }
.plan.feat { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand) inset, var(--shadow); }
.plan h4 { margin: 0 0 6px; }
.plan .price { font-size: 30px; font-weight: 800; }
.plan .price small { font-size: 14px; color: var(--muted); font-weight: 600; }
.plan ul { list-style: none; padding: 0; margin: 14px 0 0; font-size: 13.5px; }
.plan li { padding: 5px 0; display: flex; gap: 8px; } .plan li::before { content: "✓"; color: var(--safe); font-weight: 800; }

/* ---------- Drawer / modal ---------- */
.scrim { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 60; opacity: 0; pointer-events: none; transition: opacity .2s; }
.scrim.open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: 460px; max-width: 92vw; background: var(--panel); z-index: 70; box-shadow: -16px 0 40px rgba(15,23,42,.18); transform: translateX(100%); transition: transform .24s ease; display: flex; flex-direction: column; }
.drawer.open { transform: none; }
.drawer .hd { display: flex; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.drawer .hd h3 { margin: 0; font-size: 16px; }
.drawer .hd .x { margin-left: auto; border: none; background: none; font-size: 22px; color: var(--muted); }
.drawer .bd { padding: 20px; overflow-y: auto; flex: 1; }
.drawer .ft { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; font-size: 13.5px; margin-bottom: 16px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 600; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; margin: 18px 0 8px; }

.modal { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 20px; }
.modal .box { background: #fff; border-radius: 14px; width: 100%; max-width: 480px; box-shadow: var(--shadow); }
.modal .box .hd { padding: 18px 20px; border-bottom: 1px solid var(--line); font-weight: 700; }
.modal .box .bd { padding: 20px; } .modal .box .ft { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }

.empty { text-align: center; color: var(--muted); padding: 40px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tabs button { border: none; background: none; padding: 10px 14px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }

.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 6px; vertical-align: middle; }

#toasts { position: fixed; bottom: 22px; right: 22px; z-index: 90; display: flex; flex-direction: column; gap: 10px; }
.toast { background: #0f172a; color: #fff; padding: 12px 16px; border-radius: 10px; font-size: 13.5px; box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); transition: all .25s; max-width: 320px; }
.toast.show { opacity: 1; transform: none; }
.toast.ok { border-left: 3px solid var(--safe); }
.toast.warn { border-left: 3px solid var(--warn); }

.switch { position: relative; display: inline-block; width: 42px; height: 24px; }
.switch input { display: none; }
.switch .track { position: absolute; inset: 0; background: #cbd5e1; border-radius: 20px; transition: .2s; }
.switch .track::before { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: .2s; }
.switch input:checked + .track { background: var(--safe); }
.switch input:checked + .track::before { transform: translateX(18px); }
.settings-row { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.settings-row .txt { flex: 1; } .settings-row .txt b { display: block; font-size: 14px; } .settings-row .txt span { color: var(--muted); font-size: 12.5px; }

@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s; z-index: 80; width: 248px; }
  .sidebar.open { transform: none; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
  .menu-btn { display: inline-flex !important; }
}
.menu-btn { display: none; }
