:root {
  --canvas: #f3f5f7;
  --surface: #ffffff;
  --surface-subtle: #f7f9fa;
  --surface-hover: #eef5f4;
  --sidebar: #172534;
  --sidebar-soft: #213448;
  --sidebar-active: #294457;
  --text: #18232d;
  --text-strong: #111c26;
  --muted: #65727e;
  --muted-2: #8a959f;
  --line: #d9e0e5;
  --line-strong: #c7d0d7;
  --accent: #18756f;
  --accent-hover: #115f5a;
  --accent-soft: #e6f2f0;
  --info: #386f9d;
  --info-soft: #e8f0f6;
  --success: #347653;
  --success-soft: #e7f2ea;
  --warning: #a66d18;
  --warning-soft: #f7eedb;
  --danger: #b2463e;
  --danger-soft: #f7e8e6;
  --violet: #705a87;
  --violet-soft: #eee9f3;
  --radius: 6px;
  --sidebar-width: 224px;
  --header-height: 72px;
  --shadow-float: 0 18px 48px rgba(24, 34, 39, .16);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--canvas);
}

body {
  margin: 0;
  color: var(--text);
  background: var(--canvas);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  min-width: 1180px;
  font-size: 14px;
  line-height: 1.45;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 2px solid rgba(25, 108, 103, .55);
  outline-offset: 2px;
}

.app-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 60;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  color: #edf1f2;
  background: var(--sidebar);
  border-right: 1px solid rgba(255, 255, 255, .06);
}

