:root {
  --ink: #16241a;
  --palm: #0f4a1f;
  --palm-deep: #0a3315;
  --palm-light: #2f6b3c;
  --gold: #c98a2c;
  --gold-deep: #a86f1d;
  --parchment: #f6f4ec;
  --paper: #ffffff;
  --line: #dfe3d6;
  --muted: #6b7568;
  --danger: #b3412c;
  --radius: 10px;
  --font-display: 'Fraunces', serif;
  --font-body: 'Inter', -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--parchment);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  border-radius: 8px;
  padding: 10px 18px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .08s ease, box-shadow .15s ease, background .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.btn:disabled { opacity: .6; cursor: default; }
.btn-primary { background: var(--gold); color: #2b1a04; border-color: var(--gold-deep); }
.btn-primary:hover:not(:disabled) { background: var(--gold-deep); }
.btn-secondary { background: var(--paper); color: var(--palm); border-color: var(--line); }
.btn-secondary:hover { border-color: var(--palm-light); }
.btn-ghost { background: transparent; color: inherit; border-color: rgba(255,255,255,.35); }
.btn-ghost:hover { background: rgba(255,255,255,.1); }
.btn-block { width: 100%; }

/* ---------- Login screen ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: radial-gradient(circle at 20% 15%, #143d1d, var(--palm-deep) 65%);
}
.login-stripes {
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: .12;
  background-image: repeating-linear-gradient(-35deg, transparent 0 26px, #fff 26px 27px);
  pointer-events: none;
}
.login-card {
  position: relative;
  z-index: 1;
  width: min(380px, 88vw);
  background: var(--paper);
  border-radius: 16px;
  padding: 36px 32px 28px;
  box-shadow: 0 30px 60px rgba(0,0,0,.35);
  animation: rise .5s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.brand { text-align: center; margin-bottom: 26px; }
.brand-mark-img {
  width: 52px; height: 52px; margin: 0 auto 10px; display: block;
  border-radius: 12px; object-fit: contain; background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.brand-mark-img.small { width: 36px; height: 36px; border-radius: 9px; margin: 0; }
.brand h1 { font-family: var(--font-display); font-size: 24px; letter-spacing: .5px; margin: 0; color: var(--palm-deep); }
.brand-sub { font-size: 12.5px; color: var(--muted); margin: 4px 0 0; }

/* ---------- Fields ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; font-size: 13px; color: var(--muted); }
.field span { font-weight: 600; color: var(--ink); }
.field input, .field select {
  font-family: var(--font-body);
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  width: 100%;
}
.field input:focus, .field select:focus {
  outline: none; border-color: var(--palm-light);
  box-shadow: 0 0 0 3px rgba(47,107,60,.15);
}
.field-row { display: flex; gap: 8px; }
.field-row input { flex: 1; background: var(--parchment); font-family: var(--font-mono); }

.error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 8px 0 0; }

/* ---------- App screen ---------- */
.app-screen { min-height: 100vh; }
.app-header {
  background: var(--palm-deep);
  color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px;
  position: sticky; top: 0; z-index: 10;
}
.app-header-brand { display: flex; align-items: center; gap: 12px; }
.app-title { font-family: var(--font-display); font-size: 17px; line-height: 1.1; }
.app-subtitle { font-size: 11.5px; color: rgba(255,255,255,.65); }
.app-header-user { display: flex; align-items: center; gap: 14px; font-size: 13px; }

.app-main { max-width: 1040px; margin: 0 auto; padding: 28px 20px 90px; }
.grid { display: grid; grid-template-columns: 300px 1fr; gap: 20px; align-items: start; }
@media (max-width: 820px) { .grid { grid-template-columns: 1fr; } }

.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.panel-title { font-family: var(--font-display); font-size: 16px; margin: 0 0 14px; color: var(--palm-deep); }
.panel-wide { overflow: hidden; }

.table-wrap { overflow-x: auto; }
.item-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 480px; }
.item-table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); padding: 0 8px 8px; border-bottom: 2px solid var(--ink);
}
.item-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.item-table input {
  width: 100%; border: 1px solid transparent; background: transparent;
  font-family: var(--font-mono); font-size: 13px; padding: 6px 4px; border-radius: 6px;
}
.item-table input:focus { outline: none; border-color: var(--palm-light); background: #fff; }
.item-table td:first-child input { font-family: var(--font-body); }
.item-table .row-total { font-family: var(--font-mono); text-align: right; color: var(--palm-deep); font-weight: 600; white-space: nowrap; }
.item-table .row-remove { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 18px; line-height: 1; padding: 4px; }

.grand-total {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-top: 14px; padding-top: 14px; border-top: 2px solid var(--ink);
}
.grand-total span:first-child {
  font-family: var(--font-body); font-weight: 600; text-transform: uppercase;
  font-size: 12px; letter-spacing: .04em; color: var(--muted);
}
.grand-total span:last-child { font-family: var(--font-mono); font-size: 22px; font-weight: 600; color: var(--palm-deep); }

.submit-bar {
  position: sticky; bottom: 0;
  background: linear-gradient(0deg, var(--parchment) 60%, transparent);
  padding: 18px 0 4px;
  display: flex; align-items: center; justify-content: flex-end; gap: 16px;
  margin-top: 22px;
}
.submit-note { font-size: 12.5px; color: var(--danger); margin: 0; flex: 1; }

.success-panel {
  margin-top: 24px; background: #fff; border: 1px solid var(--line);
  border-left: 5px solid var(--palm); border-radius: var(--radius);
  padding: 20px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.success-icon {
  width: 38px; height: 38px; border-radius: 50%; background: var(--palm); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0;
}
.success-title { font-weight: 700; }
.success-sub { font-size: 12.5px; color: var(--muted); font-family: var(--font-mono); }

/* ---------- Dashboard ---------- */
.dashboard-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
  max-width: 720px; margin: 20px auto 0;
}
@media (max-width: 640px) { .dashboard-grid { grid-template-columns: 1fr; } }
.option-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px;
  padding: 28px 22px; text-align: left; cursor: pointer;
  font-family: var(--font-body); color: var(--ink);
  transition: transform .1s ease, box-shadow .15s ease, border-color .15s ease;
}
.option-card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(15,74,31,.12); border-color: var(--palm-light); }
.option-card:active { transform: translateY(0); }
.option-card:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.option-icon { font-size: 28px; margin-bottom: 10px; }
.option-title { font-family: var(--font-display); font-size: 18px; font-weight: 600; color: var(--palm-deep); margin-bottom: 6px; }
.option-desc { font-size: 13px; color: var(--muted); line-height: 1.5; }

