/* ═══════════════════════════════════════════════════════
   BillTrack CMS — Stylesheet
   Aesthetic: Refined dark ledger / financial luxury
   ═══════════════════════════════════════════════════════ */

:root {
  --bg:          #0c0d10;
  --bg2:         #12141a;
  --bg3:         #1a1d26;
  --border:      #252836;
  --border2:     #2e3245;
  --gold:        #c8a96e;
  --gold2:       #e8c98a;
  --text:        #e8eaf0;
  --text2:       #8b90a8;
  --text3:       #5a5f75;
  --green:       #3ecf8e;
  --red:         #ff5c6c;
  --blue:        #5c9bff;
  --orange:      #ff9f43;
  --sidebar-w:   240px;
  --radius:      10px;
  --radius-lg:   16px;
  --shadow:      0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg:   0 8px 48px rgba(0,0,0,0.6);
  font-size: 15px;
}

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

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── SCROLLBAR ─────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ════════════════════════════════════
   LOGIN
   ════════════════════════════════════ */
.login-wrap {
  display: flex;
  min-height: 100vh;
}

.login-art {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--bg2);
}

.art-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 60% at 30% 40%, rgba(200,169,110,0.12) 0%, transparent 60%),
    radial-gradient(ellipse 40% 80% at 80% 80%, rgba(92,155,255,0.06) 0%, transparent 60%);
}

.art-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg, transparent, transparent 39px,
    rgba(255,255,255,0.02) 39px, rgba(255,255,255,0.02) 40px
  ),
  repeating-linear-gradient(
    90deg, transparent, transparent 39px,
    rgba(255,255,255,0.02) 39px, rgba(255,255,255,0.02) 40px
  );
}

.art-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 1;
}

.art-text span {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: clamp(3rem, 6vw, 7rem);
  line-height: 0.9;
  color: transparent;
  -webkit-text-stroke: 1px rgba(200,169,110,0.3);
  letter-spacing: -2px;
}

.art-text span:nth-child(2) {
  -webkit-text-stroke-color: rgba(200,169,110,0.15);
  margin-left: 60px;
}

.art-text span:nth-child(3) {
  -webkit-text-stroke-color: rgba(200,169,110,0.07);
  margin-left: 120px;
}

.login-form-wrap {
  width: 440px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: var(--bg);
}

.login-card {
  width: 100%;
}

.login-logo {
  margin-bottom: 32px;
}

.login-card h1 {
  font-family: 'Syne', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.login-sub { color: var(--text2); margin-bottom: 32px; }

.login-err {
  background: rgba(255,92,108,0.1);
  border: 1px solid rgba(255,92,108,0.3);
  color: var(--red);
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 0.875rem;
}

.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.field input, .field select, .field textarea {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 11px 14px;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: 'DM Sans', sans-serif;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(200,169,110,0.12);
}

.field select option { background: var(--bg3); }
.field textarea { resize: vertical; min-height: 80px; }

/* ════════════════════════════════════
   BUTTONS
   ════════════════════════════════════ */
.btn-primary {
  background: var(--gold);
  color: #0c0d10;
  border: none;
  padding: 12px 22px;
  border-radius: var(--radius);
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 0.02em;
}
.btn-primary:hover { background: var(--gold2); }
.btn-primary:active { transform: scale(0.97); }
.btn-primary.full { width: 100%; justify-content: center; }

.btn-secondary {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border2);
  padding: 10px 18px;
  border-radius: var(--radius);
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.btn-secondary:hover { background: var(--border); border-color: var(--gold); color: var(--gold); }

.btn-danger {
  background: rgba(255,92,108,0.1);
  color: var(--red);
  border: 1px solid rgba(255,92,108,0.25);
  padding: 8px 14px;
  border-radius: 7px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.btn-danger:hover { background: rgba(255,92,108,0.2); }

.btn-icon {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  transition: color 0.2s, background 0.2s;
}
.btn-icon:hover { color: var(--gold); background: rgba(200,169,110,0.1); }
.btn-icon svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.hidden { display: none !important; }

/* ════════════════════════════════════
   APP SHELL
   ════════════════════════════════════ */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ─────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0;
  z-index: 100;
  transition: transform 0.3s;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 20px;
  border-bottom: 1px solid var(--border);
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--text2);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s;
  cursor: pointer;
}

