:root {
  color-scheme: light;
  --bg: #eef7f8;
  --panel: #ffffff;
  --text: #18323a;
  --muted: #647982;
  --line: #d4e5e9;
  --accent: #00a6c8;
  --accent-dark: #0086a2;
  --red: #e2373f;
  --error: #be2c32;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(180deg, rgba(0, 166, 200, 0.12), rgba(238, 247, 248, 0) 220px),
    var(--bg);
  color: var(--text);
}

.shell {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0;
}

.shell-wide {
  width: min(1280px, calc(100% - 32px));
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 16px 50px rgba(23, 32, 38, 0.08);
}

.topbar,
.actions,
.toolbar,
.person-card,
.section-heading {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar {
  justify-content: space-between;
  margin-bottom: 24px;
}

.brand-head {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.brand-logo {
  width: 158px;
  max-width: 34vw;
  height: auto;
}

h1,
h2,
h3 {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.15;
}

h2 {
  font-size: 20px;
}

.header-actions,
.toolbar {
  flex-wrap: wrap;
}

.notice {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  background: #f5fbfc;
}

.compact-notice {
  padding: 12px;
}

.login-status {
  margin: 12px 0 0;
}

.app-panel,
.app-section,
.tab-panel,
.settings-form,
.wish-form {
  display: grid;
  gap: 18px;
}

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--muted);
  font-weight: 700;
}

.calendar-legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.legend-box {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
}

.legend-box.preferred,
.calendar-day.preferred,
.matrix-cell.preferred {
  border-color: #66b8d2;
  background: #dff6ff;
}

.legend-box.unavailable,
.calendar-day.unavailable,
.matrix-cell.unavailable {
  border-color: #e49ca1;
  background: #ffe4e7;
}

.legend-box.neutral {
  background: #fff;
}

.calendar-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.calendar-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.month-calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(34px, 1fr));
  gap: 6px;
}

.calendar-weekday {
  display: grid;
  place-items: center;
  min-height: 28px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.calendar-empty,
.calendar-day {
  aspect-ratio: 1;
  min-width: 0;
}

.calendar-day {
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0;
  background: #fff;
  color: var(--text);
}

.calendar-day:hover {
  border-color: var(--accent);
  background: #eefbff;
}

.admin-actions {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.tabs button,
#logout-button,
.secondary-button {
  background: #e3f2f5;
  color: var(--text);
}

.tabs button.active {
  background: var(--accent);
  color: #fff;
}

.secondary-link {
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration: none;
}

.person-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f5fbfc;
}

.person-card img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
}

.person-card div {
  display: grid;
  gap: 2px;
  flex: 1;
}

.person-card span {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.metric-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric-card strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.matrix-wrap {
  max-height: 520px;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

.wish-matrix {
  min-width: max-content;
}

th,
td {
  padding: 12px 13px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 13px;
}

.wish-matrix th {
  min-width: 42px;
  padding: 8px 7px;
  text-align: center;
  white-space: nowrap;
}

.wish-matrix th span,
.wish-matrix th small {
  display: block;
}

.wish-matrix th small {
  color: var(--muted);
  font-size: 11px;
}

.wish-matrix .weekend {
  background: #f8fbfc;
}

.sticky-col {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 180px;
  background: #fff;
  box-shadow: 1px 0 0 var(--line);
}

.wish-matrix thead .sticky-col {
  z-index: 3;
}

.assistant-name-cell {
  font-weight: 700;
  white-space: nowrap;
}

.matrix-cell {
  width: 42px;
  height: 38px;
  padding: 0;
  border-left: 1px solid var(--line);
}

tr:last-child td {
  border-bottom: 0;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

label {
  display: grid;
  gap: 8px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  font: inherit;
  color: var(--text);
  background: #fff;
}

textarea {
  resize: vertical;
}

button {
  border: 0;
  border-radius: 6px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
}

button:hover {
  background: var(--accent-dark);
}

.danger-button {
  background: #f1dddd;
  color: var(--error);
}

.danger-button:hover {
  background: #e8caca;
}

.ok {
  color: var(--accent-dark);
}

.error {
  color: var(--error);
}

@media (max-width: 720px) {
  .topbar,
  .actions,
  .toolbar,
  .person-card {
    align-items: stretch;
    flex-direction: column;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .calendar-pair {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 20px;
  }

  h1 {
    font-size: 24px;
  }

  .brand-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .brand-logo {
    width: 132px;
    max-width: 100%;
  }
}
