:root {
  --bg: #efe6d8;
  --ink: #1c1915;
  --muted: #6f675e;
  --line: #e3d9cc;
  --card: #fffdf8;
  --accent: #b4532a;
  --accent-dark: #8c3e1d;
  --sidebar: #17211e;
  --shadow: 0 12px 30px rgba(48, 32, 16, 0.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  color: var(--ink);
  font-family: Outfit, "Segoe UI", sans-serif;
  font-size: 15.5px;
  line-height: 1.45;
}
h1, h2, .brand-mark, .grand, .stat .v {
  font-family: "Source Serif 4", Georgia, serif;
  font-weight: 700;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-dark); }

.page-app {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 240px),
    var(--bg);
  min-height: 100vh;
}
.page-login {
  background:
    radial-gradient(900px 420px at 0% 0%, rgba(180, 83, 42, 0.18), transparent 55%),
    var(--bg);
  min-height: 100vh;
}

.shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 248px;
  background: var(--sidebar);
  color: #d5ded8;
  display: flex;
  flex-direction: column;
  padding: 22px 14px 16px;
}
.brand-block { padding: 2px 10px 18px; }
.brand-mark { color: #fff; font-size: 22px; line-height: 1.15; letter-spacing: -0.03em; }
.brand-sub { color: #8ea199; font-size: 12px; margin-top: 4px; letter-spacing: 0.04em; text-transform: uppercase; }
.side-nav a {
  display: block;
  color: #d7e0da;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 10px;
  font-weight: 600;
  margin-bottom: 4px;
}
.side-nav a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.side-nav a.active { background: rgba(255, 255, 255, 0.08); color: #fff; box-shadow: inset 3px 0 0 #e08a4f; }
.side-foot { margin-top: auto; padding: 14px 12px 4px; font-size: 13px; }
.side-foot .who { color: #fff; font-weight: 700; margin-bottom: 6px; word-break: break-word; }
.side-foot a { color: #f0d2c2; text-decoration: none; font-weight: 600; }
.main { margin-left: 248px; padding: 28px 32px 64px; }

.pagehead {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin: 4px 0 18px;
}
.pagehead h1 { margin: 0; font-size: 36px; letter-spacing: -0.03em; line-height: 1; }
.pagehead .sub, .sub { margin: 6px 0 0; color: var(--muted); }
.pagehead-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px 18px 18px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 14px; }
.card h2 { margin: 0 0 12px; font-size: 22px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px 16px 14px; box-shadow: var(--shadow); }
.stat .k { margin: 0; color: var(--muted); font-size: 13px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.stat .v { margin: 8px 0 0; font-size: 30px; letter-spacing: -0.03em; line-height: 1.1; }
.stat .f { margin: 8px 0 0; color: var(--muted); font-size: 13px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 10px 14px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  font-weight: 650;
  font-weight: 600;
  cursor: pointer;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.ghost { background: #fff; border-color: #d9d0c4; }
.btn.ghost:hover { border-color: #c9bbaa; }
.btn.danger { background: #fff; border-color: #e7c1c1; color: #8d1d1d; }
.btn.small { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn.wide { width: 100%; }

.flash { padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; font-weight: 600; }
.flash.ok { background: #e5f6ec; color: #145c32; }
.flash.err, .errors { background: #fdecec; color: #8d1d1d; }
.errors { border-radius: 12px; padding: 10px 14px 10px 18px; margin-bottom: 12px; }
.errors ul { margin: 6px 0 0; padding-left: 18px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
table.data { width: 100%; border-collapse: collapse; }
table.data th {
  text-align: left;
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #faf7f2;
  white-space: nowrap;
}
table.data td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: #fffaf3; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.row-actions form { margin: 0; }

.badge { display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge.export { background: #fff3bf; color: #7a5b00; }
.badge.igst { background: #e5f3ec; color: #1d5c45; }
.badge.split { background: #e7eef5; color: #1e3a5f; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.filters input[type="search"], .filters input[type="text"], .filters input[type="month"] { width: auto; min-width: 220px; }

label.field { display: block; margin-bottom: 12px; }
label.field > span, .field-label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; }
input[type="text"], input[type="password"], input[type="date"], input[type="number"],
input[type="email"], input[type="search"], input[type="month"], input[type="file"], select, textarea {
  width: 100%;
  border: 1px solid #d9d0c4;
  background: #fff;
  border-radius: 10px;
  padding: 10px 12px;
}
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(180, 83, 42, 0.28);
  border-color: #b4532a;
}
input[readonly] { background: #f6f2eb; color: #6f675e; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.span-2 { grid-column: span 2; }
.note { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.checkline { display: flex; gap: 8px; align-items: flex-start; font-weight: 600; margin: 10px 0; }
.checkline input { width: auto; margin-top: 3px; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

.editor { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.78fr); gap: 16px; align-items: start; }
.summary { position: sticky; top: 16px; }
.choices { display: grid; gap: 8px; margin-bottom: 12px; }
.choice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
  cursor: pointer;
}
.choice input { width: auto; margin-top: 3px; }
.choice strong { display: block; }
.choice small { display: block; color: var(--muted); font-weight: 500; margin-top: 2px; }
.choice:has(input:checked) { border-color: var(--accent); background: #fff7f2; }
.rates { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sum-row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.sum-row span:last-child { font-variant-numeric: tabular-nums; font-weight: 650; font-weight: 600; }
.grand-row { border-bottom: none; align-items: baseline; padding-top: 12px; }
.grand { font-size: 30px; letter-spacing: -0.03em; }

.lines-wrap { overflow-x: auto; }
table.lines { width: 100%; border-collapse: collapse; min-width: 640px; }
table.lines th { font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; text-align: left; color: var(--muted); padding: 0 4px 6px; }
table.lines td { padding: 4px; vertical-align: middle; }
table.lines input { padding: 8px; }
.icon-x {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid #e7d0d0;
  background: #fff;
  color: #8d1d1d;
  cursor: pointer;
  font-size: 18px;
}

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(440px, 100%); }
.login-card h1 { margin: 0 0 8px; font-size: 36px; letter-spacing: -0.03em; }
.eyebrow { margin: 0 0 6px; letter-spacing: 0.12em; text-transform: uppercase; font-size: 12px; font-weight: 700; color: var(--accent); }
.login-hint { background: #fff7e8; border-radius: 10px; padding: 10px 12px; font-size: 13px; margin: 0 0 14px; }
.setup-steps { margin: 8px 0 12px; padding-left: 18px; }
.setup-error { background: #fdecec; color: #8d1d1d; border-radius: 10px; padding: 10px 12px; font-size: 13px; word-break: break-word; }
.sign-preview { display: block; max-height: 72px; max-width: 180px; background: #fff; border: 1px solid var(--line); padding: 6px; border-radius: 8px; margin-bottom: 8px; }
.empty { padding: 28px 8px; color: var(--muted); text-align: center; }
.identity { margin: -8px 0 16px; color: var(--muted); font-size: 14px; }
.month-block + .month-block { margin-top: 14px; }
.month-meta { margin: -4px 0 12px; color: var(--muted); }

@media (max-width: 1100px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .editor { grid-template-columns: 1fr; }
  .summary { position: static; }
}
@media (max-width: 760px) {
  .sidebar { position: relative; width: auto; height: auto; }
  .main { margin-left: 0; padding: 18px 16px 40px; }
  .stats, .grid-2, .rates { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .pagehead { flex-direction: column; align-items: flex-start; }
  .pagehead h1 { font-size: 30px; }
}
