/* ============================================================
   FacturaShop — Diseño moderno 2025
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --primary:       #4f46e5;        /* indigo */
  --primary-dark:  #3730a3;
  --primary-light: #eef2ff;
  --secondary:     #06b6d4;        /* cyan */
  --accent:        #10b981;        /* emerald */
  --success:       #10b981;
  --warning:       #f59e0b;
  --danger:        #ef4444;
  --info:          #3b82f6;
  --light:         #f8fafc;
  --border:        #e2e8f0;
  --border-light:  #f1f5f9;
  --text:          #1e293b;
  --text-muted:    #94a3b8;
  --text-soft:     #64748b;
  --white:         #ffffff;
  --sidebar-w:     256px;
  --header-h:      64px;
  --radius:        10px;
  --radius-lg:     16px;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow:        0 4px 16px rgba(0,0,0,.07);
  --shadow-md:     0 8px 32px rgba(0,0,0,.10);
  --shadow-lg:     0 20px 60px rgba(0,0,0,.14);
  --font:          'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}

/* ── Reset ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--light);
  display: flex;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: none; }
img { max-width: 100%; }
code {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  background: var(--light);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: 5px;
  font-size: .82em;
  color: var(--primary-dark);
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: #0f172a;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .25s cubic-bezier(.4,0,.2,1);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.brand-icon { font-size: 1.5rem; }
.brand-name {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.3px;
  line-height: 1.1;
}
.brand-name small {
  display: block;
  font-size: .65rem;
  font-weight: 400;
  color: rgba(255,255,255,.35);
  letter-spacing: .5px;
  text-transform: uppercase;
  margin-top: 1px;
}

.sidebar-nav {
  flex: 1;
  padding: .5rem 0 .75rem;
  overflow-y: auto;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 4px; }

.nav-section-label {
  font-size: .6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: rgba(255,255,255,.25);
  padding: 1rem 1.25rem .3rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .55rem 1rem .55rem 1.25rem;
  color: rgba(255,255,255,.6);
  font-size: .84rem;
  font-weight: 500;
  transition: all .15s;
  border-radius: 0;
  text-decoration: none;
  position: relative;
}
.nav-item:hover {
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.9);
  text-decoration: none;
}
.nav-item.active {
  background: rgba(79,70,229,.25);
  color: #a5b4fc;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 3px;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
}
.nav-icon { width: 18px; text-align: center; font-size: .95rem; flex-shrink: 0; }
.nav-divider {
  height: 1px;
  background: rgba(255,255,255,.06);
  margin: .5rem 1.25rem;
}

.sidebar-footer {
  padding: .875rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,.06);
  display: flex;
  align-items: center;
  gap: .75rem;
}
.user-info { display: flex; align-items: center; gap: .6rem; flex: 1; min-width: 0; }
.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: .82rem;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(79,70,229,.4);
}
.user-name { font-size: .82rem; color: rgba(255,255,255,.85); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: .67rem; color: rgba(255,255,255,.35); text-transform: uppercase; letter-spacing: .5px; }
.btn-logout {
  color: rgba(255,255,255,.3);
  font-size: 1.1rem;
  cursor: pointer;
  transition: color .15s;
  text-decoration: none;
  flex-shrink: 0;
}
.btn-logout:hover { color: var(--danger); }

/* ── Main layout ─────────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.page-header {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 0 var(--border);
}
.page-header-left { display: flex; align-items: center; gap: .875rem; }
.page-title { font-size: 1.05rem; font-weight: 700; color: var(--text); letter-spacing: -.3px; }
.header-date { font-size: .75rem; color: var(--text-muted); text-transform: capitalize; font-weight: 400; }
.sidebar-toggle {
  background: none; border: none; cursor: pointer;
  font-size: 1.2rem; padding: .25rem .35rem; color: var(--text-muted);
  border-radius: 6px;
  transition: background .15s, color .15s;
}
.sidebar-toggle:hover { background: var(--light); color: var(--text); }
.page-body { padding: 1.75rem; flex: 1; }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--white);
}
.card-title {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.2px;
}
.card-body { padding: 1.5rem; }
.p-0 { padding: 0 !important; }
.mt-2 { margin-top: .6rem; }
.mt-3 { margin-top: 1.1rem; }
.mt-4 { margin-top: 1.75rem; }
.mb-3 { margin-bottom: 1.1rem; }
.ml-2 { margin-left: .5rem; }

/* ── Stats grid ──────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.stats-grid--small { grid-template-columns: repeat(4, 1fr); gap: .875rem; margin-bottom: 0; }
.stats-grid--6     { grid-template-columns: repeat(7, 1fr); }

.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.35rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s, transform .2s;
  overflow: hidden;
  position: relative;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.stat-card--green::after  { background: linear-gradient(90deg, var(--success), #34d399); }
.stat-card--blue::after   { background: linear-gradient(90deg, var(--primary), #818cf8); }
.stat-card--orange::after { background: linear-gradient(90deg, var(--warning), #fbbf24); }
.stat-card--red::after    { background: linear-gradient(90deg, var(--danger), #f87171); }
.stat-card--cyan::after   { background: linear-gradient(90deg, var(--secondary), #67e8f9); }

.stat-icon {
  font-size: 1.75rem;
  line-height: 1;
  padding: .6rem;
  border-radius: 10px;
  background: var(--light);
  flex-shrink: 0;
}
.stat-body { min-width: 0; flex: 1; overflow: hidden; }
.stat-value {
  font-size: clamp(0.75rem, 1.4vw, 1.4rem);
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
  letter-spacing: -.3px;
  white-space: normal;
  word-break: break-word;
  overflow: visible;
}
.stat-label { font-size: .68rem; color: var(--text-muted); margin-top: .3rem; font-weight: 500; text-transform: uppercase; letter-spacing: .3px; white-space: normal; overflow: hidden; line-height: 1.3; }
.stat-hint  { font-size: .62rem; color: var(--text-muted); margin-top: .15rem; font-style: italic; }

/* Hero stat card */
.stat-value--hero {
  font-size: clamp(1rem, 1.8vw, 1.65rem) !important;
  font-weight: 800;
  color: var(--text);
  white-space: nowrap;
}

