/* ── NEXTGEN AISHWARYAM INVOICE — SHARED STYLES ── */
:root {
  --ink: #0d0d1a;
  --ink2: #1e1c2e;
  --ink3: #5a5870;
  --ink4: #9896b0;
  --cream: #fafaf7;
  --cream2: #f4f3ed;
  --cream3: #ebe9e0;
  --gold: #c8a84b;
  --gold2: #e8c870;
  --green2: #22a06b;
  --red2: #d94f4f;
  --blue2: #3b7dd8;
  --sh: 0 4px 16px rgba(13,13,26,.08);
  --sh2: 0 8px 32px rgba(13,13,26,.12);
}

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

html { overflow-x: hidden; }

body {
  font-family: 'Outfit', sans-serif;
  background: var(--cream2);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;          /* never let pages overflow horizontally */
  max-width: 100vw;
}

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

/* ── SIDEBAR ─────────────────────────────────────────────── */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--ink);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  text-decoration: none;
}

.logo-n {
  width: 32px; height: 32px;
  border-radius: 7px;
  background: rgba(200,168,75,.12);
  border: 1px solid rgba(200,168,75,.2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.logo-n span {
  font-family: 'Cormorant Garamond', serif;
  font-size: 18px; font-weight: 700;
  color: var(--gold);
}

.sb-firm {
  font-family: 'Cormorant Garamond', serif;
  font-size: 15px; font-weight: 700;
  color: rgba(255,255,255,.8);
  line-height: 1.2;
}

.sb-firm em {
  color: var(--gold);
  font-style: normal;
}

.sb-section {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(255,255,255,.25);
  padding: 18px 20px 6px;
}

.sb-nav { padding: 4px 12px; }

.sb-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: 7px;
  color: rgba(255,255,255,.5);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all .2s;
  position: relative;
}

.sb-link:hover { color: rgba(255,255,255,.85); background: rgba(255,255,255,.05); }
.sb-link.active { color: #fff; background: rgba(255,255,255,.08); }
.sb-link.active::before { content: ''; position: absolute; left: 0; top: 6px; bottom: 6px; width: 3px; border-radius: 0 3px 3px 0; background: var(--gold); }

.sb-ico { font-size: 15px; flex-shrink: 0; }

.sb-badge {
  margin-left: auto;
  background: var(--red2);
  color: #fff;
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
  border-radius: 10px;
  padding: 1px 6px;
  font-weight: 700;
}

.sb-bottom {
  margin-top: auto;
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,.06);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sb-user {
  display: flex; align-items: center; gap: 10px;
}

.sb-av {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(200,168,75,.15);
  border: 1px solid rgba(200,168,75,.25);
  display: flex; align-items: center; justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; font-weight: 600;
  color: var(--gold);
  flex-shrink: 0;
}

.sb-uname { font-size: 12.5px; font-weight: 600; color: rgba(255,255,255,.8); }
.sb-urole { font-size: 11px; color: rgba(255,255,255,.3); text-transform: capitalize; margin-top: 1px; }

.sb-logout {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 6px;
  color: rgba(255,255,255,.3);
  text-decoration: none; font-size: 12.5px;
  transition: all .2s;
}
.sb-logout:hover { color: var(--red2); background: rgba(217,79,79,.08); }

/* ── MAIN ─────────────────────────────────────────────── */
.main { flex: 1; min-width: 0; max-width: 100%; display: flex; flex-direction: column; overflow-x: hidden; }

/* ── TOPBAR ─────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(250,250,247,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--cream3);
  padding: 14px 28px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;             /* allow wrapping on narrow screens */
}

.topbar-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 22px; font-weight: 700;
  letter-spacing: -.5px; color: var(--ink);
}

.topbar-sub {
  font-size: 12px; color: var(--ink4);
  font-family: 'JetBrains Mono', monospace;
  margin-top: 2px;
}

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

.tb-search {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border: 1.5px solid var(--cream3);
  border-radius: 7px; background: #fff;
  transition: border-color .2s;
}
.tb-search:focus-within { border-color: var(--gold); }
.tb-search input { border: none; outline: none; background: none; font-family: 'Outfit', sans-serif; font-size: 13px; color: var(--ink); width: 180px; }
.tb-search input::placeholder { color: var(--ink4); }

