/* ── TOKENS ── */
:root {
  --bg:      #f7f5f1;
  --card:    #ffffff;
  --border:  #e8e6e2;
  --text:    #14120e;
  --muted:   #a09e9a;
  --accent:  #c0392b;
  --sidebar: #212121;
  --sidebar-text: #f7f5f1;
  --shadow:  0 2px 12px rgba(0,0,0,.07);
  --radius:  10px;
}

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

body {
  font-family: 'Jost', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── LOGIN ── */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}

.login-logo {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--text);
  margin-bottom: 4px;
}

.login-sub {
  font-size: .75rem;
  color: var(--muted);
  margin-bottom: 28px;
}

.login-error {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #dc2626;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: .8rem;
  margin-bottom: 14px;
}

.login-link {
  font-size: .78rem;
  color: var(--muted);
  text-align: center;
  margin-top: 14px;
  cursor: default;
}
.login-link span {
  color: var(--accent);
  cursor: pointer;
  font-weight: 500;
}

/* ── LAYOUT ── */
#app-screen {
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ── */
.sidebar {
  width: 230px;
  min-height: 100vh;
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 30;
  transition: transform .25s ease;
}

.sidebar-logo {
  font-size: .85rem;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--sidebar-text);
  padding: 24px 20px 20px;
  line-height: 1.3;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 15px 20px;
  background: none;
  border: none;
  color: rgba(247,245,241,.55);
  font-family: 'Jost', sans-serif;
  font-size: .8rem;
  font-weight: 500;
  letter-spacing: .03em;
  cursor: pointer;
  text-align: left;
  transition: background .15s, color .15s;
}

.nav-item:hover { background: rgba(255,255,255,.06); color: var(--sidebar-text); }
.nav-item.active { background: rgba(255,255,255,.1); color: var(--sidebar-text); }
.nav-icon { font-size: .85rem; width: 16px; text-align: center; }

.logout-btn {
  margin-top: auto;
  margin-bottom: 16px;
  color: rgba(247,245,241,.4);
}
.logout-btn:hover { color: #ef4444; background: rgba(239,68,68,.08); }

/* ── MAIN ── */
.main-wrap {
  margin-left: 230px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: 52px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-left { display: flex; align-items: center; gap: 12px; }

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--text);
}

.topbar-title {
  font-size: .92rem;
  font-weight: 600;
  letter-spacing: .02em;
}

.topbar-user {
  font-size: .72rem;
  color: var(--muted);
  font-weight: 500;
}

.content {
  flex: 1;
  padding: 28px 40px 40px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* ── PAGE HEADER ── */
.page-header { margin-bottom: 22px; }
.page-header h2 { font-size: 1.15rem; font-weight: 700; }
.page-header p  { font-size: .78rem; color: var(--muted); margin-top: 3px; }
.page-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
}

/* ── CARDS ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.stat-card .label {
  font-size: .68rem;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.stat-card .value {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}

.stat-card .value.accent { color: var(--accent); }
.stat-card .value.green  { color: #16a34a; }

/* ── PROFIT ROW ── */
.profit-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

/* ── TABLE ── */
.table-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table-card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .8rem;
  font-weight: 600;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  font-size: .68rem;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 10px 20px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 11px 20px;
  font-size: .82rem;
  border-bottom: 1px solid var(--border);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #faf9f6; }

/* ── BADGES ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .03em;
}

.badge-green  { background: #dcfce7; color: #16a34a; }
.badge-yellow { background: #fef9c3; color: #ca8a04; }
.badge-red    { background: #fee2e2; color: #dc2626; }
.badge-blue   { background: #dbeafe; color: #2563eb; }
.badge-gray   { background: #f1f0ec; color: var(--muted); }

/* ── FORMS ── */
.form-field {
  margin-bottom: 14px;
}

.form-field label {
  display: block;
  font-size: .72rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-bottom: 5px;
}

input[type=text], input[type=email], input[type=password],
input[type=number], input[type=date], select, textarea {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  font-family: 'Jost', sans-serif;
  font-size: .85rem;
  color: var(--text);
  transition: border-color .15s;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: #aaa;
}

textarea { resize: vertical; min-height: 80px; }

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

/* ── BUTTONS ── */
.btn-primary, .btn-secondary, .btn-danger, .btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 7px;
  font-family: 'Jost', sans-serif;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity .15s, background .15s;
}

