:root {
  --canvas: #f3f1eb;
  --surface: #fffdf9;
  --surface-muted: #eae7df;
  --surface-raised: #ffffff;
  --ink: #1e2c29;
  --ink-soft: #354641;
  --muted: #6f7b76;
  --muted-light: #909a95;
  --line: #d9d5cb;
  --line-strong: #c5c0b4;
  --primary: #176b5c;
  --primary-dark: #173d37;
  --primary-soft: #dceae5;
  --accent: #c9692d;
  --accent-soft: #f4e5d8;
  --danger: #b13f36;
  --danger-soft: #fae9e6;
  --focus: #287e6e;
  --shadow: 0 12px 30px rgba(32, 44, 40, 0.12);
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--canvas);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.58;
}

input,
select,
textarea {
  min-width: 0;
}

textarea {
  resize: vertical;
}

::selection {
  color: #fff;
  background: var(--primary);
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.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;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 68px;
  padding: 10px 24px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(360px, 1fr);
  align-items: center;
  gap: 20px;
  color: #f7faf8;
  background: var(--primary-dark);
  border-bottom: 3px solid var(--accent);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  color: #173d37;
  background: #e5b673;
  border-radius: 7px;
}

.brand-mark .icon {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}

.brand-copy {
  min-width: 0;
}

.brand-copy h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 680;
  letter-spacing: 0;
  line-height: 1.25;
}

.brand-copy p {
  margin: 1px 0 0;
  color: #a9c0ba;
  font-size: 11px;
  line-height: 1.35;
}

.topbar-context {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-self: center;
  color: #c2d3cf;
  font-size: 12px;
  white-space: nowrap;
}

.week-label {
  padding: 5px 9px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 5px;
  color: #eef5f2;
}

.connection-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  color: #d4e4df;
  border-radius: 5px;
  border: 1px solid transparent;
}

.connection-state[data-state="online"] .connection-dot {
  background: #7ed1a9;
  box-shadow: 0 0 0 3px rgba(126, 209, 169, 0.13);
}

.connection-state[data-state="connecting"] .connection-dot,
.connection-state[data-state="saving"] .connection-dot {
  background: #e5b673;
}

.connection-state[data-state="offline"] .connection-dot {
  background: #e6887e;
}

.connection-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9caaa6;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.online-people {
  display: flex;
  align-items: center;
  flex-direction: row-reverse;
  margin-right: 4px;
}

.mini-avatar,
.identity-avatar,
.activity-avatar {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  font-weight: 650;
  text-transform: uppercase;
}

.mini-avatar {
  width: 28px;
  height: 28px;
  margin-left: -7px;
  color: #1e2c29;
  background: #d7e8e2;
  border: 2px solid var(--primary-dark);
  font-size: 10px;
}

.mini-avatar.more {
  color: #dae7e3;
  background: #31554e;
}

.identity-button {
  height: 36px;
  max-width: 150px;
  padding: 0 9px 0 5px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #edf5f2;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
}

.identity-button:hover {
  background: rgba(255, 255, 255, 0.12);
}

.identity-avatar {
  width: 25px;
  height: 25px;
  color: #173d37;
  background: #c8dfd7;
  font-size: 11px;
}

