:root {
  --bg: #f6f8fc;
  --surface: #ffffff;
  --ink: #1f1f1f;
  --muted: #5f6368;
  --line: #e0e3e8;
  --line-strong: #c4c7c5;
  --primary: #0b57d0;
  --primary-hover: #0842a0;
  --primary-soft: #d3e3fd;
  --primary-text: #041e49;
  --danger: #b3261e;
  --danger-soft: #fce8e6;
  --ok: #0c6e3d;
  --ok-soft: #c4eed0;
  --warn: #8c5000;
  --warn-soft: #feefc3;
  --info: #0842a0;
  --info-soft: #d3e3fd;
  --void: #5f6368;
  --void-soft: #e8eaed;
  --shadow: 0 1px 2px rgba(31, 31, 31, 0.06);
  --font: "Google Sans", "Roboto", "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: 0.01em;
}

a { color: var(--primary); }
button, input, select, textarea { font: inherit; }

.topbar {
  height: 64px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 0 12px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.product {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--ink);
  padding: 8px;
  border-radius: 24px;
}
.product:hover { background: #f1f3f4; }
.logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 18px;
}
.product-name { font-size: 22px; font-weight: 400; letter-spacing: 0; }
.account {
  display: flex;
  align-items: center;
  gap: 10px;
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #aecbfa;
  color: #041e49;
  display: grid;
  place-items: center;
  font-weight: 600;
}
.account-meta { display: flex; flex-direction: column; line-height: 1.2; }
.account-meta strong { font-size: 13px; font-weight: 500; }
.account-meta em { font-style: normal; font-size: 12px; color: var(--muted); }
.text-btn {
  background: none;
  border: 0;
  color: var(--primary);
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 20px;
  font-weight: 500;
}
.text-btn:hover { background: var(--primary-soft); }

.workspace { display: flex; min-height: calc(100vh - 64px); }
.rail {
  width: 256px;
  flex-shrink: 0;
  padding: 12px 0 32px;
}
.nav-label {
  margin: 18px 12px 6px 28px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}
.rail a {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 40px;
  margin: 0 12px 4px 0;
  padding: 0 16px 0 24px;
  border-radius: 0 20px 20px 0;
  text-decoration: none;
  color: #444746;
  font-size: 14px;
}
.rail a:hover { background: #e9eef6; }
.rail a.active {
  background: var(--primary-soft);
  color: var(--primary-text);
  font-weight: 500;
}
.nav-icon { width: 20px; height: 20px; display: grid; place-items: center; }
.nav-icon svg { width: 20px; height: 20px; fill: currentColor; }

.content { flex: 1; min-width: 0; padding: 24px 32px 72px; }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin: 0 0 20px;
}
.page-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

dialog.modal {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: 760px;
  width: calc(100% - 32px);
}
dialog.modal::backdrop { background: rgba(32, 33, 36, 0.46); }
.modal-card {
  background: #fff;
  border-radius: 28px;
  box-shadow: 0 1px 3px rgba(60, 64, 67, 0.3), 0 4px 8px 3px rgba(60, 64, 67, 0.15);
  max-height: 90vh;
  overflow: auto;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}
.modal-head h2 { margin: 0; font-size: 22px; font-weight: 400; }
.icon-btn {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: grid;
  place-items: center;
}
.icon-btn:hover { background: #f1f3f4; }
.icon-btn svg { width: 20px; height: 20px; fill: currentColor; }
.sheet {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px 24px 0;
}
.sheet-block {
  background: #f8f9fa;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px 16px 14px;
}
.sheet-block.money {
  background: #f3f8ff;
  border-color: #c4d7f5;
}
.sheet-block-head { margin: 0 0 12px; }
.sheet-block-head h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink);
}
.sheet-block-head p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
}
.sheet-fields {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 12px 12px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  grid-column: span 6;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  min-width: 0;
}
.field.w2 { grid-column: span 2; }
.field.w3 { grid-column: span 3; }
.field.w4 { grid-column: span 4; }
.field.w5 { grid-column: span 5; }
.field.w6 { grid-column: span 6; }
.field.w7 { grid-column: span 7; }
.field.w8 { grid-column: span 8; }
.field.wide { grid-column: span 12; }
.field.emphasis input {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  background: #fff;
  border-color: #a8c7fa;
}
.field input, .field select {
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 8px;
  padding: 8px 12px;
  height: 40px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 400;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}
