:root {
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-soft: #eef4f3;
  --ink: #172026;
  --muted: #697780;
  --line: #dbe3e6;
  --brand: #1b7f79;
  --brand-dark: #115b57;
  --blue: #2769a8;
  --amber: #b36a12;
  --red: #b73535;
  --green: #267a45;
  --shadow: 0 18px 50px rgba(28, 42, 48, 0.09);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(27, 127, 121, 0.1), transparent 300px),
    var(--bg);
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

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

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.is-hidden {
  display: none !important;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 18px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-panel h1,
.topbar h1,
.section-heading h2,
.dialog-head h2 {
  margin: 0;
  letter-spacing: 0;
}

.login-panel h1,
.topbar h1 {
  font-size: clamp(28px, 4vw, 42px);
}

.app-shell {
  width: min(1360px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.topbar,
.topbar-actions,
.tabs,
.toolbar,
.section-heading,
.heading-actions,
.dialog-head,
.dialog-actions,
.summary-strip,
.card-head,
.card-actions,
.stats-row,
.money-line,
.row-actions,
.search-box,
.status-line {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.topbar-actions,
.heading-actions,
.toolbar {
  gap: 10px;
  flex-wrap: wrap;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 10;
  gap: 6px;
  padding: 8px;
  margin-bottom: 18px;
  overflow-x: auto;
  background: rgba(245, 247, 248, 0.9);
  border: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.tab,
.chip,
.ghost-button,
.primary-button,
.danger-button,
.icon-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 13px;
  color: var(--ink);
  background: var(--surface);
  white-space: nowrap;
}

.tab,
.ghost-button,
.primary-button,
.danger-button,
.icon-button,
.search-box {
  gap: 7px;
}

.tab,
.ghost-button,
.primary-button,
.danger-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tab.is-active,
.primary-button {
  color: #fff;
  border-color: var(--brand);
  background: var(--brand);
}

.tab:hover,
.ghost-button:hover {
  border-color: var(--brand);
}

.tab.is-active:hover,
.primary-button:hover {
  background: var(--brand-dark);
}

.danger-button {
  color: var(--red);
}

.danger-button:hover {
  border-color: var(--red);
}

.icon-button {
  width: 38px;
  padding: 8px;
}

i[data-lucide] {
  width: 17px;
  height: 17px;
  stroke-width: 2;
  flex: 0 0 auto;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.summary-strip {
  align-items: stretch;
  gap: 12px;
  margin-bottom: 16px;
  overflow-x: auto;
}

.metric {
  min-width: 180px;
  flex: 1;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}

.toolbar {
  justify-content: space-between;
  margin-bottom: 14px;
}

.search-box {
  flex: 1 1 320px;
  min-height: 40px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

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

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  outline: 0;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(27, 127, 121, 0.13);
}

.container-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
}

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

.card-head {
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.card-head h3 {
  margin: 0;
  font-size: 20px;
}

.card-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.card-body {
  padding: 16px;
}

.stats-row {
  align-items: stretch;
  gap: 10px;
  margin-bottom: 12px;
}

.stat {
  flex: 1;
  min-width: 0;
  padding: 10px;
  background: var(--surface-soft);
  border-radius: 8px;
}

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

.stat strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

.money-box,
.item-preview {
  display: none;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.money-box.is-open,
.item-preview.is-open {
  display: block;
}

.money-line {
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  color: var(--muted);
  font-size: 13px;
}

.money-line strong {
  color: var(--ink);
}

.card-actions {
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.status-line {
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--muted);
  background: #eef1f3;
  font-size: 12px;
  font-weight: 800;
}

.badge.green {
  color: var(--green);
  background: rgba(38, 122, 69, 0.11);
}

.badge.blue {
  color: var(--blue);
  background: rgba(39, 105, 168, 0.11);
}

.badge.amber {
  color: var(--amber);
  background: rgba(179, 106, 18, 0.12);
}

.badge.red {
  color: var(--red);
  background: rgba(183, 53, 53, 0.12);
}

.section-heading {
  justify-content: space-between;
  gap: 16px;
  margin: 22px 0 16px;
}

.section-heading h2,
.dialog-head h2 {
  font-size: 24px;
}

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

th,
td {
  padding: 12px 11px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #fff;
  background: var(--brand-dark);
}

td.num,
th.num {
  text-align: right;
}

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

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

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.wide {
  grid-column: span 2;
}

dialog {
  width: min(920px, calc(100% - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.2);
}

dialog::backdrop {
  background: rgba(13, 24, 30, 0.45);
}

.dialog-body {
  padding: 18px;
}

.dialog-head {
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.dialog-body .form-grid {
  box-shadow: none;
}

.dialog-actions {
  justify-content: flex-end;
  gap: 10px;
}

.empty-state {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.item-preview ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
}

.form-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.toast-host {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 80;
  display: grid;
  gap: 10px;
}

.toast {
  width: min(360px, calc(100vw - 32px));
  padding: 13px 14px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.toast.error {
  border-left-color: var(--red);
}

.toast.warning {
  border-left-color: var(--amber);
}

@media (max-width: 900px) {
  .topbar,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

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

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1360px);
    padding-top: 16px;
  }

  .form-grid,
  .wide {
    grid-template-columns: 1fr;
    grid-column: span 1;
  }

  .summary-strip,
  .stats-row {
    flex-direction: column;
  }

  .container-list {
    grid-template-columns: 1fr;
  }
}
