:root {
  --ink: #0f1c2e;
  --muted: #5a6a7e;
  --line: #d5dde8;
  --bg: #eef1f6;
  --surface: #fff;
  --accent: #1b4f8a;
  --accent-2: #0d7a5f;
  --danger: #9b1c1c;
  --warn-bg: #fff8e8;
  --err-bg: #fdecec;
  --ok-bg: #e7f6ef;
  --shadow: 0 1px 2px rgba(15, 28, 46, 0.06), 0 10px 28px rgba(15, 28, 46, 0.06);
  --font: "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--ink); line-height: 1.45; font-size: 14.5px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.header {
  background: var(--ink); color: #f4f6fa; padding: 12px 18px;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  border-bottom: 3px solid var(--accent-2);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; flex-direction: column; min-width: 140px; }
.brand strong { font-size: 16px; letter-spacing: 0.02em; }
.brand span { font-size: 11px; opacity: 0.7; }
.header-actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pill { font-size: 11.5px; border: 1px solid rgba(255,255,255,0.2); border-radius: 999px; padding: 3px 10px; opacity: 0.85; }
.layout { display: grid; grid-template-columns: 240px 1fr; min-height: calc(100vh - 58px); }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); padding: 12px; overflow-y: auto; }
.sidebar h2 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin: 10px 6px 8px; }
.inv-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.inv-list button {
  width: 100%; text-align: left; border: 1px solid transparent; background: transparent;
  border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px;
}
.inv-list button:hover { background: #f4f6fa; border-color: var(--line); }
.inv-list button.active { background: #e8f0fa; border-color: #b8cce6; }
.inv-list .n { font-weight: 650; font-size: 13px; }
.inv-list .m { font-size: 11.5px; color: var(--muted); }
.main { padding: 18px 20px 48px; overflow-x: auto; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 14px;
}
.card h3 { margin: 0 0 12px; font-size: 15px; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; }
.hint { color: var(--muted); font-size: 13px; margin: -4px 0 12px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 11.5px; font-weight: 650; color: var(--muted); }
.field input, .field select, .field textarea {
  border: 1px solid #b8c2d1; border-radius: 7px; padding: 7px 9px; background: #fff; min-height: 36px;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid rgba(27, 79, 138, 0.28); border-color: var(--accent);
}
.field.full { grid-column: 1 / -1; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 8px; padding: 7px 12px; border: 1px solid transparent;
  font-weight: 650; font-size: 13px; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #163f6e; }
.btn-green { background: var(--accent-2); color: #fff; }
.btn-green:hover { background: #0a634d; }
.btn-ghost { background: #fff; border-color: #b8c2d1; }
.btn-ghost:hover { background: #f4f6fa; }
.btn-danger { background: var(--err-bg); color: var(--danger); border-color: #f0c0c0; }
.btn-sm { padding: 5px 9px; font-size: 12px; border-radius: 6px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table.data { width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 1100px; }
table.data th, table.data td { padding: 6px 7px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data th {
  background: #f4f6fa; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); text-align: left; white-space: nowrap; position: sticky; top: 0;
}
table.data input, table.data select {
  width: 100%; border: 1px solid transparent; background: transparent; padding: 4px 5px; border-radius: 4px; min-width: 0;
}
table.data input:hover, table.data select:hover { border-color: var(--line); background: #fff; }
table.data input:focus, table.data select:focus { outline: none; border-color: var(--accent); background: #fff; }
table.data .money { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 12px; }
table.data tfoot td { font-weight: 700; background: #f4f6fa; }
.alert { border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; font-size: 13px; }
.alert ul { margin: 6px 0 0; padding-left: 1.2em; }
.alert-error { background: var(--err-bg); color: var(--danger); border: 1px solid #f0c0c0; }
.alert-warn { background: var(--warn-bg); color: #7a5a00; border: 1px solid #f0dca0; }
.alert-ok { background: var(--ok-bg); color: #0d5c42; border: 1px solid #b7dfc9; }
.empty {
  max-width: 620px; margin: 40px auto; background: var(--surface); border-radius: 12px;
  border: 1px solid var(--line); box-shadow: var(--shadow); padding: 32px 36px;
}
.empty h1 { margin: 0 0 10px; font-size: 24px; letter-spacing: -0.02em; }
.empty p { color: var(--muted); }
.toast {
  position: fixed; bottom: 18px; right: 18px; background: var(--ink); color: #fff;
  padding: 10px 14px; border-radius: 8px; z-index: 50; font-size: 13px;
}
.preview {
  font-family: var(--mono); font-size: 11.5px; background: #0f1c2e; color: #d7e2f0;
  padding: 12px; border-radius: 8px; overflow-x: auto; white-space: pre; max-height: 220px;
}
.footer-note { font-size: 12px; color: var(--muted); margin-top: 20px; max-width: 720px; line-height: 1.5; }
@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { max-height: 180px; border-right: none; border-bottom: 1px solid var(--line); }
  .pill { display: none; }
}
