:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --border: #e4e6ee;
  --text: #1a1d29;
  --muted: #6b7280;
  --primary: #2d6cdf;
  --primary-dark: #1f4fa8;
  --danger: #c73434;
  --ok: #1f9d55;
  --warn: #d97706;
  --yellow: #fde68a;
  --green: #bbf7d0;
  --orange: #fed7aa;
  --shadow: 0 1px 2px rgba(20,20,30,.06), 0 4px 12px rgba(20,20,30,.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
main { max-width: 1400px; margin: 24px auto; padding: 0 20px; }

.topbar { display: flex; align-items: center; gap: 20px; padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand a { font-weight: 700; color: var(--text); font-size: 18px; }
.topbar nav { display: flex; gap: 14px; margin-left: 24px; }
.topbar nav a { color: var(--muted); font-weight: 500; }
.topbar nav a:hover { color: var(--text); }
.topbar .user { margin-left: auto; display: flex; align-items: center; gap: 12px; color: var(--muted); }
.footer { text-align: center; color: var(--muted); padding: 24px; }

.btn { display: inline-block; padding: 8px 14px; border-radius: 8px; background: var(--surface); color: var(--text); border: 1px solid var(--border); font-weight: 500; cursor: pointer; font-size: 14px; }
.btn:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-dark); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.google {
  display: inline-flex; align-items: center; gap: 10px;
  width: 100%; justify-content: center;
  padding: 10px 14px;
  background: #fff; color: #3c4043;
  border: 1px solid #dadce0; border-radius: 8px;
  font-family: "Roboto","Helvetica Neue",Arial,sans-serif;
  font-weight: 500; font-size: 14px; letter-spacing: 0.25px;
  transition: box-shadow .15s, background .15s, border-color .15s;
}
.btn.google:hover {
  background: #f8faff; border-color: #d2e3fc;
  box-shadow: 0 1px 2px rgba(60,64,67,.08), 0 1px 3px rgba(60,64,67,.12);
  color: #3c4043; text-decoration: none;
}
.btn.google:active { background: #eef3ff; }
.btn.google .g-logo { flex: 0 0 auto; display: block; }

.btn.magic {
  display: inline-flex; align-items: center; gap: 10px;
  width: 100%; justify-content: center;
  padding: 10px 14px; margin-top: 10px;
  background: #fff; color: #3c4043;
  border: 1px solid #dadce0; border-radius: 8px;
  font-weight: 500; font-size: 14px; letter-spacing: 0.25px;
  transition: box-shadow .15s, background .15s, border-color .15s;
}
.btn.magic:hover {
  background: #f8faff; border-color: #d2e3fc;
  box-shadow: 0 1px 2px rgba(60,64,67,.08), 0 1px 3px rgba(60,64,67,.12);
  color: #3c4043; text-decoration: none;
}
.btn.magic svg { color: #2d6cdf; }
.linkish { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0; }
.linkish:hover { color: var(--text); text-decoration: underline; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 6px; }
.icon-btn:hover { background: var(--bg); text-decoration: none; }
.icon-btn svg { display: block; }

.auth-wrap { min-height: 60vh; display: grid; place-items: center; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 28px; box-shadow: var(--shadow); }
.auth-card h1 { margin: 0 0 16px; font-size: 22px; }
.divider { text-align: center; margin: 12px 0; color: var(--muted); position: relative; }
.divider::before, .divider::after { content: ""; position: absolute; top: 50%; width: 40%; height: 1px; background: var(--border); }
.divider::before { left: 0; } .divider::after { right: 0; }

.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.row > label { flex: 1 1 160px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
input, select, textarea { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font: inherit; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(45,108,223,.25); border-color: var(--primary); }
.inline-check { flex-direction: row; align-items: center; gap: 6px; color: var(--text); }

.alert { padding: 10px 12px; border-radius: 8px; border: 1px solid transparent; font-size: 14px; }
.alert.error { background: #fde2e2; border-color: #f5a5a5; color: #7a1d1d; }
.alert.success { background: #d7f5e3; border-color: #88d7a6; color: #115a35; }

.auth-links { margin-top: 16px; font-size: 14px; color: var(--muted); display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.auth-links a { color: var(--primary); font-weight: 500; }
.auth-links .dot { color: #ccc; }
.muted-note { color: var(--muted); font-size: 13px; margin: 8px 0 14px; text-align: center; }

.cal-head { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.cal-head .nav-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.cal-head h1 { margin: 0; font-size: 22px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.calendar .dow, .calendar .grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.calendar .dow { font-size: 12px; text-transform: uppercase; color: var(--muted); padding: 6px 4px; }
.calendar .grid { grid-auto-rows: minmax(120px, auto); }
.cell { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 6px 8px; display: flex; flex-direction: column; gap: 4px; min-height: 120px; }
.cell.muted { background: #fafbfd; color: var(--muted); }
.cell.today { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; }
.day-head { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); }
.daynum { font-weight: 600; color: var(--text); }
.mini { font-weight: 700; color: var(--muted); padding: 0 4px; }
.mini:hover { color: var(--primary); }
.events { display: flex; flex-direction: column; gap: 2px; }

.chip { display: inline-block; background: var(--yellow); color: #3b2b00; padding: 2px 6px; border-radius: 4px; font-size: 12px; line-height: 1.3; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 1px solid transparent; }
.chip.status-tentative { background: var(--orange); color: #7a3500; }
.chip.status-cancelled { background: #f1f1f1; color: #666; text-decoration: line-through; }
.chip.holiday { background: var(--green); color: #14532d; }
a.chip:hover { text-decoration: none; filter: brightness(.95); }

.legend { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 16px 0; color: var(--muted); font-size: 13px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card h2 { margin: 0 0 12px; font-size: 17px; }

table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
table.data th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.inline-form { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.tag { padding: 2px 8px; background: #eef2ff; color: #3730a3; border-radius: 999px; font-size: 12px; }
.chips { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; }

.form-wrap { max-width: 720px; margin: 0 auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 24px; }
.form-wrap h1 { margin-top: 0; }
.actions { display: flex; gap: 8px; align-items: center; }
.danger-zone { margin-top: 24px; padding-top: 16px; border-top: 1px dashed var(--border); }

.error-page { text-align: center; padding: 60px 0; }
.error-page h1 { font-size: 48px; margin: 0; color: var(--primary); }
details pre { background: #0f172a; color: #e2e8f0; padding: 10px; border-radius: 6px; overflow-x: auto; font-size: 12px; }

@media (max-width: 800px) {
  .calendar .grid { grid-auto-rows: minmax(90px, auto); }
  .cell { min-height: 90px; }
  .chip { font-size: 11px; }
}
