:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --ink: #111827;
  --muted: #64748b;
  --line: #e5eaf2;
  --blue: #1685f8;
  --blue-dark: #0f5fbc;
  --green: #18b981;
  --amber: #f59e0b;
  --danger: #ef4444;
  --radius: 20px;
  --shadow: 0 18px 48px rgba(15, 23, 42, 0.08);
  font-family: Montserrat, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; }
a { color: inherit; }
.skip-link { background: var(--ink); color: white; left: 16px; padding: 10px 14px; position: absolute; top: -44px; z-index: 20; }
.skip-link:focus { top: 12px; }
.is-hidden { display: none !important; }
.auth-screen { align-items: center; display: grid; min-height: 100vh; padding: 32px; }
.auth-card { background: linear-gradient(135deg, #fff9cf, #dff8de 40%, #dff3ff); border: 1px solid var(--line); border-radius: 32px; box-shadow: var(--shadow); margin: auto; max-width: 760px; padding: 36px; width: 100%; }
.eyebrow { color: var(--blue-dark); font-size: 0.76rem; font-weight: 800; letter-spacing: 0.08em; margin: 0 0 8px; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(2rem, 5vw, 4rem); line-height: 1; margin-bottom: 14px; }
h2 { font-size: clamp(1.4rem, 2vw, 2rem); margin-bottom: 0; }
h3 { font-size: 1.05rem; }
.auth-card p, .empty-state span, .detail-grid span, .metric span, .brand span, .breadcrumb { color: var(--muted); }
form { display: grid; gap: 12px; }
label { font-weight: 800; }
input, select, textarea { background: white; border: 1px solid var(--line); border-radius: 14px; min-height: 44px; padding: 10px 12px; width: 100%; }
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 3px solid rgba(22, 133, 248, 0.28); outline-offset: 3px; }
.button { align-items: center; border: 0; border-radius: 999px; cursor: pointer; display: inline-flex; font-weight: 800; justify-content: center; min-height: 44px; padding: 0 18px; text-decoration: none; transition: transform 160ms ease, box-shadow 160ms ease; }
.button:active { transform: translateY(1px) scale(0.99); }
.button.primary { background: var(--blue); color: white; box-shadow: 0 12px 24px rgba(22, 133, 248, 0.25); }
.button.secondary { background: #eef6ff; color: var(--blue-dark); }
.button.small { font-size: 0.84rem; min-height: 36px; padding: 0 14px; }
.icon-button { background: white; border: 1px solid var(--line); border-radius: 14px; min-height: 44px; min-width: 44px; }
.state-grid, .metric-grid, .quick-grid, .detail-grid { display: grid; gap: 14px; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 24px; }
.state-grid article, .metric, .detail-grid article, .empty-state, .form-card { background: rgba(255, 255, 255, 0.78); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.state-grid article { display: grid; gap: 8px; }
.admin-shell { display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: #0f172a; color: white; padding: 24px; position: sticky; top: 0; height: 100vh; overflow: auto; }
.brand { align-items: center; display: flex; gap: 12px; margin-bottom: 24px; }
.brand-mark { align-items: center; background: linear-gradient(135deg, #ffe81f, #20d287, #1685f8); border-radius: 16px; color: #06132d; display: inline-flex; font-weight: 900; height: 44px; justify-content: center; width: 44px; }
.side-nav { display: grid; gap: 6px; }
.side-nav a { border-radius: 14px; color: #cbd5e1; font-weight: 750; padding: 12px 14px; text-decoration: none; }
.side-nav a[aria-current="page"], .side-nav a:hover { background: rgba(255,255,255,0.12); color: white; }
.nav-group-label { color: #93a4bb; font-size: 0.72rem; font-weight: 900; letter-spacing: 0.08em; margin: 18px 8px 4px; text-transform: uppercase; }
.workspace { min-width: 0; }
.topbar { align-items: center; background: rgba(245, 247, 251, 0.86); backdrop-filter: blur(18px); border-bottom: 1px solid var(--line); display: grid; gap: 18px; grid-template-columns: auto minmax(0, 1fr) auto auto auto; padding: 18px 28px; position: sticky; top: 0; z-index: 10; }
.workspace-meta { align-items: center; color: var(--muted); display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; max-width: 520px; }
.workspace-switcher { align-items: center; display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.badge { background: #e8f7f1; border-radius: 999px; color: #087a50; display: inline-flex; font-size: 0.75rem; font-weight: 850; line-height: 1; padding: 8px 10px; white-space: nowrap; }
.badge.warn { background: #fff6db; color: #9a5c00; }
.badge.muted { background: #eef2f7; color: var(--muted); }
.badge.danger { background: #fee2e2; color: #b91c1c; }
main { display: grid; gap: 18px; padding: 28px; }
.notice { background: #eaf5ff; border: 1px solid #c9e5ff; border-radius: var(--radius); color: var(--blue-dark); font-weight: 750; padding: 14px 16px; }
.notice[data-tone="success"] { background: #e8f7f1; border-color: #bae9d5; color: #087a50; }
.notice[data-tone="error"] { background: #fff1f2; border-color: #fecdd3; color: #b91c1c; }
.notice[data-tone="warn"] { background: #fff6db; border-color: #fde68a; color: #9a5c00; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 28px; box-shadow: var(--shadow); display: grid; gap: 20px; padding: 24px; }
.section-heading { align-items: center; display: flex; gap: 16px; justify-content: space-between; }
.quick-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.quick-grid a { background: #f8fafc; border: 1px solid var(--line); border-radius: var(--radius); color: var(--blue-dark); font-weight: 850; padding: 18px; text-decoration: none; }
.metric strong { display: block; font-size: 2rem; line-height: 1.1; margin-top: 8px; }
.toolbar { display: grid; gap: 12px; grid-template-columns: minmax(220px, 1fr) 220px; }
#workspace-select { min-height: 36px; min-width: 220px; }
table { border-collapse: collapse; width: 100%; }
th, td { border-bottom: 1px solid var(--line); padding: 14px 10px; text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; }
.form-card { background: #f8fafc; display: grid; gap: 12px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.detail-grid article { display: grid; gap: 8px; }
.empty-state { display: grid; gap: 8px; }
.pipeline { display: grid; gap: 10px; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.pipeline span { background: #f8fafc; border: 1px solid var(--line); border-radius: 16px; color: var(--muted); font-weight: 850; min-height: 48px; padding: 14px; text-align: center; }
.nav-toggle { display: none; }

@media (max-width: 980px) {
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; height: auto; position: static; }
  .sidebar.is-open { display: block; }
  .nav-toggle { display: inline-flex; }
  .topbar { grid-template-columns: auto minmax(0, 1fr); }
  .workspace-meta, .workspace-switcher, .topbar > .button { grid-column: 1 / -1; justify-content: flex-start; }
  .state-grid, .metric-grid, .quick-grid, .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pipeline { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .auth-screen, main { padding: 16px; }
  .auth-card, .panel { border-radius: 22px; padding: 18px; }
  .state-grid, .metric-grid, .quick-grid, .detail-grid, .toolbar { grid-template-columns: 1fr; }
  .pipeline { grid-template-columns: 1fr; }
  table, thead, tbody, tr, th, td { display: block; }
  thead { position: absolute; left: -9999px; }
  tr { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; padding: 12px; }
  td { border: 0; padding: 8px 0; }
}
