:root {
  --ivory: #FAF8F5;
  --ivory-2: #FDFCF9;
  --gold: #D4B26F;
  --gold-dark: #B38E3A;
  --emerald: #1B3B36;
  --emerald-deep: #032521;
  --charcoal: #1E1A16;
  --bronze-muted: #2C2621;
  --border: rgba(179, 142, 58, .3);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', sans-serif;
  background: var(--ivory);
  color: var(--charcoal);
}

.font-display { font-family: 'Playfair Display', serif; }

a { color: inherit; }

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

.sidebar {
  width: 220px;
  background: var(--emerald);
  color: #fff;
  padding: 24px 16px;
  flex-shrink: 0;
}
.sidebar h1 { font-size: 1.2rem; margin: 0 0 24px; }
.sidebar nav a {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  color: rgba(255,255,255,.8);
  text-decoration: none;
  font-size: .9rem;
  margin-bottom: 4px;
  cursor: pointer;
}
.sidebar nav a:hover, .sidebar nav a.active { background: rgba(212,178,111,.15); color: var(--gold); }
.sidebar .logout { margin-top: 32px; font-size: .8rem; color: rgba(255,255,255,.5); cursor: pointer; }

.main { flex: 1; padding: 24px 32px; overflow-x: auto; }
.main h2 { font-family: 'Playfair Display', serif; color: var(--emerald); margin-top: 0; }

.view { display: none; }
.view.active { display: block; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--ivory-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.stat-card .value { font-size: 1.6rem; font-weight: 700; color: var(--emerald); }
.stat-card .label { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--bronze-muted); }

table { width: 100%; border-collapse: collapse; background: var(--ivory-2); border-radius: 12px; overflow: hidden; }
th, td { text-align: left; padding: 10px 12px; font-size: .85rem; border-bottom: 1px solid var(--border); }
th { background: rgba(179,142,58,.1); text-transform: uppercase; font-size: .7rem; letter-spacing: .05em; }
tr:last-child td { border-bottom: none; }

.btn {
  display: inline-block;
  background: var(--gold-dark);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: .85rem;
  cursor: pointer;
  font-weight: 600;
}
.btn:hover { background: var(--gold); }
.btn.secondary { background: transparent; border: 1px solid var(--border); color: var(--emerald); }
.btn.danger { background: #b3403a; }
.btn.small { padding: 4px 10px; font-size: .75rem; }

.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar input, .toolbar select { padding: 8px; border: 1px solid var(--border); border-radius: 8px; font-size: .85rem; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .7rem; font-weight: 600; }
.badge.pendiente { background: #f3e0b0; color: #6b5220; }
.badge.confirmada { background: #cfe8d8; color: #1B3B36; }
.badge.completada { background: #d6e4f0; color: #1a3a5c; }
.badge.cancelada { background: #f0d0cd; color: #7a2a24; }
.badge.expirada { background: #eaeaea; color: #555; }
.badge.no_show { background: #f0d0cd; color: #7a2a24; }

.day-grid { display: grid; grid-template-columns: 60px repeat(var(--cols, 1), 1fr); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--ivory-2); }
.day-grid .head { background: rgba(179,142,58,.1); font-weight: 600; padding: 8px; font-size: .8rem; text-align: center; }
.day-grid .hour-label { font-size: .7rem; color: var(--bronze-muted); padding: 4px; text-align: right; border-top: 1px solid var(--border); }
.day-grid .slot-cell { border-top: 1px solid var(--border); border-left: 1px solid var(--border); min-height: 24px; position: relative; }
.appt-block {
  position: absolute; left: 2px; right: 2px; border-radius: 6px; color: #fff; font-size: .7rem;
  padding: 2px 4px; overflow: hidden; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); display: none;
  align-items: center; justify-content: center; z-index: 50; padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--ivory-2); border-radius: 16px; padding: 24px; max-width: 480px; width: 100%;
  max-height: 90vh; overflow-y: auto;
}
.modal-box h3 { margin-top: 0; font-family: 'Playfair Display', serif; color: var(--emerald); }
.form-row { margin-bottom: 12px; }
.form-row label { display: block; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; color: var(--bronze-muted); }
.form-row input, .form-row select, .form-row textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: .9rem;
}
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

.login-shell { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: var(--ivory-2); border: 1px solid var(--border); border-radius: 16px; padding: 32px; width: 320px; }
.login-card h1 { font-family: 'Playfair Display', serif; color: var(--emerald); text-align: center; }
.error-text { color: #b3403a; font-size: .8rem; margin-top: 8px; }