.btn-primary   { background: var(--text); color: #fff; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-danger    { background: #fee2e2; color: #dc2626; }
.btn-ghost     { background: transparent; color: var(--muted); }
.btn-primary:hover   { opacity: .85; }
.btn-secondary:hover { background: #eeece8; }
.btn-danger:hover    { background: #fecaca; }

.btn-primary.full, .btn-secondary.full { width: 100%; justify-content: center; }
.btn-sm { padding: 5px 12px; font-size: .76rem; }

button:disabled { opacity: .5; cursor: not-allowed; }

/* ── BUDGET PAGE ── */
.budget-grid {
  display: grid;
  grid-template-columns: 20cm 360px;
  gap: 0 0.5cm;
  align-items: start;
}

.category-block {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  margin-bottom: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.08);
  overflow: hidden;
}

.cat-header {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.cat-header-left { display: flex; align-items: center; gap: 8px; }
.cat-name { font-size: .8rem; font-weight: 700; letter-spacing: .03em; }
.cat-arrow { font-size: .7rem; color: var(--muted); transition: transform .2s; }
.cat-open .cat-arrow { transform: rotate(180deg); }

.svc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
}
.svc-row:last-child { border-bottom: none; }

.svc-name { font-size: .83rem; }
.svc-price { font-size: .76rem; color: var(--muted); margin-top: 2px; }

.svc-right { display: flex; align-items: center; gap: 10px; }

.qty-ctrl { display: flex; align-items: center; gap: 6px; }
.qty-btn {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem;
  line-height: 1;
  color: var(--text);
  transition: background .15s;
}
.qty-btn:hover { background: #eeece8; }
.qty-display { font-size: .85rem; font-weight: 600; min-width: 20px; text-align: center; }

/* Summary box */
.summary-box {
  background: var(--card);
  border-radius: 1.25rem;
  box-shadow: 0 8px 30px rgba(0,0,0,0.08);
  overflow: hidden;
  position: sticky;
  top: 72px;
}

.summary-card-header {
  padding: 1rem 1.5rem 0.875rem;
  background: #faf9f6;
}
.summary-card-header h2 {
  font-size: .92rem;
  font-weight: 700;
  color: #1a1a1a;
}

.summary-divider { height: 1px; background: #d0cec9; }

.summary-items { padding: 1.1rem 1.5rem; min-height: 60px; display: flex; flex-direction: column; gap: 0.5rem; }

.sum-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .83rem;
}
.sum-item-name { color: #797979; }
.sum-item-total { font-weight: 700; color: #1a1a1a; }

.sum-empty { font-size: .82rem; color: var(--muted); text-align: center; padding: 10px 0; }

.summary-controls { padding: 1.1rem 1.5rem; display: flex; flex-direction: column; gap: .75rem; }

.summary-control-row { display: flex; justify-content: space-between; align-items: center; }
.summary-control-label { font-weight: 600; color: #797979; font-size: .83rem; }

.pct-stepper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pct-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .85rem;
  line-height: 1;
  color: var(--text);
  font-family: 'Jost', sans-serif;
  transition: background .15s;
}
.pct-btn:hover { background: #eeece8; }

.pct-value {
  font-size: .82rem;
  font-weight: 400;
  color: #1a1a1a;
  min-width: 28px;
  text-align: center;
}

.summary-totals { background: #212121; padding: 1.1rem 1.5rem; }

.dark-subtotal-row {
  display: flex;
  justify-content: space-between;
  font-size: .83rem;
  color: #797979;
  margin-bottom: .4rem;
}

.dark-divider { height: 1px; background: #797979; margin: .5rem 0; }

.dark-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.dark-total-row span {
  color: #f0f0f0;
  font-size: 1.05rem;
  font-weight: 700;
}

.btn-pdf-main {
  display: block;
  width: 100%;
  padding: 1.1rem;
  margin-top: 2px;
  background: #f45830;
  color: #fff;
  border: none;
  font-family: 'Jost', sans-serif;
  font-size: .82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .2em;
  cursor: pointer;
  transition: opacity .2s;
}
.btn-pdf-main:hover { opacity: .88; }

/* Category count badge */
.cat-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 0.45cm;
  height: 0.45cm;
  background: #e2633f;
  border-radius: 50%;
  color: #fff;
  font-size: 6pt;
  font-weight: 700;
  margin-left: 0.04cm;
  line-height: 1;
}

/* ── SERVICES EDIT ── */
.svc-edit-row {
  display: grid;
  grid-template-columns: 2fr 1.2fr 1fr 0.8fr 80px 36px;
  gap: 8px;
  align-items: center;
  padding: 8px 18px;
  border-bottom: 1px solid var(--border);
}
.svc-edit-row:last-child { border-bottom: none; }
.svc-edit-row:hover { background: #faf9f6; }

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal {
  background: var(--card);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .9rem;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  color: var(--muted);
  padding: 0;
}

.modal-body { padding: 20px; }

/* ── BUDGET STATUS EDIT ── */
.status-select, .payment-select {
  padding: 4px 8px;
  font-size: .75rem;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
}

/* ── HISTORY MONTH TABS ── */
.month-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.month-tab {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: .76rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--card);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.month-tab:hover { background: #eeece8; }
.month-tab.active { background: var(--text); color: #fff; border-color: var(--text); }

/* ── LOADING / EMPTY ── */
.loading-state, .empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  font-size: .85rem;
}

.empty-state .empty-icon { font-size: 2rem; margin-bottom: 10px; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-wrap {
    margin-left: 0;
  }
  .sidebar-toggle {
    display: block;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .profit-row {
    grid-template-columns: 1fr;
  }
  .budget-grid {
    grid-template-columns: 1fr;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .svc-edit-row {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
}