.btn-back {
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.3); color: #fff;
  width: 32px; height: 32px; border-radius: 8px; font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; margin-right: 2px;
}
.btn-back:hover { background: rgba(255,255,255,.2); }

.hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; line-height: 1.4; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .two-col { grid-template-columns: 1fr; } }
.field input[type="file"] {
  padding: 8px; background: var(--parchment); cursor: pointer;
}

.notice-box {
  background: #fff8e6; border: 1px solid #e8d5a3; border-radius: 8px;
  padding: 12px 14px; font-size: 13px; color: #6b5a2a; margin-bottom: 16px; line-height: 1.5;
}

@media (prefers-reduced-motion: reduce) { .login-card { animation: none; } }

/* ---------- Stats & data tables ---------- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 22px;
}
@media (max-width: 720px) { .stats-row { grid-template-columns: 1fr 1fr; } }
.stat-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
}
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.stat-value { font-family: var(--font-mono); font-size: 20px; font-weight: 600; color: var(--palm-deep); margin-top: 4px; }

.dashboard-grid-4 {
  grid-template-columns: 1fr 1fr;
  max-width: 760px;
}
@media (max-width: 640px) { .dashboard-grid-4 { grid-template-columns: 1fr; } }

.data-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 640px; }
.data-table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); padding: 8px 10px; border-bottom: 2px solid var(--ink);
  background: var(--parchment); position: sticky; top: 0;
}
.data-table th.num, .data-table td.num { text-align: right; font-family: var(--font-mono); }
.data-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); }
.data-table tbody tr:hover { background: #fafaf5; }
.muted-cell { color: var(--muted); text-align: center; padding: 24px !important; }

.filter-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1.2fr auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}
@media (max-width: 800px) { .filter-row { grid-template-columns: 1fr 1fr; } }
.field-btn .btn { width: 100%; }

.summary-bar {
  background: var(--parchment);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  font-family: var(--font-mono);
  color: var(--palm-deep);
  margin-bottom: 14px;
}
.btn-sm { padding: 6px 12px; font-size: 12px; }
