:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;
  --ink: #172033;
  --muted: #667085;
  --line: #dce1e8;
  --bg: #f4f6fa;
  --card: #fff;
  --shadow: 0 10px 30px rgba(24, 33, 56, .08);
  --radius: 14px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.55 "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
h1,h2,h3 { margin: 0; }
p { margin: 0; }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #1f3a8a, #2563eb 55%, #60a5fa);
}
.login-card {
  width: min(430px, 100%);
  background: #fff;
  padding: 34px;
  border-radius: 22px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.login-brand { display: flex; gap: 16px; align-items: center; margin-bottom: 26px; }
.login-brand h1 { font-size: 22px; }
.login-brand p { color: var(--muted); margin-top: 5px; }
.brand-mark {
  width: 54px; height: 54px; display: grid; place-items: center;
  background: var(--primary); color: #fff; font-weight: 800; border-radius: 16px;
  letter-spacing: 1px;
}
.brand-mark.small { width: 36px; height: 36px; border-radius: 11px; font-size: 13px; }
.field { display: grid; gap: 7px; margin-bottom: 16px; }
.field > span, .filter-bar label > span { font-size: 12px; color: var(--muted); font-weight: 700; }
input, select, textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 10px;
  background: #fff;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(37,99,235,.2); border-color: var(--primary); }
.form-error { min-height: 20px; color: var(--danger); margin-top: 12px; }
.login-tip { margin-top: 16px; color: var(--muted); font-size: 12px; }

.btn {
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 9px 14px;
  min-height: 38px;
  background: #fff;
  font-weight: 700;
}
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.secondary { background: #e8f0ff; color: var(--primary-dark); }
.btn.ghost { border-color: var(--line); background: #fff; color: var(--ink); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger.ghost { background: #fff; color: var(--danger); border-color: #f3c3c3; }
.btn.small { min-height: 32px; padding: 5px 10px; font-size: 12px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.app-header {
  min-height: 66px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 26px;
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; }
.header-right { display: flex; align-items: center; gap: 10px; }
.current-user { color: var(--muted); font-size: 12px; white-space: nowrap; }
.main-nav {
  display: flex; gap: 8px; padding: 14px 26px 0;
  background: linear-gradient(#fff,#fff) no-repeat;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.nav-link {
  border: 1px solid transparent;
  border-bottom: 0;
  background: transparent;
  padding: 10px 16px;
  color: var(--muted);
  border-radius: 10px 10px 0 0;
  white-space: nowrap;
}
.nav-link.active { background: var(--bg); color: var(--primary-dark); font-weight: 800; border-color: var(--line); }
.content { padding: 24px 26px 50px; max-width: 1500px; }
.page { display: none; }
.page.active { display: block; }
.page-head {
  display: flex; justify-content: space-between; gap: 18px; align-items: flex-end;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); flex-wrap: wrap;
}
.page-head h2 { font-size: 19px; }
.page-head p { color: var(--muted); margin-top: 5px; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.range-sep { color: var(--muted); }

.filter-bar {
  display: grid; grid-template-columns: repeat(auto-fit,minmax(150px,1fr));
  gap: 12px; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin: 16px 0;
}
.filter-bar .button-col { display: flex; gap: 8px; align-items: end; }
.summary-strip { display: grid; grid-template-columns: repeat(auto-fit,minmax(150px,1fr)); gap: 12px; margin-bottom: 16px; }
.summary-card {
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 13px 15px;
}
.summary-card span { display: block; color: var(--muted); font-size: 12px; }
.summary-card strong { display: block; font-size: 20px; margin-top: 5px; }
.table-wrap {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  overflow-x: auto; box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; min-width: 900px; }
th,td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { background: #f8fafc; color: #526071; font-size: 12px; white-space: nowrap; }
tbody tr:hover { background: #fbfcff; }
tbody tr:last-child td { border-bottom: 0; }
.amount { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 34px; text-align: center; color: var(--muted); }
.status { display: inline-flex; padding: 4px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.status.pending { color: #92400e; background: #fef3c7; }
.status.approved { color: #166534; background: #dcfce7; }
.status.paid { color: #1e40af; background: #dbeafe; }
.status.rejected { color: #991b1b; background: #fee2e2; }

.kpi-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(170px,1fr)); gap:12px; margin:16px 0; }
.kpi { background:#fff; border:1px solid var(--line); border-radius:var(--radius); padding:16px; box-shadow:var(--shadow); }
.kpi span { color:var(--muted); font-size:12px; }
.kpi strong { display:block; font-size:25px; margin-top:6px; font-variant-numeric:tabular-nums; }
.kpi small { color:var(--muted); }
.dashboard-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(320px,1fr)); gap:16px; }
.panel { background:#fff; border:1px solid var(--line); border-radius:var(--radius); box-shadow:var(--shadow); overflow:hidden; }
.panel h3 { font-size:15px; padding:14px 16px; border-bottom:1px solid var(--line); background:#f8fafc; }
.panel .table-inner { max-height:360px; overflow:auto; }
.panel table { min-width:100%; }

.modal-backdrop {
  position:fixed; inset:0; background:rgba(15,23,42,.55);
  display:grid; place-items:center; padding:20px; z-index:100;
}
.modal {
  width:min(1100px,100%); max-height:92vh; overflow:auto;
  background:#fff; border-radius:18px; padding:22px; box-shadow:0 20px 80px rgba(0,0,0,.3);
}
.modal-head { display:flex; justify-content:space-between; align-items:center; margin-bottom:18px; gap:12px; }
.modal-head h3 { font-size:19px; }
.form-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); gap:14px; }
.form-grid .wide { grid-column:1/-1; }
.form-actions { display:flex; justify-content:flex-end; gap:10px; margin-top:18px; }
.alert { border-radius:10px; padding:10px 12px; margin-bottom:12px; background:#eff6ff; color:#1e40af; }
.alert.error { background:#fef2f2; color:#991b1b; }
.detail-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(160px,1fr)); gap:10px; margin-bottom:14px; }
.detail-item span { display:block; color:var(--muted); font-size:12px; }
.detail-item strong { font-weight:700; }
.items-title { font-weight:800; margin:14px 0 8px; }
.item-editor { border:1px solid var(--line); border-radius:12px; padding:14px; margin-bottom:12px; }
.item-editor-head { display:flex; justify-content:space-between; align-items:center; margin-bottom:10px; }
.item-editor-head strong { color:var(--primary-dark); }
.checkbox-row { display:flex; align-items:center; gap:8px; }
.checkbox-row input { width:auto; min-height:auto; }
.toast {
  position:fixed; right:20px; bottom:20px; z-index:200;
  background:#172033; color:#fff; padding:12px 16px; border-radius:10px; box-shadow:var(--shadow);
}
@media (max-width:760px) {
  .app-header,.main-nav,.content { padding-left:14px; padding-right:14px; }
  .header-right { flex-wrap:wrap; justify-content:flex-end; }
  .page-head { align-items:stretch; }
}