/* Store color dot */
.store-dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
  flex-shrink: 0;
}

/* Table total row */
.table-total-row td {
  border-top: 2px solid var(--border) !important;
  padding-top: .75rem;
}

/* ── Dashboard charts ────────────────────────────────────────── */
.dashboard-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.1rem;
  margin-bottom: 1.1rem;
}
.chart-body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  min-height: 260px;
}
.chart-body canvas { max-height: 240px; }

/* ── Dashboard grid ──────────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.1rem;
}

/* ── Quick actions ───────────────────────────────────────────── */
.quick-actions { display: flex; flex-direction: column; gap: .5rem; }
.quick-action-btn {
  display: flex;
  align-items: center;
  gap: .875rem;
  padding: .8rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  transition: all .2s;
  text-decoration: none;
  background: var(--white);
}
.quick-action-btn:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
  background: var(--primary-light);
  text-decoration: none;
}
.quick-action-btn span { font-size: 1.4rem; }
.quick-action-btn strong { display: block; font-size: .875rem; font-weight: 600; color: var(--text); }
.quick-action-btn small { color: var(--text-muted); font-size: .75rem; }

/* ── Toolbar ─────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: .75rem;
}
.toolbar-filters { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; flex: 1; }
.toolbar-actions { display: flex; gap: .5rem; flex-shrink: 0; }
.search-input { min-width: 220px; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .475rem 1rem;
  border-radius: 8px;
  font-size: .84rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .18s cubic-bezier(.4,0,.2,1);
  text-decoration: none;
  white-space: nowrap;
  font-family: var(--font);
  letter-spacing: -.1px;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 1px 3px rgba(79,70,229,.3);
}
.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: white;
  box-shadow: 0 4px 12px rgba(79,70,229,.4);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--text);
  color: white;
  border-color: var(--text);
}
.btn-secondary:hover { background: #0f172a; color: white; }

.btn-outline {
  background: var(--white);
  color: var(--text-soft);
  border-color: var(--border);
}
.btn-outline:hover {
  border-color: #c7d2e0;
  background: var(--light);
  color: var(--text);
}

.btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
  box-shadow: 0 1px 3px rgba(239,68,68,.3);
}
.btn-danger:hover { background: #dc2626; color: white; box-shadow: 0 4px 12px rgba(239,68,68,.35); transform: translateY(-1px); }

.btn-success {
  background: var(--success);
  color: white;
  border-color: var(--success);
}
.btn-success:hover { background: #059669; color: white; }

.btn-sm { padding: .3rem .65rem; font-size: .77rem; border-radius: 6px; }
.btn-lg { padding: .65rem 1.5rem; font-size: .95rem; border-radius: 10px; }
.btn-block { width: 100%; justify-content: center; }
.w-full { width: 100%; }
.d-flex { display: flex; }
.align-end { align-items: flex-end; }

/* ── Forms ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.1rem; }
.form-row { display: flex; gap: .875rem; flex-wrap: wrap; }
.form-label {
  display: block;
  font-size: .79rem;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: .35rem;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.form-label.required::after, .required-mark { content: ' *'; color: var(--danger); }
.form-control {
  width: 100%;
  padding: .52rem .875rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .875rem;
  font-family: var(--font);
  color: var(--text);
  background: var(--white);
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}
.form-control::placeholder { color: var(--text-muted); }
.form-hint { font-size: .73rem; color: var(--text-muted); margin-top: .3rem; display: block; }
.select-sm { width: auto; min-width: 130px; }
.form-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1.75rem; padding-top: 1.25rem; border-top: 1px solid var(--border-light); }
.section-title {
  font-size: .75rem;
  font-weight: 700;
  color: var(--text-muted);
  margin: 1.5rem 0 .875rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-light);
}
hr { border: none; border-top: 1px solid var(--border-light); margin: 1.5rem 0; }

/* Columnas de formulario */
.col-2  { flex: 0 0 calc(16.66% - .6rem); min-width: 100px; }
.col-3  { flex: 0 0 calc(25%    - .6rem); min-width: 120px; }
.col-4  { flex: 0 0 calc(33.33% - .6rem); min-width: 140px; }
.col-5  { flex: 0 0 calc(41.66% - .6rem); }
.col-6  { flex: 0 0 calc(50%    - .6rem); }
.col-7  { flex: 0 0 calc(58.33% - .6rem); }
.col-12 { flex: 0 0 100%; }

