:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --surface: #ffffff;
  --surface-2: #f0f3ef;
  --ink: #151a17;
  --muted: #66736c;
  --line: #dce4dd;
  --accent: #0a806f;
  --accent-strong: #075f53;
  --gold: #a9824b;
  --positive: #16845f;
  --negative: #bd463d;
  --warning: #c77a25;
  --info: #355f87;
  --shadow: 0 14px 34px rgba(21, 26, 23, 0.08);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.45; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 22px 14px; background: linear-gradient(180deg, #111713, #1b251f); color: #fffdf8; }
.sidebar-brand { display: flex; gap: 12px; align-items: center; padding: 8px 6px 18px; margin-bottom: 22px; color: inherit; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar-brand strong, .sidebar-brand small { display: block; }
.sidebar-brand small { color: rgba(255,255,255,.62); }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: var(--radius); background: linear-gradient(135deg, var(--accent), var(--accent-strong)); color: white; font-weight: 900; }
.main-nav { display: grid; gap: 6px; }
.main-nav a { min-height: 42px; display: flex; align-items: center; border-radius: var(--radius); padding: 0 13px; color: rgba(255,255,255,.66); text-decoration: none; font-weight: 760; }
.main-nav a:hover, .main-nav a.active { background: rgba(255,255,255,.12); color: white; }
.main-shell { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; gap: 16px; padding: 16px 28px; background: rgba(251,252,249,.92); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 0; font-size: 24px; line-height: 1.1; }
.eyebrow { margin: 0 0 5px; color: var(--muted); font-size: 11px; text-transform: uppercase; font-weight: 820; letter-spacing: .04em; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.user-chip { min-height: 34px; display: inline-flex; align-items: center; padding: 0 11px; border: 1px solid var(--line); border-radius: var(--radius); color: var(--muted); background: white; font-size: 12px; font-weight: 760; }
.view { max-width: 1680px; margin: 0 auto; padding: 24px 28px 54px; }

.auth-body { background: var(--bg); }
.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-panel { width: min(430px, 100%); display: grid; gap: 14px; padding: 34px; background: white; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.auth-panel h1 { margin: 8px 0 0; font-size: 30px; }
.auth-panel p { margin: 0 0 8px; color: var(--muted); }

.panel, .entity-hero { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel { padding: 18px; margin-bottom: 16px; min-width: 0; }
.panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.panel-header h2, .panel h3 { margin: 0; }
.panel-header p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }

.entity-hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(420px, .7fr); gap: 18px; padding: 22px; margin-bottom: 16px; background: linear-gradient(135deg, #111713 0%, #1e2b25 62%, #3a382e 100%); color: #fffdf8; }
.entity-hero h2 { margin: 0; font-size: clamp(28px, 3vw, 42px); line-height: 1; }
.entity-hero p { margin: 10px 0 0; max-width: 780px; color: rgba(255,255,255,.72); }
.hero-metrics { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; }
.hero-metrics article { padding: 13px; border: 1px solid rgba(255,255,255,.13); border-radius: var(--radius); background: rgba(255,255,255,.08); }
.hero-metrics span, .kpi span { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; font-weight: 820; }
.hero-metrics strong { display: block; margin-top: 9px; color: white; font-size: 20px; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { min-height: 96px; padding: 15px; background: white; border: 1px solid var(--line); border-left: 3px solid var(--gold); border-radius: var(--radius); box-shadow: var(--shadow); }
.kpi strong { display: block; margin-top: 11px; font-size: 24px; line-height: 1.05; }
.kpi.negative { border-left-color: var(--negative); }
.kpi.warning { border-left-color: var(--warning); }
.kpi.positive { border-left-color: var(--positive); }

.dashboard-grid, .detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.actions-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

.toolbar { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; }
.toolbar input[name="q"] { min-width: min(320px, 100%); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 13px; }
.quick-forms { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.quick-forms form { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: #fbfcfa; }
.full-width { grid-column: 1 / -1; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 760; }
input, select, textarea { width: 100%; min-height: 40px; border: 1px solid var(--line); border-radius: var(--radius); padding: 9px 11px; background: white; color: var(--ink); outline: none; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(10,128,111,.14); }
.checkbox { display: flex; align-items: center; gap: 8px; }
.checkbox input { width: auto; min-height: auto; }

.primary-button, .ghost-button, .danger-button { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius); border: 0; padding: 0 14px; text-decoration: none; font-weight: 790; white-space: nowrap; }
.primary-button { background: linear-gradient(135deg, var(--accent), var(--accent-strong)); color: white; }
.ghost-button { background: #eef2ed; color: var(--ink); }
.danger-button { background: #fff0ed; color: var(--negative); }
.button-row, .action-row, .form-actions, .pagination { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.action-row { margin-bottom: 16px; }
.pagination { justify-content: center; margin-top: 14px; color: var(--muted); }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: white; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; border-bottom: 1px solid #e8eee8; text-align: left; vertical-align: top; white-space: nowrap; }
thead th { background: #f1f4ef; color: var(--muted); font-size: 11px; text-transform: uppercase; font-weight: 830; }
td small { display: block; margin-top: 3px; color: var(--muted); }
.actions-cell { text-align: right; }

.badge { display: inline-flex; align-items: center; min-height: 24px; border-radius: 999px; padding: 0 9px; background: #eef2ed; color: var(--muted); font-size: 11px; font-weight: 790; }
.badge.positive, .priority-A { background: #e3f4ec; color: var(--positive); }
.badge.negative, .priority-out { background: #fff0ed; color: var(--negative); }
.badge.warning, .priority-B { background: #fff0dc; color: var(--warning); }
.priority-C { background: #e7eef5; color: var(--info); }
.pill-list { display: flex; gap: 8px; flex-wrap: wrap; }
.notice { margin-bottom: 14px; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--line); font-weight: 760; }
.notice.success { background: #edf8f2; color: var(--positive); }
.notice.error { background: #fff0ed; color: var(--negative); }

.list-stack { display: grid; gap: 10px; }
.list-row, .action-card { display: grid; gap: 3px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); color: inherit; text-decoration: none; background: #fbfcfa; }
.list-row span, .list-row small, .action-card span, .action-card small { color: var(--muted); font-size: 12px; }
.list-row strong, .action-card strong { font-size: 14px; }
.action-card { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
.empty-state { padding: 24px; color: var(--muted); text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); background: #fbfcfa; }
.empty-state strong { display: block; color: var(--ink); margin-bottom: 5px; }
.empty-state p { margin: 0; }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid #edf1ec; }
.kv span { color: var(--muted); }
.kv strong { text-align: right; }
.score-line { display: grid; grid-template-columns: minmax(0, 1fr) 70px; gap: 9px; align-items: center; margin: 10px 0; }
.score-line i { grid-column: 1 / -1; height: 7px; border-radius: 99px; background: #e5ebe5; overflow: hidden; }
.score-line b { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--gold)); }

.kanban { display: grid; grid-template-columns: repeat(4, minmax(250px, 1fr)); gap: 14px; align-items: start; }
.kanban-column { min-height: 220px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: #eef2ed; }
.kanban-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.kanban-title h2 { margin: 0; font-size: 15px; }
.pipeline-card { display: grid; gap: 9px; margin-bottom: 10px; padding: 13px; border: 1px solid var(--line); border-radius: var(--radius); background: white; }
.pipeline-card h3 { margin: 0; font-size: 15px; }
.pipeline-card p { margin: 0; color: var(--muted); }
.pipeline-card dl { display: grid; gap: 5px; margin: 0; }
.pipeline-card dl div { display: flex; justify-content: space-between; gap: 10px; }
.pipeline-card dt { color: var(--muted); }
.pipeline-card dd { margin: 0; font-weight: 790; }
.pipeline-card form { display: grid; gap: 8px; }

.import-form { display: grid; gap: 12px; }

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .main-nav { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .main-nav, .toolbar, .detail-grid, .dashboard-grid, .actions-layout, .quick-forms, .entity-hero { display: grid; grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
  .topbar, .topbar-actions, .action-card { grid-template-columns: 1fr; flex-direction: column; align-items: stretch; }
  .view { padding: 18px; }
  .main-nav, .toolbar, .form-grid, .detail-grid, .dashboard-grid, .actions-layout, .quick-forms, .entity-hero, .hero-metrics { grid-template-columns: 1fr; }
  .sidebar { padding: 16px; }
}
