:root {
  color-scheme: light;
  --bg: #eef2f4;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --ink: #16202a;
  --muted: #607081;
  --line: #d8e0e6;
  --navy: #192647;
  --teal: #0f766e;
  --green: #15803d;
  --amber: #b7791f;
  --red: #b42318;
  --purple: #7e22ce;
  --blue: #1d4ed8;
  --radius: 8px;
  font-family: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink);
  min-height: 38px;
  padding: 0 13px;
  cursor: pointer;
}

button:hover {
  border-color: #9aaaba;
}

button.primary {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
  font-weight: 700;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.landing-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  background: #192647;
  color: #fff;
}

.landing-nav {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
}

.brand-mark {
  font-size: 24px;
  font-weight: 900;
}

.landing-nav button {
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-weight: 800;
}

.landing-main {
  width: min(1160px, calc(100vw - 36px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 390px);
  gap: 42px;
  align-items: center;
  padding: 38px 0 74px;
}

.landing-copy h1,
.landing-copy p,
.login-panel h2,
.login-panel p {
  margin: 0;
}

.landing-copy h1 {
  font-size: clamp(48px, 8vw, 88px);
  line-height: 0.96;
  letter-spacing: 0;
}

.landing-copy p {
  margin-top: 20px;
  max-width: 640px;
  color: #dce6f2;
  font-size: 19px;
  line-height: 1.45;
}

.landing-actions {
  margin-top: 28px;
}

.login-panel {
  background: #fff;
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.26);
}

.login-panel h2 {
  font-size: 24px;
}

.login-panel p {
  color: var(--muted);
  margin-top: 5px;
  margin-bottom: 20px;
}

.login-panel form {
  display: grid;
  gap: 14px;
}

.login-error {
  margin-top: 12px;
  border-radius: 7px;
  background: #fee2e2;
  color: #7f1d1d;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 700;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  min-height: 74px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 16px 24px;
  background: var(--navy);
  color: #fff;
}

.topbar h1,
.topbar p {
  margin: 0;
}

.topbar h1 {
  font-size: 24px;
  line-height: 1.1;
}

.topbar p {
  margin-top: 4px;
  color: #dce6f2;
  font-size: 13px;
}

.status-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar-actions button {
  min-height: 36px;
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-weight: 800;
}

.user-chip {
  color: #dce6f2;
  font-size: 13px;
  font-weight: 700;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.status-pill.ok {
  background: rgba(21, 128, 61, 0.2);
}

.status-pill.warn {
  background: rgba(183, 121, 31, 0.24);
}

.status-pill.neutral {
  background: rgba(255, 255, 255, 0.12);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 348px) minmax(0, 1fr);
  min-height: 0;
}

.control-panel {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 16px;
  overflow-y: auto;
}

.control-panel form {
  display: grid;
  gap: 14px;
}

.framework-grid {
  display: grid;
  gap: 10px;
  padding-top: 4px;
}

label {
  display: grid;
  gap: 6px;
  color: #39495a;
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  min-height: 38px;
  padding: 8px 10px;
}

