:root {
  --bg: #efe8dc;
  --paper: #fffdf8;
  --ink: #1b2420;
  --muted: #66706a;
  --line: #e4d9c8;
  --nav: #173128;
  --nav-text: #e7f0e8;
  --green: #1c7a52;
  --green-dark: #145c3d;
  --green-soft: #e7f4ec;
  --danger: #9a3b30;
  --shadow: 0 10px 30px rgba(40, 48, 42, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(900px 320px at 10% -10%, rgba(28, 122, 82, 0.08), transparent 60%),
    var(--bg);
  font: 15px/1.5 "Source Han Sans SC", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

h1 { margin: 0 0 8px; font-size: 26px; font-weight: 680; letter-spacing: 0.01em; }
h2 { margin: 0 0 14px; font-size: 16px; }

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

label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
}

input, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus {
  border-color: #8fbfa4;
  box-shadow: 0 0 0 3px rgba(28, 122, 82, 0.15);
}

button {
  border: 0;
  border-radius: 10px;
  padding: 9px 14px;
  background: transparent;
  cursor: pointer;
}

button.primary { background: var(--green); color: white; }
button.primary:hover { background: var(--green-dark); }
button.ghost { border: 1px solid var(--line); background: white; }
button.danger { color: var(--danger); padding-inline: 8px; }
button:disabled { opacity: 0.6; cursor: default; }

.hidden { display: none !important; }
.muted, .hint { color: var(--muted); font-size: 13px; }
.error { min-height: 1.2em; margin: 0 0 8px; color: var(--danger); font-size: 13px; }

.card {
  background: var(--paper);
  border: 1px solid rgba(228, 217, 200, 0.9);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.actions { display: flex; gap: 8px; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 28px 16px; }
.login-card { width: min(400px, 100%); }
.login-card h1 { margin-bottom: 8px; }
.login-card .primary { width: 100%; margin-top: 4px; }

header {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 20px;
  background: rgba(255, 253, 248, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 5;
}

header strong {
  margin-right: auto;
  font-size: 17px;
  letter-spacing: 0.04em;
}

header strong::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px var(--green-soft);
  vertical-align: 1px;
}

header button {
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  padding: 7px 12px;
}

header button:hover { border-color: #b7c9bc; background: #f7fbf8; }
#who { color: var(--muted); font-size: 13px; }

.shell { display: grid; grid-template-columns: 196px 1fr; min-height: calc(100vh - 58px); }
nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 12px;
  background: linear-gradient(180deg, #1b3830 0%, var(--nav) 40%);
}

nav button {
  text-align: left;
  color: var(--nav-text);
  padding: 11px 14px;
  border-radius: 12px;
}

nav button:hover { background: rgba(255, 255, 255, 0.06); }
nav button.active { background: var(--green); color: white; }

main { padding: 26px 28px 56px; max-width: 1180px; }
.page > .hint { margin: 0 0 16px; }

.toast {
  margin: 0 0 14px;
  padding: 10px 14px;
  border: 1px solid #b7d7c4;
  border-radius: 12px;
  background: #e5f2ea;
  color: #145c38;
}

.toast.bad { border-color: #e3c2bb; background: #f8e8e4; color: var(--danger); }

.split { display: grid; grid-template-columns: 300px 1fr; gap: 18px; align-items: start; }
.split.single { grid-template-columns: 1fr; }
td select { width: auto; min-width: 108px; }

.table-wrap {
  max-height: 520px;
  overflow: auto;
  background: white;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 14px; border-bottom: 1px solid #f0e8dc; text-align: left; vertical-align: middle; }
th {
  position: sticky;
  top: 0;
  background: #faf6ef;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.04em;
}
tbody tr:hover td { background: #fbfaf6; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.low { color: var(--danger); font-weight: 700; }
.category-list { display: grid; gap: 6px; margin-top: 14px; }
.category-list button { text-align: left; }
.row-actions button { padding: 6px 8px; border-radius: 8px; }
.row-actions button:hover { background: #f3eee6; }

.order-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 5.5rem 5.5rem auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.line-amount { text-align: right; font-variant-numeric: tabular-nums; }
.total { margin: 8px 0 4px; font-size: 20px; }
.total span { font-variant-numeric: tabular-nums; color: var(--green-dark); }

table.inner { min-width: 460px; }
table.inner td { border: 0; padding: 2px 12px 2px 0; background: transparent; }
tr.detail td { background: #f8f4ec; }

dialog {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  background: var(--paper);
  width: min(380px, calc(100% - 32px));
  box-shadow: var(--shadow);
}

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

@media (max-width: 860px) {
  header { flex-wrap: wrap; }
  header strong { width: 100%; }
  .shell { grid-template-columns: 1fr; }
  nav { flex-direction: row; overflow: auto; padding: 8px; }
  nav button { white-space: nowrap; }
  main { padding: 18px 14px 40px; }
  .split { grid-template-columns: 1fr; }
  .order-line { grid-template-columns: minmax(0, 1fr) 4.5rem auto; }
  .line-amount { display: none; }
}