/* ── Tables ──────────────────────────────────────────────────── */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .845rem;
}
.table th {
  background: var(--light);
  padding: .7rem 1.1rem;
  text-align: left;
  font-size: .72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: .7rem 1.1rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table-hover tbody tr { transition: background .12s; }
.table-hover tbody tr:hover { background: #fafbfc; }
.thead-dark th { background: var(--text); color: white; }
.text-right  { text-align: right !important; }
.text-center { text-align: center !important; }
.table-responsive { overflow-x: auto; }
.invoice-builder th, .invoice-builder td { padding: .4rem .5rem; }
.invoice-builder .form-control { font-size: .82rem; padding: .32rem .5rem; }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .22rem .65rem;
  border-radius: 20px;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .3px;
  white-space: nowrap;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef9c3; color: #854d0e; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-info    { background: #dbeafe; color: #1d4ed8; }

/* ── Alerts ──────────────────────────────────────────────────── */
.alert {
  padding: .875rem 1.125rem;
  border-radius: var(--radius);
  font-size: .875rem;
  margin-bottom: 1rem;
  border: 1px solid transparent;
  display: flex;
  align-items: flex-start;
  gap: .5rem;
}
.alert p { margin: .1rem 0; }
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alert-danger  { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-warning { background: #fffbeb; border-color: #fed7aa; color: #92400e; }
.alert-info    { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }

/* ── Pagination ──────────────────────────────────────────────── */
.pagination {
  display: flex;
  gap: .3rem;
  padding: .875rem 1.1rem;
  justify-content: flex-end;
  border-top: 1px solid var(--border-light);
}
.page-link {
  padding: .3rem .7rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-soft);
  text-decoration: none;
  transition: all .15s;
  background: var(--white);
}
.page-link:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); text-decoration: none; }
.page-link.active { background: var(--primary); color: white; border-color: var(--primary); box-shadow: 0 2px 8px rgba(79,70,229,.35); }

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3.5rem 1.5rem;
  color: var(--text-muted);
}
.empty-icon { font-size: 3.5rem; margin-bottom: 1rem; opacity: .6; }
.empty-state p { font-size: .9rem; margin-bottom: 1.25rem; color: var(--text-soft); }

