:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eceff3;
  --line: #d8dde5;
  --text: #16202a;
  --muted: #647182;
  --accent: #165dff;
  --accent-dark: #0e43b5;
  --ok: #1f8a5b;
  --warn: #9a6200;
  --danger: #b42318;
  --shadow: 0 14px 36px rgba(15, 23, 42, .08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  color: #ecf2ff;
  background: #111827;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  color: #ffffff;
  background: var(--accent);
  font-weight: 800;
  letter-spacing: 0;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 4px;
  color: #9aa7bd;
}

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

.nav-item {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  color: #c7d2e4;
  background: transparent;
  text-align: left;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}

.nav-item:hover,
.nav-item.active {
  color: #ffffff;
  background: rgba(255, 255, 255, .1);
}

.nav-item:hover {
  transform: translateX(2px);
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 74px;
  margin-bottom: 18px;
}

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

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 6px;
  font-size: 18px;
  line-height: 1.3;
}

h3 {
  margin-bottom: 14px;
  font-size: 16px;
}

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

.top-actions input {
  width: min(42vw, 430px);
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  color: var(--text);
  background: #ffffff;
  outline: none;
  transition: border-color .16s ease, box-shadow .16s ease;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(22, 93, 255, .12);
}

button,
.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border-radius: 7px;
  border: 1px solid var(--line);
  padding: 0 14px;
  color: var(--text);
  background: #ffffff;
  white-space: nowrap;
  transition: transform .16s ease, background .16s ease, border-color .16s ease;
}

button:hover,
.file-button:hover {
  transform: translateY(-1px);
}

.primary {
  border-color: var(--accent);
  color: #ffffff;
  background: var(--accent);
}

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

.ghost {
  color: var(--accent-dark);
  border-color: rgba(22, 93, 255, .25);
  background: rgba(22, 93, 255, .06);
}

.danger {
  color: #ffffff;
  border-color: var(--danger);
  background: var(--danger);
}

.wide {
  width: 100%;
  justify-content: flex-start;
}

.button-row,
.system-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.view {
  display: none;
  animation: viewIn .22s ease both;
}

.view.active {
  display: block;
}

@keyframes viewIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric,
.panel,
.print-sheet {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  min-height: 118px;
  padding: 18px;
}

.metric span,
.metric small {
  display: block;
  color: var(--muted);
}

.metric strong {
  display: block;
  margin: 8px 0;
  font-size: 30px;
  line-height: 1;
  letter-spacing: 0;
}

.work-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 14px;
}

.panel {
  min-width: 0;
  padding: 18px;
}

.inspector {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.note {
  margin-top: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.note p,
.section-head p {
  color: var(--muted);
  margin-bottom: 0;
}

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

.section-head.full {
  grid-column: 1 / -1;
}

.table-wrap {
  min-width: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.table-wrap.tall {
  max-height: calc(100vh - 250px);
}

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

th,
td {
  height: 42px;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #ffffff;
  background: #2b3440;
  font-weight: 650;
}

tbody tr {
  transition: background .16s ease;
}

tbody tr:nth-child(even) {
  background: #f8fafc;
}

tbody tr:hover {
  background: #eaf1ff;
}

.status {
  display: inline-flex;
  min-width: 62px;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 8px;
  color: var(--ok);
  background: rgba(31, 138, 91, .12);
}

.form-grid,
.filters,
.print-meta,
.master-grid {
  display: grid;
  gap: 12px;
}

.form-grid {
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.wide-field {
  grid-column: span 2;
}

.filters {
  grid-template-columns: 260px 180px minmax(220px, 1fr);
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.print-sheet {
  padding: 22px;
}

.print-title {
  margin-bottom: 18px;
  text-align: center;
  font-size: 24px;
  font-weight: 800;
}

.print-meta {
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  margin-bottom: 16px;
}

.span-2 {
  grid-column: span 2;
}

.sign-row {
  display: flex;
  justify-content: space-between;
  gap: 30px;
  margin-top: 30px;
}

.statement-sheet table {
  min-width: 1400px;
}

.master-grid {
  grid-template-columns: minmax(0, 1.2fr) minmax(0, .8fr);
}

.compact-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.compact-form button {
  grid-column: 1 / -1;
}

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

.list-row,
.option-row {
  display: grid;
  grid-template-columns: 90px 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
}

.option-row {
  grid-template-columns: 110px 1fr;
}

.file-button input {
  display: none;
}

#system-status {
  min-height: 120px;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  white-space: pre-wrap;
}

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

  .sidebar {
    position: static;
    height: auto;
  }

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

  .work-split,
  .master-grid {
    grid-template-columns: 1fr;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }
}

@media (max-width: 720px) {
  .workspace {
    padding: 16px;
  }

  .topbar,
  .section-head {
    display: grid;
  }

  .top-actions,
  .top-actions input,
  .button-row {
    width: 100%;
  }

  .top-actions {
    display: grid;
  }

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

  .metrics,
  .form-grid,
  .filters,
  .print-meta,
  .compact-form {
    grid-template-columns: 1fr;
  }

  .wide-field,
  .span-2 {
    grid-column: auto;
  }
}

@media print {
  body {
    background: #ffffff;
  }

  .sidebar,
  .topbar,
  .section-head,
  .filters,
  .system-actions {
    display: none !important;
  }

  .workspace {
    padding: 0;
  }

  .view {
    display: none !important;
  }

  .view.active {
    display: block !important;
  }

  .print-sheet,
  .table-wrap {
    border: 0;
    box-shadow: none;
  }

  th {
    color: #000000;
    background: #eeeeee;
  }
}
