/* ═══════════════════════════════════════════════════════
   CA MANAGER  —  style.css
   Fonts: DM Sans + DM Serif Display
   Palette: Deep Forest Green + Ivory + Slate
   ═══════════════════════════════════════════════════════ */

:root {
  --green-900: #0f2318;
  --green-800: #1a3a2a;
  --green-700: #1e4d35;
  --green-600: #256b47;
  --green-500: #2e8b5a;
  --green-400: #3daa72;
  --green-200: #a8d5b5;
  --green-100: #d4edda;
  --green-50:  #eef7f1;

  --ivory:     #faf8f3;
  --ivory-d:   #f2ede2;
  --slate-900: #1a1f2e;
  --slate-700: #374151;
  --slate-500: #6b7280;
  --slate-300: #d1d5db;
  --slate-200: #e5e7eb;
  --slate-100: #f3f4f6;
  --white:     #ffffff;

  --red-600:    #dc2626;
  --red-100:    #fee2e2;
  --orange-600: #d97706;
  --orange-100: #fef3c7;
  --blue-600:   #2563eb;
  --blue-100:   #dbeafe;

  --sidebar-w: 240px;
  --header-h:  56px;
  --radius:    10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
  --shadow:    0 4px 12px rgba(0,0,0,.10);
  --shadow-lg: 0 12px 32px rgba(0,0,0,.14);
  --t: .18s ease;
}

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--ivory);
  color: var(--slate-900);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--green-900);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  transition: transform var(--t);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}

.sidebar-brand {
  padding: 24px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.brand-icon {
  width: 38px; height: 38px;
  background: var(--green-600);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  margin-bottom: 10px;
}
.sidebar-brand h2 {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 1.05rem;
  color: var(--white);
  font-weight: 400;
  line-height: 1.3;
}
.sidebar-brand p {
  font-size: .7rem;
  color: var(--green-200);
  margin-top: 2px;
  letter-spacing: .5px;
  text-transform: uppercase;
}

.sidebar-nav {
  padding: 10px 10px;
  flex: 1;
}
.nav-group-label {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--green-400);
  padding: 14px 10px 5px;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border-radius: 8px;
  color: rgba(255,255,255,.7);
  font-size: .86rem;
  font-weight: 400;
  transition: all var(--t);
  margin-bottom: 1px;
}
.nav-icon { font-size: 14px; width: 18px; text-align: center; flex-shrink: 0; }
.sidebar-nav a:hover { background: rgba(255,255,255,.07); color: var(--white); }
.sidebar-nav a.active { background: var(--green-700); color: var(--white); font-weight: 600; }

.sidebar-footer {
  padding: 12px 14px 18px;
  border-top: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.sidebar-user {
  font-size: .75rem;
  color: rgba(255,255,255,.4);
  padding: 0 4px;
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.logout-btn {
  width: 100%;
  padding: 8px 14px;
  background: rgba(220,38,38,.15);
  color: #fca5a5;
  border: 1px solid rgba(220,38,38,.25);
  border-radius: 8px;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t);
  letter-spacing: .2px;
}
.logout-btn:hover { background: rgba(220,38,38,.3); color: #fee2e2; }

/* ── Mobile Header ──────────────────────────────────────── */
.mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--green-900);
  z-index: 200;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  box-shadow: var(--shadow);
}
.menu-btn {
  background: none; border: none;
  color: var(--white); font-size: 20px;
  cursor: pointer; padding: 4px; line-height: 1;
}
.mobile-title {
  font-family: 'DM Serif Display', serif;
  color: var(--white); font-size: 1rem;
}
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 99;
}

/* ── Main ───────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  padding: 28px 28px 56px;
}

/* ── Page Header ────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 22px;
}
.page-header h1 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.65rem;
  color: var(--green-800);
  font-weight: 400;
  line-height: 1.2;
}
.page-header-sub {
  font-size: .8rem;
  color: var(--slate-500);
  margin-top: 2px;
}

/* ── Box / Card ─────────────────────────────────────────── */
.box {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(0,0,0,.05);
  margin-bottom: 18px;
}
.box-header { margin-bottom: 14px; }
.box-header h3 { font-size: .98rem; font-weight: 600; color: var(--slate-900); }
.box-subtitle { font-size: .78rem; color: var(--slate-500); margin-top: 2px; }

/* ── Stats ──────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(0,0,0,.05);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: box-shadow var(--t), transform var(--t);
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.stat-label {
  font-size: .74rem;
  font-weight: 600;
  color: var(--slate-500);
  letter-spacing: .4px;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.stat-card h2 {
  font-family: 'DM Serif Display', serif;
  font-size: 2rem;
  color: var(--slate-900);
  line-height: 1;
}
.stat-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.stat-icon.green  { background: var(--green-50); }
.stat-icon.red    { background: var(--red-100); }
.stat-icon.orange { background: var(--orange-100); }
.stat-icon.blue   { background: var(--blue-100); }

/* ── Quick Links ────────────────────────────────────────── */
.pill-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.pill-links a {
  display: inline-flex; align-items: center;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--green-50);
  color: var(--green-700);
  font-size: .8rem; font-weight: 500;
  border: 1px solid var(--green-200);
  transition: all var(--t);
}
.pill-links a:hover { background: var(--green-700); color: var(--white); border-color: var(--green-700); }