.tb-notif {
  position: relative; width: 36px; height: 36px;
  border-radius: 8px; border: 1.5px solid var(--cream3);
  display: flex; align-items: center; justify-content: center;
  text-decoration: none; font-size: 16px;
  transition: all .2s;
}
.tb-notif:hover { border-color: var(--gold); }
.notif-dot {
  position: absolute; top: 5px; right: 5px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--red2); border: 1.5px solid var(--cream);
}

/* ── PAGE CONTENT ─────────────────────────────────────── */
.page-content { padding: 24px 28px; flex: 1; }

/* ── CARDS ─────────────────────────────────────────────── */
.card {
  background: #fff;
  border: 1px solid var(--cream3);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--sh);
}

.card-header {
  display: flex; align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--cream3);
}

.card-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 17px; font-weight: 700;
  letter-spacing: -.3px; color: var(--ink);
}

.card-body { padding: 20px 24px; }

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

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

/* Tablet — narrower sidebar so main content has more room */
@media (min-width: 769px) and (max-width: 1024px) {
  .sidebar { width: 200px; }
  .topbar { padding: 14px 18px; }
  .page-content { padding: 18px 20px; }
  .topbar-title { font-size: 19px; }
  .tb-search input { width: 130px; }
}

.scard {
  background: #fff;
  border: 1px solid var(--cream3);
  border-radius: 10px;
  padding: 20px 22px;
  box-shadow: var(--sh);
  position: relative;
  overflow: hidden;
}

.scard-ico { font-size: 22px; margin-bottom: 10px; }
.scard-label { font-size: 11.5px; color: var(--ink4); font-weight: 600; letter-spacing: .2px; text-transform: uppercase; font-family: 'JetBrains Mono', monospace; }
.scard-val { font-family: 'Cormorant Garamond', serif; font-size: 36px; font-weight: 700; letter-spacing: -1px; color: var(--ink); line-height: 1.1; margin-top: 4px; }
.scard-val.green { color: var(--green2); }
.scard-val.gold { color: var(--gold); }
.scard-val.red { color: var(--red2); }
.scard-delta { font-size: 11.5px; color: var(--ink4); margin-top: 6px; font-family: 'JetBrains Mono', monospace; }
.scard-delta.up { color: var(--green2); }
.scard-delta.down { color: var(--red2); }

/* ── TABLE ─────────────────────────────────────────────── */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead tr { border-bottom: 2px solid var(--cream3); }
th {
  padding: 10px 16px;
  text-align: left;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px; font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--ink4);
  white-space: nowrap;
}
td { padding: 12px 16px; border-bottom: 1px solid var(--cream3); font-size: 13.5px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--cream2); }

/* ── BADGES ─────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  letter-spacing: .5px;
}
.badge-draft { background: rgba(152,150,176,.12); color: var(--ink4); }
.badge-sent { background: rgba(59,125,216,.1); color: var(--blue2); }
.badge-paid { background: rgba(34,160,107,.1); color: var(--green2); }
.badge-partial { background: rgba(200,168,75,.12); color: var(--gold); }
.badge-overdue { background: rgba(217,79,79,.1); color: var(--red2); }
.badge-cancelled { background: rgba(90,88,112,.08); color: var(--ink3); }

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px;
  border-radius: 7px;
  font-family: 'Outfit', sans-serif;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all .2s;
  border: 1.5px solid transparent;
  white-space: nowrap;
}
.btn-gold { background: var(--gold); color: var(--ink); border-color: var(--gold); }
.btn-gold:hover { background: var(--gold2); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(200,168,75,.3); }
.btn-outline { background: #fff; color: var(--ink3); border-color: var(--cream3); }
.btn-outline:hover { border-color: var(--gold); color: var(--gold); }
.btn-primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-primary:hover { opacity: .85; }
.btn-ghost { background: none; color: var(--ink4); border-color: transparent; }
.btn-ghost:hover { color: var(--gold); }
.btn-danger { background: none; color: var(--red2); border-color: rgba(217,79,79,.2); }
.btn-danger:hover { background: rgba(217,79,79,.06); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }

/* ── FORMS ─────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.form-label { font-size: 11.5px; font-weight: 600; color: var(--ink3); letter-spacing: .2px; }
.form-label .req { color: var(--red2); }
.form-control {
  padding: 10px 13px;
  border: 1.5px solid var(--cream3);
  border-radius: 7px;
  font-size: 13.5px;
  font-family: 'Outfit', sans-serif;
  color: var(--ink);
  background: var(--cream);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  width: 100%;
}
.form-control:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(200,168,75,.08); }
.form-control::placeholder { color: var(--ink4); }
.form-control:disabled { opacity: .6; cursor: not-allowed; }
textarea.form-control { resize: vertical; }
select.form-control { cursor: pointer; }

.form-row { display: grid; gap: 14px; }
.form-row.col-2 { grid-template-columns: 1fr 1fr; }
.form-row.col-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ── UTILITY ─────────────────────────────────────────────── */
.mono { font-family: 'JetBrains Mono', monospace; }
.text-gold { color: var(--gold); }
.text-green { color: var(--green2); }
.text-muted { color: var(--ink4); }
.fw-7 { font-weight: 700; }

