:root {
  color-scheme: light;
  --ink: #1f2933;
  --muted: #6b7280;
  --line: #dfe5df;
  --panel: #ffffff;
  --page: #f6f7f4;
  --nav: #f8fbff;
  --accent: #177245;
  --accent-strong: #0f5e37;
  --red: #b42318;
  --red-bg: #fff1ee;
  --yellow: #b7791f;
  --yellow-bg: #fff7e6;
  --green: #177245;
  --green-bg: #e7f4ed;
  --blue: #0b6fc6;
  --blue-bg: #e8f2ff;
  --shadow: 0 18px 45px rgba(31, 41, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family:
    Inter, "SF Pro Text", "SF Pro Display", -apple-system, BlinkMacSystemFont,
    "Segoe UI", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei",
    "Hiragino Sans GB", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 1, "cv05" 1;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(244, 247, 251, 0.96);
  padding: 18px;
}

.login-screen.hidden {
  display: none;
}

.login-panel {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.login-brand {
  padding: 0 0 22px;
  color: var(--ink);
}

.login-brand p {
  color: var(--muted);
}

.login-panel label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-weight: 650;
  margin-bottom: 14px;
}

.login-panel input {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
}

.login-panel .primary-btn {
  width: 100%;
}

.login-error {
  color: var(--red);
  min-height: 22px;
  margin: 10px 0 0;
}

.login-hint {
  color: var(--muted);
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.55;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--nav);
  border-right: 1px solid #d8e4f2;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  padding: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid #d8e4f2;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.brand-logo {
  width: 48px;
  height: 48px;
  display: block;
  border-radius: 8px;
  object-fit: contain;
  background: #ffffff;
}

.sidebar .brand-logo {
  width: 52px;
  height: 52px;
}

.brand h1 {
  font-size: 18px;
  margin: 0 0 4px;
  letter-spacing: 0;
  font-weight: 680;
}

.brand p,
.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav-btn {
  display: block;
  border: 0;
  background: transparent;
  color: #41546b;
  text-align: left;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  transition: 0.16s ease;
  font-weight: 650;
}

.nav-btn::before,
.nav-btn::after {
  content: none !important;
  display: none !important;
}

.nav-btn:hover,
.nav-btn.active {
  border-color: #cfe4fb;
  background: var(--blue-bg);
  color: #075eb7 !important;
  opacity: 1;
  text-shadow: none;
}

.sidebar-foot {
  margin-top: auto;
  border-top: 1px solid #d8e4f2;
  padding-top: 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  color: #5b6b7f;
  font-size: 12px;
}

.sidebar-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.ghost-btn {
  border: 1px solid #d8e4f2;
  background: #ffffff;
  color: #24364b;
  border-radius: 8px;
  padding: 8px 10px;
}

.workspace {
  min-width: 0;
  padding: 28px;
}

.topbar {
  min-height: 118px;
  padding: 18px 20px;
  border: 1px solid #d8e4f2;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.topbar h2 {
  margin: 5px 0 0;
  font-size: 22px;
  line-height: 1.22;
  font-weight: 680;
  letter-spacing: 0;
}

.top-actions {
  display: flex;
  gap: 10px;
}

.primary-btn,
.secondary-btn {
  border: 1px solid transparent;
  border-radius: 8px;
  min-height: 40px;
  padding: 0 14px;
  font-weight: 650;
}

.primary-btn {
  background: var(--accent);
  color: #fff;
}

.primary-btn:hover {
  background: var(--accent-strong);
}

.secondary-btn {
  background: #f8fafc;
  border-color: #d8e4f2;
  color: #24364b;
}

.compact-select {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 40px;
  padding: 0 12px;
  background: #fff;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.view.active + .view.active {
  margin-top: 16px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: none;
  min-height: 108px;
}

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

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
  font-weight: 680;
  letter-spacing: 0;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.75fr);
  gap: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-head {
  min-height: 52px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.panel-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px;
  background: #fbfcfb;
}

.segment {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
  padding: 7px 10px;
  min-width: 52px;
}

.segment.active {
  background: #fff;
  color: #075eb7;
  box-shadow: 0 2px 7px rgba(15, 23, 42, 0.09);
}

.risk-list,
.action-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.risk-card,
.action-card {
  border: 1px solid var(--line);
  border-left: 6px solid var(--green);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.risk-card.red {
  border-left-color: var(--red);
  background: var(--red-bg);
}

.risk-card.yellow {
  border-left-color: var(--yellow);
  background: var(--yellow-bg);
}

.risk-card.green {
  border-left-color: var(--green);
  background: var(--green-bg);
}

.risk-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.risk-top strong {
  font-size: 16px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.badge.red {
  background: #fed7c4;
  color: var(--red);
}

.badge.yellow {
  background: #fde99c;
  color: var(--yellow);
}

.badge.green {
  background: #c9f1d7;
  color: var(--green);
}

.risk-card p,
.action-card p {
  margin: 0;
  color: #344054;
  line-height: 1.55;
}

.risk-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  margin-top: 10px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  background: #f8fafc;
  color: #475467;
  font-weight: 700;
}

.report-panel {
  max-width: 960px;
}

.daily-report,
.answer-box {
  margin: 0;
  padding: 18px;
  color: #1f2937;
  background: #fbfdff;
  white-space: pre-wrap;
  line-height: 1.75;
  font-size: 15px;
}

.ask-panel {
  max-width: 920px;
}

.ask-box {
  display: flex;
  gap: 10px;
  padding: 16px;
}

.ask-box input {
  flex: 1;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  outline: none;
}

.intake-form {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.intake-form label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-weight: 700;
}

.intake-form input,
.intake-form select,
.intake-form textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
}