.brand {
  min-height: var(--header-height);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 11px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.brand-mark {
  width: 12px;
  height: 30px;
  flex: 0 0 auto;
  border-radius: 2px;
  background: #5eb5aa;
}

.brand strong {
  display: block;
  color: #fff;
  font-size: 15px;
  font-weight: 720;
}

.brand small {
  display: block;
  margin-top: 3px;
  color: #9eaaaf;
  font-size: 11px;
}

.tabs {
  flex: 1;
  min-height: 0;
  padding: 12px 10px;
  overflow-y: auto;
}

.nav-label {
  display: block;
  padding: 13px 9px 6px;
  color: #718092;
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

.tabs button {
  width: 100%;
  min-height: 38px;
  margin: 1px 0;
  padding: 0 12px;
  display: flex;
  align-items: center;
  border: 0;
  border-radius: 6px;
  color: #c0cad3;
  background: transparent;
  cursor: pointer;
  font-weight: 620;
  text-align: left;
  transition: color .16s ease, background .16s ease, transform .16s ease;
}

.tabs button:hover {
  color: #fff;
  background: var(--sidebar-soft);
}

.tabs button:active {
  transform: scale(.985);
}

.tabs button.active {
  color: #fff;
  background: var(--sidebar-active);
  box-shadow: inset 3px 0 0 #57b6ad;
}

.sidebar-foot {
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  border-top: 1px solid rgba(255, 255, 255, .08);
}

.env-badge {
  min-width: 0;
  overflow: hidden;
  color: #aab4b8;
  font-size: 11px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.env-badge::before {
  width: 7px;
  height: 7px;
  margin-right: 7px;
  display: inline-block;
  border-radius: 50%;
  background: #778188;
  content: "";
}

.env-badge.demo::before {
  background: #d6a64b;
}

.env-badge.official::before {
  background: #65af78;
}

.sidebar-lock {
  min-width: 54px;
  color: #e7eded;
  border-color: rgba(255, 255, 255, .16);
  background: rgba(255, 255, 255, .05);
}

.workspace {
  min-width: 0;
  grid-column: 2;
}

.workspace-header {
  position: sticky;
  top: 0;
  z-index: 45;
  min-height: var(--header-height);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: rgba(255, 255, 255, .98);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.page-heading {
  min-width: 0;
}

.page-kicker {
  display: block;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
}

.page-heading h1 {
  margin: 1px 0 0;
  color: var(--text-strong);
  font-size: 20px;
  line-height: 1.25;
}

.page-heading p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.workspace-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.export-menu {
  position: relative;
}

.export-menu summary {
  list-style: none;
}

.export-menu summary::-webkit-details-marker {
  display: none;
}

.export-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 90;
  width: 210px;
  padding: 7px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-float);
}

.export-popover strong {
  display: block;
  padding: 7px 9px 5px;
  color: var(--muted);
  font-size: 10px;
}

.export-popover button {
  width: 100%;
  padding: 8px 9px;
  border: 0;
  border-radius: 4px;
  color: var(--text);
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.export-popover button:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.container {
  width: 100%;
  max-width: 1720px;
  margin: 0 auto;
  padding: 16px 20px 44px;
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: view-enter .18s ease-out;
}

@keyframes view-enter {
  from {
    opacity: 0;
    transform: translateY(3px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.btn {
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  font-weight: 650;
  white-space: nowrap;
  transition: border-color .15s ease, color .15s ease, background .15s ease, transform .15s ease;
}

.btn:hover {
  color: var(--accent);
  border-color: #91b8b4;
  background: #fbfdfd;
}

.btn:active {
  transform: scale(.98);
}

.btn.primary {
  min-height: 36px;
  color: #fff;
  border-color: var(--accent);
  background: var(--accent);
}

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

.btn.warn {
  color: var(--warning);
  border-color: #dcc38f;
  background: #fffaf0;
}

.btn.danger {
  color: var(--danger);
  border-color: #dfbbb7;
  background: #fffafa;
}

.btn.segment.active {
  color: #fff;
  border-color: var(--accent);
  background: var(--accent);
}

.icon-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.icon-btn:hover {
  color: var(--text);
  background: var(--surface-subtle);
}

.setup-shell {
  min-height: calc(100dvh - var(--header-height) - 72px);
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, .7fr);
  align-items: center;
  gap: 28px;
}

.setup-copy {
  padding: 42px 4vw;
  border-left: 4px solid var(--accent);
}

.setup-copy h1 {
  max-width: 680px;
  margin: 8px 0 14px;
  color: var(--text-strong);
  font-size: 34px;
  line-height: 1.2;
}

.setup-copy p {
  max-width: 640px;
  color: var(--muted);
  font-size: 15px;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
}

.setup-actions {
  padding: 22px;
  display: grid;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.panel {
  margin-bottom: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.panel.flush {
  padding: 0;
  overflow: hidden;
}

.panel h2 {
  margin: 0 0 12px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-strong);
  font-size: 14px;
}

.panel h2 span {
  color: var(--muted-2);
  font-size: 10px;
  font-weight: 550;
}

.section-heading {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.section-heading h2 {
  margin: 0;
}

.section-heading p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.layout-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(340px, .65fr);
  gap: 12px;
}

.cards {
  margin-bottom: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

#view-costs .cards {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.card {
  min-height: 88px;
  padding: 13px 14px;
  border-left: 1px solid var(--line);
}

.card:first-child {
  border-left: 0;
}

.card .sub,
.card > span:first-child {
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
}

.card .label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 720;
}

.card .num {
  margin-top: 7px;
  color: var(--text-strong);
  font-size: 21px;
  font-weight: 760;
  line-height: 1.15;
  text-align: left;
}

.card .num small {
  margin-left: 3px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
}

.card .sub {
  margin-top: 5px;
}

.card .num.money-risk {
  color: var(--danger);
}

.card .num.money-warn {
  color: var(--warning);
}

.dashboard-alerts {
  min-height: 46px;
  margin-bottom: 12px;
  padding: 8px 11px;
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
}

.dashboard-alerts > strong {
  margin-right: 3px;
  color: var(--text-strong);
  font-size: 11px;
}

.dashboard-alert {
  min-height: 25px;
  padding: 4px 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 4px;
  color: var(--muted);
  background: var(--surface-subtle);
  font-size: 10px;
  white-space: nowrap;
}

.dashboard-alert b {
  color: var(--text-strong);
  font-size: 13px;
}

.dashboard-alert.danger {
  color: var(--danger);
  background: var(--danger-soft);
}

.dashboard-alert.danger b {
  color: var(--danger);
}

.dashboard-alert.warning {
  color: var(--warning);
  background: var(--warning-soft);
}

.dashboard-alert.warning b {
  color: var(--warning);
}

.dashboard-alert-note {
  margin-left: auto;
  color: var(--muted-2);
  font-size: 10px;
}

.dashboard-insights {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 12px;
}

.dashboard-side {
  min-width: 0;
  display: grid;
  grid-template-rows: 1fr;
  gap: 12px;
}

.dashboard-side .panel {
  margin-bottom: 0;
}

.monthly-panel {
  min-width: 0;
}

.compact-panel {
  min-height: 0;
}

.compact-panel .bar-row {
  margin: 7px 0;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 10px;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.chart-legend i {
  width: 8px;
  height: 8px;
  display: inline-block;
  border-radius: 2px;
  background: #14766f;
}

.chart-legend .legend-contract {
  background: #14766f;
}

.chart-legend .legend-invoice {
  background: #b26a00;
}

.chart-legend .legend-receipt {
  background: #2563eb;
}

.monthly-data {
  margin-top: 4px;
}

.monthly-chart-scroll,
.monthly-table-scroll {
  overflow-x: auto;
}

.monthly-chart {
  min-width: max(100%, calc(var(--month-count) * 46px));
  height: 160px;
  padding: 11px 8px 0;
  display: grid;
  grid-template-columns: repeat(var(--month-count), minmax(36px, 1fr));
  align-items: end;
  gap: 4px;
  border-top: 1px solid var(--line);
  background-image: linear-gradient(to bottom, transparent 32%, #edf0f1 32%, #edf0f1 calc(32% + 1px), transparent calc(32% + 1px), transparent 65%, #edf0f1 65%, #edf0f1 calc(65% + 1px), transparent calc(65% + 1px));
}

.month-column {
  min-width: 0;
  text-align: center;
}

.month-bars {
  height: 128px;
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 2px;
}

.month-bar {
  width: 7px;
  min-height: 1px;
  display: block;
  border-radius: 2px 2px 0 0;
  background: #14766f;
  transition: opacity .15s ease, transform .15s ease;
}

.month-column:hover .month-bar {
  opacity: .78;
  transform: translateY(-2px);
}

.month-bar.invoice {
  background: #b26a00;
}

.month-bar.receipt {
  background: #2563eb;
}

.month-bar.cost,
.chart-legend .legend-cost {
  background: #a33f35;
}

.metric-group {
  grid-column: 1 / -1;
}

.metric-group + .metric-group {
  margin-top: 12px;
}

.metric-group-title {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 0 0 8px;
}

.metric-group-title strong {
  font-size: 15px;
  color: var(--text);
}

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

.contract-history {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.mini-table {
  width: 100%;
  margin-top: 8px;
  border-collapse: collapse;
  font-size: 12px;
}

.mini-table th,
.mini-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

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

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

.month-column > span {
  display: block;
  margin-top: 5px;
  color: var(--muted-2);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}

.monthly-table-scroll {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.monthly-table {
  min-width: 820px;
  font-size: 10px;
}

.monthly-table th,
.monthly-table td {
  height: 28px;
  padding: 4px 6px;
  text-align: right;
}

.monthly-table th:first-child,
.monthly-table td:first-child {
  width: 60px;
  text-align: left;
}

.monthly-table th:last-child,
.monthly-table td:last-child {
  position: static;
  box-shadow: none;
}

.monthly-table .contract-value {
  color: #14766f;
}

.monthly-table .invoice-value {
  color: #b26a00;
}

.monthly-table .receipt-value {
  color: #2563eb;
}

.billing-detail-panel {
  margin-top: 0;
}

.billing-detail-heading {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.billing-definition {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
}

.data-scope {
  padding: 4px 7px;
  border-radius: 4px;
  color: var(--muted);
  background: var(--surface-subtle);
  font-size: 10px;
}

.data-scope.active {
  color: var(--warning);
  background: var(--warning-soft);
}

.billing-heading-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.billing-filters {
  position: static !important;
  top: auto;
  margin: 0;
  border-width: 0 0 1px;
  border-radius: 0;
  box-shadow: none;
}

.billing-filters .search {
  width: 220px;
}

.billing-filters select {
  width: 124px;
}

.billing-filters input[type="date"] {
  width: 112px;
}

.billing-detail-panel .table-wrap {
  min-height: 250px;
  max-height: calc(100dvh - 300px);
}

.cost-detail-panel .table-wrap {
  min-height: 260px;
  max-height: calc(100dvh - 275px);
}

.cost-filters {
  position: static !important;
  top: auto;
  margin: 0;
  border-width: 0 0 1px;
  border-radius: 0;
  box-shadow: none;
}

.cost-filters .search {
  width: 240px;
}

.cost-filters select {
  width: 150px;
}

.cost-filters input[type="date"] {
  width: 120px;
}

.card strong {
  display: block;
  margin-top: 9px;
  color: var(--text-strong);
  font-size: 21px;
  font-variant-numeric: tabular-nums;
}

.toolbar,
.inner-toolbar,
.button-row,
.form-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar {
  min-height: 48px;
  margin-bottom: 10px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.toolbar.filters {
  position: sticky;
  top: calc(var(--header-height) + 8px);
  z-index: 30;
  align-items: center;
  flex-wrap: wrap;
  box-shadow: 0 5px 14px rgba(32, 40, 45, .05);
}

.inner-toolbar {
  min-height: 44px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-subtle);
}

.spacer {
  flex: 1;
}

.hint,
.muted {
  color: var(--muted);
}

.source-note {
  margin: -3px 0 10px;
  padding: 7px 9px;
  color: #4f646a;
  background: #f1f6f5;
  border-left: 3px solid #74a9a3;
  font-size: 10px;
}

.label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

input,
select,
textarea,
.input {
  min-height: 32px;
  padding: 5px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  color: var(--text);
  background: var(--surface);
  outline: 0;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #a8b7bc;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(25, 108, 103, .1);
}

textarea {
  min-height: 70px;
  resize: vertical;
}

.search {
  width: min(260px, 100%);
}

.filters select {
  max-width: 145px;
}

.toolbar label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
}

.periodbar {
  min-height: 48px;
  margin-bottom: 10px;
  padding: 7px 9px;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.periodbar .btn {
  min-height: 30px;
  padding: 4px 9px;
  font-size: 11px;
}

.periodbar input {
  width: 118px;
  min-height: 30px;
}

.periodbar .period-label {
  margin-left: auto;
  color: var(--accent);
  font-weight: 720;
  font-variant-numeric: tabular-nums;
}

.table-wrap {
  width: 100%;
  max-height: calc(100dvh - 208px);
  overflow: auto;
  background: var(--surface);
}

.wide-table {
  max-height: calc(100dvh - 230px);
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: separate;
  border-spacing: 0;
  color: var(--text);
  font-size: 12px;
}

#projectTable {
  min-width: 4020px;
}

#billingTable {
  min-width: 1880px;
}

#costTable {
  min-width: 1760px;
}

#costExpenseTable,
#costServiceTable {
  min-width: 1480px;
}

.cost-group-head {
  text-align: center;
  border-left: 1px solid var(--line-strong);
  border-right: 1px solid var(--line-strong);
}

.cost-group-head.expense {
  color: #176b63;
  background: #eaf5f2;
}

.cost-group-head.service {
  color: #8a5b16;
  background: #fbf3e4;
}

#regTable {
  min-width: 2360px;
}

#reviewTable {
  min-width: 2200px;
}

.review-method {
  margin-bottom: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 11px;
}

th,
td {
  height: 40px;
  padding: 7px 9px;
  border-bottom: 1px solid #e8ecee;
  background: var(--surface);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 8;
  height: 36px;
  color: #59666d;
  background: #f4f6f7;
  border-bottom-color: var(--line-strong);
  font-size: 10px;
  font-weight: 760;
}

tbody tr:hover td {
  background: var(--surface-hover);
}

th:first-child,
td:first-child {
  position: sticky;
  left: 0;
  z-index: 5;
  box-shadow: 1px 0 0 var(--line);
}

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

th:last-child,
td:last-child {
  position: sticky;
  right: 0;
  z-index: 5;
  box-shadow: -1px 0 0 var(--line);
}

th:last-child {
  z-index: 10;
}

#billingTable th:last-child,
#billingTable td:last-child,
#costTable th:last-child,
#costTable td:last-child {
  position: static;
  box-shadow: none;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "zero" 0;
}

.project-name {
  color: var(--text-strong);
  font-weight: 700;
}

.sub {
  display: block;
  margin-top: 2px;
  color: var(--muted-2);
  font-size: 10px;
}

.money-risk {
  color: var(--danger);
  font-weight: 720;
}

.money-warn {
  color: var(--warning);
  font-weight: 720;
}

.edit-hint {
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid var(--warning-soft);
  border-radius: 6px;
  color: var(--warning);
  background: #fff8eb;
  font-size: 12px;
}

.pill,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  border-radius: 999px;
  color: var(--muted);
  background: #edf0f1;
  font-size: 10px;
  font-weight: 700;
}

.b-green {
  color: var(--success);
  background: var(--success-soft);
}

.b-blue {
  color: var(--info);
  background: var(--info-soft);
}

.b-yellow {
  color: var(--warning);
  background: var(--warning-soft);
}

.b-red {
  color: var(--danger);
  background: var(--danger-soft);
}

.b-violet {
  color: var(--info);
  background: var(--info-soft);
}

.b-gray {
  color: var(--muted);
  background: #edf0f1;
}

.empty {
  padding: 42px 18px;
  color: var(--muted-2);
  text-align: center;
}

.management-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.management-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
}

.management-head {
  min-height: 38px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-subtle);
  font-weight: 750;
}

