:root {
  --navy: #0f172a;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --bg: #f4f7fb;
  --text: #111827;
  --muted: #64748b;
  --border: #dce5ef;
  --teal: #0f766e;
  --teal-dark: #115e59;
  --red: #b91c1c;
  --yellow: #a16207;
  --green: #166534;
  --shadow: 0 14px 35px rgba(15, 23, 42, 0.08);
  --radius: 12px;
}

[data-theme="dark"] {
  --panel: #111827;
  --panel-soft: #0f172a;
  --bg: #0b1120;
  --text: #f8fafc;
  --muted: #94a3b8;
  --border: #263244;
  --shadow: 0 14px 35px rgba(0, 0, 0, 0.32);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #eef3f8;
}
.auth-card {
  width: min(1080px, 100%);
  min-height: 620px;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  background: #fff;
  border: 1px solid #dbe4ef;
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.14);
  overflow: hidden;
}
.auth-info {
  padding: 48px;
  color: #fff;
  background: #0f172a;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.brand { font-weight: 900; letter-spacing: -0.03em; font-size: 20px; }
.auth-info h1 { margin: 60px 0 18px; font-size: clamp(34px, 5vw, 56px); line-height: 1.02; letter-spacing: -0.06em; }
.auth-info p { margin: 0; color: #cbd5e1; line-height: 1.65; max-width: 560px; }
.auth-points { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 32px; }
.auth-points div { border: 1px solid rgba(255,255,255,.14); border-radius: 12px; padding: 15px; background: rgba(255,255,255,.04); }
.auth-points strong { display: block; margin-bottom: 4px; }
.auth-points span { color: #cbd5e1; font-size: 12px; line-height: 1.4; }
.auth-form-wrap { padding: 44px; display: flex; flex-direction: column; justify-content: center; color: #0f172a; }
.auth-form-wrap h2 { margin: 0 0 8px; font-size: 30px; letter-spacing: -0.04em; }
.auth-form-wrap p { margin: 0 0 24px; color: #64748b; }

.server-help {
  display: grid;
  gap: 10px;
  padding: 14px;
  margin: 16px 0;
  border: 1px solid #dbe4ef;
  border-radius: 12px;
  background: #f8fafc;
  color: #0f172a;
}
.server-help code {
  display: block;
  padding: 10px 12px;
  border-radius: 9px;
  background: #0f172a;
  color: #f8fafc;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
}
.server-help span {
  color: #475569;
  line-height: 1.45;
  font-size: 13px;
}

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 272px minmax(0, 1fr); }
.sidebar { background: var(--navy); color: #fff; height: 100vh; position: sticky; top: 0; overflow-y: auto; padding: 20px; z-index: 40; }
.sidebar-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid rgba(255,255,255,.12); padding-bottom: 18px; margin-bottom: 18px; }
.sidebar-role { margin: 14px 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: #94a3b8; font-weight: 900; }
.nav-list { display: grid; gap: 6px; }
.nav-item { border: 0; background: transparent; color: #cbd5e1; border-radius: 10px; padding: 10px 11px; text-align: left; font-weight: 750; width: 100%; }
.nav-item:hover, .nav-item.active { background: rgba(20,184,166,.14); color: #fff; }
.sidebar-actions { margin-top: 16px; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.12); display: grid; }

.main { min-width: 0; }
.topbar { min-height: 72px; position: sticky; top: 0; z-index: 25; background: rgba(255,255,255,.9); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 26px; }
[data-theme="dark"] .topbar { background: rgba(17,24,39,.9); }
.topbar h1 { margin: 0; font-size: clamp(22px, 3vw, 29px); letter-spacing: -0.04em; }
.topbar p { margin: 3px 0 0; color: var(--muted); font-size: 13px; font-weight: 650; }
.user-pill { border: 1px solid var(--border); background: var(--panel); border-radius: 999px; padding: 9px 12px; font-size: 13px; font-weight: 800; white-space: nowrap; }
.content { width: 100%; max-width: 1500px; margin: 0 auto; padding: 26px; }

.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, .9fr); gap: 16px; align-items: start; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 15px; }
.card-title { margin: 0; font-size: 18px; letter-spacing: -0.03em; }
.card-subtitle { margin: 4px 0 0; color: var(--muted); line-height: 1.45; font-size: 13px; }
.stat-card { min-height: 120px; display: flex; flex-direction: column; justify-content: space-between; }
.stat-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .07em; font-weight: 900; }
.stat-value { font-size: clamp(27px,4vw,40px); font-weight: 900; letter-spacing: -0.06em; margin: 3px 0; }
.stat-foot { color: var(--muted); font-size: 12px; font-weight: 650; }

.form-stack { display: grid; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
label { display: grid; gap: 7px; font-size: 13px; font-weight: 800; color: var(--muted); }
input, select, textarea { width: 100%; min-height: 42px; padding: 11px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); color: var(--text); outline: 0; }
textarea { min-height: 94px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(15,118,110,.13); }
.btn { border: 0; border-radius: 10px; min-height: 40px; padding: 10px 14px; background: var(--teal); color: #fff; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn:hover { background: var(--teal-dark); }
.btn.secondary { background: var(--panel-soft); color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: var(--red); }
.btn.small { min-height: 34px; padding: 7px 10px; font-size: 13px; border-radius: 8px; }
.inline-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.search { max-width: 360px; }
.message { margin-top: 12px; padding: 11px 12px; border-radius: 10px; font-size: 13px; font-weight: 750; }
.message.error { background: #fee2e2; border: 1px solid #fecaca; color: #991b1b; }
.message.success { background: #dcfce7; border: 1px solid #bbf7d0; color: #166534; }

.field-error {
  display: none;
  margin-top: 6px;
  color: #991b1b;
  font-size: 12px;
  font-weight: 800;
}
.field-error.show { display: block; }
.form-stack input.has-error, .form-stack select.has-error, .form-stack textarea.has-error {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}
.empty { padding: 24px; border: 1px dashed var(--border); border-radius: 12px; color: var(--muted); background: var(--panel-soft); text-align: center; font-weight: 750; }

.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; min-width: 820px; }
th, td { padding: 12px 13px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--panel-soft); color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .07em; font-weight: 900; }
td { font-size: 14px; }
tbody tr:hover { background: var(--panel-soft); }
tbody tr:last-child td { border-bottom: 0; }
.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 4px 8px; border-radius: 999px; background: var(--panel-soft); border: 1px solid var(--border); color: var(--muted); font-size: 12px; font-weight: 850; white-space: nowrap; }
.badge.green { color: #166534; background: #dcfce7; border-color: #bbf7d0; }
.badge.red { color: #991b1b; background: #fee2e2; border-color: #fecaca; }
.badge.yellow { color: #92400e; background: #fef3c7; border-color: #fde68a; }
.badge.teal { color: #0f766e; background: #ccfbf1; border-color: #99f6e4; }
[data-theme="dark"] .badge.green { color: #bbf7d0; background: rgba(34,197,94,.12); border-color: rgba(34,197,94,.22); }
[data-theme="dark"] .badge.red { color: #fecaca; background: rgba(239,68,68,.12); border-color: rgba(239,68,68,.22); }
[data-theme="dark"] .badge.yellow { color: #fde68a; background: rgba(245,158,11,.12); border-color: rgba(245,158,11,.22); }
[data-theme="dark"] .badge.teal { color: #99f6e4; background: rgba(20,184,166,.12); border-color: rgba(20,184,166,.22); }
.progress-wrap { display: grid; gap: 7px; }
.progress-top { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; font-weight: 800; }
.progress-bar { height: 9px; background: var(--panel-soft); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--teal); }
.timeline { display: grid; gap: 12px; }
.timeline-item { display: block; padding-left: 12px; border-left: 2px solid var(--border); }
.timeline-item strong { display: block; font-size: 14px; margin-bottom: 3px; }
.timeline-item p { margin: 0; color: var(--muted); line-height: 1.45; font-size: 13px; }
.chart { height: 220px; display: flex; align-items: end; gap: 4px; border: 1px solid var(--border); border-radius: 12px; padding: 14px; background: var(--panel-soft); }
.bar { flex: 1; min-width: 4px; border-radius: 5px 5px 0 0; background: var(--teal); opacity: .86; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.56); display: grid; place-items: center; padding: 20px; z-index: 100; }
.modal { width: min(520px, 100%); background: var(--panel); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 24px 70px rgba(0,0,0,.24); padding: 22px; }
.modal h2 { margin: 0 0 8px; letter-spacing: -0.04em; }
.modal p { margin: 0 0 18px; color: var(--muted); line-height: 1.6; }
.mobile-only { display: none; }

@media (max-width: 1180px) {
  .cols-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .split { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 860px) {
  .auth-card { grid-template-columns: 1fr; }
  .auth-info { padding: 32px; }
  .auth-points { grid-template-columns: 1fr; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; width: min(310px, 88vw); transform: translateX(-105%); transition: transform .22s ease; }
  .sidebar.open { transform: translateX(0); }
  .mobile-only { display: inline-flex; }
  .content { padding: 16px; }
  .cols-2, .cols-3, .cols-4, .form-grid { grid-template-columns: 1fr; }
  .user-pill { display: none; }
}
@media (max-width: 560px) {
  .auth-screen { padding: 12px; }
  .auth-form-wrap { padding: 26px; }
  .auth-info { padding: 26px; }
  .topbar, .toolbar, .card-head { display: grid; align-items: start; }
}

/* Clean auth screen */
.auth-card-clean {
  grid-template-columns: .9fr 1.1fr;
  min-height: 590px;
}
.auth-info-clean {
  justify-content: flex-start;
  gap: 30px;
}
.company-preview-card {
  margin-top: 80px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 14px;
  background: rgba(255,255,255,.05);
  padding: 24px;
}
.company-preview-card span {
  display: block;
  color: #94a3b8;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-weight: 900;
  margin-bottom: 10px;
}
.company-preview-card strong {
  display: block;
  color: #fff;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.05;
  letter-spacing: -.05em;
  word-break: break-word;
}
.auth-note {
  color: #cbd5e1;
  line-height: 1.65;
  max-width: 420px;
}
.auth-footer {
  margin-top: auto;
  color: #94a3b8;
  font-size: 13px;
  line-height: 1.5;
}
.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 5px;
  border: 1px solid #dbe4ef;
  border-radius: 12px;
  background: #f8fafc;
  margin-bottom: 26px;
}
.auth-tab {
  border: 0;
  background: transparent;
  color: #64748b;
  border-radius: 9px;
  min-height: 42px;
  font-weight: 900;
}
.auth-tab.active {
  background: #0f172a;
  color: #fff;
}
.role-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.role-option {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #dbe4ef;
  border-radius: 12px;
  padding: 12px;
  background: #fff;
  color: #0f172a;
}
.role-option input {
  width: 18px;
  min-height: 18px;
  accent-color: #0f766e;
}
.role-option span {
  display: grid;
  gap: 2px;
}
.role-option strong {
  font-size: 14px;
}
.role-option small {
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
}
@media (max-width: 860px) {
  .auth-card-clean { grid-template-columns: 1fr; }
  .company-preview-card { margin-top: 34px; }
}
@media (max-width: 560px) {
  .role-options { grid-template-columns: 1fr; }
}

.company-preview-inline {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card-soft);
  padding: 14px;
  margin-bottom: 16px;
  display: grid;
  gap: 6px;
}
.company-preview-inline strong { font-size: 16px; }
.company-preview-inline span { color: var(--muted); font-size: 13px; font-weight: 700; }
.copy-box {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card-soft);
  padding: 10px;
  word-break: break-all;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  color: var(--text);
}
.invite-list {
  display: grid;
  gap: 10px;
}
.invite-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card-soft);
  padding: 12px;
  display: grid;
  gap: 8px;
}