.nav-item svg {
  width: 18px; height: 18px;
  stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  flex-shrink: 0;
}

.nav-item:hover { color: var(--text); background: var(--bg3); }
.nav-item.active {
  color: var(--gold);
  background: rgba(200,169,110,0.1);
  border: 1px solid rgba(200,169,110,0.15);
}

.sidebar-footer {
  padding: 16px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-badge { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--gold2));
  color: #0c0d10;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.875rem;
  display: flex; align-items: center; justify-content: center;
}
.user-name { font-weight: 600; font-size: 0.85rem; }
.user-role { font-size: 0.75rem; color: var(--text3); }

.btn-logout {
  background: none; border: none;
  color: var(--text3); cursor: pointer;
  padding: 7px; border-radius: 7px;
  display: flex; align-items: center;
  transition: all 0.2s;
}
.btn-logout svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-logout:hover { color: var(--red); background: rgba(255,92,108,0.1); }

/* ── MOBILE HEADER ────────────────────── */
.mobile-header {
  display: none;
  position: fixed; top: 0; left: 0; right: 0;
  height: 56px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  align-items: center;
  padding: 0 16px;
  gap: 14px;
  z-index: 99;
}
.hamburger {
  background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; gap: 5px; padding: 4px;
}
.hamburger span {
  display: block; width: 22px; height: 2px;
  background: var(--text); border-radius: 2px;
  transition: all 0.2s;
}
.mobile-title { font-family: 'Syne', sans-serif; font-weight: 700; color: var(--text); }

/* ── MAIN CONTENT ─────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  background: var(--bg);
}

.page { display: none; padding: 32px; }
.page.active { display: block; }

/* ── PAGE HEADER ─────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-title { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 1.6rem; color: var(--text); }
.page-sub { font-size: 0.875rem; color: var(--text2); margin-top: 3px; }
.page-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ════════════════════════════════════
   STAT CARDS
   ════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s;
}
.stat-card:hover { border-color: var(--border2); }
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 80px; height: 80px;
  border-radius: 50%;
  opacity: 0.06;
  transform: translate(20px, -20px);
}
.stat-card.gold::before { background: var(--gold); }
.stat-card.green::before { background: var(--green); }
.stat-card.red::before { background: var(--red); }
.stat-card.blue::before { background: var(--blue); }

.stat-icon {
  width: 38px; height: 38px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
}
.stat-icon svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.stat-card.gold .stat-icon { background: rgba(200,169,110,0.15); color: var(--gold); }
.stat-card.green .stat-icon { background: rgba(62,207,142,0.12); color: var(--green); }
.stat-card.red   .stat-icon { background: rgba(255,92,108,0.12);  color: var(--red); }
.stat-card.blue  .stat-icon { background: rgba(92,155,255,0.12);  color: var(--blue); }

.stat-label { font-size: 0.78rem; color: var(--text3); text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 6px; }
.stat-value { font-family: 'Syne', sans-serif; font-size: 1.75rem; font-weight: 700; color: var(--text); }

/* ════════════════════════════════════
   TABLES
   ════════════════════════════════════ */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 20px;
}
.card-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.card-title { font-family: 'Syne', sans-serif; font-weight: 600; font-size: 1rem; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text3);
  font-weight: 600;
  padding: 13px 18px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.02); }
tbody td { padding: 13px 18px; font-size: 0.875rem; color: var(--text2); vertical-align: middle; }
tbody td:first-child { color: var(--text); }

