:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --ink: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --primary: #2563eb;
    --danger: #dc2626;
    --success: #16a34a;
    --shadow: 0 18px 45px rgba(15, 23, 42, .08);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--primary); text-decoration: none; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 280px 1fr; }
.sidebar { background: #0f172a; color: #e5e7eb; padding: 24px; }
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 34px; }
.brand.centered { justify-content: center; margin-bottom: 24px; }
.brand-mark { width: 42px; height: 42px; border-radius: 14px; background: linear-gradient(135deg, #60a5fa, #1d4ed8); display: grid; place-items: center; color: white; font-weight: 900; }
.brand strong { display: block; line-height: 1.1; }
.brand span { display: block; color: #94a3b8; font-size: 13px; margin-top: 4px; }
.sidebar nav { display: grid; gap: 8px; }
.sidebar nav a { color: #cbd5e1; padding: 11px 12px; border-radius: 12px; }
.sidebar nav a:hover { background: rgba(255,255,255,.08); color: white; }
.sidebar nav a.disabled { opacity: .45; pointer-events: none; }
.main { padding: 32px; }
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top, #dbeafe, #f8fafc 45%, #eef2ff); }
.auth-card { width: 100%; max-width: 430px; background: white; padding: 30px; border-radius: 24px; box-shadow: var(--shadow); }
h1 { margin: 0 0 8px; font-size: 32px; letter-spacing: -0.04em; }
h2 { margin: 0 0 16px; font-size: 20px; }
p { line-height: 1.6; }
.muted { color: var(--muted); }
.center { text-align: center; }
.page-head { display: flex; justify-content: space-between; gap: 20px; align-items: center; margin-bottom: 24px; }
.page-head p { color: var(--muted); margin: 0; }
.card, .empty-state, .tenant-hero { background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 22px; padding: 24px; margin-bottom: 22px; }
.empty-state { text-align: center; padding: 60px 24px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat { background: white; border: 1px solid var(--line); border-radius: 20px; padding: 20px; box-shadow: 0 10px 22px rgba(15,23,42,.04); }
.stat span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.stat strong { font-size: 26px; }
.btn { display: inline-flex; align-items: center; justify-content: center; border: 0; background: var(--primary); color: white; padding: 11px 16px; border-radius: 12px; font-weight: 700; cursor: pointer; font-size: 14px; }
.btn:hover { filter: brightness(.95); color: white; }
.btn.secondary { background: #e2e8f0; color: #0f172a; }
.btn.danger { background: var(--danger); }
.btn.small { padding: 8px 10px; font-size: 12px; }
.btn.full { width: 100%; margin-top: 12px; }
.form { display: grid; gap: 12px; }
.form label { font-weight: 700; font-size: 13px; }
input, select, textarea { width: 100%; padding: 12px 13px; border: 1px solid #cbd5e1; border-radius: 12px; font: inherit; background: white; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 3px solid #bfdbfe; border-color: #60a5fa; }
small { display: block; color: var(--muted); margin-top: 5px; }
.grid-form { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-form .wide, .wide { grid-column: 1 / -1; }
hr { border: 0; border-top: 1px solid var(--line); width: 100%; }
.check { display: flex; align-items: center; gap: 10px; }
.check input { width: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 14px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: #475569; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }
.pill { display: inline-flex; padding: 5px 10px; border-radius: 999px; font-weight: 800; font-size: 12px; background: #e2e8f0; color: #334155; }
.pill.active { background: #dcfce7; color: #166534; }
.pill.trial { background: #dbeafe; color: #1e40af; }
.pill.suspended, .pill.cancelled { background: #fee2e2; color: #991b1b; }
.alert { padding: 13px 15px; border-radius: 14px; margin-bottom: 18px; font-weight: 700; }
.alert.success { background: #dcfce7; color: #166534; }
.alert.error { background: #fee2e2; color: #991b1b; }
.tenant-hero { min-height: 420px; display: grid; align-content: center; background: linear-gradient(135deg, var(--secondary), var(--primary)); color: white; }
.tenant-hero p { color: rgba(255,255,255,.82); }
.tenant-badge { display: inline-flex; width: fit-content; padding: 7px 12px; border-radius: 999px; background: rgba(255,255,255,.16); font-weight: 800; margin-bottom: 14px; }
.portal-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 22px; }
.portal-card { background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.22); color: white; border-radius: 20px; padding: 20px; backdrop-filter: blur(8px); }
.portal-card:hover { background: rgba(255,255,255,.18); color: white; }
.portal-card strong { display: block; font-size: 20px; margin-bottom: 8px; }
.portal-card span { color: rgba(255,255,255,.78); }
@media (max-width: 900px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; }
    .stats-grid, .grid-form, .portal-grid { grid-template-columns: 1fr; }
    .page-head { align-items: flex-start; flex-direction: column; }
}

/* Phase 2 operational UI */
.page-head{display:flex;justify-content:space-between;gap:1rem;align-items:flex-start;margin-bottom:1.25rem}.page-head h1{margin:.1rem 0}.page-head p{color:#64748b;margin:.25rem 0}.grid.two{display:grid;grid-template-columns:minmax(280px,.85fr) minmax(360px,1.4fr);gap:1rem;align-items:start}.card.wide{overflow:auto}.form-grid{display:grid;grid-template-columns:repeat(2,minmax(180px,1fr));gap:1rem}label{display:block;font-weight:650;margin:.7rem 0 .3rem}input,select,textarea{width:100%;box-sizing:border-box;padding:.7rem .8rem;border:1px solid #d8dee9;border-radius:12px;background:#fff}button,.button{display:inline-flex;align-items:center;justify-content:center;background:#2563eb;color:#fff;border:0;border-radius:12px;padding:.7rem 1rem;font-weight:700;text-decoration:none;cursor:pointer}.button.secondary,button.secondary{background:#0f172a}.danger,button.danger{background:#dc2626}.linkbtn{background:transparent;color:#2563eb;padding:0;border-radius:0}.linkbtn.danger{color:#dc2626;background:transparent}.actions{display:flex;gap:.5rem;flex-wrap:wrap}.actions form{display:inline}.badge{display:inline-block;padding:.22rem .55rem;border-radius:999px;background:#eef2ff;color:#3730a3;font-size:.82rem;font-weight:700}table{width:100%;border-collapse:collapse}th,td{padding:.75rem;border-bottom:1px solid #e5e7eb;text-align:left;vertical-align:top}th{font-size:.82rem;color:#475569;text-transform:uppercase;letter-spacing:.03em}small,.muted{color:#64748b}dl{display:grid;grid-template-columns:150px 1fr;gap:.45rem .75rem}dt{font-weight:700;color:#475569}dd{margin:0}@media (max-width:900px){.grid.two,.form-grid{grid-template-columns:1fr}.page-head{display:block}}