/* ── Table ──────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--slate-200);
}
table { width: 100%; border-collapse: collapse; font-size: .87rem; }
thead tr { background: var(--green-800); }
thead th {
  padding: 11px 14px;
  color: rgba(255,255,255,.88);
  font-weight: 600;
  font-size: .75rem;
  letter-spacing: .5px;
  text-transform: uppercase;
  text-align: left;
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--slate-100); transition: background var(--t); }
tbody tr:hover { background: var(--green-50); }
tbody tr:last-child { border-bottom: none; }
tbody td { padding: 11px 14px; color: var(--slate-700); vertical-align: middle; }
.empty-note {
  text-align: center; color: var(--slate-500);
  padding: 36px !important; font-size: .88rem; font-style: italic;
}

/* ── Status Badges ──────────────────────────────────────── */
.status {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .72rem; font-weight: 700;
  letter-spacing: .4px; text-transform: uppercase;
}
.status::before {
  content: ''; width: 6px; height: 6px;
  border-radius: 50%; flex-shrink: 0;
}
.status.red    { background: var(--red-100);    color: var(--red-600); }
.status.red::before    { background: var(--red-600); }
.status.orange { background: var(--orange-100); color: var(--orange-600); }
.status.orange::before { background: var(--orange-600); }
.status.green  { background: var(--green-100);  color: var(--green-600); }
.status.green::before  { background: var(--green-500); }

/* ── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: .7rem; font-weight: 700;
  letter-spacing: .4px; text-transform: uppercase;
}
.badge-green  { background: var(--green-100);  color: var(--green-700); }
.badge-blue   { background: var(--blue-100);   color: var(--blue-600); }
.badge-orange { background: var(--orange-100); color: var(--orange-600); }
.badge-red    { background: var(--red-100);    color: var(--red-600); }

/* ── Buttons ────────────────────────────────────────────── */
.add-btn, button[type="submit"] {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px;
  background: var(--green-700); color: var(--white);
  border: none; border-radius: 8px;
  font-size: .86rem; font-weight: 600;
  cursor: pointer; transition: all var(--t);
  white-space: nowrap; letter-spacing: .2px;
}
.add-btn:hover, button[type="submit"]:hover {
  background: var(--green-800); transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(26,58,42,.22);
}
.btn-edit {
  display: inline-flex; align-items: center;
  padding: 4px 11px;
  background: var(--blue-100); color: var(--blue-600);
  border: none; border-radius: 6px;
  font-size: .78rem; font-weight: 600;
  cursor: pointer; transition: all var(--t);
}
.btn-edit:hover { background: var(--blue-600); color: var(--white); }

.btn-delete {
  display: inline-flex; align-items: center;
  padding: 4px 11px;
  background: var(--red-100); color: var(--red-600);
  border: none; border-radius: 6px;
  font-size: .78rem; font-weight: 600;
  cursor: pointer; transition: all var(--t); text-decoration: none;
}
.btn-delete:hover { background: var(--red-600); color: var(--white); }

.btn-print {
  display: inline-flex; align-items: center;
  padding: 4px 11px;
  background: var(--green-100); color: var(--green-700);
  border: none; border-radius: 6px;
  font-size: .78rem; font-weight: 600;
  cursor: pointer; transition: all var(--t); text-decoration: none;
}
.btn-print:hover { background: var(--green-700); color: var(--white); }

.btn-cancel {
  display: inline-flex; align-items: center;
  padding: 9px 18px;
  background: var(--slate-100); color: var(--slate-700);
  border: 1px solid var(--slate-300); border-radius: 8px;
  font-size: .86rem; font-weight: 500;
  cursor: pointer; transition: all var(--t);
}
.btn-cancel:hover { background: var(--slate-200); }

/* ── Forms ──────────────────────────────────────────────── */
.audit-form {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}
label {
  display: block;
  font-size: .78rem; font-weight: 600;
  color: var(--slate-700);
  margin-bottom: 5px; letter-spacing: .2px;
}
input[type="text"],
input[type="email"],
input[type="date"],
input[type="number"],
input[type="password"],
input[type="file"],
select, textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--slate-300);
  border-radius: 8px;
  background: var(--white);
  color: var(--slate-900);
  font-size: .87rem;
  transition: border-color var(--t), box-shadow var(--t);
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--green-500);
  box-shadow: 0 0 0 3px rgba(46,139,90,.11);
}
input[readonly], input[disabled] {
  background: var(--slate-100); color: var(--slate-500); cursor: not-allowed;
}
textarea { resize: vertical; min-height: 72px; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}
.check-label {
  display: flex; align-items: center; gap: 8px;
  font-size: .87rem; font-weight: 400;
  color: var(--slate-700); cursor: pointer; padding: 3px 0;
}
.check-label input[type="checkbox"] {
  width: 15px; height: 15px;
  accent-color: var(--green-600);
  cursor: pointer; margin: 0; flex-shrink: 0;
}