/* ── BADGES ─────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.badge-purchase { background: rgba(255,159,67,0.12); color: var(--orange); border: 1px solid rgba(255,159,67,0.2); }
.badge-payment  { background: rgba(62,207,142,0.1);  color: var(--green);  border: 1px solid rgba(62,207,142,0.2); }
.badge-adjust   { background: rgba(92,155,255,0.1);  color: var(--blue);   border: 1px solid rgba(92,155,255,0.2); }
.badge-owing    { background: rgba(255,92,108,0.1);  color: var(--red);    border: 1px solid rgba(255,92,108,0.2); }
.badge-clear    { background: rgba(62,207,142,0.1);  color: var(--green);  border: 1px solid rgba(62,207,142,0.2); }

.amount-positive { color: var(--red); font-weight: 600; }
.amount-payment  { color: var(--green); font-weight: 600; }
.amount-zero     { color: var(--text3); }

/* ── SEARCH / FILTER BAR ─────────────── */
.search-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}
.search-input-wrap svg {
  position: absolute;
  left: 12px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px;
  stroke: var(--text3); fill: none; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.search-input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 9px 12px 9px 38px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-family: 'DM Sans', sans-serif;
  outline: none;
  transition: border-color 0.2s;
}
.search-input:focus { border-color: var(--gold); }

.filter-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
}
.filter-tab {
  padding: 6px 14px;
  border-radius: 7px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text2);
  background: none;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}
.filter-tab.active { background: var(--gold); color: #0c0d10; font-weight: 700; }

/* ════════════════════════════════════
   CLIENT DETAIL
   ════════════════════════════════════ */
.client-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}
.summary-item {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.summary-label { font-size: 0.75rem; color: var(--text3); text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 5px; }
.summary-value { font-family: 'Syne', sans-serif; font-size: 1.3rem; font-weight: 700; }

.ledger-table tbody td:nth-child(5) { font-family: 'Syne', sans-serif; font-size: 0.85rem; }

/* ── RUNNING BALANCE ──────────────────── */
.balance-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}
.balance-owing { background: rgba(255,92,108,0.1); color: var(--red); border: 1px solid rgba(255,92,108,0.2); }
.balance-clear  { background: rgba(62,207,142,0.1); color: var(--green); border: 1px solid rgba(62,207,142,0.2); }

/* ════════════════════════════════════
   MODAL
   ════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s ease;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 1.1rem; }
.modal-close {
  background: none; border: none; color: var(--text3);
  cursor: pointer; font-size: 1.1rem; padding: 4px 8px;
  border-radius: 6px; transition: all 0.2s;
}
.modal-close:hover { color: var(--text); background: var(--bg3); }
.modal-body { padding: 22px 24px; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; padding-top: 16px; border-top: 1px solid var(--border); margin-top: 16px; }

/* ════════════════════════════════════
   REPORTS
   ════════════════════════════════════ */
.report-chart {
  height: 200px;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 16px 0 0;
}
.chart-bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
  justify-content: flex-end;
}
.chart-bars {
  display: flex;
  gap: 2px;
  width: 100%;
  align-items: flex-end;
  flex: 1;
}
.chart-bar {
  flex: 1;
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  transition: height 0.5s ease;
}
.chart-bar.purchase { background: rgba(255,159,67,0.5); }
.chart-bar.payment  { background: rgba(62,207,142,0.5); }
.chart-label { font-size: 0.65rem; color: var(--text3); text-align: center; }

/* ════════════════════════════════════
   EMPTY STATES
   ════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text3);
}
.empty-icon { font-size: 3rem; margin-bottom: 12px; opacity: 0.5; }
.empty-state h3 { font-size: 1rem; color: var(--text2); margin-bottom: 6px; }
.empty-state p { font-size: 0.875rem; }

/* ════════════════════════════════════
   LOADING
   ════════════════════════════════════ */
.loader {
  display: flex;
  gap: 6px;
  justify-content: center;
  padding: 40px;
}
.loader span {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--gold);
  animation: bounce 1.2s infinite;
}
.loader span:nth-child(2) { animation-delay: 0.15s; }
.loader span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%,80%,100% { transform: scale(0.6); opacity: 0.4; } 40% { transform: scale(1); opacity: 1; } }

/* ════════════════════════════════════
   BREADCRUMB / BACK BUTTON
   ════════════════════════════════════ */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  font-size: 0.85rem;
  color: var(--text3);
}
.breadcrumb a { color: var(--gold); text-decoration: none; cursor: pointer; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════ */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .mobile-header { display: flex; }
  .main-content { margin-left: 0; padding-top: 56px; }
  .page { padding: 16px; }
  .client-summary { grid-template-columns: 1fr; }
  .art-text span { font-size: 3rem; }
  .login-form-wrap { width: 100%; }
  .login-art { display: none; }
}
