:root {
  --bg: #0b1220;
  --bg-soft: #111827;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --line: #d7dfeb;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.12);
  --radius: 22px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--text); background: linear-gradient(180deg, #e8eefb 0%, #f5f7fb 100%); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

body {
  min-height: 100vh;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
  color: #e2e8f0;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 48px; height: 48px; display: grid; place-items: center; border-radius: 16px;
  background: linear-gradient(135deg, #3b82f6 0%, #14b8a6 100%); color: white; font-size: 24px;
  box-shadow: 0 12px 30px rgba(59, 130, 246, 0.35);
}
.brand-title { font-weight: 800; letter-spacing: -0.02em; }
.brand-subtitle { font-size: 13px; color: #94a3b8; }
.nav-list { display: flex; flex-direction: column; gap: 6px; }
.nav-item {
  padding: 12px 14px; border-radius: 14px; color: #cbd5e1; font-weight: 600;
  transition: 0.2s ease;
}
.nav-item:hover, .nav-item.active { background: rgba(148, 163, 184, 0.15); color: white; }
.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 14px; }
.user-card.compact { background: rgba(255,255,255,0.06); padding: 12px; border-radius: 16px; display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 38px; height: 38px; border-radius: 12px; background: rgba(59, 130, 246, 0.2); color: #dbeafe;
  display: grid; place-items: center; font-weight: 700;
}

.main-area {
  padding: 28px;
}
.main-area-auth {
  display: grid; place-items: center; padding: 28px;
}
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.topbar h1 { margin: 4px 0 0; font-size: 34px; line-height: 1.05; letter-spacing: -0.03em; }
.page-eyebrow, .eyebrow { color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-size: 12px; font-weight: 700; }
.topbar-meta { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.flash {
  padding: 14px 16px; border-radius: 16px; margin-bottom: 18px; font-weight: 600;
  box-shadow: var(--shadow);
}
.flash.success { background: #ecfdf3; color: #166534; border: 1px solid #bbf7d0; }
.flash.danger { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

.card {
  background: var(--panel);
  border: 1px solid rgba(148,163,184,0.18);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.hero-card {
  background: linear-gradient(135deg, #0f172a 0%, #1d4ed8 80%);
  color: white;
}
.hero-card .muted, .hero-card .eyebrow, .hero-card .metric-footnote { color: rgba(255,255,255,0.78); }
.hero-card .metric-card { background: rgba(255,255,255,0.08); color: white; border-color: rgba(255,255,255,0.12); }
.hero-card .metric-card.dark { background: rgba(255,255,255,0.16); }
.accent-soft { background: linear-gradient(180deg, #eff6ff 0%, #ffffff 100%); }

.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.card-header h2 { margin: 4px 0 0; font-size: 24px; letter-spacing: -0.02em; }
.card-footer { margin-top: 14px; }
.between { justify-content: space-between; }

.grid { display: grid; gap: 18px; }
.two-col { grid-template-columns: 1.2fr 1fr; }
.metric-grid { display: grid; gap: 14px; }
.metric-grid.two { grid-template-columns: repeat(2, 1fr); }
.metric-grid.three { grid-template-columns: repeat(3, 1fr); }
.metric-card {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  border-radius: 18px;
  padding: 18px;
}
.metric-card.dark { background: linear-gradient(135deg, #111827 0%, #1e293b 100%); color: white; border-color: rgba(255,255,255,0.12); }
.metric-label { color: var(--muted); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.metric-card.dark .metric-label, .metric-card.dark .metric-footnote { color: rgba(255,255,255,0.7); }
.metric-value { margin-top: 8px; font-size: 32px; font-weight: 800; letter-spacing: -0.03em; }
.metric-footnote { margin-top: 6px; color: var(--muted); font-size: 14px; }

.pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 999px;
  background: #eef2ff; color: #3730a3; font-weight: 700; font-size: 13px;
}
.pill.success { background: #ecfdf3; color: #166534; }
.pill.warning { background: #fff7ed; color: #9a3412; }
.pill.danger { background: #fef2f2; color: #991b1b; }
.pill.info { background: #eff6ff; color: #1d4ed8; }
.pill.muted { background: #f1f5f9; color: #334155; }
.pill.dark { background: #0f172a; color: #e2e8f0; }
.pill.tiny { padding: 6px 10px; font-size: 12px; }

.stack { display: flex; flex-direction: column; gap: 18px; }
.stack.compact { gap: 12px; }
.large-gap { gap: 24px; }
.small { font-size: 13px; }
.muted { color: var(--muted); }
.strong { font-weight: 700; }

.line-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid rgba(148,163,184,0.12);
}
.line-row:last-child { border-bottom: 0; }
.align-start { align-items: flex-start; }
.button-row { display: flex; gap: 8px; flex-wrap: wrap; }
.button-row.column { flex-direction: column; align-items: stretch; }

.alert-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 16px;
  border-radius: 16px; border: 1px solid transparent;
}
.alert-row.info { background: #eff6ff; border-color: #bfdbfe; }
.alert-row.warning { background: #fff7ed; border-color: #fed7aa; }
.alert-row.critical, .alert-row.danger { background: #fef2f2; border-color: #fecaca; }
.alert-row.success { background: #ecfdf3; border-color: #bbf7d0; }

.empty-state {
  display: grid; place-items: center; gap: 12px; text-align: center; padding: 30px 16px;
  color: var(--muted); background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%); border-radius: 18px; border: 1px dashed var(--line);
}
.empty-icon { font-size: 30px; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { padding: 14px 12px; text-align: left; border-bottom: 1px solid rgba(148,163,184,0.14); vertical-align: top; }
th { color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-size: 12px; }
tr:last-child td { border-bottom: 0; }

.toolbar-wrap, .grid.form-grid-two {
  display: grid; gap: 14px; align-items: end;
}
.toolbar-wrap { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.form-grid-two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
label { display: flex; flex-direction: column; gap: 8px; }
label > span { font-size: 14px; font-weight: 600; color: #334155; }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 14px; background: white; padding: 12px 14px; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: #60a5fa; box-shadow: 0 0 0 4px rgba(96,165,250,0.16); }
.checkbox-row { flex-direction: row; align-items: center; gap: 12px; }
.checkbox-row input { width: auto; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.btn {
  border: 0; border-radius: 14px; padding: 12px 16px; font-weight: 700; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: transform .15s ease, opacity .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); color: white; }
.btn-secondary { background: #e2e8f0; color: #0f172a; }
.btn-danger { background: var(--danger); color: white; }
.btn-full { width: 100%; }
.btn-small { padding: 9px 12px; border-radius: 12px; font-size: 13px; }
.link-button { color: var(--primary); font-weight: 700; }

.clock-strip {
  display: flex; gap: 10px; align-items: center; flex-wrap: nowrap;
}
.clock-strip.wrap { flex-wrap: wrap; }
.input.slim { max-width: 260px; }

.bar-chart {
  display: grid; grid-template-columns: repeat(7, 1fr); align-items: end; gap: 12px;
  min-height: 240px; padding-top: 18px;
}
.bar-col { display: flex; flex-direction: column; justify-content: end; align-items: center; gap: 8px; }
.bar {
  width: 100%; max-width: 42px; border-radius: 14px 14px 8px 8px;
  background: linear-gradient(180deg, #60a5fa 0%, #2563eb 100%);
  min-height: 12px;
}
.bar-label, .bar-value { font-size: 12px; color: var(--muted); }
.bar-value { font-weight: 700; }

.auth-wrap {
  width: min(1180px, 100%); display: grid; grid-template-columns: 1.2fr 420px; gap: 24px; align-items: stretch;
}
.auth-panel { padding: 28px; }
.auth-panel h1 { font-size: 52px; line-height: 1; letter-spacing: -0.04em; margin: 28px 0 16px; max-width: 14ch; }
.auth-card { align-self: center; }
.lead { color: #334155; font-size: 18px; max-width: 60ch; line-height: 1.6; }
.auth-brand { margin-bottom: 14px; }
.divider { height: 1px; background: rgba(148,163,184,0.18); margin: 10px 0; }

.details-inline summary {
  cursor: pointer; color: var(--primary); font-weight: 700; margin-top: 8px;
}
.inset-top { margin-top: 10px; }

.approval-card {
  border: 1px solid var(--line); border-radius: 18px; padding: 16px; background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
}
.approval-head { margin-bottom: 12px; }
.approval-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }

.project-pill { display: inline-flex; align-items: center; gap: 10px; }
.project-color { width: 12px; height: 12px; border-radius: 999px; display: inline-block; }

.toast-container {
  position: fixed; right: 18px; bottom: 18px; z-index: 50; display: flex; flex-direction: column; gap: 10px;
}
.toast {
  background: #0f172a; color: white; padding: 14px 16px; border-radius: 16px; box-shadow: var(--shadow); min-width: 280px;
}
.toast.success { background: #166534; }
.toast.error { background: #991b1b; }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .two-col, .metric-grid.three, .metric-grid.two, .auth-wrap, .approval-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .main-area { padding: 18px; }
  .topbar { flex-direction: column; }
  .topbar h1 { font-size: 28px; }
  .form-grid-two, .toolbar-wrap { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .auth-panel { padding: 0; }
  .auth-panel h1 { font-size: 38px; }
  .clock-strip { flex-wrap: wrap; }
  .btn, .input.slim { width: 100%; max-width: none; }
}


.topbar-switch {
  display: flex;
  gap: 8px;
  align-items: center;
  background: rgba(255,255,255,0.75);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 6px;
}
.topbar-switch select {
  min-width: 220px;
  border: 0;
  background: transparent;
  padding: 10px 12px;
}
.top-space { margin-top: 14px; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form input, .inline-form select { min-width: 160px; }
@media (max-width: 720px) {
  .topbar-switch { width: 100%; }
  .topbar-switch select { min-width: 0; }
}
.permission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.permission-group-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.6);
}
.permissions-form .checkbox-row {
  align-items: flex-start;
}
