:root {
  --bg: #f7f4f0;
  --bg-card: #ffffff;
  --bg-sidebar: #2c2420;
  --text: #2c2420;
  --text-muted: #7a6e65;
  --text-inv: #f7f4f0;
  --accent: #c4785a;
  --accent-hover: #b0684a;
  --accent-soft: #f5e6df;
  --border: #e8e0d8;
  --success: #5a8f6a;
  --warning: #c9a227;
  --danger: #b85c5c;
  --radius: 10px;
  --shadow: 0 4px 20px rgba(44, 36, 32, 0.08);
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'Outfit', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  overflow: hidden;
}

#app {
  display: flex;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 240px;
  background: var(--bg-sidebar);
  color: var(--text-inv);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 28px 20px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.brand-mark {
  width: 40px;
  height: 40px;
  background: var(--accent);
  color: white;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.brand-sub {
  font-size: 0.7rem;
  opacity: 0.6;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  background: transparent;
  border: none;
  color: rgba(247,244,240,0.7);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 400;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}

.nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text-inv);
}

.nav-item.active {
  background: rgba(196,120,90,0.25);
  color: #f0c4b0;
}

.nav-icon {
  font-size: 1rem;
  opacity: 0.8;
  width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn-ghost {
  flex: 1;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(247,244,240,0.7);
  padding: 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font-body);
}

.btn-ghost:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text-inv);
}

/* Main */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

.topbar h1 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.status-pill {
  font-size: 0.75rem;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}

.status-pill.ready {
  background: #e6f0e8;
  color: var(--success);
}

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

.view {
  display: none;
}

.view.active {
  display: block;
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 600;
  color: var(--text);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.panel {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.panel-header h2 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
}

.panel-body {
  padding: 12px 0;
  max-height: 320px;
  overflow-y: auto;
}

.panel-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.panel-item:last-child {
  border-bottom: none;
}

.panel-item .meta {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.empty {
  padding: 24px 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
}

/* Toolbar */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 16px;
}

.search-wrap {
  flex: 1;
  max-width: 320px;
}

.search-wrap input {
  width: 100%;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  background: var(--bg-card);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.search-wrap input:focus {
  border-color: var(--accent);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn.primary {
  background: var(--accent);
  color: white;
}

.btn.primary:hover {
  background: var(--accent-hover);
}

.btn.secondary {
  background: var(--accent-soft);
  color: var(--accent);
}

.btn.secondary:hover {
  background: #edd5c8;
}

.btn.danger {
  background: #f5e0e0;
  color: var(--danger);
}

.btn.danger:hover {
  background: #edd0d0;
}

.btn.sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

/* Tables */
.table-wrap {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th {
  text-align: left;
  padding: 14px 18px;
  background: #faf8f6;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: #faf8f6;
}

.data-table .actions {
  display: flex;
  gap: 6px;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge.success { background: #e6f0e8; color: var(--success); }
.badge.warning { background: #faf3d9; color: #9a7b1a; }
.badge.neutral { background: #eeeae6; color: var(--text-muted); }
.badge.danger  { background: #f5e0e0; color: var(--danger); }
.badge.info    { background: #e3eef5; color: #3a6d8c; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(44, 36, 32, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  background: var(--bg-card);
  border-radius: 14px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}

.modal-close:hover {
  color: var(--text);
}

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

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Forms */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  background: #faf8f6;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  background: white;
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: var(--bg-sidebar);
  color: var(--text-inv);
  padding: 14px 22px;
  border-radius: 10px;
  font-size: 0.9rem;
  box-shadow: 0 8px 30px rgba(0,0,0,0.2);
  z-index: 2000;
  animation: toastIn 0.25s ease;
}

.toast.hidden {
  display: none;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Responsive */
@media (max-width: 900px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .sidebar {
    width: 200px;
  }
}

@media (max-width: 640px) {
  #app {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    height: auto;
  }
  .brand {
    flex: 1;
    padding: 16px;
  }
  .nav {
    flex-direction: row;
    flex-wrap: wrap;
    padding: 8px;
    width: 100%;
  }
  .nav-item {
    padding: 8px 12px;
    font-size: 0.8rem;
  }
  .sidebar-footer {
    display: none;
  }
  .content {
    padding: 16px;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
}

/* ===== Agenda ===== */
.agenda-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.agenda-header h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  min-width: 200px;
  text-align: center;
}
.agenda-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
}
.calendar-grid {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.cal-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: #faf8f6;
  border-bottom: 1px solid var(--border);
}
.cal-header span {
  padding: 10px 4px;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
}
.cal-body {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}
.cal-day {
  min-height: 90px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 6px;
  font-size: 0.8rem;
  position: relative;
}
.cal-day:nth-child(7n) { border-right: none; }
.cal-day.other-month { background: #faf8f6; color: #bbb; }
.cal-day.today { background: var(--accent-soft); }
.cal-day .day-num {
  font-weight: 600;
  margin-bottom: 4px;
}
.cal-event {
  background: var(--accent);
  color: white;
  font-size: 0.7rem;
  padding: 2px 5px;
  border-radius: 4px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.cal-event:hover { opacity: 0.9; }

@media (max-width: 900px) {
  .agenda-layout { grid-template-columns: 1fr; }
}
