:root {
  --sidebar: #10242d;
  --sidebar-active: #29404a;
  --sidebar-muted: #8fa3ad;
  --ink: #10212b;
  --muted: #637582;
  --soft: #eef2f4;
  --canvas: #f4f6f7;
  --surface: #ffffff;
  --border: #d8e0e4;
  --border-strong: #c5d0d6;
  --brand: #f5a623;
  --brand-dark: #bd6c00;
  --teal: #0f766e;
  --teal-soft: #e8f5f2;
  --blue: #2563a8;
  --blue-soft: #eaf2fb;
  --red: #b42318;
  --red-soft: #fff0ee;
  --green: #177245;
  --green-soft: #e9f6ef;
  --amber: #a15c00;
  --amber-soft: #fff5df;
  --shadow: 0 12px 28px rgba(16, 33, 43, 0.08);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; min-height: 100%; background: var(--canvas); }
body { min-width: 320px; letter-spacing: 0; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
svg { width: 18px; height: 18px; stroke-width: 1.8; flex: 0 0 auto; }

.app-shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  display: flex;
  width: 264px;
  flex-direction: column;
  color: #fff;
  background: var(--sidebar);
  border-right: 1px solid rgba(255, 255, 255, .08);
  transition: transform .2s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 76px;
  padding: 15px 16px 14px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, .11);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 7px;
  color: #101b20;
  background: var(--brand);
  font-size: 17px;
  font-weight: 800;
}

.brand-copy { min-width: 0; }
.brand h1 { margin: 0; font-size: 19px; line-height: 1.2; }
.brand p { margin: 4px 0 0; color: #d8e1e5; font-size: 11px; }
.sidebar-close { display: inline-grid; margin-left: auto; color: #fff; }

.main-nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px 10px 16px;
  scrollbar-width: thin;
  scrollbar-color: #455a64 transparent;
}

.nav-group + .nav-group { margin-top: 9px; }
.nav-group-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 7px 10px 5px;
  border: 0;
  color: var(--sidebar-muted);
  background: transparent;
  font-size: 10px;
  font-weight: 700;
  text-align: left;
  text-transform: uppercase;
}

.nav-group-label svg { width: 14px; height: 14px; transition: transform .2s ease; }
.nav-group.collapsed .nav-group-label svg { transform: rotate(-90deg); }
.nav-group.collapsed .nav-group-items { display: none; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 0;
  border-radius: 5px;
  color: #dbe5e9;
  background: transparent;
  font-size: 13px;
  text-align: left;
}