.intake-form textarea {
  resize: vertical;
  line-height: 1.55;
}

.intake-form input:focus,
.intake-form select:focus,
.intake-form textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

.intake-drafts-panel {
  margin-top: 16px;
}

.draft-list {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.draft-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.draft-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.draft-top p,
.draft-note {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.draft-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.draft-fields span {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 8px 10px;
  color: #344054;
  overflow-wrap: anywhere;
}

.draft-fields b {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.task-list,
.alert-list {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.task-role {
  display: grid;
  gap: 10px;
}

.task-role h4 {
  margin: 0;
  color: #344054;
}

.task-card,
.alert-card {
  border: 1px solid var(--line);
  border-left: 6px solid var(--blue);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.task-card.red,
.alert-card.red {
  border-left-color: var(--red);
  background: var(--red-bg);
}

.task-card.yellow,
.alert-card.yellow {
  border-left-color: var(--yellow);
  background: var(--yellow-bg);
}

.task-card.blue,
.alert-card.blue {
  border-left-color: var(--blue);
  background: var(--blue-bg);
}

.task-main,
.alert-card {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}

.task-main strong,
.alert-card strong {
  display: block;
  margin-bottom: 6px;
}

.task-main p,
.alert-card p {
  margin: 0;
  color: #344054;
  line-height: 1.55;
}

.task-submit {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.task-submit input {
  flex: 1;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
}

.briefing-box {
  padding: 16px;
}

.briefing-box pre {
  margin: 8px 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 14px;
  white-space: pre-wrap;
  line-height: 1.7;
  color: #1f2937;
  min-height: 150px;
}

.role-desk-lists {
  margin-top: 16px;
}

.ask-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

.quick-questions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 16px;
}

.quick-questions button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 8px 12px;
  color: #344054;
}

.import-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 16px;
}

.import-grid-inner {
  padding: 16px;
}

.import-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.import-card h3 {
  margin: 0 0 4px;
}

.import-card p {
  color: var(--muted);
  margin: 0 0 14px;
  line-height: 1.55;
}

.import-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.import-card-head strong {
  color: #344054;
  font-size: 14px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.status-pill.ok {
  color: var(--green);
  background: var(--green-bg);
}

.status-pill.warn {
  color: var(--yellow);
  background: var(--yellow-bg);
}

.field-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
  background: #fbfdff;
}

.field-block span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  margin-bottom: 8px;
}

.field-block div {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.field-block code {
  border-radius: 999px;
  background: #edf4ff;
  color: var(--blue);
  padding: 5px 8px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 650;
}

.field-block.optional code {
  color: #475467;
  background: #eef2f7;
}

.check-result {
  border-left: 4px solid var(--accent);
  background: #edfdf9;
  color: #26413d;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 14px;
  line-height: 1.5;
  font-size: 14px;
}

.import-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.panel-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.bom-searchbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 10px;
  padding: 16px;
  border-top: 1px solid var(--line);
}

.bom-searchbar input {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  font-size: 15px;
}

.bom-workspace {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 16px;
  padding: 0 16px 16px;
}

.bom-style-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 680px;
  overflow: auto;
}

.bom-style-item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  color: var(--text);
}

.bom-style-item.active {
  border-color: var(--blue);
  background: #edf4ff;
}

.bom-style-item strong,
.bom-style-item span,
.bom-style-item small {
  display: block;
}

.bom-style-item span {
  margin-top: 4px;
  line-height: 1.4;
}

.bom-style-item small {
  margin-top: 6px;
  color: var(--muted);
}

.bom-detail {
  min-width: 0;
}

.bom-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.bom-detail-head h4 {
  margin: 4px 0 8px;
  font-size: 17px;
  line-height: 1.35;
}

.file-label {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 13px;
  background: #fff;
  font-weight: 650;
}

.file-label input {
  display: none;
}

.empty {
  color: var(--muted);
  padding: 16px;
}

@media (max-width: 1100px) {
  .metric-grid {
    grid-template-columns: repeat(3, minmax(132px, 1fr));
  }

  .split-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .nav {
    grid-template-columns: repeat(4, 1fr);
  }

  .nav-btn {
    text-align: center;
  }

  .workspace {
    padding: 16px;
  }

  .topbar,
  .ask-box {
    align-items: stretch;
    flex-direction: column;
  }

  .metric-grid,
  .import-grid {
    grid-template-columns: 1fr;
  }

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

  .bom-searchbar {
    grid-template-columns: 1fr;
  }

  .bom-detail-head {
    flex-direction: column;
  }
}