.field .locked {
  display: flex;
  align-items: center;
  height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  background: #f1f3f4;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
}
.sheet-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin: 4px -24px 0;
  padding: 14px 24px 18px;
  border-top: 1px solid var(--line);
  background: #fff;
  position: sticky;
  bottom: 0;
}
.sheet-signs {
  display: grid;
  grid-template-columns: repeat(3, minmax(72px, 120px));
  gap: 16px;
  flex: 1;
  font-size: 12px;
  color: var(--muted);
}
.sheet-signs span {
  border-bottom: 1px solid var(--line);
  padding: 8px 0 6px;
}
.modal .form {
  grid-template-columns: 1fr 1fr;
  padding: 8px 24px 24px;
}
.eyebrow { display: none; }
.page-title { margin: 0; font-size: 28px; font-weight: 400; letter-spacing: 0; }
.lede { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--muted);
  margin: 0 0 8px;
  padding: 6px 8px 6px 0;
  font-size: 13px;
}
.back svg { width: 18px; height: 18px; fill: currentColor; }
.back:hover { color: var(--primary); }

.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.kpis:has(> :nth-child(2):last-child) {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: 560px;
}
.kpis:has(.kpi-rank) {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: stretch;
}
.kpi-rank ol {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}
.kpi-rank li {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto;
  gap: 6px;
  align-items: baseline;
  padding: 1px 0;
  font-size: 12px;
  line-height: 1.35;
}
.kpi-rank .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.kpi-rank .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi-rank .meta { display: none; }
.kpi-rank strong { font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px 20px;
}
.kpi .k {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.money { white-space: nowrap; }
.frac { font-size: smaller; }
.kpi .v {
  font-size: 24px;
  font-weight: 400;
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.kpi .h { margin-top: 6px; color: var(--muted); font-size: 12px; }
.kpi.neg .v { color: var(--danger); }
.kpi.ok .v { color: var(--ok); }
.kpi.muted .v { color: var(--muted); font-size: 20px; }

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 16px;
}
.split .card { margin-bottom: 0; }
.card-head { padding: 16px 20px 0; }
.card h2 {
  margin: 0;
  padding: 16px 20px 0;
  font-size: 16px;
  font-weight: 500;
}
.card-head h2 { padding: 0; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  vertical-align: middle;
}
th {
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
  background: #fff;
}
tr:last-child td { border-bottom: 0; }
tbody tr.clickable { position: relative; }
tbody tr.clickable:hover td { background: #f6f8fc; }
a.cover { position: absolute; inset: 0; z-index: 1; }
tbody tr form, tbody tr button { position: relative; z-index: 2; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.neg { color: var(--danger); }
.pos { color: var(--ok); }
.doc { color: var(--primary); font-weight: 500; font-variant-numeric: tabular-nums; }
.mono { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--muted); }

.receipts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  padding: 8px 20px 20px;
}
.receipts a {
  display: block;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  text-decoration: none;
  background: #fff;
}
.receipts a:hover { border-color: var(--primary); }
.receipts img {
  display: block;
  width: 100%;
  height: 220px;
  object-fit: contain;
  background: #f8f9fa;
}
.receipts span {
  display: block;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 12px;
}

.empty { padding: 32px 20px; color: var(--muted); }
.empty strong { display: block; color: var(--ink); margin-bottom: 6px; font-weight: 500; }
.empty p { margin: 0; }

.form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  padding: 8px 20px 20px;
}
.form label, .filters label, .login label, .void-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}
.form input, .form select, .filters input, .login input, .void-form input {
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 4px;
  padding: 10px 12px;
  color: var(--ink);
  height: 40px;
}
.form input:focus, .form select:focus, .filters input:focus, .login input:focus, .void-form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}
.form .wide { grid-column: span 2; }
.form .actions { display: flex; align-items: end; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  padding: 16px 20px 8px;
}