.nav-item:hover { color: #fff; background: rgba(255, 255, 255, .07); }
.nav-item.active { color: #fff; background: var(--sidebar-active); font-weight: 700; }
.nav-item.active svg { color: var(--brand); }
.nav-item-badge {
  min-width: 20px;
  margin-left: auto;
  padding: 1px 5px;
  border-radius: 9px;
  color: #16262e;
  background: var(--brand);
  font-size: 10px;
  font-weight: 800;
  text-align: center;
}

.sidebar-tools {
  padding: 12px 14px 14px;
  border-top: 1px solid rgba(255, 255, 255, .11);
  background: rgba(0, 0, 0, .08);
}

.sync-state { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.sync-state div { display: flex; min-width: 0; flex-direction: column; }
.sync-state strong { font-size: 11px; }
.sync-state small { margin-top: 2px; color: var(--sidebar-muted); font-size: 10px; }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: #34c783; box-shadow: 0 0 0 3px rgba(52,199,131,.14); }
.data-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }

.sidebar-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 35px;
  padding: 7px 8px;
  border: 1px solid #49606b;
  border-radius: 5px;
  color: #fff;
  background: #203640;
  font-size: 11px;
}
.sidebar-action:hover { border-color: #6f858e; background: #29424d; }
.sidebar-action svg { width: 15px; height: 15px; }
.file-button { position: relative; cursor: pointer; }
.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.main { min-height: 100vh; margin-left: 264px; transition: margin-left .2s ease; }

@media (min-width: 921px) {
  .app-shell.sidebar-collapsed .sidebar { transform: translateX(-100%); }
  .app-shell.sidebar-collapsed .main { margin-left: 0; }
  .app-shell.sidebar-collapsed .icon-button.mobile-menu { display: inline-grid; }
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, .96);
}

.topbar-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.breadcrumb { margin: 0 0 4px; color: var(--muted); font-size: 10px; font-weight: 700; }
.topbar h2 { margin: 0; font-size: 23px; line-height: 1.15; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.icon-button.mobile-menu { display: none; }

.global-search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(340px, 28vw);
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}
.global-search:focus-within { border-color: #7da8a4; box-shadow: 0 0 0 3px rgba(15, 118, 110, .09); }
.global-search svg { width: 16px; color: var(--muted); }
.global-search input { min-width: 0; flex: 1; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 13px; }
.global-search kbd { padding: 2px 5px; border: 1px solid var(--border); border-radius: 4px; color: var(--muted); background: var(--soft); font-size: 9px; }

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--muted);
  background: transparent;
}
.icon-button:hover { color: var(--ink); background: var(--soft); }
.notification-button { position: relative; border-color: var(--border); background: #fff; }
.notification-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  display: grid;
  min-width: 17px;
  height: 17px;
  place-items: center;
  padding: 0 4px;
  border: 2px solid #fff;
  border-radius: 10px;
  color: #fff;
  background: var(--red);
  font-size: 9px;
  font-weight: 800;
}

