/* ============================================================
   Tech Accounting — Custom CSS
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --sidebar-w: 240px;
  --topbar-h: 56px;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-active: #2563eb;
  --sidebar-hover: #1e293b;
  --card-shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
}

/* ── Base ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: .875rem; background: #f1f5f9; color: #1e293b; margin: 0; }

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

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 1040;
  transition: transform .25s ease;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex; align-items: center; gap: .75rem;
  padding: 1.25rem 1rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.brand-icon { font-size: 1.5rem; color: var(--primary); }
.brand-name { color: #f1f5f9; font-weight: 700; font-size: .9rem; white-space: nowrap; overflow: hidden; }
.sidebar-nav { padding: .75rem 0; flex: 1; }
.nav-section-label {
  padding: .6rem 1rem .2rem;
  font-size: .65rem; font-weight: 700; letter-spacing: .08em;
  color: #475569; text-transform: uppercase;
}
.sidebar-nav .nav-link {
  display: flex; align-items: center; gap: .75rem;
  padding: .5rem 1rem;
  color: var(--sidebar-text);
  text-decoration: none;
  border-radius: 0;
  font-size: .8rem; font-weight: 500;
  transition: background .15s, color .15s;
}
.sidebar-nav .nav-link i { font-size: 1rem; min-width: 20px; }
.sidebar-nav .nav-link:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.sidebar-nav .nav-link.active { background: var(--sidebar-active); color: #fff; border-right: 3px solid #93c5fd; }

/* ── Main content ───────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin .25s ease;
}
.page-content { padding: 1.25rem; flex: 1; }

/* ── Topbar ─────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  gap: .75rem;
  position: sticky; top: 0; z-index: 1030;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.sidebar-toggle { display: none; background: none; border: 1px solid #e2e8f0; border-radius: 6px; padding: .25rem .5rem; cursor: pointer; color: #64748b; }
.topbar-title { font-weight: 600; font-size: .95rem; flex: 1; color: #1e293b; }
.topbar-clock {
  display: flex; align-items: center; gap: 6px;
  background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 8px;
  padding: 4px 12px; font-size: .8rem; color: #475569;
  white-space: nowrap; user-select: none;
}
.topbar-clock i { color: #2563eb; font-size: .85rem; }
#clockDate { color: #64748b; font-size: .75rem; }
#clockTime { color: #1e293b; }
@media (max-width: 640px) { .topbar-clock { display: none; } }
.topbar-right { display: flex; align-items: center; gap: .5rem; }
.user-btn { background: none; border: 1px solid #e2e8f0; border-radius: 8px; padding: .25rem .75rem; display: flex; align-items: center; gap: .5rem; cursor: pointer; color: #374151; }
.user-btn:hover { background: #f8fafc; }
.user-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: .75rem; font-weight: 700; }
.user-name { font-size: .8rem; font-weight: 500; }

/* ── Cards ──────────────────────────────────────────────────── */
.card { border: 1px solid #e2e8f0; border-radius: 10px; box-shadow: var(--card-shadow); background: #fff; }
.card-header { background: #fff; border-bottom: 1px solid #e2e8f0; padding: .75rem 1rem; font-size: .875rem; border-radius: 10px 10px 0 0; }
.card-footer { background: #f8fafc; border-top: 1px solid #e2e8f0; padding: .6rem 1rem; border-radius: 0 0 10px 10px; }

/* ── KPI Cards ──────────────────────────────────────────────── */
.kpi-card {
  display: flex; align-items: center; gap: 1rem;
  background: #fff; border-radius: 12px;
  padding: 1.25rem; border: 1px solid #e2e8f0;
  box-shadow: var(--card-shadow);
  transition: transform .2s, box-shadow .2s;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.1); }
.kpi-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; flex-shrink: 0; }
.kpi-blue .kpi-icon  { background: #dbeafe; color: #2563eb; }
.kpi-orange .kpi-icon{ background: #ffedd5; color: #f97316; }
.kpi-red .kpi-icon   { background: #fee2e2; color: #ef4444; }
.kpi-green .kpi-icon { background: #dcfce7; color: #16a34a; }
.kpi-label { font-size: .75rem; color: #64748b; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-size: 1.4rem; font-weight: 800; color: #1e293b; line-height: 1.1; }
.kpi-sub   { font-size: .7rem; color: #94a3b8; }

/* ── Quick stats list ───────────────────────────────────────── */
.quick-stat {
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem 1rem; border-bottom: 1px solid #f1f5f9;
  font-size: .875rem;
}
.quick-stat:last-child { border-bottom: none; }
.quick-stat i { font-size: 1.1rem; }
.quick-stat span { flex: 1; color: #64748b; }
.quick-stat strong { color: #1e293b; }

/* ── Tables ─────────────────────────────────────────────────── */
.table > thead > tr > th {
  background: #f8fafc; border-bottom: 2px solid #e2e8f0;
  font-size: .75rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: #64748b; white-space: nowrap;
  padding: .6rem .75rem;
}
.table > tbody > tr > td { padding: .6rem .75rem; vertical-align: middle; border-bottom: 1px solid #f1f5f9; font-size: .875rem; }
.table-hover > tbody > tr:hover > td { background: #f8fafc; }

/* ── Avatar circles ─────────────────────────────────────────── */
.avatar-circle {
  width: 34px; height: 34px; border-radius: 50%;
  background: #dbeafe; color: #2563eb;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700; flex-shrink: 0;
}
.avatar-orange { background: #ffedd5; color: #f97316; }
.avatar-red    { background: #fee2e2; color: #ef4444; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge { font-weight: 600; font-size: .7rem; letter-spacing: .02em; }

/* ── Status selects ─────────────────────────────────────────── */
.status-select { font-size: .75rem; padding: .2rem .5rem; height: auto; }
.status-draft    { background: #f8fafc; color: #64748b; }
.status-approved { background: #dbeafe; color: #1d4ed8; }
.status-paid     { background: #dcfce7; color: #15803d; }
.status-overdue  { background: #fee2e2; color: #b91c1c; }
.status-cancelled{ background: #f1f5f9; color: #475569; }
.status-issued   { background: #dcfce7; color: #15803d; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-control, .form-select { font-size: .875rem; border-color: #e2e8f0; }
.form-control:focus, .form-select:focus { border-color: #93c5fd; box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.form-label { font-size: .8rem; font-weight: 600; color: #374151; margin-bottom: .3rem; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-sm { font-size: .8rem; padding: .3rem .65rem; }

/* ── Login page ─────────────────────────────────────────────── */
.login-body { background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-wrapper { width: 100%; max-width: 420px; padding: 1rem; }
.login-card { background: #fff; border-radius: 16px; padding: 2.5rem; box-shadow: 0 25px 50px rgba(0,0,0,.3); }
.login-header { text-align: center; margin-bottom: 2rem; }
.login-logo { font-size: 3rem; color: var(--primary); margin-bottom: .75rem; }
.login-title { font-size: 1.5rem; font-weight: 800; color: #1e293b; margin: 0; }
.login-subtitle { color: #64748b; margin: .25rem 0 0; }
.btn-login { padding: .7rem; font-size: 1rem; font-weight: 600; }
.login-hint { text-align: center; color: #94a3b8; font-size: .8rem; margin-top: 1.25rem; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .sidebar-toggle { display: flex; align-items: center; }
  .kpi-value { font-size: 1.1rem; }
}

/* ── Overlay for mobile sidebar ────────────────────────────── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 1039;
}
.sidebar-overlay.show { display: block; }

/* ── Notification Bell ──────────────────────────────────────── */
.notif-bell { position: relative; }

.notif-btn {
  position: relative;
  background: none;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: #64748b;
  font-size: 1rem;
  transition: background .15s, border-color .15s, color .15s;
}
.notif-btn:hover { background: #f1f5f9; border-color: #cbd5e1; color: #1e293b; }
.notif-btn.active { background: #eff6ff; border-color: #93c5fd; color: #2563eb; }

.notif-badge {
  position: absolute;
  top: -6px; right: -6px;
  min-width: 18px; height: 18px;
  background: #ef4444;
  color: #fff;
  font-size: 10px; font-weight: 700;
  border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
  border: 2px solid #fff;
  animation: bellPop .35s cubic-bezier(.36,.07,.19,.97);
  pointer-events: none;
}
@keyframes bellPop {
  0%   { transform: scale(0); }
  60%  { transform: scale(1.25); }
  100% { transform: scale(1); }
}
.notif-btn.has-alerts { border-color: #fca5a5; color: #ef4444; animation: bellShake 1.2s ease .4s; }
@keyframes bellShake {
  0%,100% { transform: rotate(0); }
  15%     { transform: rotate(-14deg); }
  30%     { transform: rotate(12deg); }
  45%     { transform: rotate(-9deg); }
  60%     { transform: rotate(6deg); }
  75%     { transform: rotate(-3deg); }
}

/* Panel */
.notif-panel {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 340px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,.14), 0 2px 8px rgba(0,0,0,.08);
  z-index: 2000;
  overflow: hidden;
  animation: notifSlideIn .2s ease;
}
.notif-panel.open { display: flex; flex-direction: column; }

@keyframes notifSlideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Pointer arrow */
.notif-panel::before {
  content: '';
  position: absolute;
  top: -7px; right: 10px;
  width: 13px; height: 13px;
  background: #fff;
  border-left: 1px solid #e2e8f0;
  border-top: 1px solid #e2e8f0;
  transform: rotate(45deg);
  border-radius: 2px 0 0 0;
}

.notif-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 13px 16px 11px;
  border-bottom: 1px solid #f1f5f9;
}
.notif-title { font-weight: 700; font-size: .85rem; color: #1e293b; }

.notif-body { max-height: 360px; overflow-y: auto; }

.notif-empty {
  display: flex; flex-direction: column; align-items: center;
  gap: .5rem; padding: 2.5rem 1rem;
  color: #22c55e; font-size: .85rem; text-align: center;
}
.notif-empty i { font-size: 2rem; }

.notif-section-label {
  padding: 7px 14px 5px;
  font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
}
.notif-label-danger { background: #fff5f5; color: #b91c1c; border-bottom: 1px solid #fee2e2; }
.notif-label-warn   { background: #fffbeb; color: #92400e; border-bottom: 1px solid #fde68a; }
.notif-label-info   { background: #f0f9ff; color: #0369a1; border-bottom: 1px solid #bae6fd; }

.notif-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 14px;
  text-decoration: none;
  border-bottom: 1px solid #f8fafc;
  transition: background .12s;
}
.notif-item:hover { background: #f8fafc; }
.notif-item:last-child { border-bottom: none; }

.notif-item-danger .notif-item-icon { color: #ef4444; }
.notif-item-warn   .notif-item-icon { color: #f59e0b; }
.notif-item-icon { font-size: .9rem; margin-top: 2px; flex-shrink: 0; }

.notif-item-body { flex: 1; min-width: 0; }
.notif-item-num  { font-weight: 700; font-size: .82rem; color: #1e293b; }
.notif-item-cust { font-size: .78rem; color: #64748b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-item-meta { display: flex; justify-content: space-between; margin-top: 2px; }
.notif-item-amt  { font-size: .78rem; font-weight: 600; color: #1e293b; }
.notif-item-due  { font-size: .75rem; }

.notif-footer {
  padding: 10px 16px;
  border-top: 1px solid #f1f5f9;
  text-align: center;
  background: #f8fafc;
}
.notif-footer a { font-size: .78rem; color: #2563eb; text-decoration: none; font-weight: 600; }
.notif-footer a:hover { text-decoration: underline; }

/* ── Print ──────────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .no-print, .pagination, .notif-bell,
  .btn, button, form, .modal, .alert, .dropdown,
  .sidebar-overlay { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .page-content { padding: .5rem; }
  .card { box-shadow: none !important; border: 1px solid #ccc !important; }
  .card-header { background: #f8fafc !important; }
  .table > tbody > tr > td,
  .table > thead > tr > th { padding: .4rem .5rem !important; font-size: .78rem !important; }
  .kpi-card { border: 1px solid #e2e8f0 !important; box-shadow: none !important; page-break-inside: avoid; }
  a { color: inherit !important; text-decoration: none !important; }
  body { font-size: .8rem; background: #fff !important; }
  @page { margin: 12mm; }
}
