:root {
  --navy: #064366;
  --navy-dark: #043249;
  --navy-light: #0b5a86;
  --gold: #C29E65;
  --gold-light: #d8bd8f;
  --ivory: #F5F5F3;
  --white: #ffffff;
  --text: #223140;
  --text-soft: #5b6b78;
  --danger: #b3452c;
  --success: #3f7a52;
  --warn: #b8862f;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(6, 67, 102, 0.08);
  --font-display: 'Playfair Display', 'Georgia', serif;
  --font-body: 'Montserrat', -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--ivory);
  font-family: var(--font-body);
  color: var(--text);
}

a { text-decoration: none; color: inherit; }
button { font-family: var(--font-body); }

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-dark) 100%);
  color: var(--white);
  display: flex;
  flex-direction: column;
  padding: 28px 0 20px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  padding: 0 24px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  margin-bottom: 16px;
}
.sidebar-brand img { width: 100%; max-width: 190px; display: block; margin: 0 auto; }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 12px;
  flex: 1;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 14.5px;
  font-weight: 500;
  color: rgba(255,255,255,0.82);
  letter-spacing: 0.2px;
  transition: background 0.15s ease, color 0.15s ease;
}
.sidebar-nav a .nav-icon { font-size: 6px; color: var(--gold); }
.sidebar-nav a:hover { background: rgba(255,255,255,0.08); color: var(--white); }
.sidebar-nav a.active { background: var(--gold); color: var(--navy-dark); font-weight: 600; }
.sidebar-nav a.active .nav-icon { color: var(--navy-dark); }

.sidebar-footer {
  padding: 16px 24px 0;
  border-top: 1px solid rgba(255,255,255,0.12);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.backup-link {
  font-size: 13px;
  color: var(--gold-light);
  font-weight: 600;
}
.backup-link:hover { color: var(--white); }
.office-tag {
  font-size: 11.5px;
  color: rgba(255,255,255,0.5);
  letter-spacing: 0.5px;
}

/* ---------- Main content ---------- */
.main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 26px 40px 18px;
}
.topbar h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 30px;
  color: var(--navy);
  margin: 0;
}
.topbar-date {
  font-size: 13.5px;
  color: var(--text-soft);
  text-transform: capitalize;
}

.content {
  padding: 0 40px 40px;
  flex: 1;
}

/* ---------- Cards / grids ---------- */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  border-left: 4px solid var(--gold);
}
.stat-card .stat-label {
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-soft);
  font-weight: 600;
}
.stat-card .stat-value {
  font-family: var(--font-display);
  font-size: 30px;
  color: var(--navy);
  margin-top: 6px;
}
.stat-card.alert { border-left-color: var(--danger); }
.stat-card.warn { border-left-color: var(--warn); }

.two-col {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 980px) { .two-col { grid-template-columns: 1fr; } }

.section-title {
  font-family: var(--font-display);
  font-size: 19px;
  color: var(--navy);
  margin: 0 0 14px;
}

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.toolbar-filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.search-input, select.filter-select {
  padding: 10px 14px;
  border: 1px solid #dfe3e6;
  border-radius: 8px;
  font-size: 13.5px;
  font-family: var(--font-body);
  background: var(--white);
  color: var(--text);
}
.search-input { min-width: 220px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 8px;
  border: none;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.05s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--navy); color: var(--white); }
.btn-primary:hover { background: var(--navy-light); }
.btn-gold { background: var(--gold); color: var(--navy-dark); }
.btn-gold:hover { opacity: 0.9; }
.btn-ghost { background: transparent; color: var(--navy); border: 1px solid #d7dde1; }
.btn-ghost:hover { background: #eef2f4; }
.btn-danger-ghost { background: transparent; color: var(--danger); border: 1px solid #e8c9c0; }
.btn-danger-ghost:hover { background: #fbefec; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Table ---------- */
.table-wrap {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}
table { width: 100%; min-width: 720px; border-collapse: collapse; }
thead th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-soft);
  padding: 14px 16px;
  border-bottom: 1px solid #eceef0;
  background: #fafbfb;
}
tbody td {
  padding: 14px 16px;
  font-size: 14px;
  border-bottom: 1px solid #f1f3f4;
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fbfaf7; }
.row-actions { display: flex; gap: 8px; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-soft);
}
.empty-state .big { font-size: 40px; margin-bottom: 10px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.2px;
}
.badge-navy { background: #e2ecf1; color: var(--navy); }
.badge-gold { background: #f3e9d8; color: #8a6a30; }
.badge-green { background: #e2f0e5; color: var(--success); }
.badge-red { background: #f6e1da; color: var(--danger); }
.badge-gray { background: #eceef0; color: var(--text-soft); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6,32,48,0.45);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
  z-index: 100;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--white);
  border-radius: 14px;
  padding: 28px 30px;
  width: 100%;
  max-width: 560px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
}
.modal-box h2 {
  font-family: var(--font-display);
  color: var(--navy);
  margin: 0 0 20px;
  font-size: 22px;
}
.modal-close-row { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #dfe3e6;
  border-radius: 8px;
  font-size: 14px;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--white);
}
.field textarea { resize: vertical; min-height: 70px; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(194,158,101,0.2);
}

/* ---------- Toast ---------- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
}
.toast {
  background: var(--navy);
  color: var(--white);
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 13.5px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.2);
  animation: slideIn 0.2s ease;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }
@keyframes slideIn { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ---------- List items for dashboard ---------- */
.mini-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.mini-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: #fafbfb;
  border-radius: 8px;
  font-size: 13.5px;
}
.mini-list .mini-title { font-weight: 600; color: var(--navy); }
.mini-list .mini-sub { color: var(--text-soft); font-size: 12px; }

.kanban-stage-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 700;
  color: var(--text-soft);
}

.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.doc-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.doc-card .doc-name { font-weight: 600; font-size: 13.5px; color: var(--navy); word-break: break-word; }
.doc-card .doc-meta { font-size: 12px; color: var(--text-soft); }

.link-btn {
  background: none;
  border: none;
  color: var(--navy);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
}
.link-btn.danger { color: var(--danger); }

/* ---------- WhatsApp ---------- */
.wa-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  background: #e7f7ee;
  color: #1f8a4c;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.wa-btn:hover { background: #d3f0e0; }

/* ---------- Auth (login / setup) ---------- */
.auth-screen {
  display: none;
  position: fixed;
  inset: 0;
  background: linear-gradient(160deg, var(--navy) 0%, var(--navy-dark) 100%);
  align-items: center;
  justify-content: center;
  padding: 30px 16px;
  z-index: 300;
  overflow-y: auto;
}
.auth-card {
  background: var(--white);
  border-radius: 16px;
  padding: 36px 34px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  text-align: center;
}
.auth-logo { width: 130px; margin: 0 auto 18px; display: block; }
.auth-card h1 {
  font-family: var(--font-display);
  color: var(--navy);
  font-size: 24px;
  margin: 0 0 8px;
}
.auth-subtitle {
  color: var(--text-soft);
  font-size: 13.5px;
  margin: 0 0 22px;
}
.auth-form { text-align: left; display: flex; flex-direction: column; gap: 12px; }
.auth-error {
  color: var(--danger);
  font-size: 13px;
  min-height: 16px;
  margin: 0;
  font-weight: 600;
}
.auth-hint {
  font-size: 12px;
  color: var(--text-soft);
  margin-top: 18px;
  line-height: 1.5;
}
.finance-lock-box {
  text-align: center;
  padding: 60px 20px;
}
.finance-lock-box .big-icon { font-size: 46px; margin-bottom: 14px; }
.finance-lock-box h3 {
  font-family: var(--font-display);
  color: var(--navy);
  font-size: 20px;
  margin: 0 0 8px;
}
.finance-lock-box p { color: var(--text-soft); font-size: 13.5px; margin: 0 0 18px; }
