:root {
  --bg: #121826;
  --ink: #10182a;
  --card: #f4f7fb;
  --line: #d2dced;
  --pine: #121a2c;
  --pine-deep: #0b101a;
  --amber: #243044;
  --amber-soft: #d6e4f7;
  --danger: #8d2f2f;
  --danger-bg: #fdeeee;
  --ok: #1a2744;
  --ok-bg: #e5eef8;
  --muted: #5a6b84;
  --shadow: 0 18px 50px rgba(6, 10, 18, 0.35);
  --serif: "Source Serif 4", "Palatino Linotype", Palatino, serif;
  --sans: "Figtree", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  font-family: var(--sans);
  overflow-x: hidden;
  background:
    radial-gradient(900px 420px at 0% -10%, #1c2942 0%, transparent 62%),
    linear-gradient(180deg, #0e1522 0%, var(--bg) 46%);
}

button,
input,
select {
  font: inherit;
  font-size: 16px;
  color: inherit;
}

a { color: inherit; }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding:
    max(14px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    14px
    max(16px, env(safe-area-inset-left));
  background: var(--pine-deep);
  color: #f3f6fb;
}

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

.mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--amber);
  color: #f3f6fb;
  font-family: var(--serif);
  font-size: 1.6rem;
  font-weight: 700;
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.72rem;
  opacity: 0.75;
}

.brand h1,
.brand strong {
  display: block;
  margin: 2px 0 0;
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  text-decoration: none;
  border: 1px solid rgba(243, 246, 251, 0.35);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.95rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.nav-link:hover { background: rgba(255, 255, 255, 0.08); }

main {
  width: min(760px, calc(100% - 24px));
  margin: 20px auto 32px;
  padding-bottom: env(safe-area-inset-bottom);
}

.admin-page main { width: min(1180px, calc(100% - 32px)); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 8px solid var(--amber);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.intro h2,
.panel-head h2,
.login-card h2 {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 650;
  letter-spacing: -0.03em;
}

.lede,
.note,
.field-error,
.form-error,
.login-error {
  color: var(--muted);
  line-height: 1.5;
}

.lede { margin: 0 0 8px; }

.note {
  margin: 0 0 22px;
  font-size: 0.95rem;
}

form { display: grid; gap: 16px; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.92rem;
  font-weight: 700;
}

.req { color: var(--danger); }

input,
select {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid #c5d2e4;
  border-radius: 12px;
  background: white;
}

select:disabled {
  background: #eef2f7;
  color: var(--muted);
}

input:focus,
select:focus {
  outline: 3px solid var(--amber-soft);
  border-color: var(--amber);
}

.phone {
  display: flex;
  align-items: stretch;
}

.phone-prefix {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  min-width: 64px;
  padding: 0 12px;
  border: 1px solid #c5d2e4;
  border-right: 0;
  border-radius: 12px 0 0 12px;
  background: var(--amber-soft);
  font-weight: 800;
}

.phone input {
  border-radius: 0 12px 12px 0;
}

.field-error,
.form-error,
.login-error {
  margin: 6px 0 0;
  color: var(--danger);
  font-size: 0.88rem;
}

.form-error,
.login-error {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--danger-bg);
}

.primary,
.ghost,
.danger {
  min-height: 48px;
  border-radius: 12px;
  border: 0;
  cursor: pointer;
  font-weight: 700;
}

form .primary { width: 100%; }

td .danger {
  min-height: 36px;
  padding: 6px 12px;
}

.primary {
  background: var(--pine);
  color: white;
}

.primary:hover { background: var(--pine-deep); }

.primary:disabled {
  cursor: wait;
  opacity: 0.7;
}

.ghost,
.danger {
  background: white;
  border: 1px solid #c5d2e4;
}

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

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

.modal {
  width: min(480px, calc(100% - 24px));
  max-height: min(90dvh, 720px);
  margin: auto;
  padding: 22px 18px;
  overflow: auto;
  border: 1px solid var(--line);
  border-top: 8px solid var(--amber);
  border-radius: 18px;
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(6, 10, 18, 0.72);
}

.modal h2 {
  margin: 0 0 16px;
  font-family: var(--serif);
  font-size: 1.7rem;
  line-height: 1.25;
}

.badge {
  display: inline-flex;
  width: fit-content;
  margin: 0;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--ok-bg);
  color: var(--ok);
  font-weight: 750;
  font-size: 0.85rem;
}

dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

.pair {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

dt { color: var(--muted); }

dd {
  margin: 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.panel-head,
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.panel-head { margin-bottom: 18px; }

.panel-head p,
.count {
  margin: 0;
  color: var(--muted);
}

.toolbar { margin-bottom: 14px; }

.toolbar input {
  width: min(320px, 100%);
  max-width: none;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
  background: white;
}

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

th {
  background: var(--pine);
  color: white;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}

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

tbody tr:nth-child(even) { background: #f3f7fc; }

.phone-cell {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.empty {
  padding: 28px 8px;
  text-align: center;
  color: var(--muted);
}

.login-card { width: min(460px, 100%); margin: 0 auto; }

.foot {
  margin: 18px 4px 0;
  color: var(--muted);
  font-size: 0.85rem;
}

:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 2px;
}

@media (max-width: 700px) {
  .top { gap: 8px; }

  .mark {
    width: 40px;
    height: 40px;
    font-size: 1.35rem;
    flex-shrink: 0;
  }

  .brand h1,
  .brand strong,
  .intro h2,
  .panel-head h2,
  .login-card h2,
  .modal h2 {
    font-size: 1.45rem;
  }

  main { width: min(760px, calc(100% - 16px)); }

  .card { padding: 16px; }

  .grid-2,
  .panel-head,
  .toolbar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .pair {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .toolbar input,
  .actions,
  .actions .primary,
  .ghost,
  td .danger {
    width: 100%;
  }

  .table-wrap {
    overflow: visible;
    border: 0;
    border-radius: 0;
  }

  table {
    min-width: 0;
    background: transparent;
  }

  thead { display: none; }

  tbody tr {
    display: block;
    margin-bottom: 12px;
    padding: 4px 14px 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: white;
  }

  tbody tr:nth-child(even) { background: white; }

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

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 700;
  }

  td:last-child {
    display: block;
    padding-top: 12px;
    border-bottom: 0;
  }

  td:last-child::before { content: none; }
}