/* ── Action buttons ──────────────────────────────────────────── */
.action-buttons { display: flex; gap: .3rem; align-items: center; flex-wrap: nowrap; }

/* ── Link styles ─────────────────────────────────────────────── */
.link-primary { color: var(--primary); font-weight: 600; }
.link-primary:hover { color: var(--primary-dark); }
.text-muted  { color: var(--text-muted) !important; }
.text-soft   { color: var(--text-soft); }
.text-danger { color: var(--danger) !important; }
.text-blue   { color: var(--info); }
.text-green  { color: var(--success); }

/* ── Login page ──────────────────────────────────────────────── */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #0f172a;
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(79,70,229,.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(6,182,212,.1) 0%, transparent 40%);
}
.login-container { width: 100%; max-width: 420px; padding: 1.5rem; }
.login-card {
  background: rgba(255,255,255,.98);
  border-radius: 20px;
  padding: 2.75rem 2.25rem;
  box-shadow: 0 25px 80px rgba(0,0,0,.5);
  border: 1px solid rgba(255,255,255,.15);
}
.login-header { text-align: center; margin-bottom: 2rem; }
.login-icon { font-size: 2.75rem; margin-bottom: .75rem; line-height: 1; }
.login-title { font-size: 1.6rem; font-weight: 800; color: var(--text); letter-spacing: -.5px; }
.login-subtitle { color: var(--text-muted); font-size: .85rem; margin-top: .4rem; }
.login-form .form-group { margin-bottom: 1.25rem; }

