:root {
  --brand-navy: #0a1930;
  --brand-white: #ffffff;
  --surface: #fefefe;
  --surface-muted: #f1f2f3;
  --text: #0a1930;
  --text-muted: #586272;
  --border: #d8dce1;
  --input-border: #8993a0;
  --nav-active: #1a2c47;
  --success: #17633a;
  --success-bg: #eaf5ee;
  --warning: #7a4c00;
  --warning-bg: #fff4dc;
  --danger: #a82424;
  --danger-bg: #fff0f0;
  --info: #365b7d;
  --info-bg: #edf3f8;
  --backdrop: rgb(10 25 48 / 54%);
  --sidebar-width: 232px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 28px;
  --space-8: 32px;
  color-scheme: light;
  font-family: Arial, Helvetica, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { background: var(--surface-muted); }

body {
  margin: 0;
  color: var(--text);
  background: var(--surface-muted);
  font-size: 14px;
  line-height: 1.45;
}

button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 6px;
}

.skip-link {
  position: fixed;
  top: -60px;
  left: 16px;
  z-index: 100;
  padding: 10px 14px;
  background: var(--brand-white);
  border: 1px solid var(--text);
}
.skip-link:focus { top: 16px; }

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  color: var(--brand-white);
  background: var(--brand-navy);
  border-right: 1px solid #1f304b;
}

.sidebar__head {
  display: flex;
  height: 72px;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid #263752;
}

.wordmark {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  color: inherit;
  font-size: 15px;
  letter-spacing: .01em;
  text-decoration: none;
}
.wordmark strong { font-weight: 700; }
.wordmark span { font-weight: 400; }
.wordmark i {
  width: 7px;
  height: 7px;
  margin-left: 5px;
  background: currentcolor;
}
.wordmark--dark { color: var(--brand-navy); }

