:root {
  --navy: #1F2A44;
  --navy-light: #2E3D63;
  --orange: #D97B3F;
  --orange-dark: #B8622B;
  --cream: #F5F0E6;
  --cream-dark: #EDE4D3;
  --ink: #2B2B2B;
  --muted: #6B7280;
  --border: #E1DACB;
  --green: #2F8F5B;
  --red: #C0433D;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Georgia", "Cambria", serif;
  background: var(--cream);
  color: var(--ink);
}

h1, h2, h3, .panel-title, .brand-title, .login-company {
  font-family: "Cambria", "Georgia", serif;
}

.hidden { display: none !important; }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--navy) 0%, var(--navy-light) 100%);
  padding: 20px;
}
.login-card {
  background: var(--cream);
  border-radius: var(--radius);
  padding: 32px 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.35);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.login-mark {
  background: var(--orange);
  color: white;
  font-weight: bold;
  width: 44px; height: 44px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.login-company { font-size: 13px; color: var(--muted); }
.login-app { font-size: 18px; font-weight: bold; color: var(--navy); }
#login-form label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin: 12px 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
#login-form input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: white;
}
.login-error { color: var(--red); font-size: 13px; margin-top: 10px; min-height: 18px; }
.login-hint { font-size: 11px; color: var(--muted); margin-top: 16px; text-align: center; }

/* ---------- Buttons ---------- */
.btn {
  font-family: inherit;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s ease;
}
.btn:hover { opacity: 0.88; }
.btn-primary { background: var(--orange); color: white; }
.btn-secondary { background: var(--navy); color: white; }
.btn-ghost { background: transparent; color: white; border: 1px solid rgba(255,255,255,0.4); }
.btn-block { width: 100%; margin-top: 20px; }
.btn-danger-outline { background: transparent; border: 1px solid var(--red); color: var(--red); padding: 5px 10px; font-size: 12px; }
.btn-small { padding: 5px 10px; font-size: 12px; }

/* ---------- App shell ---------- */
.app { min-height: 100vh; }
.topbar {
  background: var(--navy);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.topbar-brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  background: var(--orange);
  color: white;
  font-weight: bold;
  width: 38px; height: 38px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
}
.brand-title { font-size: 17px; font-weight: bold; }
.brand-sub { font-size: 11px; color: #C7CEDB; }
.topbar-controls { display: flex; align-items: center; gap: 10px; }
.topbar-controls select {
  font-family: inherit;
  padding: 8px 10px;
  border-radius: 6px;
  border: none;
  background: white;
  color: var(--ink);
}

.tabs {
  background: var(--navy-light);
  display: flex;
  gap: 2px;
  padding: 0 20px;
  overflow-x: auto;
}
.tab-btn {
  background: transparent;
  border: none;
  color: #D6DBE8;
  padding: 12px 18px;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}
.tab-btn.active {
  color: white;
  border-bottom: 3px solid var(--orange);
  font-weight: bold;
}

.content { padding: 24px; max-width: 1200px; margin: 0 auto; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Cards / panels ---------- */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.summary-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  border-top: 4px solid var(--orange);
}
.summary-card.variance-negative { border-top-color: var(--red); }
.summary-card.variance-positive { border-top-color: var(--green); }
.summary-card-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.summary-card-value { font-size: 24px; font-weight: bold; color: var(--navy); margin-top: 6px; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }

.panel {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 20px;
}
.panel-title { font-size: 15px; font-weight: bold; color: var(--navy); margin-bottom: 14px; }
.panel-title-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.panel-title-row .panel-title { margin-bottom: 0; }

/* ---------- Tables ---------- */
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table thead th {
  background: var(--cream-dark);
  color: var(--navy);
  text-align: left;
  padding: 10px 12px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 2px solid var(--border);
}
.data-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.data-table tfoot td {
  padding: 10px 12px;
  font-weight: bold;
  background: var(--cream-dark);
  color: var(--navy);
}
.data-table input[type="number"] {
  width: 130px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: inherit;
}
.num { text-align: right; font-variant-numeric: tabular-nums; }
.text-red { color: var(--red); font-weight: bold; }
.text-green { color: var(--green); font-weight: bold; }

/* ---------- Forms ---------- */
.expense-form {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  align-items: end;
}
.expense-form .field-wide { grid-column: span 2; }
.field label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.field input, .field select {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
}
.expense-form button { grid-column: span 1; height: 40px; }
@media (max-width: 760px) {
  .expense-form { grid-template-columns: 1fr 1fr; }
  .expense-form .field-wide { grid-column: span 2; }
}

.category-form { display: flex; gap: 10px; }
.cat-icon-input { width: 60px; text-align: center; padding: 9px; border: 1px solid var(--border); border-radius: 6px; font-family: inherit; }
.category-form input[type="text"]:not(.cat-icon-input) {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
}

.save-status { margin-left: 12px; font-size: 13px; color: var(--green); }