/* ── Modals (shared base) ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(13,13,26,.55);
  z-index: 1000;
  display: none;
  align-items: center; justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--cream);
  border-radius: 12px;
  padding: 28px;
  width: 100%;
  max-width: 540px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}
.modal-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 18px;
  color: var(--ink);
}

@media (max-width: 768px) {
  .topbar { padding: 12px 16px; flex-wrap: wrap; gap: 10px; }
  .topbar-title { font-size: 18px; }
  .topbar-sub { font-size: 11px; }
  .topbar-right { width: 100%; flex-wrap: wrap; gap: 8px; }
  .page-content { padding: 14px; }

  /* Sidebar slides in from left */
  .sidebar {
    position: fixed;
    left: -260px;
    top: 0;
    bottom: 0;
    width: 240px;
    z-index: 200;
    transition: left .25s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,.15);
  }
  .sidebar.open { left: 0; }

  .main { margin-left: 0; width: 100%; }

  /* Hamburger button */
  .mobile-menu-btn {
    display: flex !important;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    padding: 6px;
    color: var(--ink);
    align-items: center;
    justify-content: center;
    margin-right: 8px;
  }

  /* Backdrop */
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(13,13,26,.5);
    backdrop-filter: blur(4px);
    z-index: 199;
    display: none;
  }
  .sidebar-backdrop.open { display: block; }

  /* Forms — bigger tap targets, prevent iOS zoom */
  .form-control, .filter-select, input, select, textarea {
    font-size: 16px !important;
  }
  .form-row.col-2, .form-row.col-3, .form-row.col-4 { grid-template-columns: 1fr; }

  /* Tables — horizontal scroll */
  .tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 640px; }

  /* Cards full width */
  .card { border-radius: 8px; }
  .card-header, .card-body { padding: 14px 16px; }

  /* Modal — full screen */
  .modal {
    max-width: 100% !important;
    margin: 0;
    border-radius: 16px 16px 0 0;
    max-height: 92vh;
  }
  .modal-overlay {
    align-items: flex-end !important;
    padding: 0 !important;
  }

  /* Buttons */
  .btn { padding: 10px 14px; font-size: 13px; }
  .btn-sm { padding: 8px 12px; font-size: 12px; }

  /* Stat cards stack */
  .stat-cards { grid-template-columns: 1fr 1fr !important; gap: 10px; }
  .scard { padding: 14px 16px; }
  .scard-val { font-size: 22px; }

  /* Hide non-essential columns on mobile tables */
  .hide-mobile { display: none !important; }
}

/* Hamburger button hidden on desktop */
.mobile-menu-btn { display: none; }

@media (max-width: 480px) {
  .stat-cards { grid-template-columns: 1fr !important; }
  .topbar-title { font-size: 16px; }
  .filter-bar { flex-direction: column; align-items: stretch; gap: 8px; }
  .filter-bar > * { width: 100%; }
}