.identity-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.button {
  min-height: 36px;
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.button .icon {
  width: 16px;
  height: 16px;
}

.button-primary {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

.button-primary:hover {
  background: #115d50;
  border-color: #115d50;
}

.button-light {
  color: var(--primary-dark);
  background: #f2f0e9;
  border-color: #f2f0e9;
}

.button-light:hover {
  background: #fff;
  border-color: #fff;
}

.button-ghost {
  color: var(--ink-soft);
  background: transparent;
  border-color: var(--line);
}

.button-ghost:hover {
  background: var(--surface-muted);
  border-color: var(--line-strong);
}

.button-danger,
.button-danger-ghost {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}

.button-danger-ghost {
  color: var(--danger);
  background: transparent;
  border-color: #e7c4be;
}

.button-danger-ghost:hover {
  background: var(--danger-soft);
}

.icon-button {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
}

.icon-button:hover {
  color: var(--ink);
  background: var(--surface-muted);
  border-color: var(--line);
}

.icon-button .icon {
  width: 17px;
  height: 17px;
}

.summary-band {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: #e9e6de;
  border-bottom: 1px solid var(--line);
}

.summary-item {
  position: relative;
  min-height: 86px;
  padding: 17px 24px 16px;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 12px;
  align-content: center;
  border-right: 1px solid var(--line);
}

.summary-item:last-child {
  border-right: 0;
}

.summary-item-accent::before {
  position: absolute;
  inset: 14px auto 14px 0;
  width: 3px;
  content: "";
  background: var(--accent);
}

.summary-label {
  grid-column: 1 / -1;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.04em;
}

.summary-value {
  color: var(--ink);
  font-size: 25px;
  font-weight: 680;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  line-height: 1.2;
}

.summary-item-accent .summary-value {
  color: var(--primary);
}

.summary-note {
  align-self: end;
  padding-bottom: 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.workspace {
  width: 100%;
  max-width: 1800px;
  margin: 0 auto;
  padding: 0 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 292px;
  gap: 0;
  flex: 1;
}

.ledger {
  min-width: 0;
  padding: 26px 24px 30px 0;
}

.ledger-heading,
.rail-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.section-kicker {
  margin-bottom: 3px;
  color: var(--primary);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.16em;
  line-height: 1.4;
}

.ledger-heading h2,
.rail-heading h2,
.drawer-header h2,
.join-dialog h2,
.confirm-panel h2 {
  margin: 0;
  font-size: 21px;
  font-weight: 680;
  letter-spacing: 0;
  line-height: 1.25;
}

.ledger-heading-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 2px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.sync-caption {
  padding-left: 10px;
  border-left: 1px solid var(--line-strong);
}

.sync-caption[data-state="saving"] {
  color: var(--accent);
}

.sync-caption[data-state="error"] {
  color: var(--danger);
}

.toolbar {
  margin-top: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-field {
  height: 38px;
  min-width: 220px;
  max-width: 420px;
  flex: 1;
  padding: 0 11px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.search-field:focus-within {
  border-color: var(--focus);
  box-shadow: 0 0 0 2px rgba(40, 126, 110, 0.11);
}

.search-field .icon {
  width: 16px;
  height: 16px;
}

.search-field input {
  width: 100%;
  height: 100%;
  padding: 0;
  background: transparent;
  border: 0;
  outline: 0;
}

.search-field input::placeholder {
  color: var(--muted-light);
}

.select-field select {
  height: 38px;
  min-width: 126px;
  padding: 0 30px 0 10px;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: 0;
}

.select-field select:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 2px rgba(40, 126, 110, 0.11);
}

.toolbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-actions .button {
  min-height: 38px;
}

.preset-row {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 4px;
  border-bottom: 1px solid var(--line);
}

.preset {
  height: 30px;
  padding: 0 10px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
  font-size: 12px;
}

.preset:hover {
  color: var(--ink);
  background: var(--surface-muted);
}

.preset.active {
  color: var(--primary-dark);
  background: var(--primary-soft);
  border-color: #cadfd8;
  font-weight: 620;
}

.preset-result {
  margin-left: auto;
  color: var(--muted);
  font-size: 11px;
}

.table-shell {
  position: relative;
  width: 100%;
  max-height: calc(100vh - 310px);
  min-height: 250px;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-top: 0;
  scrollbar-color: #b5b0a5 transparent;
  scrollbar-width: thin;
}

.ledger-table {
  width: 100%;
  min-width: 1524px;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.ledger-table th,
.ledger-table td {
  border-right: 1px solid #e3dfd6;
  border-bottom: 1px solid #e3dfd6;
}

.ledger-table th:last-child,
.ledger-table td:last-child {
  border-right: 0;
}

.ledger-table thead th {
  position: sticky;
  top: 0;
  z-index: 4;
  height: 42px;
  padding: 8px 9px;
  color: #53625d;
  background: #ece9e1;
  border-bottom-color: var(--line-strong);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.25;
  text-align: left;
  white-space: nowrap;
}

.required-mark {
  color: var(--accent);
  font-weight: 750;
}

.ledger-table tbody tr {
  height: 62px;
}

.ledger-table tbody tr:hover td {
  background-color: #fbfaf6;
}

.ledger-table tbody tr.is-highlighted td {
  animation: row-highlight 1.5s ease;
}

@keyframes row-highlight {
  0% {
    background: #fbe8d9;
  }
  100% {
    background: transparent;
  }
}

.ledger-table td {
  position: relative;
  padding: 5px 5px;
  vertical-align: top;
  background: var(--surface);
}

.ledger-table .sticky-column {
  position: sticky;
  left: 34px;
  z-index: 3;
  background: #f8f6f0;
  box-shadow: 1px 0 0 #d7d2c7;
}

.col-select {
  width: 34px;
}

.ledger-table .selection-cell,
.ledger-table thead .col-select {
  position: sticky;
  left: 0;
  z-index: 3;
  background: #f8f6f0;
  box-shadow: 1px 0 0 #d7d2c7;
}

.ledger-table thead .col-select {
  z-index: 7;
  background: #e5e1d8;
}

.ledger-table tbody tr:hover .selection-cell {
  background: #f4f1e9;
}

.selection-cell {
  padding: 0 !important;
  text-align: center;
  vertical-align: middle !important;
}

.row-checkbox {
  width: 14px;
  height: 14px;
  accent-color: var(--primary);
  cursor: pointer;
}

.ledger-table thead .sticky-column {
  z-index: 6;
  background: #e5e1d8;
}

.ledger-table tbody tr:hover .sticky-column {
  background: #f4f1e9;
}

.col-client {
  width: 166px;
}

.col-category {
  width: 120px;
}

.col-product {
  width: 112px;
}

.col-pipeline {
  width: 102px;
}

.col-stage {
  width: 92px;
}

.col-date {
  width: 116px;
}

.col-amount {
  width: 94px;
}

.col-progress {
  width: 104px;
}

.col-probability {
  width: 112px;
}

.col-demo {
  width: 104px;
}

.col-result {
  width: 104px;
}

.col-notes {
  width: 250px;
}

.col-actions {
  width: 52px;
}

.numeric {
  text-align: right !important;
}

.client-cell {
  padding: 8px 5px 6px 9px !important;
}

.client-cell .cell-control {
  padding: 2px 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 680;
}

.client-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 16px;
  padding-right: 2px;
  color: var(--muted-light);
  font-size: 9px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
}

.client-meta span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.editing-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex: 0 0 auto;
  color: var(--accent);
}

.editing-badge::before {
  width: 5px;
  height: 5px;
  content: "";
  border-radius: 50%;
  background: var(--accent);
}

.cell-control {
  width: 100%;
  min-height: 38px;
  padding: 6px 4px;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  outline: 0;
  line-height: 1.35;
}

textarea.cell-control {
  min-height: 46px;
  max-height: 102px;
  overflow-y: auto;
}

select.cell-control {
  padding-right: 16px;
  text-overflow: ellipsis;
}

.cell-control:hover {
  border-color: #ded9cf;
}

.cell-control:focus {
  position: relative;
  z-index: 2;
  background: #fff;
  border-color: var(--focus);
  box-shadow: 0 0 0 2px rgba(40, 126, 110, 0.1);
}

.cell-control.has-error {
  background: var(--danger-soft);
  border-color: #dc9e96;
}

.cell-control.is-saving {
  background-image: linear-gradient(90deg, transparent 55%, rgba(23, 107, 92, 0.08));
}

.cell-readonly {
  display: block;
  padding: 9px 5px;
  color: var(--ink-soft);
  line-height: 1.4;
}

.amount-readonly {
  color: var(--ink);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.progress-wrap {
  min-height: 38px;
  padding: 7px 4px 5px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.progress-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  color: var(--muted);
  font-size: 9px;
}

.progress-label strong {
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 650;
}

.progress-track {
  width: 100%;
  height: 4px;
  overflow: hidden;
  background: #e5e1d9;
  border-radius: 2px;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: inherit;
}

.probability-control {
  color: var(--primary-dark);
  font-weight: 650;
}

.row-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 7px;
}

.row-actions .icon-button {
  width: 30px;
  height: 30px;
}

.table-empty {
  position: sticky;
  left: 0;
  width: min(100%, 720px);
  min-height: 310px;
  padding: 50px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.empty-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 50%;
}

.table-empty h3 {
  margin: 14px 0 4px;
  font-size: 15px;
}

.table-empty p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.mobile-record-list {
  display: none;
}

.activity-rail {
  position: relative;
  min-width: 0;
  height: calc(100vh - 68px);
  padding: 26px 0 20px 22px;
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

.rail-heading h2 {
  font-size: 17px;
}

.rail-directory {
  min-height: 54px;
  padding: 15px 0 12px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  border-bottom: 1px solid var(--line);
}

.online-person {
  height: 26px;
  padding: 0 8px 0 5px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--ink-soft);
  background: var(--primary-soft);
  border: 1px solid #cfe2dc;
  border-radius: 13px;
  font-size: 10px;
}

.online-person .mini-avatar {
  width: 17px;
  height: 17px;
  margin: 0;
  color: var(--primary-dark);
  background: #fff;
  border: 0;
  font-size: 7px;
}

.online-empty {
  color: var(--muted);
  font-size: 11px;
}

.activity-list {
  min-height: 0;
  padding: 5px 0 10px;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
}

.activity-item {
  position: relative;
  padding: 13px 0 13px 32px;
  border-bottom: 1px solid rgba(217, 213, 203, 0.68);
}

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

.activity-avatar {
  position: absolute;
  top: 13px;
  left: 0;
  width: 23px;
  height: 23px;
  color: var(--primary-dark);
  background: #d9e7e2;
  font-size: 8px;
}

.activity-copy {
  margin: 0;
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.55;
}

.activity-copy strong {
  color: var(--ink);
  font-weight: 650;
}

.activity-detail {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.activity-time {
  display: block;
  margin-top: 4px;
  color: var(--muted-light);
  font-size: 9px;
}

.rail-footnote {
  min-height: 32px;
  padding-top: 12px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 10px;
}

.live-dot {
  width: 6px;
  height: 6px;
  background: var(--primary);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(23, 107, 92, 0.1);
}

.app-footer {
  min-height: 34px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted-light);
  border-top: 1px solid var(--line);
  font-size: 9px;
}

.footer-separator {
  width: 2px;
  height: 2px;
  background: var(--muted-light);
  border-radius: 50%;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(23, 36, 33, 0.43);
  animation: fade-in 160ms ease;
}

.record-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 31;
  width: min(590px, calc(100vw - 28px));
  display: flex;
  flex-direction: column;
  background: var(--surface);
  box-shadow: -16px 0 45px rgba(20, 33, 30, 0.18);
  transform: translateX(102%);
  visibility: hidden;
  transition: transform 190ms ease, visibility 190ms ease;
}

.record-drawer.is-open {
  transform: translateX(0);
  visibility: visible;
}

.record-drawer form {
  min-height: 0;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.drawer-header {
  min-height: 91px;
  padding: 20px 22px 17px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
}

.drawer-header h2 {
  font-size: 22px;
}

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

.drawer-close {
  margin-top: -3px;
}

.drawer-content {
  padding: 0 22px;
  overflow-y: auto;
  flex: 1;
}

.form-section {
  padding: 22px 0 23px;
  border-bottom: 1px solid var(--line);
}

.form-section:last-of-type {
  border-bottom: 0;
}

.form-section-heading {
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-index {
  color: var(--accent);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.08em;
}

.form-section-heading h3 {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 680;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field-wide {
  grid-column: 1 / -1;
}

.field > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 620;
}

.field > span b {
  color: var(--accent);
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 5px;
  outline: 0;
  line-height: 1.45;
}

.field textarea {
  min-height: 76px;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 2px rgba(40, 126, 110, 0.1);
}

.field input::placeholder,
.field textarea::placeholder {
  color: #a4aaa7;
}

.field input[readonly] {
  color: var(--muted);
  background: #f2f0e9;
}

.form-stack {
  display: grid;
  gap: 13px;
}

.record-audit {
  margin: 18px 0 8px;
  padding: 10px 12px;
  color: var(--muted);
  background: var(--surface-muted);
  border-left: 2px solid var(--line-strong);
  font-size: 10px;
  line-height: 1.55;
}

.drawer-footer {
  min-height: 66px;
  padding: 12px 22px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f7f4ed;
  border-top: 1px solid var(--line);
}

.drawer-footer .footer-spacer {
  flex: 1;
}

.import-dialog {
  width: min(920px, calc(100vw - 32px));
  max-width: 920px;
  max-height: calc(100vh - 40px);
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.import-dialog::backdrop {
  background: rgba(21, 38, 34, 0.58);
  backdrop-filter: blur(2px);
}

.import-dialog[open] {
  animation: dialog-in 170ms ease;
}

.import-dialog form {
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
}

.import-header {
  min-height: 90px;
  padding: 19px 22px 17px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
}

.import-header h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 680;
  line-height: 1.25;
}

.import-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.import-body {
  min-height: 300px;
  padding: 22px;
  overflow-y: auto;
  flex: 1;
}

.import-upload-stage {
  width: 100%;
}

.import-dropzone {
  width: 100%;
  min-height: 238px;
  padding: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--ink-soft);
  background: #faf8f2;
  border: 1px dashed var(--line-strong);
  border-radius: 7px;
}

.import-dropzone:hover,
.import-dropzone.is-dragging {
  background: #f2f7f4;
  border-color: var(--primary);
}

.import-drop-icon {
  width: 50px;
  height: 50px;
  margin-bottom: 5px;
  display: grid;
  place-items: center;
  color: var(--primary);
  background: var(--primary-soft);
  border: 1px solid #c8ddd6;
  border-radius: 7px;
}

.import-drop-icon .icon {
  width: 23px;
  height: 23px;
}

.import-dropzone strong {
  font-size: 14px;
  font-weight: 680;
}

.import-dropzone > span:last-child {
  color: var(--muted);
  font-size: 11px;
}

.import-template-row {
  min-height: 45px;
  padding: 11px 2px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 10px;
}

.text-link,
.text-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--primary);
  background: transparent;
  border: 0;
  font-size: 11px;
  font-weight: 650;
  text-decoration: none;
}

.text-link:hover,
.text-button:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

.text-link .icon {
  width: 14px;
  height: 14px;
}

.import-file-row {
  min-height: 52px;
  padding: 0 0 15px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
}

.import-file-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 6px;
}

