:root {
  --brand: #0f766e;
  --ink: #14213d;
  --muted: #5c6b7a;
  --bg: #f3f6f8;
  --card: #ffffff;
  --line: #d9e2ec;
  --ok: #047857;
  --danger: #b91c1c;
  --radius: 14px;
  --shadow: 0 18px 50px rgba(20, 33, 61, 0.08);
  font-family: "Segoe UI", "Avenir Next", "Trebuchet MS", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, color-mix(in srgb, var(--brand) 22%, white), transparent),
    linear-gradient(180deg, #eef3f6, var(--bg) 40%);
  min-height: 100vh;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { width: min(1100px, calc(100% - 2rem)); margin: 0 auto; }
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--ink);
  text-decoration: none;
}
.brand-mark {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 0.7rem;
  background: var(--brand);
  box-shadow: inset 0 0 0 3px color-mix(in srgb, white 35%, transparent);
}
.nav { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.hero {
  padding: 3.5rem 0 2.5rem;
  display: grid;
  gap: 1rem;
}
.hero h1 {
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1.1;
  margin: 0;
  max-width: 14ch;
}
.hero p {
  margin: 0;
  color: var(--muted);
  max-width: 40rem;
  font-size: 1.05rem;
}
.actions { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: .5rem; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  padding: .75rem 1.2rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { filter: brightness(1.05); text-decoration: none; }
.btn-ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  padding: 1rem 0 3rem;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem;
  box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 .35rem; font-size: 1rem; }
.card p { margin: 0; color: var(--muted); font-size: .92rem; }
.badge {
  display: inline-block;
  font-size: .75rem;
  padding: .2rem .5rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--brand) 15%, white);
  color: var(--brand);
  margin-bottom: .5rem;
}
.badge.off { background: #eee; color: #777; }

.flash {
  padding: .85rem 1rem;
  border-radius: 12px;
  margin: 1rem 0;
}
.flash-success { background: #ecfdf5; color: var(--ok); }
.flash-error { background: #fef2f2; color: var(--danger); }

.auth-box {
  width: min(420px, calc(100% - 2rem));
  margin: 3rem auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
label { display: block; font-size: .9rem; margin: .75rem 0 .35rem; }
input, select, textarea {
  width: 100%;
  padding: .7rem .8rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  background: #fff;
}
table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
}
th, td {
  text-align: left;
  padding: .75rem .9rem;
  border-bottom: 1px solid var(--line);
  font-size: .95rem;
}
th { background: #f8fafc; color: var(--muted); font-weight: 600; }

.admin-shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: #102a43;
  color: #d9e2ec;
  padding: 1.25rem;
}
.sidebar .brand { color: #fff; margin-bottom: 1.5rem; }
.sidebar a {
  display: block;
  color: #d9e2ec;
  padding: .55rem .7rem;
  border-radius: 10px;
  margin-bottom: .25rem;
  text-decoration: none;
}
.sidebar a:hover, .sidebar a.active { background: rgba(255,255,255,.08); text-decoration: none; }
.admin-main { padding: 1.5rem; }
.admin-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.stat strong { display: block; font-size: 1.6rem; }
.stat span { color: var(--muted); font-size: .9rem; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; margin-bottom: 1rem; }
.muted { color: var(--muted); }
.inline-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem; align-items: end; }
.inline-form .full { grid-column: 1 / -1; }

.message-thread { display: flex; flex-direction: column; gap: .75rem; }
.msg-bubble {
  max-width: min(640px, 92%);
  padding: .85rem 1rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #f8fafc;
}
.msg-mine {
  align-self: flex-end;
  background: color-mix(in srgb, var(--brand) 12%, white);
  border-color: color-mix(in srgb, var(--brand) 25%, var(--line));
}
.msg-theirs { align-self: flex-start; }
.msg-meta { font-size: .8rem; color: var(--muted); margin-bottom: .35rem; }
.msg-body { white-space: normal; line-height: 1.45; }

.ai-result {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--brand) 8%, white);
  line-height: 1.5;
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: .75rem;
}
.week-day {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: .75rem;
  background: #f8fafc;
  min-height: 7.5rem;
}
.week-day h3 {
  margin: 0 0 .55rem;
  font-size: .92rem;
}
.week-slot {
  font-size: .85rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .45rem .55rem;
  margin-bottom: .45rem;
}
.day-checks {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: .85rem 1rem;
  margin: 0;
}
.day-checks legend {
  padding: 0 .35rem;
  font-weight: 600;
}
.day-checks-row {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem 1rem;
}
.day-check {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  margin: 0;
  font-weight: 500;
}

@media (max-width: 860px) {
  .admin-shell { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr; }
  .sidebar { display: flex; flex-wrap: wrap; gap: .35rem; }
  .sidebar a { display: inline-block; }
  .week-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .week-grid { grid-template-columns: 1fr; }
}
