:root {
  color-scheme: light;
  --navy-950: #0c2840;
  --navy-900: #113753;
  --navy-800: #174a6d;
  --navy-700: #1f5f87;
  --copper: #b96f3d;
  --copper-soft: #f4e4d7;
  --ink: #172635;
  --muted: #657482;
  --canvas: #edf2f5;
  --paper: #ffffff;
  --line: #d7e0e6;
  --danger: #b42318;
  --success: #176b50;
  --shadow: 0 24px 70px rgba(12, 40, 64, 0.16);
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(17, 55, 83, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(17, 55, 83, 0.035) 1px, transparent 1px),
    var(--canvas);
  background-size: 28px 28px;
  font-size: 16px;
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.auth-layout {
  display: grid;
  min-height: 100vh;
  grid-template-columns: minmax(320px, 0.92fr) minmax(420px, 1.08fr);
}

.auth-brand {
  position: relative;
  display: flex;
  min-height: 100%;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  padding: clamp(32px, 5vw, 72px);
  color: #fff;
  background:
    radial-gradient(circle at 18% 18%, rgba(90, 155, 194, 0.32), transparent 33%),
    linear-gradient(145deg, var(--navy-800), var(--navy-950) 72%);
}

.auth-brand::after {
  position: absolute;
  right: -180px;
  bottom: -220px;
  width: 520px;
  height: 520px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 50%;
  box-shadow:
    0 0 0 64px rgba(255, 255, 255, 0.035),
    0 0 0 128px rgba(255, 255, 255, 0.025);
  content: "";
}

.brand-row,
.brand-copy,
.brand-footer {
  position: relative;
  z-index: 1;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.09);
  font-weight: 750;
  letter-spacing: 0.02em;
}

.brand-row strong {
  display: block;
  font-size: 1rem;
}

.brand-row small {
  display: block;
  margin-top: 3px;
  color: #bed0dc;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand-copy {
  max-width: 580px;
}

.brand-copy p {
  margin: 0 0 12px;
  color: #c9d8e2;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.brand-copy h1 {
  max-width: 12ch;
  margin: 0;
  font-size: clamp(2.25rem, 5vw, 4.4rem);
  line-height: 1.03;
  letter-spacing: -0.045em;
}

.brand-copy h1 span {
  color: #e5a475;
}

.brand-footer {
  color: #aebfcb;
  font-size: 0.84rem;
}

.auth-main {
  display: grid;
  min-height: 100%;
  place-items: center;
  padding: clamp(28px, 6vw, 80px);
}

