:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #20242a;
  --muted: #667085;
  --line: #d9dee7;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --accent: #b45309;
  --danger: #b42318;
  --ok: #067647;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

a {
  color: var(--primary-dark);
  text-decoration: none;
}

.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

nav {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

nav a {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.container {
  width: min(1180px, calc(100% - 32px));
  margin: 28px auto 56px;
}

.hero {
  min-height: calc(100vh - 150px);
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.7fr);
  gap: 32px;
  align-items: center;
}

.hero h1,
.page-head h1 {
  margin: 0;
  font-size: 42px;
  line-height: 1.1;
}

.hero p {
  max-width: 700px;
  color: var(--muted);
  font-size: 18px;
}

.eyebrow {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  margin: 0 0 8px;
}

.schedule,
.panel,
.auth form {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
}

.schedule h2,
.panel h2 {
  margin: 0 0 16px;
}

.schedule p {
  color: var(--text);
  font-size: 15px;
  margin: 12px 0;
}

.button,
button {
  appearance: none;
  border: 0;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  font-weight: 700;
  cursor: pointer;
  font-size: 14px;
  text-align: center;
}

.button:hover,
button:hover {
  background: var(--primary-dark);
}

.button.secondary {
  background: #eef2f6;
  color: var(--text);
}

.mini {
  min-height: 28px;
  padding: 0 9px;
  font-size: 12px;
  border-radius: 5px;
}

.mini.ghost {
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fed7aa;
}

.page-head,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(7, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.compact-stats {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.stats div {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.stats span,
small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.stats strong {
  display: block;
  margin-top: 6px;
  font-size: 22px;
}

.split-summary {
  display: grid;
  grid-template-columns: minmax(240px, 0.7fr) minmax(360px, 1fr);
  gap: 18px;
  align-items: center;
  margin-bottom: 20px;
}

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

.mini-stats div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fafc;
}

.mini-stats span,
.muted-text {
  color: var(--muted);
  font-size: 12px;
}

.mini-stats strong {
  display: block;
  margin-top: 4px;
  font-size: 17px;
}

.table-wrap {
  overflow-x: auto;
}

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

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

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

.tag {
  display: inline-block;
  background: #e8f3f1;
  color: var(--primary-dark);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 700;
  margin: 0 4px 4px 0;
}

.tag.warn {
  background: #fff7ed;
  color: #9a3412;
}

.row-action {
  font-weight: 700;
}

.row-actions {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 190px;
}

.row-actions form {
  margin: 0;
}

.rep-line {
  margin-bottom: 10px;
}

.rep-line:last-child {
  margin-bottom: 0;
}

.backup-list {
  display: grid;
  gap: 12px;
}

.backup-list div {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #f8fafc;
}

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

.danger-text {
  color: var(--danger);
  font-weight: 700;
}

.ok-text {
  color: var(--ok);
  font-weight: 700;
}

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

.filters {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 160px 260px auto;
  gap: 12px;
  margin-bottom: 16px;
}

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

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.readonly-field {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #f8fafc;
}

.readonly-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.readonly-field strong {
  color: var(--text);
  font-size: 16px;
}

.auth {
  min-height: calc(100vh - 170px);
  display: grid;
  place-items: center;
}

.compact {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
}

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

.full,
fieldset,
.actions {
  grid-column: 1 / -1;
}

fieldset {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

legend {
  color: var(--text);
  font-weight: 700;
  padding: 0 8px;
}

.check {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.check input {
  width: auto;
}

.actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.subtle {
  color: var(--muted);
  margin: 8px 0 0;
}

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

.payment-summary div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fafc;
}

.payment-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.payment-summary strong {
  font-size: 18px;
}

.delete-form {
  margin-top: 16px;
}

.delete-form button {
  background: var(--danger);
}

.alerts {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

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

.alert.success {
  border-color: #abefc6;
  color: var(--ok);
}

.alert.error {
  border-color: #fecdca;
  color: var(--danger);
}

@media (max-width: 900px) {
  .topbar,
  .page-head,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .hero,
  .form-grid,
  fieldset,
  .filters {
    grid-template-columns: 1fr;
  }

  .hero h1,
  .page-head h1 {
    font-size: 32px;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .split-summary,
  .mini-stats {
    grid-template-columns: 1fr;
  }

  .payment-summary {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .topbar {
    position: static;
    gap: 12px;
  }

  nav {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  nav a {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #f8fafc;
    font-size: 13px;
  }

  .schedule,
  .panel,
  .auth form {
    padding: 16px;
  }

  .table-wrap {
    overflow: visible;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  table {
    min-width: 0;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 12px;
  }

  tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    padding: 12px;
  }

  td {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    border: 0;
    padding: 8px 0;
    overflow-wrap: anywhere;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
  }

  td:first-child {
    padding-top: 0;
  }

  td:last-child {
    padding-bottom: 0;
  }

  .row-actions {
    min-width: 0;
  }

  .row-actions::before {
    align-self: center;
  }

  .row-actions form,
  .row-actions .mini,
  .row-action {
    width: 100%;
  }

  .row-action {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #f8fafc;
  }
}

@media (max-width: 520px) {
  .container {
    width: min(100% - 20px, 1180px);
    margin-top: 18px;
  }

  .topbar {
    padding: 12px 16px;
  }

  nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .stats div {
    padding: 12px;
  }

  .stats strong {
    font-size: 20px;
  }

  .page-head h1,
  .hero h1 {
    font-size: 28px;
  }

  .actions,
  .actions .button,
  .actions button,
  .filters button {
    width: 100%;
  }

  fieldset {
    padding: 12px;
  }

  td {
    grid-template-columns: 82px minmax(0, 1fr);
  }
}