/* ── Filter Bar ─────────────────────────────────────────── */
.filter-bar {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(0,0,0,.05);
  margin-bottom: 18px;
  display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end;
}
.filter-bar > div { min-width: 150px; flex: 1; }

/* ── Modal ──────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.48);
  backdrop-filter: blur(3px);
  z-index: 500;
  align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 760px;
  max-height: 92vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalIn .2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(-18px) scale(.97); }
  to   { opacity: 1; transform: none; }
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--slate-100);
  flex-shrink: 0;
}
.modal-header h3 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.1rem; color: var(--green-800); font-weight: 400;
}
.modal-close {
  background: none; border: none; font-size: 22px;
  color: var(--slate-400); cursor: pointer;
  padding: 0; line-height: 1; transition: color var(--t);
  width: auto !important; box-shadow: none !important;
  transform: none !important;
}
.modal-close:hover { color: var(--red-600); background: none !important; transform: none !important; box-shadow: none !important; }
.modal-body {
  padding: 20px 22px;
  overflow-y: auto; flex: 1;
}
.modal-body h3 {
  font-size: .78rem; font-weight: 700;
  letter-spacing: 1px; text-transform: uppercase;
  color: var(--green-600);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--green-100);
  margin: 16px 0 12px;
}
.modal-body h3:first-child { margin-top: 0; }
.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--slate-100);
  display: flex; gap: 10px; justify-content: flex-end;
  flex-shrink: 0;
}

/* ── Invoice ────────────────────────────────────────────── */
.invoice-divider { border: none; border-top: 1px solid var(--slate-100); margin: 20px 0; }
.amount-cell { text-align: right; font-weight: 600; }
.right { text-align: right; }

/* ── Flash Messages ─────────────────────────────────────── */
.messages { list-style: none; margin-bottom: 16px; }
.messages li {
  padding: 11px 16px;
  border-radius: 8px; font-size: .87rem; font-weight: 500;
  margin-bottom: 8px; display: flex; align-items: center; gap: 8px;
  transition: opacity .4s;
}
.messages .success { background: var(--green-100); color: var(--green-700); border: 1px solid var(--green-200); }
.messages .error   { background: var(--red-100);   color: var(--red-600);   border: 1px solid #fecaca; }
.messages .warning { background: var(--orange-100); color: var(--orange-600); border: 1px solid #fde68a; }
.messages .info    { background: var(--blue-100);  color: var(--blue-600);  border: 1px solid #bfdbfe; }

/* ── Welcome Box ────────────────────────────────────────── */
.welcome-box {
  background: linear-gradient(135deg, var(--green-800) 0%, var(--green-600) 100%);
  color: var(--white); border: none;
}
.welcome-box h3 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.25rem; font-weight: 400; color: var(--white);
}
.welcome-box .box-subtitle { color: rgba(255,255,255,.72); margin-top: 4px; }

/* ── Login ──────────────────────────────────────────────── */
.login-body {
  background: var(--green-900);
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
}
.login-wrapper { width: 100%; max-width: 400px; }
.login-card {
  background: var(--white);
  border-radius: 20px; padding: 38px 34px;
  box-shadow: 0 24px 64px rgba(0,0,0,.38);
}
.login-card h2 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.75rem; color: var(--green-800);
}
.login-subtitle { color: var(--slate-500); font-size: .86rem; margin-bottom: 26px; margin-top: 4px; }
.login-field { margin-bottom: 15px; }
.login-btn {
  width: 100%; padding: 12px;
  background: var(--green-700); color: var(--white);
  border: none; border-radius: 10px;
  font-size: .94rem; font-weight: 700;
  cursor: pointer; margin-top: 6px;
  transition: background var(--t), box-shadow var(--t);
  letter-spacing: .3px;
}
.login-btn:hover { background: var(--green-800); box-shadow: 0 6px 20px rgba(26,58,42,.32); }
.login-error {
  background: var(--red-100); color: var(--red-600);
  padding: 10px 14px; border-radius: 8px;
  font-size: .84rem; margin-bottom: 14px;
  border: 1px solid #fecaca;
}
.login-footer { text-align: center; color: var(--slate-500); font-size: .76rem; margin-top: 22px; }

/* ── Utilities ──────────────────────────────────────────── */
.text-muted   { color: var(--slate-500); font-size: .84rem; }
.text-center  { text-align: center; }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .mobile-header { display: flex; }
  .dash-two-col { grid-template-columns: 1fr; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .main { margin-left: 0; margin-top: var(--header-h); padding: 16px 14px 40px; }
  .audit-form { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .modal-box { max-height: 96vh; }
  .filter-bar { flex-direction: column; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}