.auth-card {
  width: min(100%, 470px);
  padding: clamp(28px, 4vw, 46px);
  border: 1px solid rgba(184, 198, 207, 0.86);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.auth-card h2 {
  margin: 0;
  color: var(--navy-950);
  font-size: clamp(1.65rem, 3vw, 2.05rem);
  letter-spacing: -0.025em;
}

.auth-card > p {
  margin: 10px 0 28px;
  color: var(--muted);
  line-height: 1.55;
}

.field {
  margin-bottom: 18px;
}

.field label {
  display: block;
  margin-bottom: 7px;
  color: #304352;
  font-size: 0.9rem;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  color: var(--ink);
  border: 1px solid #bdcbd4;
  border-radius: 10px;
  outline: none;
  background: #fff;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.field input:focus,
.field select:focus {
  border-color: var(--navy-700);
  box-shadow: 0 0 0 3px rgba(31, 95, 135, 0.13);
}

.field-help {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

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

.button:disabled {
  cursor: wait;
  opacity: 0.62;
  transform: none;
}

.button-primary {
  width: 100%;
  color: #fff;
  background: var(--navy-900);
  box-shadow: 0 10px 22px rgba(17, 55, 83, 0.18);
}

.button-primary:hover {
  background: var(--navy-800);
}

.button-secondary {
  color: var(--navy-900);
  border-color: #b8c7d0;
  background: #fff;
}

.button-danger {
  color: var(--danger);
  border-color: #efc4c0;
  background: #fff7f6;
}

.button-small {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  font-size: 0.82rem;
}

.message {
  display: none;
  margin: 0 0 18px;
  padding: 11px 13px;
  border: 1px solid;
  border-radius: 9px;
  font-size: 0.88rem;
  line-height: 1.45;
}

.message.visible {
  display: block;
}

.message.error {
  color: #8f2119;
  border-color: #f0c1bd;
  background: #fff3f2;
}

.message.success {
  color: #155f47;
  border-color: #b6dfd0;
  background: #effaf5;
}

.setup-link {
  display: none;
  margin-top: 20px;
  color: var(--navy-700);
  font-size: 0.88rem;
  font-weight: 700;
  text-align: center;
}

.setup-link.visible {
  display: block;
}

.admin-page {
  min-height: 100vh;
  background: var(--canvas);
}

.app-header {
  display: flex;
  min-height: 70px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px clamp(18px, 4vw, 56px);
  color: #fff;
  background: var(--navy-950);
  box-shadow: 0 8px 24px rgba(12, 40, 64, 0.15);
}

.app-header .brand-row small {
  color: #adc1cf;
}

.header-actions,
.form-actions,
.row-actions {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.header-user {
  color: #c6d5df;
  font-size: 0.86rem;
}

.app-header .button-secondary {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.08);
}

.admin-main {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding: 34px 0 56px;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.page-heading h1 {
  margin: 0;
  color: var(--navy-950);
  font-size: clamp(1.7rem, 3vw, 2.35rem);
  letter-spacing: -0.035em;
}

.page-heading p {
  margin: 7px 0 0;
  color: var(--muted);
}

.panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
  box-shadow: 0 12px 34px rgba(12, 40, 64, 0.07);
}

.panel + .panel {
  margin-top: 22px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}

.panel-header h2 {
  margin: 0;
  color: var(--navy-950);
  font-size: 1.08rem;
}

.panel-body {
  padding: 22px;
}

.create-grid {
  display: grid;
  grid-template-columns: 1fr 1.25fr 1fr 0.75fr auto;
  align-items: end;
  gap: 12px;
}

.create-grid .field {
  margin: 0;
}

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

.users-table {
  width: 100%;
  border-collapse: collapse;
}

.users-table th,
.users-table td {
  padding: 14px 16px;
  border-bottom: 1px solid #e3eaee;
  font-size: 0.88rem;
  text-align: left;
  vertical-align: middle;
}

.users-table th {
  color: #536675;
  background: #f7f9fa;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

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

.user-name {
  color: var(--navy-950);
  font-weight: 750;
}

.user-login {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 750;
}

.badge-admin {
  color: #7a431d;
  background: var(--copper-soft);
}

.badge-viewer {
  color: #28566f;
  background: #e6f0f5;
}

.badge-active {
  color: var(--success);
  background: #e7f5ef;
}

.badge-locked {
  color: var(--danger);
  background: #fdeceb;
}

.empty-state {
  padding: 48px 20px;
  color: var(--muted);
  text-align: center;
}

.loading {
  opacity: 0.62;
  pointer-events: none;
}

dialog {
  width: min(92vw, 450px);
  padding: 0;
  border: 0;
  border-radius: 16px;
  color: var(--ink);
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(8, 28, 43, 0.55);
  backdrop-filter: blur(3px);
}

.dialog-content {
  padding: 25px;
}

.dialog-content h2 {
  margin: 0 0 8px;
  color: var(--navy-950);
  font-size: 1.25rem;
}

.dialog-content > p {
  margin: 0 0 20px;
  color: var(--muted);
  line-height: 1.5;
}

@media (max-width: 980px) {
  .auth-layout {
    grid-template-columns: 1fr;
  }

  .auth-brand {
    min-height: 290px;
    padding: 30px;
  }

  .brand-copy h1 {
    max-width: 16ch;
    font-size: clamp(2rem, 8vw, 3.2rem);
  }

  .brand-footer {
    display: none;
  }

  .auth-main {
    min-height: auto;
    padding: 28px 18px 44px;
  }

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

@media (max-width: 660px) {
  .auth-brand {
    min-height: 250px;
  }

  .app-header,
  .page-heading {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .create-grid .button {
    width: 100%;
  }

  .admin-main {
    width: min(100% - 22px, 1180px);
    padding-top: 22px;
  }

  .panel-header,
  .panel-body {
    padding: 17px;
  }
}
