:root {
  --navy-950: #081426;
  --navy-900: #0d1c31;
  --navy-800: #152942;
  --navy-700: #203b5e;
  --surface: #ffffff;
  --background: #f3f5f7;
  --border: #dce2e8;
  --text: #1d2733;
  --muted: #667384;
  --blue: #2563eb;
  --blue-soft: #eaf1ff;
  --green: #168252;
  --green-soft: #eaf7f0;
  --amber: #a46300;
  --amber-soft: #fff4d9;
  --red: #b42318;
  --red-soft: #fff0ee;
  --shadow: 0 10px 30px rgba(18, 34, 54, .07);
  --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--background);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--background); }
body { min-height: 100vh; margin: 0; background: var(--background); color: var(--text); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }

.skip-link {
  position: fixed;
  left: 12px;
  top: -60px;
  z-index: 1000;
  padding: 10px 14px;
  background: var(--surface);
  color: var(--navy-950);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.skip-link:focus { top: 12px; }

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  background: linear-gradient(145deg, var(--navy-950), var(--navy-800));
}
.auth-card {
  width: min(100%, 430px);
  background: var(--surface);
  border-radius: 18px;
  padding: 34px;
  box-shadow: 0 22px 70px rgba(0,0,0,.22);
}
.auth-card-wide { width: min(100%, 560px); }
.brand-lockup { display: flex; gap: 12px; align-items: center; margin-bottom: 38px; }
.brand-lockup > div { display: grid; gap: 1px; }
.brand-lockup strong { color: var(--navy-950); letter-spacing: .12em; font-size: 14px; }
.brand-lockup span:not(.brand-mark) { color: var(--muted); font-size: 12px; }
.brand-mark {
  width: 42px; height: 42px; display: grid; place-items: center;
  border-radius: 11px; background: var(--navy-950); color: white;
  font-weight: 800; font-size: 20px; letter-spacing: -.04em;
}
.brand-mark-small { width: 34px; height: 34px; border-radius: 9px; font-size: 16px; background: white; color: var(--navy-950); }
.auth-copy { margin-bottom: 24px; }
.auth-copy h1, .auth-card h1 { font-size: 29px; line-height: 1.15; letter-spacing: -.03em; margin: 7px 0 10px; }
.auth-copy p, .auth-card > p { color: var(--muted); line-height: 1.55; }
.eyebrow { margin: 0; color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }

