:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-soft: #f9fafc;
  --text: #171b25;
  --muted: #6c7484;
  --line: #e7eaf0;
  --accent: #5b5bd6;
  --accent-soft: #ededff;
  --dark: #11131a;
  --good: #21956a;
  --warn: #b97a20;
  --bad: #cf4a62;
  --shadow: 0 18px 50px rgba(28, 35, 55, .08);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; font-family: Inter, system-ui, sans-serif; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.boot-screen { position: fixed; inset: 0; display: grid; place-items: center; align-content: center; gap: 14px; background: var(--bg); z-index: 500; color: var(--muted); font-size: 12px; }
.spinner { width: 34px; height: 34px; border: 3px solid #e3e6ee; border-top-color: var(--accent); border-radius: 50%; animation: spin .85s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.auth-layout { min-height: 100vh; display: grid; grid-template-columns: minmax(420px, 1.05fr) minmax(420px, .95fr); }
.auth-hero { background: radial-gradient(circle at 20% 20%, rgba(110,110,230,.25), transparent 34%), linear-gradient(145deg, #12141d, #1c2030); color: white; display: grid; place-items: center; padding: 64px; }
.hero-inner { width: min(650px, 100%); }
.platform-brand { display: flex; align-items: center; gap: 12px; }
.platform-brand strong { display: block; font-size: 13px; }
.platform-brand span { display: block; color: #9499a8; font-size: 10px; margin-top: 3px; }
.logo-mark { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: linear-gradient(145deg, #7a7aeb, #4e4ec6); color: white; font-weight: 800; box-shadow: inset 0 1px 0 rgba(255,255,255,.18); }
.hero-copy { margin: 100px 0 56px; }
.eyebrow { color: #7878df; font-size: 10px; font-weight: 800; letter-spacing: .14em; }
.auth-hero .eyebrow { color: #9e9efa; }
.hero-copy h1 { font-size: clamp(38px, 4.2vw, 64px); line-height: 1.02; letter-spacing: -.045em; max-width: 640px; margin: 13px 0 20px; }
.hero-copy p { color: #aab0bf; line-height: 1.75; font-size: 14px; max-width: 560px; }
.trust-list { display: grid; gap: 18px; }
.trust-list > div { display: grid; grid-template-columns: 28px 1fr; gap: 12px; }
.trust-icon { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: rgba(68,200,145,.12); color: #52d59d; font-size: 11px; font-weight: 800; }
.trust-list strong { font-size: 12px; }
.trust-list p { color: #888f9f; font-size: 10px; line-height: 1.55; margin: 4px 0 0; }

.auth-panel { display: grid; place-items: center; padding: 40px; }
.auth-card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 34px; box-shadow: var(--shadow); }
.auth-card h2 { margin: 7px 0 8px; font-size: 28px; letter-spacing: -.035em; }
.muted { color: var(--muted); font-size: 12px; line-height: 1.6; }
.mobile-brand { display: none; align-items: center; gap: 10px; margin-bottom: 28px; }
.form-stack { display: grid; gap: 15px; margin-top: 24px; }
.form-stack.compact { margin-top: 12px; }
.form-stack label { display: grid; gap: 7px; color: var(--muted); font-size: 10px; font-weight: 700; }
.form-stack input, .workspace-control select { width: 100%; border: 1px solid var(--line); border-radius: 10px; background: #fbfcfe; color: var(--text); padding: 12px 13px; outline: none; transition: .15s ease; }
.form-stack input:focus, .workspace-control select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.btn { border: 0; border-radius: 10px; padding: 11px 14px; font-weight: 750; font-size: 11px; }
.btn.primary { background: var(--accent); color: white; box-shadow: 0 7px 18px rgba(91,91,214,.22); }
.btn.secondary { background: #f1f3f7; color: #42495a; border: 1px solid #e3e6ec; }
.btn.dark { background: #242833; color: #dfe2e9; }
.btn.full { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.link-button { border: 0; background: transparent; color: var(--accent); padding: 13px 0 0; font-size: 10px; font-weight: 700; }
.invite-note { border-top: 1px solid var(--line); margin-top: 24px; padding-top: 18px; color: var(--muted); font-size: 10px; line-height: 1.55; }
.message { border-radius: 10px; padding: 10px 12px; font-size: 10px; line-height: 1.5; margin: 14px 0; background: #edf8f3; border: 1px solid #ccebdc; color: #277957; }
.message.error { background: #fff0f2; border-color: #f4d2d9; color: #a83d53; }
.message.warning { background: #fff8ea; border-color: #f0dfb7; color: #896019; }

.portal { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0,1fr); }
.portal-sidebar { position: sticky; top: 0; height: 100vh; background: var(--dark); color: white; padding: 22px 18px; display: flex; flex-direction: column; }
.sidebar-brand { padding: 0 6px 24px; }
.workspace-control { border-top: 1px solid #2a2d37; border-bottom: 1px solid #2a2d37; padding: 18px 4px; margin-bottom: 18px; }
.workspace-control label { display: block; color: #757b89; font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 7px; }
.workspace-control select { background: #1c1f28; border-color: #30343f; color: #edf0f6; padding: 10px; min-width: 0; }
.portal-nav { display: grid; gap: 6px; }
.portal-nav button { border: 0; background: transparent; color: #9096a4; display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 10px; text-align: left; font-size: 11px; }
.portal-nav button span { width: 18px; text-align: center; color: #9f9ff4; }
.portal-nav button:hover, .portal-nav button.active { background: #20232e; color: white; }
.sidebar-footer { margin-top: auto; border-top: 1px solid #2a2d37; padding: 18px 4px 0; }
.security-status { color: #9399a7; font-size: 9px; display: flex; align-items: center; gap: 7px; }
.security-status span { width: 7px; height: 7px; border-radius: 50%; background: #38c88c; box-shadow: 0 0 0 4px rgba(56,200,140,.10); }
.user-email { color: #c7cbd4; font-size: 9px; word-break: break-all; margin: 10px 0 12px; }

.portal-main { min-width: 0; padding: 0 30px 42px; }
.portal-header { min-height: 112px; display: flex; justify-content: space-between; align-items: center; gap: 22px; border-bottom: 1px solid var(--line); margin-bottom: 25px; }
.portal-header h1 { margin: 4px 0 5px; font-size: 25px; letter-spacing: -.03em; }
.portal-header p { margin: 0; color: var(--muted); font-size: 11px; }
.header-user { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 10px; }
.role-badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 8px; font-size: 8px; font-weight: 800; letter-spacing: .06em; color: #5454bf; background: var(--accent-soft); }
.role-badge.admin { color: #9b5b17; background: #fff2df; }
.portal-section { display: none; }
.portal-section.active { display: block; }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 18px; margin-bottom: 18px; }
.section-head h2 { margin: 0 0 4px; font-size: 18px; }
.section-head p { margin: 0; color: var(--muted); font-size: 11px; }
.workspace-secure { color: var(--good); background: #edf8f3; border: 1px solid #ccebdc; border-radius: 999px; padding: 7px 10px; font-size: 9px; font-weight: 700; }
.stat-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 14px; margin-bottom: 16px; }
.stat-card, .card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.stat-card { padding: 17px; }
.stat-card > span { color: var(--muted); font-size: 9px; font-weight: 700; }
.stat-card strong { display: block; margin: 12px 0 6px; font-size: 22px; letter-spacing: -.03em; }
.stat-card small { color: #8c93a1; font-size: 9px; }
.content-grid { display: grid; grid-template-columns: minmax(0,1.45fr) minmax(300px,.75fr); gap: 16px; }
.card { padding: 18px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 14px; }
.card-head h3 { margin: 0 0 3px; font-size: 12px; }
.card-head p { margin: 0; color: var(--muted); font-size: 9px; }
.phase-badge { border-radius: 999px; padding: 5px 8px; background: #f2f3f7; color: #7d8491; font-size: 8px; font-weight: 800; }
.preview-chart { position: relative; height: 300px; border-radius: 12px; background: linear-gradient(180deg,#fbfcff,#f6f8fc); border: 1px solid #edf0f5; overflow: hidden; }
.preview-chart::before { content: ''; position: absolute; inset: 0; background-image: linear-gradient(#edf0f4 1px, transparent 1px), linear-gradient(90deg,#edf0f4 1px, transparent 1px); background-size: 100% 48px, 75px 100%; opacity: .55; }
.chart-line { position: absolute; left: 5%; right: 5%; height: 2px; border-radius: 999px; transform-origin: left center; z-index: 2; }
.line-a { top: 58%; background: var(--accent); transform: rotate(-8deg); box-shadow: 100px -28px 0 -1px var(--accent), 220px -14px 0 -1px var(--accent), 340px -54px 0 -1px var(--accent); }
.line-b { top: 72%; background: #30a275; transform: rotate(-4deg); }
.chart-placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: #8d94a3; font-size: 10px; font-weight: 700; z-index: 3; }
.security-list { display: grid; gap: 13px; }
.security-list > div { display: grid; grid-template-columns: 31px 1fr; gap: 10px; align-items: start; }
.security-list > div > span { width: 29px; height: 29px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 9px; font-weight: 800; }
.security-list strong { font-size: 10px; }
.security-list p { margin: 4px 0 0; color: var(--muted); font-size: 9px; line-height: 1.5; }
.empty-state { text-align: center; padding: 70px 24px; }
.empty-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; margin: 0 auto 16px; color: var(--accent); background: var(--accent-soft); font-size: 23px; }
.empty-state h3 { margin: 0 0 8px; font-size: 14px; }
.empty-state p { color: var(--muted); max-width: 520px; margin: 0 auto; font-size: 10px; line-height: 1.6; }
.account-card { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 16px; }
.account-card > div { border-right: 1px solid var(--line); padding-right: 16px; }
.account-card > div:last-child { border-right: 0; }
.account-card span { display: block; color: var(--muted); font-size: 9px; margin-bottom: 7px; }
.account-card strong { font-size: 11px; word-break: break-all; }
.admin-grid { display: grid; grid-template-columns: minmax(0,1.2fr) minmax(280px,.6fr); gap: 16px; margin-bottom: 16px; }
.admin-summary { display: flex; flex-direction: column; justify-content: center; }
.admin-summary > span { color: var(--muted); font-size: 9px; font-weight: 700; }
.admin-summary > strong { font-size: 42px; letter-spacing: -.05em; margin: 10px 0; }
.admin-summary p { color: var(--muted); font-size: 9px; line-height: 1.55; margin: 0; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 10px; }
th { text-align: left; color: var(--muted); font-size: 8px; text-transform: uppercase; letter-spacing: .06em; padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 8px; border-bottom: 1px solid #f0f2f5; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
.table-empty { text-align: center; color: var(--muted); padding: 28px; }
.status-pill { border-radius: 999px; padding: 4px 7px; font-size: 8px; font-weight: 700; background: #edf8f3; color: var(--good); }

@media (max-width: 1100px) {
  .auth-layout { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .auth-panel { min-height: 100vh; }
  .mobile-brand { display: flex; }
  .stat-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .content-grid, .admin-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .portal { display: block; }
  .portal-sidebar { position: static; height: auto; }
  .portal-nav { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .sidebar-footer { margin-top: 18px; }
  .portal-main { padding: 0 15px 30px; }
  .portal-header { align-items: flex-start; flex-direction: column; padding: 22px 0; }
  .stat-grid, .account-card { grid-template-columns: 1fr; }
  .account-card > div { border-right: 0; border-bottom: 1px solid var(--line); padding: 0 0 14px; }
  .account-card > div:last-child { border-bottom: 0; }
  .section-head { align-items: flex-start; flex-direction: column; }
  .auth-panel { padding: 18px; }
  .auth-card { padding: 25px; }
}