.import-file-icon .icon {
  width: 18px;
  height: 18px;
}

.import-file-row > div {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.import-file-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.import-file-row > div span {
  color: var(--muted);
  font-size: 10px;
}

.import-summary {
  margin: 16px 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: #f5f2eb;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.import-summary > div {
  min-height: 66px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column-reverse;
  justify-content: center;
  gap: 2px;
  border-right: 1px solid var(--line);
}

.import-summary > div:last-child {
  border-right: 0;
}

.import-summary span {
  color: var(--muted);
  font-size: 9px;
}

.import-summary strong {
  color: var(--ink);
  font-size: 20px;
  font-weight: 680;
  font-variant-numeric: tabular-nums;
}

.import-summary > div:nth-child(2) strong {
  color: var(--primary);
}

.import-summary > div:nth-child(3) strong {
  color: var(--danger);
}

.import-warning {
  margin-bottom: 14px;
  padding: 9px 11px;
  display: flex;
  align-items: flex-start;
  gap: 7px;
  color: #714221;
  background: var(--accent-soft);
  border-left: 2px solid var(--accent);
  font-size: 10px;
  line-height: 1.5;
}

.import-warning .icon {
  width: 15px;
  height: 15px;
  margin-top: 1px;
}

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

.compact-field {
  width: min(340px, 100%);
}

.import-options p {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 10px;
  text-align: right;
}

.import-preview-table-wrap {
  max-height: 286px;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.import-preview-table {
  width: 100%;
  min-width: 660px;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.import-preview-table th,
.import-preview-table td {
  padding: 8px 9px;
  border-right: 1px solid #e8e4da;
  border-bottom: 1px solid #e8e4da;
  text-align: left;
  vertical-align: middle;
}

.import-preview-table th:last-child,
.import-preview-table td:last-child {
  border-right: 0;
}

.import-preview-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: #efebe3;
  font-size: 9px;
  font-weight: 680;
}

.import-preview-table td {
  color: var(--ink-soft);
  font-size: 10px;
  line-height: 1.45;
}

.import-preview-table th:nth-child(1),
.import-preview-table td:nth-child(1) {
  width: 44px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.import-preview-table th:nth-child(2),
.import-preview-table td:nth-child(2) {
  width: 150px;
}

.import-preview-table th:nth-child(3),
.import-preview-table td:nth-child(3) {
  width: 130px;
}

.import-preview-table th:nth-child(4),
.import-preview-table td:nth-child(4) {
  width: 110px;
}

.import-preview-table th:nth-child(5),
.import-preview-table td:nth-child(5) {
  width: 74px;
  text-align: right;
}

.import-preview-table th:nth-child(6),
.import-preview-table td:nth-child(6) {
  width: 200px;
}

.import-preview-table tr.row-error td {
  background: #fff8f6;
}

.import-preview-table tr.row-duplicate td {
  background: #fffbf4;
}

.import-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 9px;
  line-height: 1.45;
}

.import-status.ready {
  color: #175f51;
  background: #e0eee9;
}

.import-status.error {
  color: #8d312a;
  background: #fae7e4;
}

.import-status.duplicate {
  color: #78451e;
  background: #f5e7d7;
}

.import-status.warning {
  color: #6f4914;
  background: #f4e9c9;
}

.import-preview-note {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 9px;
  text-align: right;
}

.import-loading {
  min-height: 250px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 13px;
  color: var(--muted);
  font-size: 11px;
}

.loading-ring {
  width: 28px;
  height: 28px;
  border: 2px solid #d8e5e0;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 750ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.import-error {
  padding: 12px 13px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: #83332b;
  background: var(--danger-soft);
  border-left: 2px solid var(--danger);
  font-size: 11px;
  line-height: 1.55;
}

.import-error .icon {
  width: 16px;
  height: 16px;
  margin-top: 1px;
}

.import-footer {
  min-height: 66px;
  padding: 12px 22px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f7f4ed;
  border-top: 1px solid var(--line);
}

.import-footer .footer-spacer {
  flex: 1;
}

.join-dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.join-dialog::backdrop {
  background: rgba(21, 38, 34, 0.58);
  backdrop-filter: blur(2px);
}

.join-dialog[open] {
  animation: dialog-in 170ms ease;
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.join-dialog form {
  position: relative;
  padding: 32px;
}

.join-close {
  position: absolute;
  top: 13px;
  right: 14px;
}

.join-emblem {
  width: 44px;
  height: 44px;
  margin-bottom: 17px;
  display: grid;
  place-items: center;
  color: var(--primary-dark);
  background: #dce9e4;
  border: 1px solid #c8ddd6;
  border-radius: 7px;
}

.join-emblem .icon {
  width: 22px;
  height: 22px;
}

.join-dialog h2 {
  font-size: 25px;
}

.auth-tabs {
  margin: 0 0 18px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--line);
}

.auth-tabs button {
  position: relative;
  min-height: 36px;
  padding: 0 8px;
  color: var(--muted);
  background: transparent;
  border: 0;
  font-size: 11px;
  font-weight: 620;
}

.auth-tabs button::after {
  position: absolute;
  right: 10px;
  bottom: -1px;
  left: 10px;
  height: 2px;
  content: "";
  background: transparent;
}

.auth-tabs button.active {
  color: var(--primary-dark);
}

.auth-tabs button.active::after {
  background: var(--accent);
}

.auth-error {
  margin: 2px 0 12px;
  padding: 8px 10px;
  display: flex;
  align-items: flex-start;
  gap: 7px;
  color: #84352d;
  background: var(--danger-soft);
  border-left: 2px solid var(--danger);
  font-size: 10px;
  line-height: 1.5;
}

.auth-error .icon {
  width: 14px;
  height: 14px;
  margin-top: 1px;
}

.join-dialog form > p {
  margin: 7px 0 22px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.join-dialog form > .auth-error {
  margin: 2px 0 12px;
  color: #84352d;
  font-size: 10px;
}

.join-field {
  margin-bottom: 12px;
}

.join-submit {
  width: 100%;
  min-height: 42px;
}

.join-dialog .join-caption {
  margin: 13px 0 0;
  color: var(--muted-light);
  font-size: 9px;
  text-align: center;
}

.account-panel {
  padding: 32px;
}

.account-panel h2 {
  font-size: 25px;
}

.account-panel p {
  margin: 8px 0 22px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.account-role {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  color: var(--primary-dark);
  background: var(--primary-soft);
  border-radius: 4px;
  font-size: 9px;
  font-weight: 650;
}

.account-role.admin {
  color: #704011;
  background: var(--accent-soft);
}

.account-manage {
  width: 100%;
  min-height: 42px;
  margin-bottom: 8px;
}

.account-logout {
  width: 100%;
  min-height: 42px;
}

.admin-dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.admin-dialog::backdrop {
  background: rgba(21, 38, 34, 0.58);
  backdrop-filter: blur(2px);
}

.admin-dialog[open] {
  animation: dialog-in 170ms ease;
}

.admin-header {
  min-height: 82px;
  padding: 18px 20px 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
}

.admin-header h2 {
  margin: 0;
  font-size: 21px;
}

.admin-body {
  max-height: calc(100vh - 125px);
  padding: 0 20px;
  overflow-y: auto;
}

.admin-section {
  padding: 20px 0 22px;
  border-bottom: 1px solid var(--line);
}

.admin-section:last-child {
  border-bottom: 0;
}

.admin-create-form {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  align-items: end;
  gap: 10px;
}

.admin-create-form .button {
  min-height: 38px;
}

.admin-user-list {
  display: grid;
  gap: 6px;
}

.admin-user-row {
  min-height: 48px;
  padding: 8px 10px;
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  background: #faf8f3;
  border: 1px solid var(--line);
  border-radius: 5px;
}

.admin-user-name {
  font-size: 12px;
  font-weight: 650;
}

.admin-user-meta {
  color: var(--muted);
  font-size: 9px;
  text-align: right;
}

.admin-role-badge {
  min-height: 22px;
  padding: 0 7px;
  display: inline-flex;
  align-items: center;
  color: var(--primary-dark);
  background: var(--primary-soft);
  border-radius: 4px;
  font-size: 9px;
  font-weight: 650;
}

.admin-role-badge.admin {
  color: #704011;
  background: var(--accent-soft);
}

.toast-region {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  width: min(360px, calc(100vw - 40px));
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 11px 13px;
  color: #f6faf8;
  background: #24433d;
  border-left: 3px solid #7ed1a9;
  border-radius: 5px;
  box-shadow: 0 10px 25px rgba(19, 35, 31, 0.2);
  font-size: 12px;
  line-height: 1.5;
  animation: toast-in 170ms ease;
}

.toast.error {
  border-left-color: #ef9287;
  background: #4a2b28;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.confirm-dialog {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(24, 36, 33, 0.48);
}

.confirm-panel {
  width: min(390px, 100%);
  padding: 24px;
  background: var(--surface);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.confirm-panel h2 {
  font-size: 19px;
}

.confirm-panel p {
  margin: 8px 0 22px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

@media (max-width: 1180px) {
  .topbar {
    grid-template-columns: minmax(200px, 1fr) auto;
  }

  .topbar-context {
    display: none;
  }

  .summary-item {
    padding-right: 18px;
    padding-left: 18px;
  }

  .workspace {
    grid-template-columns: minmax(0, 1fr) 260px;
  }
}

@media (max-width: 960px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .ledger {
    padding-right: 0;
  }

  .activity-rail {
    height: auto;
    min-height: 300px;
    padding: 22px 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .activity-list {
    max-height: 340px;
  }

  .rail-directory {
    max-width: 620px;
  }

  .topbar {
    grid-template-columns: 1fr auto;
  }

  .online-people {
    display: none;
  }
}

@media (max-width: 760px) {
  .topbar {
    min-height: 64px;
    padding: 9px 14px;
    gap: 10px;
  }

  .brand-mark {
    width: 33px;
    height: 33px;
  }

  .brand-copy h1 {
    font-size: 15px;
  }

  .brand-copy p {
    display: none;
  }

  .identity-name {
    display: none;
  }

  .identity-button {
    width: 34px;
    padding: 0 3px;
    border-color: transparent;
    background: transparent;
  }

  .topbar-actions .button-light span {
    display: none;
  }

  .topbar-actions .button-light {
    width: 34px;
    padding: 0;
  }

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

  .summary-item {
    min-height: 78px;
    padding: 13px 14px;
  }

  .summary-item:nth-child(2) {
    border-right: 0;
  }

  .summary-item:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  .summary-value {
    font-size: 22px;
  }

  .summary-note {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .workspace {
    padding: 0 14px;
  }

  .ledger {
    padding-top: 20px;
    padding-bottom: 24px;
  }

  .ledger-heading {
    align-items: flex-start;
  }

  .ledger-heading-meta {
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
  }

  .sync-caption {
    padding-left: 0;
    border-left: 0;
  }

  .toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .search-field {
    grid-column: 1 / -1;
    max-width: none;
  }

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

  .toolbar-actions {
    grid-column: 1 / -1;
    width: 100%;
    margin-top: 2px;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .toolbar-actions .button {
    width: 100%;
  }

  .preset-row {
    overflow-x: auto;
    scrollbar-width: none;
  }

  .preset-row::-webkit-scrollbar {
    display: none;
  }

  .preset-result {
    display: none;
  }

  .table-shell {
    display: none;
  }

  .mobile-record-list {
    display: grid;
    gap: 9px;
    margin-top: 12px;
  }

  .mobile-record {
    padding: 14px;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: 8px;
  }

.mobile-record-head {
  display: flex;
  align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
  }

  .mobile-record h3 {
    margin: 0;
    font-size: 15px;
    line-height: 1.3;
  }

  .mobile-record-subtitle {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 10px;
  }

  .mobile-record-amount {
    color: var(--primary);
    font-size: 18px;
    font-weight: 680;
    white-space: nowrap;
  }

  .mobile-record-amount small {
    margin-left: 2px;
    color: var(--muted);
    font-size: 9px;
    font-weight: 500;
  }

  .mobile-tags {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
  }

  .mobile-tag {
    padding: 3px 6px;
    color: var(--ink-soft);
    background: #f0eee8;
    border-radius: 4px;
    font-size: 9px;
    line-height: 1.4;
  }

  .mobile-tag.primary {
    color: var(--primary-dark);
    background: var(--primary-soft);
  }

  .mobile-progress {
    margin-top: 12px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 9px;
  }

  .mobile-progress .progress-track {
    height: 5px;
  }

  .mobile-notes {
    margin: 11px 0 0;
    padding-top: 10px;
    color: var(--ink-soft);
    border-top: 1px solid #ebe7de;
    font-size: 11px;
    line-height: 1.55;
    display: -webkit-box;
    overflow: hidden;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
  }

  .mobile-record-foot {
    margin-top: 11px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: var(--muted-light);
    font-size: 9px;
  }

  .mobile-open {
    color: var(--primary);
    background: transparent;
    border: 0;
    font-size: 10px;
    font-weight: 650;
  }

  .activity-rail {
    padding-bottom: 18px;
  }

  .app-footer {
    padding: 0 14px;
  }

  .record-drawer {
    width: 100%;
    max-width: none;
  }

  .import-dialog {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
  }

  .import-dialog form {
    max-height: calc(100dvh - 16px);
  }

  .import-header {
    min-height: 82px;
    padding: 15px 16px 13px;
  }

  .import-header h2 {
    font-size: 19px;
  }

  .import-body {
    padding: 16px;
  }

  .import-dropzone {
    min-height: 205px;
    padding: 22px 16px;
  }

  .import-template-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 7px;
  }

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

  .import-summary > div:nth-child(2) {
    border-right: 0;
  }

  .import-summary > div:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  .import-options {
    align-items: stretch;
    flex-direction: column;
    gap: 7px;
  }

  .compact-field {
    width: 100%;
  }

  .import-options p {
    text-align: left;
  }

  .import-preview-table-wrap {
    max-height: 250px;
  }

  .import-footer {
    padding: 10px 14px;
  }

  .import-footer .button-primary {
    min-width: 126px;
  }

  .admin-dialog {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
  }

  .admin-header {
    min-height: 76px;
    padding: 15px 16px 13px;
  }

  .admin-body {
    max-height: calc(100dvh - 92px);
    padding: 0 16px;
  }

  .admin-create-form {
    grid-template-columns: 1fr;
  }

  .admin-user-row {
    grid-template-columns: 1fr auto;
  }

  .admin-user-meta {
    grid-column: 1 / -1;
    text-align: left;
  }

  .drawer-header {
    padding: 17px 16px 14px;
  }

  .drawer-content {
    padding: 0 16px;
  }

  .drawer-footer {
    padding: 10px 14px;
    flex-wrap: wrap;
  }

  .drawer-footer .footer-spacer {
    display: none;
  }

  .drawer-footer .button-danger-ghost {
    margin-right: auto;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .join-dialog form {
    padding: 28px 22px 24px;
  }
}

.mobile-row-checkbox {
  margin-top: 4px;
  flex: 0 0 auto;
}

@media (max-width: 420px) {
  .brand-copy h1 {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .summary-item {
    padding-right: 11px;
    padding-left: 11px;
  }

  .summary-value {
    font-size: 20px;
  }

  .drawer-footer .button {
    padding: 0 10px;
  }
}

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