:root {
  --bg: #ffffff;
  --chrome: #f7f9fc;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #111827;
  --muted: #64748b;
  --line: #e5e7eb;
  --line-strong: #cbd5e1;
  --brand: #2563eb;
  --brand-2: #0f766e;
  --accent: #4f46e5;
  --danger: #b42318;
  --warn: #a15c07;
  --ok: #067647;
  --shadow: 0 18px 42px rgba(15, 23, 42, .08);
  --soft-shadow: 0 1px 2px rgba(15, 23, 42, .05);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
}
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: none; }
.app-frame {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px 14px;
  background: var(--chrome);
  border-right: 1px solid var(--line);
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 68px;
  padding: 12px 28px;
  background: rgba(255,255,255,.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); padding: 6px; border-radius: 8px; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  font-weight: 800;
}
.brand span:last-child { display: grid; line-height: 1.05; }
.brand small { color: var(--muted); margin-top: 4px; font-weight: 650; }
.nav { display: flex; align-items: stretch; gap: 4px; flex-direction: column; }
.public-nav { flex-direction: row; align-items: center; gap: 14px; }
.nav a {
  display: flex;
  align-items: center;
  min-height: 38px;
  color: #334155;
  font-weight: 700;
  padding: 0 11px;
  border-radius: 8px;
}
.nav a:hover { background: #eef2ff; color: #1e3a8a; }
.nav a.active { background: #dbeafe; color: #1d4ed8; box-shadow: inset 3px 0 0 var(--brand); }
.new-record {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  box-shadow: var(--soft-shadow);
}
.new-record:hover { color: #fff; background: #1d4ed8; }
.sidebar-foot {
  margin-top: auto;
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
}
.sidebar-foot span { color: var(--text); font-weight: 800; }
.shell {
  width: min(1260px, calc(100% - 48px));
  margin: 26px auto 60px;
}
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr);
  gap: 28px;
  align-items: stretch;
  min-height: calc(100vh - 150px);
}
.hero-copy { display: flex; flex-direction: column; justify-content: center; padding: 30px 0; }
.hero h1 { font-size: 56px; line-height: 1.02; margin: 0 0 18px; max-width: 760px; }
.hero p { color: var(--muted); font-size: 19px; line-height: 1.6; max-width: 660px; }
.hero-panel {
  align-self: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 22px;
}
.quick-grid, .stats, .record-grid, .admin-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.record-grid { grid-template-columns: 1.3fr .7fr; align-items: start; }
.admin-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--soft-shadow);
}
.card { padding: 18px; transition: border-color .16s ease, box-shadow .16s ease; }
.card:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.panel-header, .panel-body { padding: 18px 20px; }
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
  border-radius: 8px 8px 0 0;
}
h1, h2, h3 { letter-spacing: 0; }
h1 { font-size: 32px; margin: 0 0 8px; line-height: 1.14; }
h2 { font-size: 20px; margin: 0; line-height: 1.2; }
h3 { font-size: 13px; margin: 0 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.subtle { color: var(--muted); }
.eyebrow {
  margin: 0 0 8px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  margin-bottom: 18px;
}
.button, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid var(--brand);
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  padding: 0 16px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.button:hover { color: #fff; text-decoration: none; }
.button.secondary, button.secondary { background: #fff; color: var(--text); border-color: var(--line); }
.button.secondary:hover, button.secondary:hover { background: #f8fafc; border-color: var(--line-strong); }
.button.danger { background: var(--danger); border-color: var(--danger); }
.button.small { min-height: 34px; padding: 0 11px; font-size: 13px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field { display: grid; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.form-section {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: #0f172a;
  font-size: 14px;
  font-weight: 850;
}
.form-section:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}
.form-section:before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--brand);
}
.input-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
label { font-weight: 750; font-size: 13px; color: #334155; }
input, select, textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 9px 12px;
  font: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: 3px solid rgba(15, 118, 110, .14);
  border-color: var(--brand);
}
textarea { min-height: 116px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #94a3b8; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
tbody tr { transition: background .14s ease; }
tbody tr:hover { background: #f8fafc; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; background: #fff; }
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 9px;
  background: #eef2f7;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.pill.due { background: #fff4e5; color: var(--warn); }
.pill.overdue { background: #fee4e2; color: var(--danger); }
.pill.ok { background: #dcfae6; color: var(--ok); }
.alert {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
}
.alert.success { border-color: #abeaca; color: var(--ok); }
.alert.error { border-color: #fecdca; color: var(--danger); }
.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.day, .weekday {
  min-height: 110px;
  padding: 9px;
  background: #fff;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.weekday { min-height: auto; background: #f8fafc; color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; }
.day:nth-child(7n), .weekday:nth-child(7n) { border-right: 0; }
.date-num { color: var(--muted); font-weight: 800; font-size: 12px; }
.cal-item { display: block; margin-top: 6px; padding: 6px 7px; border-radius: 6px; background: #eff6ff; color: #1d4ed8; font-size: 12px; font-weight: 800; }
.group-canvas {
  display: grid;
  gap: 6px;
  padding: 6px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid var(--line);
}
.group-stack { display: grid; gap: 6px; }
.group-node {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 48px;
  padding: 8px 11px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(15, 23, 42, .04);
}
.group-node:before {
  content: "";
  position: absolute;
  left: -14px;
  top: 23px;
  width: 12px;
  border-top: 1px solid var(--line);
}
.group-icon {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 7px;
  background: var(--group-color);
  border: 1px solid rgba(32, 33, 36, .12);
  box-shadow: inset 0 0 0 999px rgba(255, 255, 255, .68);
}
.group-node strong { display: block; }
.group-node small { display: block; color: var(--muted); margin-top: 2px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 999px; margin-right: 7px; vertical-align: middle; }
.empty { padding: 28px; color: var(--muted); text-align: center; }
@media (max-width: 850px) {
  .app-frame { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .topbar { align-items: flex-start; flex-direction: column; padding: 14px 16px; }
  .hero, .record-grid { grid-template-columns: 1fr; }
  .hero { min-height: auto; }
  .hero h1 { font-size: 40px; }
  .quick-grid, .stats, .admin-grid, .form-grid { grid-template-columns: 1fr; }
  .input-row { grid-template-columns: 1fr; }
  .day { min-height: 86px; padding: 6px; }
  .page-head { align-items: start; flex-direction: column; }
  .shell { width: min(100% - 24px, 1240px); margin-top: 18px; }
}
