:root {
  --bg: #f3f5f1;
  --ink: #18201c;
  --muted: #647067;
  --line: #d7ddd3;
  --paper: #fffdf7;
  --paper-2: #eef3ea;
  --green: #0f7c46;
  --green-2: #dff1e5;
  --amber: #b47705;
  --amber-2: #fff0c9;
  --red: #b6382f;
  --blue: #2867b2;
  --shadow: 0 18px 45px rgba(31, 44, 35, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "Segoe UI", sans-serif;
}

button, input, select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

.sidebar {
  background: #17231c;
  color: #f7fbf2;
  padding: 24px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: #d9f2c7;
  color: #17231c;
  font-weight: 800;
  border-radius: 8px;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
}

.brand p, .summary-panel p, .panel-head p {
  margin: 4px 0 0;
  color: var(--muted);
}

.sidebar .brand p {
  color: #b7c3b9;
}

.file-drop {
  display: block;
  padding: 18px;
  border: 1px dashed rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  margin-bottom: 20px;
  cursor: pointer;
}

.file-drop span, .file-drop strong {
  display: block;
}

.file-drop strong {
  margin-top: 6px;
  color: #d9f2c7;
  font-size: 13px;
}

.file-drop input {
  display: none;
}

.nav-group {
  display: grid;
  gap: 8px;
  margin-bottom: 24px;
}

.nav-item, .secondary, .primary, .danger {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
}

.nav-item {
  text-align: left;
  color: #e6eee8;
  background: transparent;
}

.nav-item.active, .nav-item:hover {
  background: #2b3b30;
}

.side-actions {
  display: grid;
  gap: 10px;
}

.primary {
  background: var(--green);
  color: white;
}

.secondary {
  background: #e7ece2;
  color: var(--ink);
}

.danger {
  background: rgba(182, 56, 47, 0.14);
  color: #ffd8d4;
}

.small {
  min-height: 34px;
}

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

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-weight: 700;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: 30px;
}

.search-wrap {
  width: min(520px, 48vw);
}

.search-wrap input, .date-mode input, .range-panel input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 8px;
  padding: 0 12px;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(132px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.kpi {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

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

.kpi strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
}

.range-panel {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px 180px auto;
  align-items: end;
  gap: 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 18px;
}

.range-title {
  display: grid;
  gap: 4px;
}

.range-title strong {
  font-size: 15px;
}

.range-title span, .range-panel label, .date-mode label {
  color: var(--muted);
  font-size: 12px;
}

.range-panel label, .date-mode label {
  display: grid;
  gap: 5px;
}

.summary-panel, .table-panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  overflow: hidden;
}

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

.panel-head.compact {
  padding: 14px 18px;
}

.panel-head h3 {
  margin: 0;
  font-size: 18px;
}

.date-mode {
  display: flex;
  align-items: end;
  gap: 8px;
}

.company-chip {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 8px;
  background: var(--green-2);
  color: var(--green);
  font-weight: 700;
  white-space: nowrap;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.date-mode label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.table-wrap, .summary-table-wrap {
  overflow: auto;
}

.summary-visual {
  display: grid;
  grid-template-columns: minmax(300px, 0.85fr) minmax(420px, 1.35fr);
  gap: 18px;
  padding: 18px;
  align-items: stretch;
}

.progress-stack {
  display: grid;
  gap: 14px;
  align-content: center;
  padding: 8px 0;
}

.progress-row {
  display: grid;
  gap: 7px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.progress-track {
  height: 12px;
  background: #e5e9e1;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
}

.progress-fill.budget { background: var(--green); }
.progress-fill.construction { background: #d89b10; }
.progress-fill.acceptance { background: var(--red); }

.bar-chart {
  height: 178px;
  display: grid;
  grid-template-columns: repeat(4, minmax(72px, 1fr));
  align-items: stretch;
  gap: 18px;
  padding: 10px 16px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(#f1f5ee 1px, transparent 1px) 0 0 / 100% 25%;
  overflow: hidden;
}

.bar-item {
  display: grid;
  grid-template-rows: 22px 104px 28px;
  justify-items: center;
  align-items: end;
  gap: 4px;
  min-width: 0;
}

.bar {
  width: min(54px, 70%);
  min-height: 4px;
  border-radius: 7px 7px 0 0;
  background: var(--blue);
}

.bar.budget { background: var(--green); }
.bar.construction { background: #d89b10; }
.bar.acceptance { background: var(--red); }

.bar-value {
  font-weight: 800;
}

.bar-label {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  white-space: normal;
  line-height: 1.2;
  align-self: start;
}

.table-panel {
  margin-top: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  background: #edf3ea;
  z-index: 1;
  font-weight: 700;
}

#ordersTable {
  table-layout: fixed;
  min-width: 1380px;
}

#ordersTable th {
  position: sticky;
  overflow: visible;
}

.resize-handle {
  position: absolute;
  top: 0;
  right: -3px;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  z-index: 3;
}

.resize-handle::after {
  content: "";
  position: absolute;
  top: 7px;
  bottom: 7px;
  left: 3px;
  width: 1px;
  background: transparent;
}

#ordersTable th:hover .resize-handle::after {
  background: var(--green);
}

td.title-cell {
  white-space: normal;
  line-height: 1.45;
}

.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-weight: 700;
}

.done {
  background: var(--green-2);
  color: var(--green);
}

.todo {
  background: var(--amber-2);
  color: var(--amber);
}

.row-actions {
  display: flex;
  gap: 6px;
}

.complete-btn, .void-btn, .restore-btn {
  height: 30px;
  padding: 0 10px;
  border-radius: 7px;
  background: #e8efe5;
  color: var(--ink);
}

.complete-btn.is-done {
  background: var(--green);
  color: white;
}

.void-btn {
  background: rgba(182, 56, 47, 0.12);
  color: var(--red);
}

.restore-btn {
  background: var(--green-2);
  color: var(--green);
}

.date-input {
  width: 128px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
  background: white;
}

.empty-state {
  display: grid;
  place-items: center;
  text-align: center;
  min-height: 360px;
  padding: 42px;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 82px;
  height: 82px;
  border-radius: 8px;
  background: var(--green-2);
  color: var(--green);
  font-weight: 900;
  margin-bottom: 16px;
}

.empty-state p {
  max-width: 560px;
  color: var(--muted);
}

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
  }
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .range-panel { grid-template-columns: 1fr 1fr; }
  .range-title { grid-column: 1 / -1; }
  .topbar { align-items: stretch; flex-direction: column; }
  .search-wrap { width: 100%; }
  .summary-visual { grid-template-columns: 1fr; }
  .panel-head { align-items: flex-start; flex-direction: column; }
}