.user-menu { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 3px 6px 3px 4px; border: 0; color: var(--ink); background: transparent; }
.user-menu:hover { background: var(--soft); }
.avatar { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 50%; color: #fff; background: var(--teal); font-size: 12px; font-weight: 800; }
.user-copy { display: flex; flex-direction: column; text-align: left; }
.user-copy strong { font-size: 11px; }
.user-copy small { margin-top: 2px; color: var(--muted); font-size: 9px; }
.user-menu > svg { width: 14px; }

.content { padding: 20px 24px 40px; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.page-header h3 { margin: 0; font-size: 18px; }
.page-header p { max-width: 720px; margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.page-actions { display: flex; align-items: center; gap: 8px; }

.primary-button, .secondary-button, .danger-button, .text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 7px 13px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.primary-button { border: 1px solid var(--teal); color: #fff; background: var(--teal); }
.primary-button:hover { background: #0a625c; }
.secondary-button { border: 1px solid var(--border-strong); color: var(--ink); background: #fff; }
.secondary-button:hover { background: var(--soft); }
.danger-button { border: 1px solid #e1a6a0; color: var(--red); background: var(--red-soft); }
.text-button { min-height: 30px; padding: 4px 7px; border: 0; color: var(--teal); background: transparent; }
.primary-button svg, .secondary-button svg, .danger-button svg { width: 15px; height: 15px; }

.segmented { display: inline-flex; padding: 3px; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.segmented button { min-height: 28px; padding: 4px 10px; border: 0; border-radius: 4px; color: var(--muted); background: transparent; font-size: 10px; }
.segmented button.active { color: var(--ink); background: var(--soft); font-weight: 700; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat-card { min-width: 0; padding: 14px 15px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); }
.stat-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stat-label { color: var(--muted); font-size: 11px; font-weight: 700; }
.stat-icon { display: grid; width: 28px; height: 28px; place-items: center; border-radius: 5px; color: var(--teal); background: var(--teal-soft); }
.stat-icon svg { width: 15px; height: 15px; }
.stat-value { display: block; margin-top: 9px; font-size: 25px; line-height: 1; font-weight: 800; white-space: nowrap; }
.stat-foot { display: flex; align-items: center; gap: 5px; min-height: 18px; margin-top: 8px; color: var(--muted); font-size: 10px; }
.trend-up { color: var(--green); font-weight: 700; }
.trend-down { color: var(--red); font-weight: 700; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(310px, .75fr); gap: 14px; margin-bottom: 14px; }
.dashboard-grid.equal { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel { min-width: 0; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 50px; padding: 11px 15px; border-bottom: 1px solid var(--border); }
.panel-head h3 { margin: 0; font-size: 14px; }
.panel-head p { margin: 3px 0 0; color: var(--muted); font-size: 10px; }
.panel-body { padding: 14px 15px; }

.pipeline { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); overflow: hidden; border: 1px solid var(--border); border-radius: 6px; }
.pipeline-step { position: relative; min-width: 0; padding: 13px 10px 12px; border-right: 1px solid var(--border); background: #fff; }
.pipeline-step:last-child { border-right: 0; }
.pipeline-step::after { content: ""; position: absolute; right: -5px; top: 22px; z-index: 1; width: 8px; height: 8px; border-top: 1px solid var(--border-strong); border-right: 1px solid var(--border-strong); background: #fff; transform: rotate(45deg); }
.pipeline-step:last-child::after { display: none; }
.pipeline-step span { display: block; overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.pipeline-step strong { display: block; margin-top: 7px; font-size: 19px; }
.pipeline-step small { display: block; overflow: hidden; margin-top: 5px; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }

.risk-list { display: grid; gap: 0; }
.risk-item { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--soft); }
.risk-item:last-child { border-bottom: 0; }
.risk-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); }
.risk-dot.danger { background: var(--red); }
.risk-copy { min-width: 0; }
.risk-copy strong { display: block; overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.risk-copy span { display: block; overflow: hidden; margin-top: 3px; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }

.bar-list { display: grid; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 82px minmax(0, 1fr) 78px; gap: 10px; align-items: center; font-size: 10px; }
.bar-track { height: 8px; overflow: hidden; border-radius: 4px; background: #e9eef0; }
.bar-fill { height: 100%; border-radius: 4px; background: var(--teal); }
.bar-fill.orange { background: var(--brand); }
.bar-fill.blue { background: var(--blue); }
.bar-value { text-align: right; font-weight: 800; }

.progress-line { min-width: 96px; }
.progress-line-head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 5px; font-size: 9px; }
.progress-track { height: 6px; overflow: hidden; border-radius: 4px; background: #e7edef; }
.progress-fill { height: 100%; border-radius: 4px; background: var(--teal); }
.progress-fill.warn { background: var(--brand); }
.progress-fill.danger { background: var(--red); }

.module-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
}
.module-toolbar .search-field { min-width: 220px; flex: 1; }
.search-field { display: flex; align-items: center; gap: 7px; height: 34px; padding: 0 9px; border: 1px solid var(--border); border-radius: 5px; background: #fff; }
.search-field svg { width: 15px; color: var(--muted); }
.search-field input { min-width: 0; flex: 1; border: 0; outline: 0; background: transparent; font-size: 11px; }
.filter-select { height: 34px; min-width: 130px; padding: 0 30px 0 9px; border: 1px solid var(--border); border-radius: 5px; color: var(--ink); background: #fff; font-size: 11px; }
.toolbar-count { color: var(--muted); font-size: 10px; white-space: nowrap; }
.toolbar-spacer { flex: 1; }

.table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; min-width: 850px; border-collapse: collapse; table-layout: auto; }
.data-table th { height: 40px; padding: 8px 12px; border-bottom: 1px solid var(--border); color: #63717a; background: #fbfcfc; font-size: 10px; font-weight: 700; text-align: left; white-space: nowrap; }
.data-table td { max-width: 270px; height: 46px; padding: 8px 12px; border-bottom: 1px solid #e5eaed; color: #1b2a33; font-size: 11px; vertical-align: middle; }
.data-table tbody tr { cursor: pointer; }
.data-table tbody tr:hover { background: #f7faf9; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.cell-text { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-primary { color: #0b5f59; font-weight: 700; }
.money { font-variant-numeric: tabular-nums; font-weight: 800; white-space: nowrap; }
.muted-cell { color: var(--muted); }
.row-actions { display: flex; justify-content: flex-end; gap: 2px; }
.row-actions .icon-button { width: 30px; height: 30px; }
.select-check { width: 15px; height: 15px; accent-color: var(--teal); }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 128px;
  min-height: 22px;
  padding: 3px 7px;
  border-radius: 11px;
  color: #4b5c65;
  background: var(--soft);
  font-size: 9px;
  font-weight: 700;
  white-space: nowrap;
}
.status-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #75858e; }
.status-pill.ok { color: var(--green); background: var(--green-soft); }
.status-pill.ok::before { background: var(--green); }
.status-pill.warn { color: var(--amber); background: var(--amber-soft); }
.status-pill.warn::before { background: var(--amber); }
.status-pill.danger { color: var(--red); background: var(--red-soft); }
.status-pill.danger::before { background: var(--red); }
.status-pill.info { color: var(--blue); background: var(--blue-soft); }
.status-pill.info::before { background: var(--blue); }

.summary-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: 7px; margin-bottom: 12px; background: #fff; }
.summary-item { padding: 11px 14px; border-right: 1px solid var(--border); }
.summary-item:last-child { border-right: 0; }
.summary-item span { display: block; color: var(--muted); font-size: 9px; }
.summary-item strong { display: block; margin-top: 5px; font-size: 16px; }

.empty-state { display: grid; min-height: 260px; place-items: center; padding: 30px; color: var(--muted); text-align: center; }
.empty-state svg { width: 34px; height: 34px; margin-bottom: 9px; color: #9baab1; }
.empty-state strong { display: block; color: var(--ink); font-size: 13px; }
.empty-state p { margin: 5px 0 0; font-size: 10px; }

.kanban { display: grid; grid-template-columns: repeat(4, minmax(230px, 1fr)); gap: 12px; overflow-x: auto; }
.kanban-column { min-width: 230px; }
.kanban-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; color: var(--muted); font-size: 10px; font-weight: 700; }
.kanban-count { display: grid; width: 20px; height: 20px; place-items: center; border-radius: 10px; background: #e3e9ec; }
.kanban-card { margin-bottom: 8px; padding: 11px; border: 1px solid var(--border); border-left: 3px solid var(--teal); border-radius: 6px; background: #fff; cursor: pointer; }
.kanban-card.risk { border-left-color: var(--red); }
.kanban-card strong { display: block; font-size: 11px; }
.kanban-card p { margin: 5px 0; color: var(--muted); font-size: 9px; }
.kanban-meta { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 9px; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(8, 23, 30, .56);
}
.modal-backdrop[hidden], .drawer-scrim[hidden], .detail-drawer[hidden], .sidebar-scrim[hidden] { display: none; }
.modal { width: min(820px, 100%); max-height: calc(100vh - 48px); overflow: auto; border: 1px solid var(--border); border-radius: 8px; background: #fff; box-shadow: var(--shadow); }
.workflow-modal { width: min(680px, 100%); }
.modal-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); background: #fff; }
.modal-head h3 { margin: 2px 0 0; font-size: 17px; }
.eyebrow { margin: 0; color: var(--teal); font-size: 9px; font-weight: 800; text-transform: uppercase; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px 15px; padding: 18px; }
.field { min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label { display: block; margin-bottom: 5px; color: #42545d; font-size: 10px; font-weight: 700; }
.required { color: var(--red); }
.field input, .field select, .field textarea { width: 100%; min-height: 37px; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: 5px; outline: 0; color: var(--ink); background: #fff; font-size: 12px; }
.field textarea { min-height: 82px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: #6d9e99; box-shadow: 0 0 0 3px rgba(15,118,110,.08); }
.field input[readonly] { color: var(--muted); background: var(--soft); }
.line-items-field { min-width: 0; }
.line-items-title { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 8px; }
.line-items-title label { margin: 0; color: #42545d; font-size: 11px; font-weight: 800; }
.line-items-title span { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; }
.line-items-editor { overflow: hidden; border: 1px solid var(--border-strong); border-radius: 6px; background: #fff; }
.line-items-scroll { overflow-x: auto; }
.line-items-head, .line-items-row { display: grid; align-items: center; min-width: 700px; }
.line-items-editor.sales .line-items-head, .line-items-editor.sales .line-items-row { grid-template-columns: minmax(210px, 2fr) minmax(90px, .7fr) minmax(120px, 1fr) minmax(130px, 1fr) 42px; }
.line-items-editor.purchase .line-items-head, .line-items-editor.purchase .line-items-row { grid-template-columns: minmax(190px, 1.8fr) minmax(140px, 1.2fr) minmax(82px, .65fr) minmax(82px, .65fr) minmax(120px, 1fr) minmax(130px, 1fr) 42px; min-width: 930px; }
.line-items-head { min-height: 34px; color: #5d6e77; background: #f2f5f6; font-size: 9px; font-weight: 700; }
.line-items-head span { padding: 7px 9px; }
.line-items-row { min-height: 47px; border-top: 1px solid var(--border); }
.line-items-row input { width: calc(100% - 12px); min-width: 0; min-height: 34px; margin: 6px; padding: 7px 8px; border: 1px solid var(--border); border-radius: 4px; outline: 0; color: var(--ink); background: #fff; font-size: 11px; }
.line-items-row input:focus { border-color: #6d9e99; box-shadow: 0 0 0 2px rgba(15,118,110,.08); }
.line-items-row output { display: block; padding: 0 9px; overflow: hidden; font-size: 11px; font-variant-numeric: tabular-nums; font-weight: 800; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.line-remove { width: 30px; height: 30px; color: var(--red); }
.line-remove svg { width: 15px; height: 15px; }
.line-items-total { display: flex; align-items: center; justify-content: flex-end; gap: 24px; min-height: 43px; padding: 9px 12px; border-top: 1px solid var(--border-strong); color: var(--muted); background: #fafbfb; font-size: 10px; }
.line-items-total span { margin: 0; }
.line-items-total strong { margin-left: 4px; color: var(--ink); font-size: 12px; }
.line-items-total span:last-child strong { color: var(--teal); font-size: 14px; }
.workflow-summary { margin: 16px 18px 0; padding: 11px 12px; border-left: 3px solid var(--teal); background: #f1f6f6; color: #40545d; font-size: 10px; line-height: 1.55; }
.workflow-summary strong { color: var(--ink); }
.modal-actions { position: sticky; bottom: 0; display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); background: #fff; }
.spacer { flex: 1; }

.drawer-scrim { position: fixed; inset: 0; z-index: 44; background: rgba(8, 23, 30, .28); }
.detail-drawer { position: fixed; inset: 0 0 0 auto; z-index: 45; width: min(560px, 94vw); overflow-y: auto; border-left: 1px solid var(--border); background: #fff; box-shadow: -14px 0 32px rgba(16,33,43,.14); }
.drawer-head { position: sticky; top: 0; z-index: 1; padding: 16px 18px; border-bottom: 1px solid var(--border); background: #fff; }
.drawer-head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.drawer-head h3 { margin: 4px 0 0; font-size: 18px; }
.drawer-subhead { display: flex; align-items: center; gap: 8px; margin-top: 9px; color: var(--muted); font-size: 10px; }
.drawer-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
.locked-note { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 7px 10px; border: 1px solid #b8c6cc; border-radius: 5px; color: #53666f; background: #f3f6f7; font-size: 10px; font-weight: 700; }
.locked-note svg { width: 15px; height: 15px; }
.drawer-section { padding: 16px 18px; border-bottom: 1px solid var(--border); }
.drawer-section h4 { margin: 0 0 11px; font-size: 12px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px 18px; }
.detail-item { min-width: 0; }
.detail-item.full { grid-column: 1 / -1; }
.detail-item span { display: block; color: var(--muted); font-size: 9px; }
.detail-item strong { display: block; overflow-wrap: anywhere; margin-top: 4px; font-size: 11px; line-height: 1.45; }
.order-lines-table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: 5px; }
.order-lines-table { width: 100%; min-width: 520px; border-collapse: collapse; }
.order-lines-table th, .order-lines-table td { padding: 8px 9px; border-bottom: 1px solid var(--border); font-size: 10px; text-align: left; }
.order-lines-table th { color: #5f7079; background: #f5f7f8; font-size: 9px; white-space: nowrap; }
.order-lines-table td.number { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.order-lines-table tfoot td { border-bottom: 0; color: var(--ink); background: #fafbfb; font-weight: 800; }
.timeline { position: relative; display: grid; gap: 14px; padding-left: 18px; }
.timeline::before { content: ""; position: absolute; left: 4px; top: 4px; bottom: 4px; width: 1px; background: var(--border); }
.timeline-item { position: relative; }
.timeline-item::before { content: ""; position: absolute; left: -18px; top: 3px; width: 8px; height: 8px; border: 2px solid #fff; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 1px var(--teal); }
.timeline-item strong { display: block; font-size: 10px; }
.timeline-item span { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; line-height: 1.5; }

.toast-region { position: fixed; right: 18px; bottom: 18px; z-index: 80; display: grid; gap: 8px; width: min(360px, calc(100vw - 36px)); }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 12px 13px; border: 1px solid var(--border-strong); border-left: 4px solid var(--teal); border-radius: 6px; background: #fff; box-shadow: var(--shadow); }
.toast.error { border-left-color: var(--red); }
.toast svg { width: 17px; color: var(--teal); }
.toast.error svg { color: var(--red); }
.toast strong { display: block; font-size: 11px; }
.toast span { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; }

.sidebar-scrim { position: fixed; inset: 0; z-index: 29; background: rgba(8,23,30,.48); }

@media (max-width: 1180px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pipeline { grid-template-columns: repeat(4, minmax(140px, 1fr)); overflow-x: auto; }
  .pipeline-step { min-width: 140px; }
  .dashboard-grid, .dashboard-grid.equal { grid-template-columns: 1fr; }
  .user-copy, .user-menu > svg, .global-search kbd { display: none; }
}

@media (max-width: 920px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close, .icon-button.mobile-menu { display: inline-grid; }
  .main { margin-left: 0; }
  .topbar { padding: 11px 16px; }
  .content { padding: 16px 16px 34px; }
  .global-search { width: min(300px, 38vw); }
}

@media (max-width: 640px) {
  .topbar { min-height: 66px; }
  .topbar h2 { font-size: 18px; }
  .breadcrumb { display: none; }
  .global-search { width: 42px; padding: 0 12px; border-color: transparent; }
  .global-search input { position: absolute; width: 1px; opacity: 0; }
  .user-menu { display: none; }
  .content { padding: 13px 11px 28px; }
  .page-header { align-items: stretch; flex-direction: column; }
  .page-actions { justify-content: flex-end; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stat-card { padding: 12px; }
  .stat-value { font-size: 20px; }
  .summary-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-item:nth-child(2) { border-right: 0; }
  .summary-item:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
  .pipeline { grid-template-columns: repeat(7, 142px); }
  .module-toolbar { align-items: stretch; flex-wrap: wrap; }
  .module-toolbar .search-field { min-width: 100%; }
  .filter-select { min-width: 0; flex: 1; }
  .toolbar-count { align-self: center; }
  .form-grid { grid-template-columns: 1fr; padding: 14px; }
  .field.full { grid-column: auto; }
  .line-items-title { align-items: flex-start; }
  .line-items-total { align-items: flex-end; flex-direction: column; gap: 4px; }
  .modal-backdrop { padding: 0; place-items: end center; }
  .modal { width: 100%; max-height: 94vh; border-radius: 8px 8px 0 0; }
  .detail-drawer { width: 100%; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-item.full { grid-column: auto; }
  .kanban { grid-template-columns: repeat(4, 84vw); }
}
