:root {
  --primary: #d9480f;
  --primary-dark: #a8380a;
  --bg: #fdf6ee;
  --card-bg: #ffffff;
  --text: #2b2119;
  --muted: #8a7a6a;
  --border: #e8dcc9;
  --success: #2f9e44;
  --danger: #c92a2a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px 60px;
}

h1 { font-size: 1.4rem; margin: 12px 0 4px; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }
.muted { color: var(--muted); font-size: 0.9rem; }

/* Nav */
.topnav {
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-weight: 700; font-size: 1.05rem; }
.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: white;
  font-size: 1.4rem;
  cursor: pointer;
}
.nav-links { display: flex; gap: 14px; align-items: center; }
.nav-links a {
  color: white;
  text-decoration: none;
  font-size: 0.92rem;
  opacity: 0.9;
}
.nav-links a:hover { opacity: 1; text-decoration: underline; }
.logout-form { margin: 0; }
.link-btn {
  background: none;
  border: none;
  color: white;
  font-size: 0.92rem;
  cursor: pointer;
  padding: 0;
  opacity: 0.9;
}
.link-btn.danger { color: var(--danger); }

@media (max-width: 640px) {
  .nav-toggle { display: block; }
  .nav-links {
    display: none;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    position: absolute;
    top: 52px;
    right: 0;
    background: var(--primary-dark);
    padding: 14px 20px;
    width: 220px;
    border-radius: 0 0 0 8px;
  }
  .nav-links.open { display: flex; }
}

/* Cards */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
}

/* Forms */
label { display: block; font-size: 0.85rem; font-weight: 600; margin: 12px 0 4px; }
input, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  background: #fffdfa;
}
input:focus, select:focus { outline: 2px solid var(--primary); border-color: var(--primary); }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 12px;
}

.btn {
  display: inline-block;
  padding: 10px 16px;
  border-radius: 8px;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #f1e6d6; color: var(--text); }
.btn-block { width: 100%; margin-top: 16px; }
.btn-sm { padding: 6px 10px; font-size: 0.85rem; }

/* Preview box */
.preview-box {
  margin-top: 16px;
  background: #f6f0e5;
  border-radius: 10px;
  padding: 12px 14px;
}
.preview-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 0.92rem;
  color: var(--muted);
}
.preview-row.total {
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 8px;
  font-size: 1.1rem;
  color: var(--text);
}
.preview-row.total strong { color: var(--primary); }

/* Alerts */
.alert {
  padding: 10px 14px;
  border-radius: 8px;
  margin: 10px 0 16px;
  font-size: 0.92rem;
}
.alert-success { background: #ebfbee; color: var(--success); border: 1px solid #b2f2bb; }
.error { color: var(--danger); font-size: 0.9rem; margin-top: 10px; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--card-bg); }
.table { width: 100%; border-collapse: collapse; font-size: 0.88rem; min-width: 560px; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th { background: #f6f0e5; font-size: 0.8rem; text-transform: uppercase; color: var(--muted); }
.row-actions { display: flex; gap: 8px; align-items: center; }

.text-positive { color: var(--success); font-weight: 600; }
.text-negative { color: var(--danger); font-weight: 600; }

/* Filter form */
.filter-form { display: flex; gap: 12px; align-items: flex-end; margin-bottom: 16px; flex-wrap: wrap; }
.filter-form label { font-size: 0.85rem; font-weight: 600; }

/* Stat cards */
.stat-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 20px; }
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-card.highlight { border-color: var(--primary); background: #fff4ea; }
.stat-label { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; }
.stat-value { font-size: 1.15rem; font-weight: 700; }

@media (max-width: 480px) {
  .stat-cards { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}

/* Login */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(160deg, #d9480f, #a8380a);
}
.login-card {
  background: white;
  padding: 32px 28px;
  border-radius: 16px;
  width: 100%;
  max-width: 340px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.login-card h1 { margin-bottom: 0; }
