:root {
  --bg-a: #f6fafc;
  --bg-b: #dcebf1;
  --surface: #ffffff;
  --text: #202b33;
  --muted: #60727d;
  --brand: #00577a;
  --brand-bright: #08779d;
  --brand-deep: #00384f;
  --accent: var(--brand);
  --accent-strong: var(--brand-deep);
  --warn: #8f1d2c;
  --line: #d6e2e8;
  --soft: #edf4f7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  line-height: 1.5;
  background: radial-gradient(900px 520px at 100% -10%, rgba(55, 159, 190, 0.2) 0%, transparent 62%),
              radial-gradient(720px 440px at -10% 15%, rgba(0, 87, 122, 0.09) 0%, transparent 66%),
              linear-gradient(155deg, var(--bg-a), var(--bg-b));
}

.lang-float {
  position: fixed;
  top: 16px;
  right: 18px;
  z-index: 40;
}

.lang-float a {
  color: var(--muted);
  text-decoration: none;
  border: 0;
  background: transparent;
  border-radius: 999px;
  width: 44px;
  height: 40px;
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  line-height: 1;
}

.lang-float a:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.72);
}

h1, h2 {
  margin: 0;
}

a {
  color: inherit;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid rgba(0, 56, 79, 0.1);
  backdrop-filter: blur(14px);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 8px 30px rgba(0, 56, 79, 0.05);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-identity {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.topbar-context {
  padding-left: 18px;
  border-left: 1px solid var(--line);
  min-width: 0;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--brand-deep);
  text-decoration: none;
}

.brand-mark {
  width: 56px;
  height: 56px;
  flex: 0 0 auto;
  object-fit: contain;
}

.brand-wordmark {
  display: grid;
  line-height: 1;
}

.brand-wordmark strong {
  font-size: 1.45rem;
  letter-spacing: -0.045em;
}

.brand-wordmark small {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.brand-lockup-compact .brand-mark {
  width: 44px;
  height: 44px;
}

.brand-lockup-compact .brand-wordmark strong {
  font-size: 1.18rem;
}

.brand-lockup-compact .brand-wordmark small {
  font-size: 0.62rem;
}

.topbar h1 {
  font-size: clamp(1.25rem, 2.4vw, 1.7rem);
  line-height: 1.15;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand);
  font-weight: 700;
}

.wrap {
  max-width: 980px;
  margin: 26px auto;
  padding: 0 22px 34px;
  display: grid;
  gap: 16px;
}

.wide {
  max-width: 1200px;
}

.card {
  background: var(--surface);
  border: 1px solid rgba(0, 56, 79, 0.09);
  border-radius: 18px;
  box-shadow: 0 16px 42px rgba(0, 56, 79, 0.09);
  overflow: hidden;
}

.panel {
  padding: 22px;
}

.narrow {
  max-width: 460px;
  margin: 56px auto;
}

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

.panel h2 {
  margin: 0 0 8px;
}

.panel p {
  margin: 0 0 14px;
}

.panel-divider {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 14px 0 12px;
}

.section-subhead {
  margin: 0 0 8px;
  font-size: 1rem;
}

.card-lite {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

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

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

.form-grid > *:last-child {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.95rem;
}

input,
select,
button {
  font: inherit;
  border-radius: 10px;
}

input,
select {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  min-height: 44px;
  padding: 10px 12px;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--brand-bright);
  box-shadow: 0 0 0 3px rgba(8, 119, 157, 0.16);
}

button,
.link-btn {
  border: none;
  background: linear-gradient(135deg, var(--brand-bright), var(--brand-deep));
  color: #fff;
  padding: 9px 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  font-size: 0.92rem;
}

button:hover,
.link-btn:hover {
  filter: brightness(1.06);
}

button.ghost,
.link-btn.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}

.lang-inline {
  width: 42px;
  height: 38px;
  padding: 0;
  border: 0 !important;
  background: transparent !important;
  display: grid;
  place-items: center;
  font-size: 1.35rem;
  line-height: 1;
}

.icon-link {
  width: 34px;
  height: 32px;
  padding: 0;
  display: grid;
  place-items: center;
  line-height: 1;
}

.icon-link svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.icon-link-large svg {
  width: 20px;
  height: 20px;
}