/* ── Stores grid ─────────────────────────────────────────────── */
.stores-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 1.1rem;
}
.store-card-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.35rem 1.35rem .875rem;
}
.store-logo { height: 50px; width: 90px; object-fit: contain; }
.store-logo-placeholder {
  width: 52px; height: 52px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(79,70,229,.3);
}
.store-info h3 { font-size: .95rem; font-weight: 700; color: var(--text); letter-spacing: -.2px; }
.store-card-body { padding: .875rem 1.35rem; border-top: 1px solid var(--border-light); }
.store-detail { display: flex; gap: .5rem; padding: .28rem 0; font-size: .82rem; }
.detail-label { color: var(--text-muted); min-width: 80px; font-weight: 500; }
.store-card-footer {
  display: flex;
  gap: .5rem;
  padding: .875rem 1.35rem;
  border-top: 1px solid var(--border-light);
  background: var(--light);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ── Invoice preview ─────────────────────────────────────────── */
.invoice-preview { padding: 0; }
.invoice-head {
  display: flex;
  justify-content: space-between;
  padding: 1.75rem;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
  color: white;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.invoice-company h2 { font-size: 1.1rem; margin-bottom: .35rem; font-weight: 700; }
.invoice-company p { font-size: .79rem; opacity: .7; margin: .1rem 0; }
.invoice-logo { max-height: 50px; margin-bottom: .5rem; filter: brightness(0) invert(1); }
.invoice-meta-box {
  text-align: right;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px;
  padding: 1.1rem 1.35rem;
  min-width: 220px;
  backdrop-filter: blur(4px);
}
.invoice-title { font-size: .68rem; letter-spacing: 2px; opacity: .5; margin-bottom: .2rem; text-transform: uppercase; }
.invoice-number { font-size: 1.35rem; font-weight: 800; letter-spacing: -.5px; }
.invoice-status { display: inline-block; margin-top: .4rem; }
.invoice-dates { margin-top: .6rem; font-size: .79rem; opacity: .8; }
.invoice-dates div { display: flex; justify-content: flex-end; gap: .5rem; margin: .15rem 0; }
.invoice-parties { padding: 1.35rem 1.75rem; border-bottom: 1px solid var(--border-light); }
.party-box { max-width: 300px; }
.party-label { font-size: .67rem; font-weight: 700; text-transform: uppercase; color: var(--text-muted); letter-spacing: 1.2px; margin-bottom: .5rem; }
.party-name { font-size: 1rem; font-weight: 700; color: var(--text); margin-bottom: .3rem; }
.party-box p { font-size: .82rem; color: var(--text-soft); margin: .1rem 0; }
.invoice-items { padding: 1.35rem 1.75rem; }
.invoice-table th { background: var(--text); color: white; }
.invoice-totals { display: flex; justify-content: flex-end; padding: 0 1.75rem 1.35rem; }
.totals-table { width: 260px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.totals-table td { padding: .55rem .9rem; font-size: .875rem; border-bottom: 1px solid var(--border-light); }
.totals-table td:last-child { text-align: right; }
.totals-total td { background: var(--primary); color: white; font-weight: 700; font-size: 1rem; border: none; }
.invoice-notes { margin: 0 1.75rem 1.35rem; padding: .875rem 1rem; background: var(--light); border-radius: var(--radius); font-size: .84rem; border-left: 3px solid var(--border); }

/* ── Form totals ─────────────────────────────────────────────── */
.form-totals {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .4rem;
  margin-top: 1rem;
  border-top: 1px solid var(--border-light);
  padding-top: 1rem;
}
.totals-row { display: flex; gap: 2rem; align-items: center; font-size: .875rem; }
.totals-row span { color: var(--text-muted); min-width: 120px; text-align: right; }
.totals-row strong { min-width: 130px; text-align: right; }
.totals-row--total { font-size: 1.05rem; color: var(--primary); font-weight: 700; }
.totals-row--total strong { font-size: 1.15rem; }

/* ── Logo upload ─────────────────────────────────────────────── */
.logo-upload-area { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.logo-preview { max-height: 80px; max-width: 160px; border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem; }

/* ── Loading overlay ─────────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(3px);
}
.loading-box {
  background: white;
  border-radius: 20px;
  padding: 2.5rem 3rem;
  text-align: center;
  max-width: 360px;
  box-shadow: var(--shadow-lg);
}
.spinner {
  width: 44px; height: 44px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1.25rem;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-box p { font-size: .9rem; font-weight: 600; color: var(--text); }

/* ── Section header (dashboard) ─────────────────────────────── */
.section-header { display: flex; gap: .75rem; margin-bottom: .875rem; flex-wrap: wrap; align-items: center; }
.section-badge {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: .25rem .75rem;
  border-radius: 20px;
}
.section-badge--blue { background: #dbeafe; color: #1d4ed8; }
.section-badge--red  { background: #fee2e2; color: #991b1b; }

/* ── Filter grid (received invoices) ────────────────────────── */
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: .875rem;
  align-items: end;
}

/* ── Month grid (summary) ────────────────────────────────────── */
.month-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0;
}
.month-cell {
  padding: 1.1rem .875rem;
  text-align: center;
  border-right: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  text-decoration: none;
  color: var(--text);
  transition: all .18s;
  background: var(--white);
}
.month-cell:hover {
  background: var(--primary-light);
  text-decoration: none;
  transform: scale(1.01);
  position: relative;
  z-index: 1;
  box-shadow: var(--shadow);
}
.month-cell--active { background: #f0f4ff; }
.month-cell:nth-child(6n) { border-right: none; }
.month-cell:nth-child(n+7) { border-bottom: none; }
.month-name { font-weight: 700; font-size: .82rem; color: var(--text); margin-bottom: .3rem; }
.month-count { font-size: .7rem; color: var(--text-muted); }
.month-total { font-size: .925rem; font-weight: 700; color: var(--primary); margin-top: .25rem; }

/* ── Nav section labels ──────────────────────────────────────── */
.nav-section-label {
  font-size: .6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: rgba(255,255,255,.25);
  padding: 1rem 1.25rem .3rem;
}

/* ── Misc utilities ──────────────────────────────────────────── */
.text-center { text-align: center !important; }
.text-right  { text-align: right !important; }
.font-bold   { font-weight: 700; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .stats-grid--6 { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-grid--6 { grid-template-columns: repeat(3, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-charts { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; }
  [class*="col-"] { flex: 0 0 100% !important; }
  .page-body { padding: 1.25rem; }
  .month-grid { grid-template-columns: repeat(4, 1fr); }
  .month-cell:nth-child(4n) { border-right: none; }
  .month-cell:nth-child(6n) { border-right: 1px solid var(--border-light); }
}
@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-filters { flex-direction: column; }
  .page-body { padding: 1rem .875rem; }
  .month-grid { grid-template-columns: repeat(3, 1fr); }
  .filter-grid { grid-template-columns: 1fr 1fr; }
}
