:root {
  --ink: #17211b;
  --muted: #66736b;
  --paper: #f4f1ea;
  --card: #fffefa;
  --line: #ded9ce;
  --wine: #6e1834;
  --wine-dark: #4b1023;
  --gold: #bd8b42;
  --green: #22705b;
  --red: #a52936;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at top right, #efe5da 0, transparent 32rem), var(--paper); }
a { color: var(--wine); text-decoration: none; }
a:hover { text-decoration: underline; }
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 28px 20px; background: #23191c; color: #f6eee8; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; font-weight: 750; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--wine); color: white; font-family: Georgia, serif; font-size: 20px; }
.nav-group { margin: 20px 0 8px; color: #aa989e; font-size: 12px; letter-spacing: .12em; }
.nav a { display: block; margin: 3px 0; padding: 9px 12px; border-radius: 8px; color: #e8dde0; }
.nav a:hover, .nav a.active { background: #402a31; text-decoration: none; color: white; }
.sidebar-user { margin-top: 28px; padding-top: 18px; border-top: 1px solid #4a373d; font-size: 13px; color: #cbbec2; }
.sidebar-user strong { display: block; color: white; margin-bottom: 4px; }
.link-button { padding: 0; border: 0; background: none; color: #dbbfc8; cursor: pointer; }
.main { min-width: 0; padding: 34px clamp(20px, 4vw, 58px) 64px; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-head h1 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: clamp(26px, 3vw, 38px); font-weight: 600; }
.eyebrow { margin: 0 0 5px; color: var(--wine); text-transform: uppercase; letter-spacing: .12em; font-size: 12px; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { padding: 22px; border: 1px solid var(--line); border-radius: 14px; background: color-mix(in srgb, var(--card) 96%, transparent); box-shadow: 0 8px 24px rgba(47, 32, 22, .05); }
.card h2, .card h3 { margin-top: 0; }
.metric { font-size: 29px; font-weight: 750; font-variant-numeric: tabular-nums; }
.metric-label { color: var(--muted); font-size: 13px; }
.metric-accent { color: var(--wine); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.button, button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 9px 15px; border: 1px solid var(--wine); border-radius: 8px; background: var(--wine); color: white; font: inherit; font-weight: 650; cursor: pointer; }
.button:hover { color: white; background: var(--wine-dark); text-decoration: none; }
.button.secondary, button.secondary { border-color: var(--line); background: var(--card); color: var(--ink); }
.button.danger, button.danger { border-color: var(--red); background: var(--red); }
.button.small-button, button.small-button { min-height: 32px; padding: 5px 10px; font-size: 13px; }
label { display: grid; gap: 6px; font-size: 13px; font-weight: 650; color: #3d4942; }
input, select, textarea { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid #cfc9be; border-radius: 8px; background: white; color: var(--ink); font: inherit; }
textarea { min-height: 92px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(110, 24, 52, .12); border-color: var(--wine); }
.field-span-2 { grid-column: span 2; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { padding: 11px 13px; background: #eee9df; text-align: left; white-space: nowrap; color: #4b554f; }
td { padding: 12px 13px; border-top: 1px solid #e7e2d8; vertical-align: top; }
td.number, th.number { text-align: right; font-variant-numeric: tabular-nums; }
.badge { display: inline-flex; padding: 4px 8px; border-radius: 999px; background: #ece7dc; color: #4b554f; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge.good { background: #dcece5; color: #1b624e; }
.badge.warn { background: #f5e6c8; color: #7d571a; }
.badge.bad { background: #f5dadd; color: #8c2430; }
.flash { margin-bottom: 18px; padding: 13px 16px; border-radius: 9px; background: #dcece5; color: #165743; }
.flash.error { background: #f5dadd; color: #8c2430; }
.line-item { display: grid; grid-template-columns: minmax(190px, 2fr) 100px 110px 130px 120px 100px 40px; gap: 9px; align-items: end; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.line-total { padding: 11px 0; text-align: right; font-weight: 700; white-space: nowrap; }
.remove-line { width: 36px; min-height: 36px; padding: 0; border-color: #c9c1b5; background: transparent; color: var(--red); }
.totals { margin-left: auto; width: min(100%, 360px); display: grid; grid-template-columns: 1fr auto; gap: 9px 20px; padding-top: 18px; }
.totals strong { color: var(--wine); font-size: 20px; }
.empty { padding: 42px 20px; text-align: center; color: var(--muted); }
.login-body { display: grid; min-height: 100vh; place-items: center; padding: 20px; }
.login-card { width: min(100%, 430px); padding: 38px; border-radius: 20px; background: rgba(255, 254, 250, .96); box-shadow: 0 24px 80px rgba(50, 24, 33, .16); border: 1px solid var(--line); }
.login-card h1 { margin-bottom: 5px; font-family: Georgia, "Songti SC", serif; }
.login-card form { display: grid; gap: 17px; margin-top: 28px; }
.detail-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; }
.detail-list dt { color: var(--muted); font-size: 12px; }
.detail-list dd { margin: 4px 0 0; font-weight: 650; }
.danger-zone { margin-top: 24px; padding: 18px; border: 1px dashed #cf9299; border-radius: 10px; }
@media (max-width: 1050px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .line-item { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 760px) {
  .shell { display: block; }
  .sidebar { position: static; width: auto; height: auto; padding: 18px; overflow: hidden; }
  .nav { display: flex; overflow-x: auto; gap: 5px; }
  .nav { scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav-group, .sidebar-user { display: none; }
  .nav a { white-space: nowrap; }
  .main { padding: 24px 15px 50px; }
  .grid-2, .grid-3, .grid-4, .detail-list { grid-template-columns: 1fr; }
  .field-span-2 { grid-column: auto; }
  .page-head { align-items: start; flex-direction: column; }
  .page-head > .toolbar { width: 100%; }
  .page-head > .toolbar > .button { flex: 1 1 105px; }
  .line-item { grid-template-columns: 1fr 1fr; }
}
