:root {
  color-scheme: light;
  --bg: #fbfbff;
  --ink: #10184f;
  --muted: #667099;
  --line: #d8dcef;
  --panel: #ffffff;
  --navy: #10184f;
  --navy-2: #2b356c;
  --purple: #7b66f6;
  --purple-soft: #e5e0ff;
  --yellow: #ffc62e;
  --yellow-soft: #ffe39b;
  --orange: #ff6508;
  --orange-soft: #ffd9cb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(16, 24, 79, 0.035) 1px, transparent 1px),
    linear-gradient(rgba(16, 24, 79, 0.035) 1px, transparent 1px),
    var(--bg);
  background-size: 44px 44px;
  color: var(--ink);
  font-family: Raleway, Rubik, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
  border: 2px solid var(--navy);
  border-radius: 22px;
  background: var(--navy);
  padding: 18px;
  color: #fff;
  box-shadow: 8px 8px 0 var(--purple-soft);
}

.eyebrow {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  margin: 0 0 8px;
  border-radius: 8px;
  background: var(--purple);
  padding: 0 10px;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  color: #fff;
  font-family: Rubik, Raleway, sans-serif;
  font-size: 36px;
  line-height: 1;
}

h2 {
  color: var(--navy);
  font-family: Rubik, Raleway, sans-serif;
  font-size: 20px;
  margin-bottom: 18px;
}

.status,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 8px;
  padding: 0 10px;
  background: var(--purple-soft);
  color: var(--navy);
  font-weight: 900;
  font-size: 13px;
}

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

.admin-actions a,
.link-button {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  border: 2px solid rgba(255, 255, 255, 0.38);
  border-radius: 12px;
  padding: 0 12px;
  background: #fff;
  color: var(--navy);
  font-size: 13px;
  font-weight: 900;
  text-decoration: none;
}

.admin-actions form {
  margin: 0;
}

.admin-actions a:hover,
.link-button:hover {
  background: var(--yellow);
}

.link-button {
  cursor: pointer;
}

.admin-login-page {
  display: grid;
  place-items: center;
  padding: 20px;
}

.admin-login-shell {
  width: min(100%, 440px);
}

.admin-login-card {
  border: 2px solid var(--navy);
  border-radius: 22px;
  background: var(--panel);
  padding: 26px;
  box-shadow: 8px 8px 0 var(--purple-soft), 0 22px 60px rgba(16, 24, 79, 0.12);
}

.admin-login-card h1 {
  margin-bottom: 10px;
  color: var(--navy);
}

.admin-login-card button {
  width: 100%;
}

.admin-login-error {
  border: 2px solid var(--orange);
  border-radius: 12px;
  background: var(--orange-soft);
  padding: 10px 12px;
  color: var(--navy);
  font-size: 13px;
  font-weight: 800;
}

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

.metrics div,
.panel {
  border: 2px solid var(--navy);
  border-radius: 18px;
  background: var(--panel);
}

.metrics div {
  padding: 18px;
  box-shadow: 5px 5px 0 var(--yellow-soft);
}

.metrics span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 8px;
}

.metrics strong {
  color: var(--navy);
  font-family: Rubik, Raleway, sans-serif;
  font-size: 32px;
}

.workspace {
  display: grid;
  grid-template-columns: 350px minmax(0, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}

.birthdays-panel,
.iiko-panel,
.mailing-panel {
  margin-bottom: 12px;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.section-head h2 {
  margin-bottom: 0;
}

.mailing-count {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  border-radius: 12px;
  background: var(--yellow);
  padding: 0 12px;
  color: var(--navy);
  font-size: 14px;
  white-space: nowrap;
}

.sync-ok {
  background: #18c991;
  color: #fff;
}

.sync-warn {
  background: var(--orange-soft);
  color: var(--navy);
}

.iiko-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 12px;
  align-items: start;
}

.iiko-grid .hint {
  margin-bottom: 8px;
}

.iiko-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0 12px;
}

.iiko-summary div {
  border: 1px solid var(--navy);
  border-radius: 12px;
  padding: 12px;
}

.iiko-summary span,
.iiko-summary strong {
  display: block;
}

.iiko-summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 5px;
}

.iiko-summary strong {
  color: var(--navy);
  font-size: 22px;
}

.iiko-summary .iiko-updated {
  font-size: 15px;
}

.iiko-balances-table {
  max-height: 430px;
}

.sync-success {
  color: #087c59;
  font-size: 12px;
  font-weight: 800;
}

.mailing-filters {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

.mailing-filter-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.secondary-link {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 0 12px;
  background: #fff;
  color: var(--navy);
  font-weight: 900;
  text-decoration: none;
}

.secondary-link:hover {
  background: var(--purple-soft);
}

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

.mailing-copy {
  margin-bottom: 0;
}

.mailing-table {
  min-width: 900px;
}

.mailing-table-wrap {
  border: 2px solid var(--line);
  border-radius: 16px;
}

.recipient-check {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 13px;
}

.recipient-check input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--orange);
}

.recipient-check span {
  display: grid;
  gap: 3px;
}

.recipient-check small {
  color: var(--muted);
  font-weight: 700;
}

.sync-error {
  display: block;
  max-width: 240px;
  color: var(--orange);
  font-size: 12px;
  font-weight: 800;
  white-space: normal;
}

.birthday-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}

.birthday-list article {
  display: grid;
  gap: 4px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: #f8f7ff;
  padding: 12px;
}

.birthday-list strong {
  color: var(--navy);
}

.birthday-list span,
.birthday-list small {
  color: var(--muted);
  font-size: 13px;
}

.panel {
  padding: 18px;
}

.hint {
  margin: -8px 0 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

code {
  color: var(--purple);
  font-weight: 900;
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--navy);
  font-size: 13px;
  font-weight: 900;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #f8f8ff;
  padding: 8px 10px;
  color: var(--ink);
  font: inherit;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--purple);
  outline: none;
  box-shadow: 0 0 0 4px rgba(123, 102, 246, 0.18);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 14px;
  background: var(--orange);
  color: white;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  box-shadow: inset 0 -3px 0 rgba(16, 24, 79, 0.22);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.secondary {
  background: var(--purple-soft);
  color: var(--navy);
}

.admin-actions .link-button {
  min-height: 36px;
  background: #fff;
  color: var(--navy);
  box-shadow: none;
}

.admin-actions .link-button:hover {
  background: var(--yellow);
}

.table-panel {
  min-width: 0;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  white-space: nowrap;
}

td:last-child {
  max-width: 280px;
  white-space: normal;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.empty {
  color: var(--muted);
  text-align: center;
}

@media (max-width: 780px) {
  .topbar,
  .workspace {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
    box-shadow: 5px 5px 0 var(--purple-soft);
  }

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

  .section-head,
  .iiko-grid,
  .iiko-summary,
  .mailing-grid,
  .mailing-filters {
    grid-template-columns: 1fr;
  }

  .section-head {
    display: grid;
  }

  .mailing-count {
    justify-content: center;
  }
}