.btn {
  background: var(--primary);
  color: #fff;
  border: 0;
  border-radius: 20px;
  height: 40px;
  padding: 0 24px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.btn:hover { background: var(--primary-hover); }
.btn.ghost {
  background: #fff;
  color: var(--primary);
  border: 1px solid var(--line-strong);
}
.btn.ghost:hover { background: var(--primary-soft); border-color: transparent; }
.btn.small { height: 32px; padding: 0 16px; font-size: 13px; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger.ghost { background: #fff; color: var(--danger); border-color: #f2b8b5; }
.btn.danger.ghost:hover { background: var(--danger-soft); }

.flash {
  margin: 0 0 16px;
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--danger-soft);
  color: var(--danger);
}
.flash.ok { background: var(--ok-soft); color: var(--ok); }

.tag {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  background: var(--primary-soft);
  color: var(--primary-text);
}
.tag.wait { background: var(--warn-soft); color: var(--warn); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.info { background: var(--info-soft); color: var(--info); }
.tag.void { background: var(--void-soft); color: var(--void); }
.tag.transit { background: #e8f0fe; color: #1967d2; }
.tag.inbound { background: #e8f0fe; color: #1967d2; }
.tag.outbound { background: var(--ok-soft); color: var(--ok); }
.tag.expense { background: var(--warn-soft); color: var(--warn); }
.tag.reimbursement { background: #f3e8fd; color: #7627bb; }

.tabs {
  display: flex;
  gap: 8px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
}
.tabs a {
  text-decoration: none;
  padding: 14px 12px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-weight: 500;
}
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }

.bar {
  height: 4px;
  background: #e8eaed;
  border-radius: 99px;
  margin-top: 8px;
  overflow: hidden;
}
.bar span { display: block; height: 100%; background: var(--primary); border-radius: 99px; }

.notices { list-style: none; margin: 0; padding: 4px 0 8px; }
.notices li {
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.notices li:last-child { border-bottom: 0; }
.notices strong { font-size: 14px; font-weight: 500; }
.notices span { color: var(--muted); font-size: 13px; }
.notices .warn strong { color: var(--warn); }
.notices .todo strong { color: var(--primary); }

.stats { margin: 0; padding: 4px 0 8px; }
.stats > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
}
.stats > div:last-child { border-bottom: 0; }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; font-variant-numeric: tabular-nums; }

.steps {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 0 0 16px;
  padding: 0;
}
.steps li {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.steps span { color: var(--muted); font-size: 12px; }
.steps strong { font-size: 22px; font-weight: 400; font-variant-numeric: tabular-nums; }
.steps .active { background: #f3f8ff; border-color: #a8c7fa; }
.steps .done { background: #f6fef9; border-color: #addeb4; }

.hint, .formula {
  padding: 0 20px 16px;
  color: var(--muted);
  font-size: 13px;
}
.meta {
  margin: 0;
  padding: 4px 0 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.meta > div {
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
}
.meta dt { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.meta dd { margin: 0; font-size: 14px; }
.entries td:first-child { color: var(--muted); width: 64px; }
.void-form {
  display: flex;
  gap: 12px;
  align-items: end;
  padding: 0 20px 20px;
}
.void-form label { flex: 1; }

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--bg);
}
.login {
  width: min(400px, calc(100% - 32px));
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 36px 40px 40px;
  box-shadow: var(--shadow);
}
.login-mark { margin-bottom: 16px; }
.login h1 { margin: 0 0 4px; font-size: 32px; font-weight: 400; }
.login p { margin: 0 0 24px; color: var(--muted); }
.login label { margin-bottom: 16px; }
.login input { width: 100%; }
.login .btn { width: 100%; margin-top: 8px; }

@media (max-width: 1100px) {
  .kpis, .kpis:has(.kpi-rank), .split, .steps, .meta { grid-template-columns: 1fr 1fr; }
  .kpi-rank { grid-column: 1 / -1; }
}
@media (max-width: 860px) {
  .workspace { display: block; }
  .rail { width: auto; padding-bottom: 8px; }
  .rail a { border-radius: 20px; margin: 0 8px 4px; }
  .kpis, .kpis:has(.kpi-rank), .split, .steps, .form, .meta { grid-template-columns: 1fr; }
  .kpi-rank { grid-column: 1 / -1; }
  .sheet-fields { grid-template-columns: 1fr 1fr; }
  .field, .field.w2, .field.w3, .field.w4, .field.w5, .field.w6, .field.w7, .field.w8 { grid-column: span 1; }
  .field.wide { grid-column: span 2; }
  .sheet-foot { flex-direction: column; align-items: stretch; }
  .sheet-signs { grid-template-columns: 1fr; }
  .content { padding: 16px 16px 48px; }
  .topbar { padding: 0 8px; }
  .product-name { font-size: 18px; }
}