.nav-list { display: grid; gap: 2px; padding: 20px 12px; }
.nav-list a {
  display: flex;
  min-height: 40px;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  color: #d8dfe9;
  border-left: 2px solid transparent;
  text-decoration: none;
}
.nav-list a:hover { color: #fff; background: #13243e; }
.nav-list a[aria-current="page"] {
  color: #fff;
  background: var(--nav-active);
  border-left-color: #fff;
  font-weight: 700;
}
.nav-icon { width: 18px; color: #aab6c8; text-align: center; }
.sidebar__foot {
  display: grid;
  gap: 14px;
  margin-top: auto;
  padding: 16px 20px 20px;
  border-top: 1px solid #263752;
}
.user-summary { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-summary span:last-child { display: grid; min-width: 0; }
.user-summary strong { overflow: hidden; text-overflow: ellipsis; }
.user-summary small { color: #aab6c8; }
.avatar {
  display: inline-grid;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  place-items: center;
  color: var(--brand-navy);
  background: #d9e2ed;
  font-size: 11px;
  font-weight: 700;
}
.sidebar .sidebar__close { display: none; color: white; }
.text-button { padding: 0; color: var(--info); background: none; border: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.text-button--light { color: #d8dfe9; }

.main { min-height: 100vh; margin-left: var(--sidebar-width); }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  height: 72px;
  align-items: center;
  gap: 12px;
  padding: 0 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar .menu-button { display: none; }
.global-search {
  display: flex;
  width: min(440px, 60vw);
  height: 38px;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  color: var(--text-muted);
  background: var(--surface-muted);
  border: 1px solid transparent;
  cursor: pointer;
  text-align: left;
}
.global-search:hover { border-color: var(--input-border); }
kbd { padding: 2px 5px; color: var(--text-muted); background: var(--surface); border: 1px solid var(--border); font-size: 11px; }
.notification-button { margin-left: auto; color: var(--warning); font-size: 9px; }
.icon-button { display: inline-grid; width: 36px; height: 36px; padding: 0; place-items: center; background: transparent; border: 0; cursor: pointer; font-size: 18px; }

.page { max-width: 1600px; margin: 0 auto; padding: 28px; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.page-header h1 { margin: 0; font-size: 26px; line-height: 1.2; letter-spacing: -.02em; }
.page-header p { max-width: 680px; margin: 6px 0 0; color: var(--text-muted); }
.page-header__actions { display: flex; gap: 8px; }

.button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 2px;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
}
.button:disabled { cursor: not-allowed; opacity: .55; }
.button--primary { color: #fff; background: var(--brand-navy); border-color: var(--brand-navy); }
.button--primary:hover { background: #182b48; }
.button--secondary { color: var(--text); background: var(--surface); border-color: var(--input-border); }
.button--secondary:hover { background: var(--surface-muted); }
.button--danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.button--full { width: 100%; }

.metric-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.metric { min-height: 94px; padding: 18px 20px; border-right: 1px solid var(--border); }
.metric:last-child { border-right: 0; }
.metric span { display: block; color: var(--text-muted); font-size: 13px; }
.metric strong { display: block; margin-top: 5px; font-size: 24px; font-weight: 600; }
.metric strong.danger { color: var(--danger); }

.work-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(280px, .85fr); gap: 20px; }
.panel { background: var(--surface); border: 1px solid var(--border); }
.panel__head { display: flex; min-height: 54px; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.panel__head h2 { margin: 0; font-size: 16px; }
.panel__head a { color: var(--info); font-size: 13px; }
.panel__body { padding: 16px; }
.panel + .panel { margin-top: 20px; }

.table-wrap { overflow: auto; background: var(--surface); border: 1px solid var(--border); }
.panel .table-wrap { border: 0; }
.data-table { width: 100%; border-collapse: collapse; white-space: nowrap; }
.data-table th { position: sticky; top: 0; z-index: 1; padding: 10px 14px; color: var(--text-muted); background: var(--surface-muted); border-bottom: 1px solid var(--border); font-size: 12px; font-weight: 700; text-align: left; }
.data-table td { height: 52px; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #f8f9fa; }
.data-table a { color: var(--text); font-weight: 700; text-decoration: none; }
.data-table a:hover { text-decoration: underline; }
.cell-main { display: grid; }
.cell-main small, .muted { color: var(--text-muted); }

.status { display: inline-flex; min-height: 24px; align-items: center; padding: 2px 7px; border: 1px solid currentcolor; font-size: 11px; font-weight: 700; }
.status--new, .status--discovery { color: var(--info); background: var(--info-bg); }
.status--qualification, .status--proposal, .status--negotiation { color: var(--warning); background: var(--warning-bg); }
.status--won { color: var(--success); background: var(--success-bg); }
.status--lost { color: var(--danger); background: var(--danger-bg); }
.tag { display: inline-block; padding: 2px 6px; background: var(--surface-muted); border: 1px solid var(--border); font-size: 11px; }

.action-list { list-style: none; margin: 0; padding: 0; }
.action-list li { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: start; padding: 12px 0; border-bottom: 1px solid var(--border); }
.action-list li:first-child { padding-top: 0; }
.action-list li:last-child { padding-bottom: 0; border: 0; }
.action-check { width: 18px; height: 18px; margin-top: 2px; }
.action-list strong { display: block; }
.action-list small { color: var(--text-muted); }
.action-time { color: var(--text-muted); font-size: 12px; white-space: nowrap; }
.action-time--overdue { color: var(--danger); font-weight: 700; }

.filter-bar { display: flex; align-items: end; gap: 10px; margin-bottom: 14px; }
.field { display: grid; gap: 6px; }
.field label { font-size: 12px; font-weight: 700; }
.field input, .field select, .field textarea, .search-input input {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--input-border);
  border-radius: 0;
}
.field textarea { min-height: 100px; resize: vertical; }
.field input[aria-invalid="true"] { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 12px; }
.filter-bar .field { min-width: 180px; }
.filter-bar .search-field { min-width: min(320px, 100%); margin-right: auto; }

.kanban { display: grid; grid-template-columns: repeat(7, 286px); gap: 12px; overflow-x: auto; padding-bottom: 14px; scroll-snap-type: x proximity; }
.kanban-column { min-height: 520px; background: #e9ebee; border: 1px solid var(--border); scroll-snap-align: start; }
.kanban-column__head { display: flex; height: 48px; align-items: center; justify-content: space-between; padding: 0 12px; background: var(--surface); border-bottom: 1px solid var(--border); }
.kanban-column__head h2 { margin: 0; font-size: 13px; }
.kanban-column__head span { color: var(--text-muted); font-size: 12px; }
.kanban-list { display: grid; gap: 8px; min-height: 466px; padding: 8px; }
.kanban-card { padding: 12px; background: var(--surface); border: 1px solid #cbd0d7; cursor: grab; }
.kanban-card:active { cursor: grabbing; }
.kanban-card[aria-grabbed="true"] { opacity: .55; }
.kanban-card h3 { margin: 0 0 5px; font-size: 14px; }
.kanban-card p { margin: 0; color: var(--text-muted); font-size: 12px; }
.kanban-card__foot { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
.kanban-card select { max-width: 138px; min-height: 30px; border: 1px solid var(--input-border); font-size: 12px; }
.kanban-column.is-over { background: #dde4eb; border-color: var(--info); }

.empty-state { padding: 48px 20px; color: var(--text-muted); text-align: center; }
.empty-state strong { display: block; margin-bottom: 4px; color: var(--text); font-size: 15px; }
.loading-row { height: 52px; background: var(--surface-muted); border-bottom: 1px solid var(--border); }

.dialog { width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--text); border-radius: 0; }
.dialog::backdrop { background: var(--backdrop); }
.dialog__frame { margin: 0; }
.dialog__head { display: flex; align-items: flex-start; justify-content: space-between; padding: 20px 20px 16px; border-bottom: 1px solid var(--border); }
.dialog__head h2 { margin: 0; font-size: 20px; }
.dialog__head p { margin: 4px 0 0; color: var(--text-muted); }
.dialog__body { display: grid; gap: 16px; max-height: 60vh; overflow: auto; padding: 20px; }
.dialog__actions { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; background: var(--surface-muted); border-top: 1px solid var(--border); }
.dialog--search { width: min(680px, calc(100vw - 32px)); margin-top: 10vh; }
.search-input { display: grid; grid-template-columns: 28px 1fr 36px; align-items: center; padding: 10px; border-bottom: 1px solid var(--border); }
.search-input input { border: 0; font-size: 16px; }
.search-results { max-height: 430px; overflow: auto; padding: 8px; }
.search-result { display: grid; gap: 2px; padding: 11px 12px; text-decoration: none; }
.search-result:hover { background: var(--surface-muted); }
.search-result small { color: var(--text-muted); }
.empty-copy { padding: 20px; color: var(--text-muted); text-align: center; }

.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: grid; gap: 8px; width: min(360px, calc(100vw - 40px)); }
.toast { padding: 12px 14px; color: #fff; background: var(--brand-navy); border-left: 4px solid #fff; }
.toast--error { background: var(--danger); }
.nav-backdrop { display: none; }

.login-page { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: var(--surface-muted); }
.login-panel { width: min(400px, 100%); padding: 32px; background: var(--surface); border: 1px solid var(--border); }
.login-panel h1 { margin: 40px 0 6px; font-size: 26px; }
.login-panel p { margin: 0 0 24px; color: var(--text-muted); }
.login-panel small { display: block; margin-top: 20px; color: var(--text-muted); text-align: center; }
.dev-login { display: block; margin-top: 12px; color: var(--info); text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

@media (max-width: 1100px) {
  .work-grid { grid-template-columns: 1fr; }
  .metric-row { grid-template-columns: repeat(2, 1fr); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
}

@media (max-width: 767px) {
  .sidebar { width: min(290px, 86vw); transform: translateX(-100%); }
  body.nav-open .sidebar { transform: translateX(0); }
  .sidebar .sidebar__close, .topbar .menu-button { display: inline-grid; }
  .nav-backdrop { position: fixed; inset: 0; z-index: 25; background: var(--backdrop); }
  body.nav-open .nav-backdrop { display: block; }
  .main { margin-left: 0; }
  .topbar { height: 60px; padding: 0 14px; }
  .global-search { width: auto; flex: 1; }
  .global-search span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .global-search kbd { display: none; }
  .page { padding: 20px 14px; }
  .page-header { align-items: stretch; flex-direction: column; }
  .page-header h1 { font-size: 22px; }
  .page-header__actions .button { flex: 1; }
  .metric-row { grid-template-columns: 1fr 1fr; }
  .metric { min-height: 82px; padding: 14px; }
  .metric strong { font-size: 20px; }
  .filter-bar { align-items: stretch; flex-direction: column; }
  .filter-bar .field { min-width: 0; }
  .data-table--stack thead { display: none; }
  .data-table--stack, .data-table--stack tbody, .data-table--stack tr, .data-table--stack td { display: block; width: 100%; }
  .data-table--stack tr { padding: 8px 12px; border-bottom: 1px solid var(--border); }
  .data-table--stack td { display: flex; height: auto; min-height: 38px; align-items: center; justify-content: space-between; gap: 16px; padding: 7px 0; border: 0; white-space: normal; text-align: right; }
  .data-table--stack td::before { content: attr(data-label); color: var(--text-muted); font-size: 12px; font-weight: 700; text-align: left; }
  .data-table--stack td:first-child { display: block; text-align: left; }
  .data-table--stack td:first-child::before { display: none; }
  .kanban { grid-template-columns: repeat(7, min(82vw, 300px)); }
  .dialog__body { max-height: 54vh; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