textarea {
  resize: vertical;
  line-height: 1.35;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 92px;
  gap: 10px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.check-row input {
  width: 17px;
  height: 17px;
  min-height: 0;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 74px 64px;
  gap: 8px;
}

.button-row.compact {
  grid-template-columns: 1fr 1fr;
}

.stage-box {
  display: grid;
  gap: 8px;
}

.stage-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.stage-actions button {
  text-align: left;
  justify-content: flex-start;
  font-weight: 800;
}

.saved-block {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.panel-title {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.saved-list {
  display: grid;
  gap: 8px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.saved-item {
  width: 100%;
  text-align: left;
  display: grid;
  gap: 2px;
  padding: 9px 10px;
  min-height: 0;
}

.saved-item strong {
  font-size: 13px;
}

.saved-item span {
  color: var(--muted);
  font-size: 12px;
}

.result-panel {
  padding: 16px;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 12px;
  min-width: 0;
}

.result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.result-header h2,
.result-header p {
  margin: 0;
}

.result-header h2 {
  font-size: 20px;
  line-height: 1.2;
}

.result-header p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.validation-summary {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.summary-chip {
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
}

.summary-chip.ok {
  background: var(--green);
}

.summary-chip.warn {
  background: var(--amber);
}

.summary-chip.bad {
  background: var(--red);
}

.ai-review {
  background: #fffaf0;
  border: 1px solid #f2d49b;
  border-radius: var(--radius);
  padding: 12px 14px;
  color: #5f4213;
  font-size: 13px;
}

.ai-review strong {
  color: #3f2b0c;
}

.workflow-panel {
  display: grid;
  grid-template-columns: repeat(6, minmax(118px, 1fr));
  gap: 8px;
}

.workflow-step {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  min-height: 74px;
}

.workflow-step strong {
  display: block;
  color: var(--navy);
  font-size: 13px;
  line-height: 1.2;
}

.workflow-step span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.workflow-step.done {
  border-color: #8fd0bf;
  background: #f0fdfa;
}

.tabs {
  display: flex;
  gap: 8px;
}

.tab {
  background: var(--surface-2);
  font-weight: 700;
}

.tab.active {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

.table-wrap {
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  min-width: 1280px;
}

th,
td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 7px 8px;
  text-align: center;
  font-size: 12px;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--navy);
  color: #fff;
  font-weight: 800;
}

th:first-child,
td:first-child {
  position: sticky;
  left: 0;
  z-index: 3;
}

td:first-child {
  background: #f8fafc;
  text-align: left;
  font-weight: 800;
}

th:first-child {
  z-index: 4;
}

tr.block-start td {
  border-top: 3px solid #2c3e66;
}

.sheet-table th,
.sheet-table td {
  height: 30px;
  font-size: 13px;
  padding: 5px 8px;
}

.sheet-table .sheet-title {
  background: #0f4c9a;
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  text-align: center;
  border-bottom: 3px solid #1d8cff;
}

.sheet-table .summary-row td {
  background: #eef1fb;
  font-weight: 900;
}

.sheet-table .dark-row td,
.sheet-table .block-label td {
  background: var(--navy);
  color: #fff;
  font-weight: 900;
  text-align: center;
}

.sheet-table .reg-header th {
  background: var(--navy);
  color: #fff;
  font-size: 14px;
}

.sheet-table .sheet-spacer {
  background: #fff;
  min-width: 18px;
  width: 18px;
}

.sheet-table .count-cell {
  background: #fffdf2;
}

.sheet-table .block-total td {
  background: #fff8dc;
  font-weight: 900;
}

.shift-OFF {
  background: #eeeeee;
  color: #111827;
}

.shift-NW1,
.shift-NW2 {
  background: #ffff00;
  color: #111111;
  font-weight: 800;
}

.shift-DW1 {
  background: #9c27b0;
  color: #ffffff;
  font-weight: 800;
}

.shift-DW2 {
  background: #e91e63;
  color: #ffffff;
  font-weight: 800;
}

.shift-LDW3,
.shift-LDW4 {
  background: #81c784;
  color: #111827;
}

.shift-LDW5 {
  background: #ff9800;
  color: #111827;
}

.shift-SDW3 {
  background: #fff8e1;
  color: #111827;
}

.shift-SDW4 {
  background: #81c784;
  color: #111827;
}

.shift-SDW5 {
  background: #ffcc80;
  color: #111827;
}

.shift-CAN1 {
  background: #fde68a;
  color: #713f12;
}

.shift-CAN2 {
  background: #fecaca;
  color: #7f1d1d;
}

.shift-ADMEV {
  background: #26c6da;
  color: #111827;
}

.shift-OnC {
  background: #e5e7eb;
  color: #111827;
}

.metric-bad {
  background: #fee2e2;
  color: #7f1d1d;
  font-weight: 800;
}

.metric-warn {
  background: #fef3c7;
  color: #713f12;
  font-weight: 800;
}

.metric-ok {
  background: #dcfce7;
  color: #14532d;
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  background: #111827;
  color: #fff;
  padding: 11px 13px;
  border-radius: 8px;
  box-shadow: 0 12px 34px rgba(15, 23, 42, 0.26);
  font-size: 13px;
  z-index: 20;
}

.floating-chat {
  position: fixed;
  left: 18px;
  bottom: 18px;
  width: min(420px, calc(100vw - 36px));
  z-index: 30;
  pointer-events: none;
}

.chat-toggle {
  pointer-events: auto;
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
  font-weight: 900;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.22);
}

.chat-panel {
  pointer-events: auto;
  margin-top: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 18px 60px rgba(15, 23, 42, 0.28);
  padding: 12px;
}

.floating-chat.collapsed .chat-panel {
  display: none;
}

.chat-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.chat-head strong {
  color: var(--navy);
  font-size: 14px;
}

.chat-head button {
  min-height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

.chat-messages {
  display: grid;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
  margin-bottom: 10px;
}

.chat-message {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 10px;
  background: #fff;
  font-size: 13px;
  line-height: 1.35;
}

.chat-message.user {
  background: #eef6ff;
}

.chat-message.assistant {
  background: #f0fdfa;
}

.chat-message ul {
  margin: 8px 0 0 18px;
  padding: 0;
}

.chat-message button {
  margin-top: 8px;
  min-height: 32px;
}

.chat-form {
  display: grid;
  gap: 8px;
}

@media (max-width: 920px) {
  .landing-main {
    grid-template-columns: 1fr;
    align-items: start;
    gap: 24px;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .workflow-panel {
    grid-template-columns: 1fr 1fr;
  }

  .control-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .topbar,
  .result-header {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    align-items: flex-start;
    justify-content: flex-start;
  }

  .status-row,
  .validation-summary {
    justify-content: flex-start;
  }
}
