:root {
  --orange: #CDA554;
  --orange-dark: #B08B3A;
  --dark: #1a1a1a;
  --gray: #6b6b6b;
  --gray-light: #f5f5f5;
  --border: #e0e0e0;
  --green: #27AE60;
  --red: #E74C3C;
  --blue: #2980B9;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--gray-light);
  color: var(--dark);
  line-height: 1.5;
}

/* ===== Navigation ===== */
.topnav {
  background: var(--dark);
  color: white;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.brand { display: flex; flex-direction: column; line-height: 1; }
.brand .logo {
  font-weight: 800;
  font-size: 22px;
  color: var(--orange);
  letter-spacing: 1px;
}
.brand .sub { font-size: 9px; color: #aaa; margin-top: 2px; }

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
}

.menu { list-style: none; display: flex; gap: 6px; align-items: center; }
.menu a {
  color: white;
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 14px;
  transition: background 0.2s;
}
.menu a:hover { background: rgba(255,255,255,0.1); }
.menu a.btn-primary {
  background: var(--orange);
  color: white;
  font-weight: 600;
}
.menu a.btn-primary:hover { background: var(--orange-dark); }

/* ===== Container ===== */
.container {
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 16px;
  scroll-margin-top: 70px;
}

/* ===== Cards & KPIs ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.kpi {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  border-left: 4px solid var(--orange);
}
.kpi .label { font-size: 12px; color: var(--gray); text-transform: uppercase; letter-spacing: 0.5px; }
.kpi .value { font-size: 28px; font-weight: 700; margin-top: 6px; color: var(--dark); }
.kpi .sub { font-size: 12px; color: var(--gray); margin-top: 4px; }

.card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  margin-bottom: 20px;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.card-header h2 { font-size: 18px; font-weight: 600; }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
th {
  background: var(--gray-light);
  font-weight: 600;
  color: var(--gray);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
tr:hover td { background: #fafafa; }
.t-right { text-align: right; }
.t-center { text-align: center; }
.muted { color: var(--gray); font-size: 12px; }

/* ===== Forms ===== */
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.field { display: flex; flex-direction: column; }
.field label {
  font-size: 12px;
  text-transform: uppercase;
  color: var(--gray);
  margin-bottom: 6px;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.field input, .field textarea, .field select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
  background: white;
  transition: border 0.2s;
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(243,156,18,0.15);
}
.field textarea { min-height: 80px; resize: vertical; }

.btn {
  display: inline-block;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s, transform 0.1s;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--orange);
  color: white;
}
.btn-primary:hover { background: var(--orange-dark); }
.btn-secondary {
  background: white;
  color: var(--dark);
  border: 1px solid var(--border);
}
.btn-danger { background: var(--red); color: white; }
.btn-small { padding: 6px 12px; font-size: 13px; }

/* ===== Flash messages ===== */
.flash {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}
.flash-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.flash-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* ===== Login ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a1a1a 0%, #2c2c2c 100%);
  padding: 20px;
}
.login-box {
  background: white;
  border-radius: 16px;
  padding: 40px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}
.login-box .brand-large {
  text-align: center;
  margin-bottom: 32px;
}
.login-box .brand-large .logo {
  font-weight: 800;
  font-size: 42px;
  color: var(--orange);
  letter-spacing: 2px;
}
.login-box .brand-large .sub {
  font-size: 11px;
  color: var(--gray);
  letter-spacing: 1px;
}
.login-box h1 {
  font-size: 20px;
  margin-bottom: 24px;
  text-align: center;
  color: var(--dark);
}

/* ===== Chart bars (simple CSS) ===== */
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 200px; padding: 16px 0; }
.bar {
  flex: 1;
  background: var(--orange);
  border-radius: 4px 4px 0 0;
  position: relative;
  min-width: 30px;
  transition: opacity 0.2s;
}
.bar:hover { opacity: 0.85; }
.bar .bar-value {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  white-space: nowrap;
  color: var(--gray);
  font-weight: 600;
}
.bar .bar-count {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 13px;
  font-weight: 700;
  color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.bar .bar-label {
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--gray);
}

/* ===== Invoice line builder ===== */
.line-row {
  display: grid;
  grid-template-columns: 1fr 140px 40px;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}
.line-row .remove-line {
  background: var(--red);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 8px;
  cursor: pointer;
}

/* ===== Mobile ===== */
@media (max-width: 768px) {
  .menu-toggle { display: block; }
  .menu {
    display: none;
    flex-direction: column;
    width: 100%;
    margin-top: 12px;
  }
  .menu.open { display: flex; }
  .menu li { width: 100%; }
  .menu a { display: block; }
  .kpi .value { font-size: 22px; }
  th, td { padding: 8px 6px; font-size: 13px; }
  .line-row { grid-template-columns: 1fr; }
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray);
}
.empty-state p { font-size: 15px; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}
.badge-ok { background: #d4edda; color: #155724; }
.badge-pending { background: #fff3cd; color: #856404; }

/* ===== Payment status toggle ===== */
.payment-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  transition: transform 0.1s, box-shadow 0.15s;
}
.payment-toggle:hover { transform: scale(1.05); box-shadow: 0 2px 6px rgba(0,0,0,0.12); }
.payment-toggle .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}
.payment-toggle.is-paid {
  background: #d4edda;
  color: #155724;
  border-color: #c3e6cb;
}
.payment-toggle.is-paid .dot { background: #27AE60; box-shadow: 0 0 0 2px #c3e6cb; }
.payment-toggle.is-unpaid {
  background: #f8d7da;
  color: #721c24;
  border-color: #f5c6cb;
}
.payment-toggle.is-unpaid .dot { background: #E74C3C; box-shadow: 0 0 0 2px #f5c6cb; }

.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.search-bar input { flex: 1; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }
