/* ── Reset & Variables ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --blu:    #1a3a6b;
  --blu2:   #0f2548;
  --blu-lt: #e8eef8;
  --oro:    #c8a96e;
  --bg:     #f5f3ef;
  --card:   #ffffff;
  --text:   #1c1c1a;
  --muted:  #6b6860;
  --border: rgba(0,0,0,0.09);
  --success:#15803d;
  --warn:   #b45309;
  --danger: #dc2626;
  --radius: 12px;
  --sidebar-w: 240px;
}

body { font-family: 'DM Sans', sans-serif; background: var(--bg); color: var(--text);
  min-height: 100vh; display: flex; overflow: hidden; }

/* ── Sidebar ── */
.sidebar { width: var(--sidebar-w); background: var(--blu); color: #fff; display: flex;
  flex-direction: column; flex-shrink: 0; transition: transform .25s; z-index: 100;
  position: relative; }

.sidebar-header { padding: 20px 16px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.1); }
.logo { width: 36px; height: 36px; background: rgba(255,255,255,0.15); border-radius: 10px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.logo svg { color: var(--oro); }
.logo-text { flex: 1; min-width: 0; }
.brand { display: block; font-family: 'Playfair Display', serif; font-size: 14px; color: #fff; }
.sub { display: block; font-size: 10px; color: rgba(255,255,255,0.5); margin-top: 1px; }
.sidebar-close { display: none; background: none; border: none; color: rgba(255,255,255,0.5);
  cursor: pointer; font-size: 16px; padding: 4px; }

.nav-section { padding: 16px 8px; flex: 1; }
.nav-label { font-size: 10px; text-transform: uppercase; letter-spacing: .1em;
  color: rgba(255,255,255,0.35); padding: 0 10px; margin-bottom: 6px; }

.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 8px; cursor: pointer; font-size: 13.5px; font-weight: 400;
  color: rgba(255,255,255,0.7); transition: all .15s; text-decoration: none;
  position: relative; }
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: rgba(255,255,255,0.15); color: #fff; font-weight: 500; }
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; fill: currentColor; }
.nav-item svg[stroke] { fill: none; }

.nav-badge { margin-left: auto; background: rgba(255,255,255,0.2); color: #fff;
  font-size: 10px; padding: 1px 7px; border-radius: 999px; }
.nav-badge.alert { background: var(--danger); }
.nav-badge:empty { display: none; }

.sidebar-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,0.1);
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: rgba(255,255,255,0.55); }
.sidebar-footer button { background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,0.4); padding: 4px; border-radius: 6px;
  transition: color .15s, background .15s; }
.sidebar-footer button:hover { color: #fff; background: rgba(255,255,255,0.1); }

/* ── Main layout ── */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; height: 100vh; }

.topbar { padding: 0 20px; height: 56px; border-bottom: 1px solid var(--border);
  background: var(--card); display: flex; align-items: center; gap: 12px;
  flex-shrink: 0; }
.menu-btn { display: none; background: none; border: none; cursor: pointer;
  color: var(--muted); padding: 6px; border-radius: 6px; }
.page-title { font-family: 'Playfair Display', serif; font-size: 18px; font-weight: 500;
  flex: 1; color: var(--blu); }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

.content { flex: 1; overflow-y: auto; padding: 24px; }

/* ── Cards ── */
.card { background: var(--card); border-radius: var(--radius); border: 0.5px solid var(--border);
  padding: 20px 22px; margin-bottom: 16px; }
.card-title { font-family: 'Playfair Display', serif; font-size: 15px; color: var(--blu);
  margin-bottom: 16px; padding-bottom: 12px; border-bottom: 0.5px solid var(--border); }

/* ── Stat cards ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card { background: var(--card); border-radius: var(--radius); border: 0.5px solid var(--border);
  padding: 16px 18px; }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 6px; }
.stat-value { font-size: 28px; font-weight: 500; color: var(--text); font-family: 'Playfair Display', serif; }
.stat-card.warn .stat-value { color: var(--warn); }
.stat-card.danger .stat-value { color: var(--danger); }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 500; padding: 0 12px 10px; }
td { padding: 10px 12px; border-top: 0.5px solid var(--border); vertical-align: middle; }
tr:hover td { background: #fafaf8; }
.td-name { font-weight: 500; }
.td-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ── Badges ── */
.badge { display: inline-flex; align-items: center; padding: 3px 10px;
  border-radius: 999px; font-size: 11px; font-weight: 500; }
.badge-ok      { background: #dcfce7; color: #166534; }
.badge-warn    { background: #fef3c7; color: #92400e; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-blue    { background: var(--blu-lt); color: var(--blu); }
.badge-gray    { background: #f3f4f6; color: #374151; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px;
  font-family: inherit; font-size: 13px; font-weight: 500; border-radius: 8px;
  cursor: pointer; transition: all .15s; border: 1px solid var(--border);
  background: var(--card); color: var(--text); white-space: nowrap; }
.btn:hover { border-color: var(--blu); color: var(--blu); }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--blu); color: #fff; border-color: var(--blu); }
.btn-primary:hover { background: var(--blu2); border-color: var(--blu2); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-danger { color: var(--danger); border-color: #fca5a5; }
.btn-danger:hover { background: #fee2e2; }

/* ── Forms ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-full { grid-column: 1/-1; }
.form-3 { grid-template-columns: 1fr 1fr 1fr; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 11px; font-weight: 500; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted); }
.field input, .field select, .field textarea {
  padding: 9px 12px; font-family: inherit; font-size: 14px;
  border: 1px solid var(--border); border-radius: 8px;
  background: #fafaf8; color: var(--text); outline: none;
  transition: border-color .2s, box-shadow .2s; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--blu); box-shadow: 0 0 0 3px rgba(26,58,107,.07); }
.field textarea { resize: vertical; min-height: 80px; }

.check-row { display: flex; align-items: center; gap: 8px; font-size: 13px;
  color: var(--text); padding: 3px 0; cursor: pointer; }
.check-row input { accent-color: var(--blu); width: 15px; height: 15px; cursor: pointer; }

/* ── Search bar ── */
.search-bar { display: flex; gap: 10px; margin-bottom: 16px; align-items: center; }
.search-bar input { flex: 1; padding: 9px 14px; font-family: inherit; font-size: 14px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--card);
  outline: none; transition: border-color .2s; }
.search-bar input:focus { border-color: var(--blu); }

/* ── Row actions ── */
.row-actions { display: flex; gap: 4px; }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state svg { width: 40px; height: 40px; margin-bottom: 12px; opacity: .3; }
.empty-state p { font-size: 14px; }

/* ── Modal ── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: none; align-items: center; justify-content: center; z-index: 200;
  padding: 20px; backdrop-filter: blur(2px); }
.modal-backdrop.open { display: flex; }
.modal-box { background: var(--card); border-radius: var(--radius); width: 100%;
  max-width: 640px; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15); }
.modal-header { padding: 20px 24px 16px; display: flex; align-items: center;
  justify-content: space-between; border-bottom: 0.5px solid var(--border); }
.modal-header h2 { font-family: 'Playfair Display', serif; font-size: 18px; color: var(--blu); }
.modal-close { background: none; border: none; cursor: pointer; font-size: 20px;
  color: var(--muted); padding: 4px; border-radius: 4px; line-height: 1; }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 16px 24px; border-top: 0.5px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end; }

/* ── Toast ── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 300;
  display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 16px; border-radius: 10px; font-size: 13.5px; font-weight: 500;
  display: flex; align-items: center; gap: 8px; box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  animation: slideIn .2s ease; }
.toast.ok      { background: #dcfce7; color: #166534; }
.toast.error   { background: #fee2e2; color: #991b1b; }
.toast.warning { background: #fef3c7; color: #92400e; }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Calendar ── */
.cal-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 1px;
  background: var(--border); border-radius: 8px; overflow: hidden; }
.cal-day-hdr { background: var(--bg); padding: 8px 4px; text-align: center;
  font-size: 11px; font-weight: 500; text-transform: uppercase; color: var(--muted); }
.cal-day { background: var(--card); min-height: 80px; padding: 6px; font-size: 12px; }
.cal-day-num { font-weight: 500; color: var(--muted); margin-bottom: 4px; }
.cal-day.today .cal-day-num { color: var(--blu); font-weight: 700; }
.cal-day.other-month { background: #fafaf8; }
.cal-day.other-month .cal-day-num { color: #ccc; }
.cal-event { font-size: 10px; background: var(--blu-lt); color: var(--blu);
  border-radius: 4px; padding: 2px 5px; margin-bottom: 2px;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis; cursor: pointer; }
.cal-event.scad { background: #fef3c7; color: var(--warn); }
.cal-event.scad-over { background: #fee2e2; color: var(--danger); }

.cal-nav { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.cal-nav h2 { font-family: 'Playfair Display', serif; font-size: 18px; flex: 1; color: var(--blu); }

/* ── Section divider ── */
.section-hdr { display: flex; align-items: center; justify-content: space-between;
  margin: 20px 0 12px; }
.section-hdr h2 { font-family: 'Playfair Display', serif; font-size: 15px; color: var(--blu); }

/* ── Responsive ── */
.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  z-index: 90; }

@media (max-width: 768px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: block; }
  .overlay.open { display: block; }
  .menu-btn { display: flex; }
  .form-grid { grid-template-columns: 1fr; }
  .form-3 { grid-template-columns: 1fr; }
  .form-full { grid-column: 1; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .content { padding: 16px; }
  .cal-grid { font-size: 11px; }
  .cal-day { min-height: 50px; padding: 4px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  table td:nth-child(3), table th:nth-child(3),
  table td:nth-child(4), table th:nth-child(4) { display: none; }
}
