:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1d2530;
  --muted: #667085;
  --line: #d7dde6;
  --brand: #245f73;
  --brand-dark: #184454;
  --accent: #b5792d;
  --success: #247554;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.app-shell {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: #173947;
  color: #fff;
  padding: 24px 18px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 30px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #e5a64b;
  color: #1b2c34;
  font-weight: 800;
}

.brand small {
  display: block;
  color: #bbccd4;
  margin-top: 4px;
}

nav {
  display: grid;
  gap: 8px;
}

nav a {
  color: #dce8ed;
  text-decoration: none;
  padding: 11px 12px;
  border-radius: 6px;
}

nav a.active,
nav a:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.logout-form {
  margin-top: 24px;
}

.logout-form button {
  width: 100%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.logout-form button:hover {
  background: rgba(255, 255, 255, 0.2);
}

.content {
  padding: 28px;
  max-width: 1280px;
  width: 100%;
}

.page-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
}

.page-header p {
  color: var(--muted);
  margin-top: 8px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 18px;
}

.panel-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.panel-title a,
.ghost-button {
  color: var(--brand);
  text-decoration: none;
  font-weight: 700;
}

.ghost-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 14px;
  background: #fff;
}

.expense-form,
.filter-form,
.settings-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.logs-filter {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 7px;
}

label span {
  color: #344054;
  font-weight: 700;
  font-size: 14px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cbd3df;
  border-radius: 6px;
  padding: 10px 11px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

.span-2 {
  grid-column: span 2;
}

.span-3 {
  grid-column: span 3;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  align-items: end;
  gap: 10px;
}

.line-items {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  overflow: hidden;
}

.line-items-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: #f0f4f7;
}

.line-items-head,
.line-item-row {
  display: grid;
  grid-template-columns: 160px minmax(220px, 1fr) 130px minmax(180px, 0.8fr) 42px;
  gap: 10px;
  align-items: center;
}

.line-items-head {
  padding: 10px 14px;
  color: #475467;
  font-size: 13px;
  font-weight: 800;
  border-bottom: 1px solid var(--line);
}

#line-items-body {
  display: grid;
}

.line-item-row {
  padding: 10px 14px;
  border-bottom: 1px solid #e4e9f0;
}

.line-item-row:last-child {
  border-bottom: 0;
}

.icon-button {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 6px;
  background: #eef2f6;
  color: #344054;
  font-size: 20px;
  line-height: 1;
}

.icon-button:hover {
  background: #d7dde6;
  color: #1d2530;
}

.line-total {
  display: flex;
  justify-content: flex-end;
  gap: 18px;
  align-items: center;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.line-total span {
  color: var(--muted);
  font-weight: 700;
}

.line-total strong {
  font-size: 20px;
}

button,
.secondary-button {
  border: 0;
  border-radius: 6px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 800;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
}

button:hover {
  background: var(--brand-dark);
  color: #fff;
}

.danger-button {
  background: var(--danger);
  color: #fff;
}

.danger-button:hover {
  background: #8f1b13;
  color: #fff;
}

.secondary-button {
  background: #eef2f6;
  color: #344054;
}

.secondary-button:hover {
  background: #d7dde6;
  color: #1d2530;
}

.ghost-button:hover {
  background: #eef6f8;
  border-color: #b9c9d4;
  color: var(--brand-dark);
}

.link-button {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 18px;
}

.voucher-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.voucher-summary div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfe;
}

.voucher-summary span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}

.compare-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.merge-recommended {
  border-color: #a6d8bf;
}

.compact-table table {
  min-width: 620px;
}

.confirm-form {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

.metric {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
  border-radius: 8px;
  padding: 16px;
}

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

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  border-bottom: 1px solid #e4e9f0;
  padding: 11px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f0f4f7;
  color: #344054;
  font-size: 13px;
  white-space: nowrap;
}

.num {
  text-align: right;
  white-space: nowrap;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

.muted {
  color: var(--muted);
}

.tag {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 6px;
  background: #e7f2f5;
  color: var(--brand-dark);
  font-weight: 700;
}

.status-pill {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 800;
}

.status-pill.ok {
  background: #edf8f2;
  color: var(--success);
}

.status-pill.bad {
  background: #fff1f0;
  color: var(--danger);
}

.logs-table {
  min-width: 1230px;
}

.logs-table input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

.bulk-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.check-row {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  color: #344054;
  font-weight: 800;
}

.check-row input {
  width: 18px;
  height: 18px;
}

.log-summary {
  min-width: 360px;
  max-width: 520px;
  line-height: 1.55;
  font-weight: 700;
}

.tech-detail {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.tech-detail summary {
  cursor: pointer;
  color: var(--brand);
  font-weight: 700;
}

.tech-detail div {
  max-width: 360px;
  margin-top: 6px;
  word-break: break-word;
}

.table-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  padding: 6px 9px;
  border-radius: 6px;
  background: #eef6f8;
  color: var(--brand);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.table-action:hover {
  background: #dbeef3;
}

.empty-state {
  padding: 34px;
  text-align: center;
  color: var(--muted);
  background: #f8fafc;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.flash-list {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.flash {
  border-radius: 6px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  background: #fff;
}

.flash.success {
  border-color: #a6d8bf;
  background: #edf8f2;
  color: var(--success);
}

.flash.error {
  border-color: #f1aaa4;
  background: #fff1f0;
  color: var(--danger);
}

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

.login-panel {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
}

.login-brand {
  margin-bottom: 24px;
  color: var(--ink);
}

.login-brand small {
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 16px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #f0f4f7;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 8px 6px 12px;
}

.pill button {
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 50%;
  background: #d7dde6;
  color: #344054;
}

.pill button:hover {
  background: #c7d0dc;
  color: #1d2530;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  nav {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }

  .expense-form,
  .filter-form,
  .settings-form,
  .logs-filter,
  .settings-grid,
  .summary-grid,
  .voucher-summary,
  .compare-grid {
    grid-template-columns: 1fr;
  }

  .span-2,
  .span-3 {
    grid-column: span 1;
  }

  .line-items-head {
    display: none;
  }

  .line-item-row {
    grid-template-columns: 1fr;
  }

  .icon-button {
    width: 100%;
  }
}