.management-head span {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.management-body {
  max-height: 260px;
  overflow: auto;
}

.management-item {
  width: 100%;
  padding: 9px 10px;
  display: block;
  border: 0;
  border-bottom: 1px solid #edf0f1;
  color: var(--text);
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.management-item:last-child {
  border-bottom: 0;
}

.management-item:hover {
  background: var(--surface-hover);
}

.management-item strong {
  display: block;
  overflow: hidden;
  color: var(--text-strong);
  text-overflow: ellipsis;
}

.management-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
  white-space: normal;
}

.risk-group {
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  overflow: hidden;
}

.risk-head {
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
  background: var(--surface-subtle);
  font-weight: 720;
}

.risk-list {
  display: grid;
}

.risk-item {
  padding: 8px 10px;
  display: grid;
  grid-template-columns: minmax(120px, .75fr) minmax(180px, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 0;
  border-top: 1px solid #edf0f1;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
}

.risk-item:hover {
  background: var(--surface-hover);
}

.bar-row {
  margin: 9px 0;
  display: grid;
  grid-template-columns: 74px 1fr 40px;
  align-items: center;
  gap: 8px;
}

.bar-track {
  height: 7px;
  overflow: hidden;
  border-radius: 2px;
  background: #edf0f1;
}

.bar-fill {
  height: 100%;
  background: var(--accent);
}

.chart-bars {
  min-height: 210px;
  padding-top: 10px;
  display: grid;
  grid-template-columns: repeat(12, minmax(34px, 1fr));
  align-items: end;
  gap: 8px;
}

.chart-col {
  min-width: 0;
  text-align: center;
}

.chart-pair {
  height: 160px;
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 3px;
}

.chart-stick {
  width: 10px;
  min-height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--accent);
}

.chart-stick + .chart-stick {
  background: #7d91a0;
}

.chart-label {
  margin-top: 6px;
  color: var(--muted-2);
  font-size: 9px;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 5px;
  overflow: hidden;
}

.status-cell {
  min-height: 72px;
  padding: 10px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.status-cell:nth-child(2n) {
  border-right: 0;
}

.status-cell strong {
  display: block;
  margin-top: 5px;
  color: var(--text-strong);
}

.alert,
.issue-box {
  margin-bottom: 10px;
  padding: 9px 11px;
  border-left: 3px solid var(--warning);
  color: #6e4c17;
  background: var(--warning-soft);
}

.issue-line {
  padding: 5px 0;
  border-bottom: 1px solid rgba(154, 104, 25, .15);
}

.issue-line:last-child {
  border-bottom: 0;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  justify-content: flex-end;
  background: rgba(20, 27, 31, .42);
  backdrop-filter: blur(2px);
}

.overlay.show {
  display: flex;
}

.modal {
  width: min(780px, calc(100vw - var(--sidebar-width)));
  height: 100dvh;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line-strong);
  background: var(--surface);
  box-shadow: var(--shadow-float);
  animation: drawer-enter .22s cubic-bezier(.16, 1, .3, 1);
}

.modal.large {
  width: min(1120px, calc(100vw - var(--sidebar-width)));
}

@keyframes drawer-enter {
  from {
    transform: translateX(18px);
    opacity: .7;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.modal-head,
.modal-foot {
  min-height: 58px;
  padding: 11px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
}

.modal-head {
  border-bottom: 1px solid var(--line);
}

.modal-foot {
  margin-top: auto;
  border-top: 1px solid var(--line);
}

.modal-head h2 {
  margin: 0;
  color: var(--text-strong);
  font-size: 17px;
}

.modal-body {
  min-height: 0;
  padding: 14px 16px 28px;
  overflow: auto;
  background: #fafbfb;
}

.modal-body h3 {
  margin: 18px 0 8px;
  padding: 6px 8px;
  color: var(--text-strong);
  border-left: 3px solid var(--accent);
  background: #f0f4f3;
  font-size: 12px;
}

.modal-body h3:first-of-type {
  margin-top: 8px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 12px;
}

.form-grid.compact {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.form-grid label {
  min-width: 0;
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 680;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
  width: 100%;
}

.sensitive-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}

.sensitive-input .btn {
  min-height: 34px;
  white-space: nowrap;
}

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

.span-3 {
  grid-column: 1 / -1;
}

.metric-strip {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 5px;
  overflow: hidden;
}

.metric {
  padding: 9px 10px;
  border-left: 1px solid var(--line);
  background: var(--surface);
}

.metric:first-child {
  border-left: 0;
}

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

.metric strong {
  display: block;
  margin-top: 4px;
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
}

.receipt-entry {
  display: grid;
  grid-template-columns: 150px 160px minmax(220px, 1fr) auto;
  align-items: end;
  gap: 8px;
}

.receipt-entry label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 680;
}

.receipt-entry input {
  width: 100%;
}

.receipt-entry .btn {
  min-height: 32px;
}

.receipt-table-wrap {
  max-height: 260px;
  margin-top: 10px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
}

.cost-batch-table-wrap {
  max-height: 260px;
  margin-bottom: 16px;
}

.cost-batch-table {
  min-width: 1180px;
}

.cost-form-label {
  margin-top: 4px;
  padding: 8px 10px;
  border-left: 3px solid var(--accent);
  background: #f4f6f7;
  color: var(--text);
  font-size: 11px;
  font-weight: 760;
}

.cost-batch-form input[type="number"] {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.receipt-table {
  min-width: 660px;
}

.receipt-table.cost-batch-table {
  min-width: 1180px;
}

.subview-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 12px 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.cost-subview-tabs .btn,
.cost-entry-tabs .btn {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.section-kicker {
  display: inline-block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 780;
}

.section-kicker.input {
  color: var(--accent);
}

.section-kicker.reference {
  color: #66747b;
}

.compact-heading {
  margin-bottom: 10px;
}

.compact-heading h2,
.compact-heading h3 {
  margin: 0;
}

.finance-input-section,
.finance-reference-section,
.cost-reference-section,
.cost-entry-section,
.cost-history-section {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.finance-input-section {
  padding: 14px;
  border: 1px solid #cfe3df;
  border-left: 3px solid var(--accent);
  background: #fbfdfd;
}

.finance-reference-section,
.cost-reference-section {
  padding: 14px;
  border: 1px solid var(--line);
  background: #f7f9fa;
}

.readonly-grid input[readonly] {
  color: #3f4c52;
  background: #edf1f2;
  border-color: #d9e0e2;
}

.reference-summary {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1px;
  margin-bottom: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--line);
}

.reference-summary > div {
  min-width: 0;
  padding: 9px 10px;
  background: var(--surface);
}

.reference-summary span,
.reference-summary strong {
  display: block;
}

.reference-summary span {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 9px;
}

.reference-summary strong {
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 11px;
  white-space: nowrap;
}

.project-reference-select {
  min-width: 280px;
  color: var(--muted);
  font-size: 10px;
}

.project-reference-select select {
  width: 100%;
  margin-top: 3px;
}

.cost-entry-tabs {
  margin-top: 14px;
  padding-left: 0;
  padding-right: 0;
}

.cost-dual-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.cost-dual-entry .cost-entry-section {
  min-width: 0;
  margin-top: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  background: #fbfdfd;
}

.cost-dual-entry .service-entry-section {
  border-left-color: #b47a1f;
  background: #fffdf8;
}

.cost-entry-actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  margin-top: 10px;
}

.cost-dual-entry .table-wrap {
  max-height: 260px;
  margin-top: 10px;
  overflow: auto;
}

.cost-field-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.cost-field-grid label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 680;
}

.cost-field-grid input {
  width: 100%;
  margin-top: 4px;
  text-align: right;
}

.attendance-entry-layout {
  display: grid;
  grid-template-columns: minmax(390px, 2fr) minmax(520px, 3fr);
  gap: 9px;
  margin-bottom: 10px;
}

.attendance-entry-panel,
.attendance-project-panel {
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.attendance-entry-panel {
  border-left: 3px solid var(--accent);
}

.attendance-form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.attendance-form-grid label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 680;
}

.attendance-form-grid input,
.attendance-form-grid select {
  width: 100%;
  margin-top: 4px;
}

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

.attendance-form-grid .span-3 {
  grid-column: 1 / -1;
}

.attendance-weekend-toggle {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.attendance-weekend-toggle .toggle-line {
  min-height: 34px;
  margin-top: 4px;
  padding: 0 9px;
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  color: var(--text);
  background: #f7f9fa;
  font-weight: 650;
}

.attendance-weekend-toggle input {
  width: auto;
  margin: 0;
}

.attendance-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 9px;
}

.attendance-edit-banner {
  margin-bottom: 10px;
  padding: 9px 12px;
  border-left: 3px solid var(--warning);
  color: #75511a;
  background: #fff8e9;
  font-size: 11px;
  font-weight: 700;
}

.project-selection-label {
  padding: 7px 8px 3px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 760;
}

.attendance-record-toolbar strong {
  margin-right: auto;
  font-size: 12px;
}

.receipt-table th,
.receipt-table td {
  height: 36px;
  padding: 6px 8px;
}

.receipt-table th:first-child,
.receipt-table td:first-child,
.receipt-table th:last-child,
.receipt-table td:last-child {
  position: static;
  box-shadow: none;
}

.member-box,
.choice-box {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
}

.member-box {
  padding: 8px;
}

.member-box table {
  min-width: 0;
}

.choice-box {
  max-height: 112px;
  padding: 7px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  overflow: auto;
}

.choice {
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-subtle);
}

.weekly-reminder {
  margin-bottom: 12px;
  padding: 11px 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--success);
  border-radius: var(--radius);
  background: var(--surface);
}