form { display: grid; gap: 9px; }
label { margin-top: 8px; color: var(--text); font-size: 13px; font-weight: 700; }
input, select, textarea {
  width: 100%; border: 1px solid #cbd4de; border-radius: 9px;
  padding: 12px 13px; background: white; color: var(--text); outline: none;
}
textarea { resize: vertical; min-height: 96px; line-height: 1.45; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.13); }
.form-error, .app-error { color: var(--red); background: var(--red-soft); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.auth-footnote { margin: 22px 0 0 !important; font-size: 12px; }

.button {
  border: 0; border-radius: 9px; padding: 10px 14px; font-weight: 750;
  transition: background-color .15s ease, border-color .15s ease, transform .15s ease;
}
.button:focus-visible, .nav-item:focus-visible, .organization-button:focus-visible, .workspace-tab:focus-visible, .icon-button:focus-visible {
  outline: 3px solid rgba(37,99,235,.35); outline-offset: 2px;
}
.button-primary { margin-top: 12px; background: var(--navy-950); color: white; }
.button-primary:hover { background: var(--navy-800); }
.button-secondary { background: var(--surface); color: var(--navy-900); border: 1px solid var(--border); }
.button-secondary:hover { border-color: #b7c3cf; }
.button-quiet { background: transparent; color: #dbe6f3; border: 1px solid rgba(255,255,255,.18); }
.button-quiet:hover { background: rgba(255,255,255,.08); }
.button-small { padding: 8px 11px; font-size: 12px; }

.organization-list { display: grid; gap: 10px; margin-top: 22px; }
.organization-button {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  text-align: left; border: 1px solid var(--border); background: var(--surface);
  padding: 15px; border-radius: 11px; color: var(--text);
}
.organization-button:hover { border-color: #aebbc9; background: #fafbfd; }
.organization-button strong { display: block; margin-bottom: 3px; }
.organization-button span { color: var(--muted); font-size: 12px; }
.organization-button::after { content: "→"; color: var(--blue); font-size: 20px; }

.app-shell { min-height: 100vh; display: grid; grid-template: 64px 1fr / 220px 1fr; }
.topbar {
  grid-column: 1 / -1; background: var(--navy-950); color: white;
  display: flex; align-items: center; justify-content: space-between; padding: 0 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.topbar-brand { display: flex; align-items: center; gap: 10px; }
.topbar-brand > div { display: grid; gap: 1px; }
.topbar-brand strong { font-size: 13px; letter-spacing: .12em; }
.topbar-brand span:not(.brand-mark) { font-size: 11px; color: #aebed1; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.user-name { font-size: 13px; color: #dbe6f3; }
.sidebar { background: var(--navy-900); color: white; padding: 22px 12px; min-height: calc(100vh - 64px); }
.sidebar nav { display: grid; gap: 4px; }
.nav-section { margin: 18px 10px 4px; color: #8fa2b8; font-size: 9px; font-weight: 800; letter-spacing: .16em; }
.nav-section:first-child { margin-top: 0; }
.nav-item {
  border: 0; background: transparent; color: #d4deea; border-radius: 8px;
  padding: 10px; text-align: left; display: flex; justify-content: space-between; gap: 10px;
  font-size: 13px;
}
.nav-item span { color: #91a4ba; font-size: 10px; text-transform: uppercase; letter-spacing: .07em; }
.nav-item.is-active { background: rgba(255,255,255,.11); color: white; font-weight: 700; }
.nav-item:not(:disabled):hover { background: rgba(255,255,255,.06); }
.nav-item:disabled { opacity: .72; }

.main-content { padding: 30px; max-width: 1440px; width: 100%; margin: 0 auto; }
.workspace-view { width: 100%; }
.page-heading, .section-heading, .panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.page-heading { margin-bottom: 28px; }
.page-heading h1 { margin: 5px 0 6px; font-size: 31px; letter-spacing: -.035em; }
.page-subtitle { margin: 0; color: var(--muted); font-size: 13px; }
.page-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.page-actions .button-primary, .dialog-actions .button-primary { margin-top: 0; }
.section-heading { margin-bottom: 12px; }
.section-heading h2, .panel-heading h2 { margin: 4px 0 0; font-size: 19px; letter-spacing: -.02em; }

.focus-list { display: grid; gap: 9px; margin-bottom: 24px; }
.focus-item {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--blue);
  padding: 14px 16px; border-radius: 10px; display: grid; gap: 4px;
}
.focus-item.is-generated { border-left-color: var(--amber); }
.focus-meta { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 11px; }
.focus-item strong { font-size: 14px; }
.focus-item p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }

.summary-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 24px; }
.summary-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 17px; box-shadow: var(--shadow); }
.summary-label { display: block; color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.summary-value { display: block; margin: 8px 0 2px; color: var(--navy-950); font-size: 30px; line-height: 1; }
.summary-detail { color: var(--muted); font-size: 12px; }
.summary-detail.is-warning { color: var(--amber); }
.summary-detail.is-critical { color: var(--red); }
.summary-detail.is-success { color: var(--green); }

.two-column { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr); gap: 16px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; min-height: 230px; box-shadow: var(--shadow); }
.panel-heading { padding-bottom: 16px; border-bottom: 1px solid #edf0f3; }
.empty-state { padding: 28px 4px; color: var(--muted); }
.empty-state strong { color: var(--text); display: block; margin-bottom: 6px; }
.empty-state p { margin: 0; line-height: 1.5; font-size: 13px; }
.scorecard-row, .attention-item { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 2px; border-bottom: 1px solid #edf0f3; }
.scorecard-row:last-child, .attention-item:last-child { border-bottom: 0; }
.status-pill { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 8px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.status-pill.good { background: var(--green-soft); color: var(--green); }
.status-pill.warn { background: var(--amber-soft); color: var(--amber); }
.status-pill.bad { background: var(--red-soft); color: var(--red); }
.attention-item strong { font-size: 13px; }
.attention-item span { color: var(--muted); font-size: 12px; }

.workspace-tabs {
  display: flex; gap: 4px; width: max-content; max-width: 100%; margin-bottom: 14px;
  padding: 4px; border: 1px solid var(--border); border-radius: 11px; background: #e9edf1;
  overflow-x: auto;
}
.workspace-tab {
  border: 0; border-radius: 8px; padding: 9px 16px; background: transparent; color: #4b5a6b;
  font-size: 13px; font-weight: 700; white-space: nowrap;
}
.workspace-tab:hover { color: var(--navy-950); }
.workspace-tab.is-active { background: var(--surface); color: var(--navy-950); box-shadow: 0 1px 4px rgba(18,34,54,.09); }
.execution-summary {
  min-height: 38px; display: flex; align-items: center; justify-content: space-between; gap: 18px;
  margin-bottom: 12px; color: var(--text); font-size: 13px;
}
.execution-summary strong { color: var(--navy-950); font-size: 17px; }
.muted { color: var(--muted); }
.execution-list { display: grid; gap: 11px; }
.execution-empty {
  border: 1px dashed #c6d0da; border-radius: var(--radius); background: rgba(255,255,255,.65); padding: 34px 20px;
}
.execution-card {
  position: relative; display: grid; gap: 14px; background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid #aab5c2; border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow);
}
.execution-card.status-on_track, .execution-card.status-completed, .execution-card.status-resolved, .execution-card.status-closed { border-left-color: var(--green); }
.execution-card.status-at_risk { border-left-color: var(--amber); }
.execution-card.status-off_track { border-left-color: var(--red); }
.execution-card.status-cancelled { border-left-color: #7b8795; background: #fafbfc; }
.execution-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.execution-card-head > div { min-width: 0; }
.execution-card h3 { margin: 0; color: var(--navy-950); font-size: 17px; line-height: 1.3; overflow-wrap: anywhere; }
.execution-meta { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.execution-description { margin: 0; max-width: 900px; color: #4f5d6b; font-size: 13px; line-height: 1.55; }
.execution-facts { display: flex; flex-wrap: wrap; gap: 8px; }
.execution-fact {
  min-width: 120px; display: grid; gap: 2px; padding: 8px 10px; background: #f7f9fb; border: 1px solid #e7ebef;
  border-radius: 8px;
}
.execution-fact > span { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.execution-fact strong { color: var(--text); font-size: 12px; overflow-wrap: anywhere; }
.execution-fact.is-bad { border-color: #f2c8c3; background: var(--red-soft); }
.execution-fact.is-bad strong { color: var(--red); }
.execution-fact.is-warn { border-color: #ecd5a2; background: var(--amber-soft); }
.execution-fact.is-warn strong { color: #825000; }
.execution-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 2px; }
.execution-actions .button-quiet {
  color: var(--navy-900); background: #f7f9fb; border-color: var(--border);
}
.execution-actions .button-quiet:hover { background: #eef2f6; border-color: #bec8d2; }
.execution-actions .button:disabled { opacity: .55; }

.execution-dialog {
  width: min(92vw, 650px); max-height: min(88vh, 820px); margin: auto; padding: 0;
  color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 30px 90px rgba(8,20,38,.28); overflow: auto;
}
.execution-dialog::backdrop { background: rgba(8,20,38,.62); backdrop-filter: blur(2px); }
.execution-form { display: grid; gap: 20px; padding: 24px; }
.dialog-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.dialog-heading h2 { margin: 5px 0 0; color: var(--navy-950); font-size: 22px; line-height: 1.25; overflow-wrap: anywhere; }
.icon-button {
  flex: 0 0 auto; width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--border);
  border-radius: 9px; background: #f7f9fb; color: var(--navy-900); font-size: 22px; line-height: 1;
}
.icon-button:hover { background: #edf1f5; }
.form-fields { display: grid; gap: 13px; }
.field-group { display: grid; gap: 7px; margin: 0; }
.field-group > span { color: var(--text); font-size: 12px; font-weight: 800; }
.form-grid-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; padding-top: 4px; border-top: 1px solid #edf0f3; }

.app-error { margin-top: 16px; }
.noscript { padding: 20px; }

@media (max-width: 1050px) {
  .summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .two-column { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .app-shell { grid-template: 60px auto 1fr / 1fr; }
  .topbar { grid-column: 1; }
  .sidebar { min-height: auto; padding: 8px 10px; overflow-x: auto; }
  .sidebar nav { display: flex; gap: 4px; min-width: max-content; }
  .nav-section { display: none; }
  .nav-item { white-space: nowrap; }
  .main-content { padding: 20px 16px; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-heading { align-items: center; }
  .page-actions { justify-content: flex-end; }
  .user-name { display: none; }
  .execution-card { padding: 16px; }
  .execution-card-head { gap: 10px; }
  .execution-fact { min-width: calc(50% - 4px); }
}

@media (max-width: 560px) {
  .page-heading { display: grid; align-items: start; }
  .page-actions { width: 100%; justify-content: stretch; }
  .page-actions .button { flex: 1; }
  .execution-summary { display: grid; gap: 4px; }
  .execution-card-head { display: grid; }
  .execution-card-head .status-pill { justify-self: start; }
  .execution-fact { width: 100%; min-width: 0; }
  .form-grid-two { grid-template-columns: 1fr; }
  .dialog-actions { display: grid; grid-template-columns: 1fr 1fr; }
}

@media (max-width: 470px) {
  .auth-card { padding: 26px 22px; }
  .summary-grid { grid-template-columns: 1fr; }
  .page-heading { align-items: flex-start; }
  .page-heading h1 { font-size: 26px; }
  .execution-form { padding: 20px 16px; }
}

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