button.danger {
  background: linear-gradient(135deg, #b91c1c, #991b1b);
}

button.warn {
  background: linear-gradient(135deg, #facc15, #eab308);
  color: #1f2937;
}

button.subtle {
  opacity: 0.8;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.check input {
  margin: 0;
}

.switch-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}

.list-toggle {
  margin: 0 0 10px;
  max-width: 260px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #cbd5e1;
  transition: 0.2s;
  border-radius: 999px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  top: 3px;
  background-color: #fff;
  transition: 0.2s;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.switch input:checked + .slider {
  background-color: var(--accent);
}

.switch input:checked + .slider:before {
  transform: translateX(20px);
}

.inline {
  display: inline;
}

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

.actions form {
  display: inline-flex;
  gap: 0;
}

.actions .link-btn,
.actions button {
  min-height: 32px;
  padding: 5px 10px;
  border-radius: 10px;
  display: inline-grid;
  place-items: center;
  line-height: 1;
}

.actions .icon-link,
.actions .lang-inline {
  width: 42px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  display: inline-grid;
  place-items: center;
}

.gate-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.gate-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  display: grid;
  gap: 6px;
  text-decoration: none;
  background: var(--soft);
}

.gate-item:hover {
  transform: translateY(-1px);
}

.select-number-btn {
  justify-self: start;
}

.compact-list {
  display: grid;
  gap: 8px;
}

.log-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.available-picker {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  max-height: 420px;
  overflow: auto;
}

.available-search-label {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 0;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

#available-search {
  width: 100%;
}

#available-list {
  padding: 8px;
}

.compact-item {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
}

.pop-item {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.pop-item.ready {
  opacity: 1;
  transform: translateY(0);
}

.compact-item:focus {
  outline: none;
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}

.compact-item.picked {
  border-color: var(--accent);
  background: #edf8f4;
}

.mono {
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
}

.pick-hint {
  font-size: 0.85rem;
  color: var(--muted);
}

.hidden-data {
  display: none;
}

#register-gate-btn {
  width: fit-content;
  padding: 8px 12px;
  font-size: 0.92rem;
}

.btn-compact {
  width: fit-content;
  padding: 7px 11px;
  font-size: 0.88rem;
}

.title-sep {
  color: var(--muted);
  margin: 0 4px;
}

.title-meta {
  font-size: 0.95rem;
  color: var(--muted);
  font-weight: 600;
}

.terminate-row {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
}

.phone-short {
  max-width: 180px;
}

#auth_value {
  max-width: none;
  width: 100%;
}

.caller-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(110px, 0.85fr) minmax(220px, 1.35fr) minmax(260px, 1.8fr) minmax(120px, 0.95fr);
  column-gap: 4px;
  row-gap: 8px;
  align-items: end;
}

.auth-method {
  min-width: 92px;
}

.access-mode {
  min-width: 110px;
}

#grant-form {
  gap: 8px;
}

#grant-form .btn-compact {
  margin-top: 0;
}

#duration-start-wrap,
#duration-days-wrap,
#duration-until-wrap {
  display: none;
}

.terminate-form {
  margin-top: 12px;
}

.danger-zone {
  border-color: rgba(185, 28, 28, 0.22);
}

table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

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

th {
  background: var(--soft);
}

.cell-actions {
  text-align: right;
  white-space: nowrap;
}

.cell-actions form {
  display: inline-block;
  margin-left: 4px;
}

.cell-actions form:first-child {
  margin-left: 0;
}

.grant-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  min-width: 0;
}

.grant-actions .action-left {
  margin-right: 0;
}

.grant-actions .action-right {
  margin-left: 0;
}

.grants-table .status-col {
  width: 110px;
  white-space: nowrap;
}

.grants-table .action-col {
  width: 124px;
}

.compact-table th,
.compact-table td {
  padding: 7px 9px;
  font-size: 0.88rem;
}

.compact-contacts {
  margin-top: 8px;
}

.notify-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--line);
}

.notify-failed {
  background: #fff7ed;
  color: #9a3412;
  border-color: #fed7aa;
}

.notify-all {
  background: #ecfeff;
  color: #155e75;
  border-color: #a5f3fc;
}

.notify-none {
  background: #f8fafc;
  color: #475569;
  border-color: #cbd5e1;
}

.btn-xs {
  padding: 4px 8px;
  font-size: 0.78rem;
}

.error {
  color: var(--warn);
  font-weight: 600;
}

.error-banner {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(143, 29, 44, 0.28);
  color: var(--warn);
  background: rgba(143, 29, 44, 0.08);
}

.ok-banner {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(11, 110, 79, 0.3);
  color: #065f46;
  background: rgba(11, 110, 79, 0.12);
}

.input-hint {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.trigger-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.notify-mode-field {
  max-width: 130px;
}

.notify-mode-select {
  padding-right: 28px;
  border-radius: 999px;
  background-color: #fff;
  font-size: 0.88rem;
}

.auth-shell {
  min-height: 100vh;
  max-width: 1180px;
  margin: 0 auto;
  padding: 48px 28px;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.92fr);
  gap: clamp(36px, 7vw, 84px);
  align-items: center;
  position: relative;
  z-index: 1;
}