.weekly-reminder.pending {
  display: block;
  border-left-color: var(--danger);
  background: #fffdfd;
}

.weekly-reminder-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.weekly-reminder strong,
.weekly-reminder span {
  display: block;
}

.weekly-reminder strong {
  color: var(--text-strong);
  font-size: 12px;
}

.weekly-reminder-head > div > span,
.weekly-reminder.complete > div > span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.weekly-missing-list {
  margin-top: 9px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.weekly-missing-list button {
  min-height: 26px;
  padding: 3px 8px;
  border: 1px solid #dfbbb7;
  border-radius: 4px;
  color: var(--danger);
  background: var(--danger-soft);
  cursor: pointer;
  font-size: 10px;
}

.weekly-missing-list button:hover {
  border-color: var(--danger);
  background: #fff;
}

.weekly-overdue-groups {
  margin-top: 9px;
  display: grid;
  gap: 7px;
}

.weekly-overdue-group {
  border: 1px solid #f0d6d3;
  border-radius: 5px;
  background: #fff;
}

.weekly-overdue-group summary {
  padding: 8px 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  list-style: none;
}

.weekly-overdue-group summary::-webkit-details-marker {
  display: none;
}

.weekly-overdue-group summary::before {
  content: "+";
  width: 17px;
  height: 17px;
  display: inline-flex;
  flex: 0 0 17px;
  align-items: center;
  justify-content: center;
  border: 1px solid #dfbbb7;
  border-radius: 3px;
  color: var(--danger);
  font-size: 12px;
}

.weekly-overdue-group[open] summary::before {
  content: "-";
}

.weekly-period {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.weekly-period span {
  color: var(--danger);
  font-size: 10px;
  font-weight: 700;
}

.weekly-overdue-group .weekly-missing-list {
  margin: 0 9px 9px;
  padding-top: 7px;
  border-top: 1px solid #f4e2e0;
}

.project-picker {
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
}

.project-picker-toolbar {
  padding: 7px;
  display: grid;
  grid-template-columns: minmax(190px, 1fr) auto auto;
  align-items: center;
  gap: 7px;
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--line);
}

.project-picker-toolbar input[type="search"] {
  width: 100%;
}

.project-picker-toolbar .check-row {
  padding: 0 4px;
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.selected-projects {
  min-height: 36px;
  padding: 6px 7px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  border-bottom: 1px solid var(--line);
}

.selected-count {
  margin-right: 2px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 750;
}

.selected-project {
  min-height: 24px;
  padding: 3px 4px 3px 7px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 4px;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 10px;
}

.selected-project button {
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: 3px;
  color: var(--accent);
  background: transparent;
  cursor: pointer;
  line-height: 1;
}

.selected-project button:hover {
  color: #fff;
  background: var(--accent);
}

.choice-box.project-results {
  max-height: 208px;
  padding: 0;
  display: grid;
  gap: 0;
  overflow-y: auto;
  border: 0;
  border-radius: 0;
}

.project-choice {
  min-height: 45px;
  padding: 7px 9px;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid #edf0f1;
  cursor: pointer;
}

.project-choice:last-child {
  border-bottom: 0;
}

.project-choice:hover {
  background: var(--surface-hover);
}

.project-choice input {
  min-height: auto;
}

.project-choice strong,
.project-choice small {
  display: block;
}

.project-choice strong {
  overflow: hidden;
  color: var(--text-strong);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-choice small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
}

.project-choice-empty {
  padding: 28px 12px;
  color: var(--muted-2);
  text-align: center;
}

.project-result-summary {
  position: sticky;
  bottom: 0;
  padding: 6px 9px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: #f7f9f9;
  font-size: 9px;
  text-align: right;
}

.wide {
  flex: 1;
  min-width: 220px;
}

.form-row.top {
  align-items: end;
}

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

@media (max-width: 1180px) {
  :root {
    --sidebar-width: 184px;
  }

  .cards {
    grid-template-columns: repeat(3, 1fr);
  }

  #view-costs .cards {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .card:nth-child(4) {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .card:nth-child(n+5) {
    border-top: 1px solid var(--line);
  }

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

  .dashboard-insights {
    grid-template-columns: 1fr;
  }

  .dashboard-side {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

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

@media (max-width: 820px) {
  :root {
    --sidebar-width: 0px;
  }

  .app-shell {
    display: block;
  }

  .app-sidebar {
    position: static;
    width: 100%;
    min-height: auto;
  }

  .brand {
    min-height: 58px;
  }

  .tabs {
    display: flex;
    padding: 6px 10px;
    overflow-x: auto;
  }

  .tabs button {
    width: auto;
    flex: 0 0 auto;
  }

  .nav-label,
  .sidebar-foot {
    display: none;
  }

  .workspace-header {
    min-height: 66px;
    padding: 10px 14px;
  }

  .page-heading p,
  .page-kicker {
    display: none;
  }

  .container {
    padding: 12px;
  }

  .cards,
  .management-grid,
  .status-grid,
  .form-grid,
  .form-grid.compact,
  .metric-strip,
  .setup-shell {
    grid-template-columns: 1fr;
  }

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

  #view-costs .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .cards .card {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .cards .card:nth-child(-n+3) {
    border-top: 0;
  }

  .cards .card:not(:nth-child(3n+1)) {
    border-left: 1px solid var(--line);
  }

  .dashboard-side {
    grid-template-columns: 1fr;
  }

  .dashboard-alerts {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .dashboard-alert-note {
    width: 100%;
    margin-left: 0;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .billing-heading-actions {
    width: 100%;
    justify-content: space-between;
  }

  .chart-legend {
    flex-wrap: wrap;
  }

  .project-picker-toolbar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .project-picker-toolbar input[type="search"] {
    grid-column: 1 / -1;
  }

  .attendance-entry-layout,
  .reference-summary {
    grid-template-columns: 1fr;
  }

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

  .project-reference-select {
    width: 100%;
    min-width: 0;
  }

  .weekly-reminder-head {
    align-items: flex-start;
  }

  .sensitive-input {
    grid-template-columns: 1fr;
  }

  .receipt-entry {
    grid-template-columns: 1fr;
  }

  .card,
  .metric,
  .status-cell {
    border-left: 0;
    border-right: 0;
    border-top: 1px solid var(--line);
  }

  .card:first-child,
  .metric:first-child {
    border-top: 0;
  }

  .modal,
  .modal.large {
    width: 100vw;
  }
}

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

  .cards .card,
  .cards .card:nth-child(-n+3),
  .cards .card:not(:nth-child(3n+1)) {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .cards .card:first-child {
    border-top: 0;
  }
}