.auth-page {
  background: radial-gradient(circle at 15% 15%, rgba(16, 129, 165, 0.32), transparent 34%),
              radial-gradient(circle at 95% 80%, rgba(46, 151, 180, 0.2), transparent 30%),
              linear-gradient(145deg, #002d40 0%, #004b68 52%, #00364b 100%);
  overflow-x: hidden;
}

.auth-page::before,
.auth-page::after {
  content: "";
  position: fixed;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  pointer-events: none;
}

.auth-page::before {
  width: 520px;
  height: 520px;
  left: -260px;
  bottom: -260px;
}

.auth-page::after {
  width: 360px;
  height: 360px;
  right: -180px;
  top: -180px;
}

.auth-page .lang-float a {
  color: rgba(255, 255, 255, 0.82);
}

.auth-page .lang-float a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.auth-hero {
  padding: 18px 0;
  color: #fff;
}

.auth-brand {
  margin-bottom: clamp(36px, 7vh, 76px);
  color: #fff;
}

.auth-brand .brand-mark {
  width: 74px;
  height: 74px;
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.2));
}

.auth-brand .brand-wordmark strong {
  font-size: clamp(1.8rem, 4vw, 2.35rem);
}

.auth-brand .brand-wordmark small {
  color: rgba(255, 255, 255, 0.66);
}

.auth-hero h1 {
  margin: 0 0 18px;
  max-width: 11ch;
  font-size: clamp(2.4rem, 5.5vw, 4.6rem);
  letter-spacing: -0.045em;
  line-height: 0.98;
}

.auth-hero p {
  margin: 0 0 22px;
  max-width: 50ch;
  color: rgba(255, 255, 255, 0.74);
  font-size: 1.02rem;
}

.auth-hero .eyebrow {
  color: #80cce4;
  letter-spacing: 0.13em;
}

.auth-list {
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
  list-style: none;
  color: rgba(255, 255, 255, 0.86);
}

.auth-list li {
  display: flex;
  align-items: center;
  gap: 10px;
}

.auth-list li::before {
  content: "";
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #76c9df;
  box-shadow: 0 0 0 5px rgba(118, 201, 223, 0.12);
}

.auth-card {
  padding: clamp(26px, 4vw, 40px);
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: 0 28px 80px rgba(0, 25, 36, 0.32);
}

.auth-card h2 {
  margin: 0 0 8px;
  font-size: clamp(1.55rem, 3vw, 2rem);
  letter-spacing: -0.025em;
}

.auth-card-copy {
  margin: 0 0 24px;
  color: var(--muted);
}

.dev-notice {
  margin: 0 0 18px;
  padding: 10px 12px;
  border: 1px solid rgba(8, 119, 157, 0.24);
  border-radius: 10px;
  color: var(--brand-deep);
  background: rgba(8, 119, 157, 0.08);
  font-size: 0.88rem;
  font-weight: 650;
}

.auth-form {
  gap: 16px;
}

.auth-submit {
  width: 100%;
  min-height: 46px;
  margin-top: 4px;
  font-weight: 700;
}

.auth-switch {
  margin: 22px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  text-align: center;
}

.auth-switch a {
  color: var(--brand);
  font-weight: 700;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.confirm-modal {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0;
  max-width: 360px;
  width: calc(100% - 28px);
  color: var(--text);
  background: #fff;
  box-shadow: 0 16px 36px rgba(10, 24, 42, 0.28);
}

.confirm-modal::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.confirm-modal-body {
  margin: 0;
  padding: 16px;
  display: grid;
  gap: 10px;
}

.confirm-modal-body h3 {
  margin: 0;
  font-size: 1.02rem;
}

.confirm-modal-body p {
  margin: 0;
  color: var(--muted);
}

.confirm-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

@media (max-width: 820px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    padding: 16px;
  }

  .topbar-identity {
    width: 100%;
    align-items: flex-start;
  }

  .brand-lockup-compact .brand-wordmark small {
    display: none;
  }

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

  .actions {
    width: 100%;
    justify-content: flex-start;
  }

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

  thead {
    display: none;
  }

  tr {
    border-top: 1px solid var(--line);
    padding: 8px 10px;
  }

  td {
    border: none;
    padding: 7px 2px;
  }

  .wrap {
    padding: 0 12px 24px;
  }

  .panel {
    padding: 16px;
  }

  .auth-shell {
    grid-template-columns: 1fr;
    padding: 24px 16px 30px;
    gap: 24px;
  }

  .auth-hero {
    padding: 6px;
  }

  .auth-brand {
    margin-bottom: 34px;
  }

  .auth-brand .brand-mark {
    width: 58px;
    height: 58px;
  }

  .auth-hero h1 {
    max-width: 13ch;
    font-size: clamp(2.35rem, 13vw, 3.6rem);
  }

  .auth-card {
    padding: 24px 20px;
  }

  .caller-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .topbar-identity {
    gap: 10px;
  }

  .topbar-context {
    padding-left: 10px;
  }

  .brand-lockup-compact .brand-mark {
    width: 38px;
    height: 38px;
  }

  .brand-lockup-compact .brand-wordmark {
    display: none;
  }
}
