:root {
  --bg: #060c18;
  --bg-soft: #0b1324;
  --panel: rgba(15, 26, 46, .76);
  --panel-strong: rgba(8, 15, 30, .88);
  --line: rgba(255, 255, 255, .09);
  --line-strong: rgba(255, 255, 255, .14);
  --text: #f0f4ff;
  --muted: #92a2c4;
  --muted-2: #667896;
  --brand: #6d5ef5;
  --brand-2: #9b5de5;
  --cyan: #38bdf8;
  --green: #22c55e;
  --danger: #fb7185;
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --shadow: 0 28px 90px rgba(0, 0, 0, .46);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 8%, rgba(109, 94, 245, .28), transparent 32rem),
    radial-gradient(circle at 88% 18%, rgba(56, 189, 248, .13), transparent 28rem),
    radial-gradient(circle at 78% 94%, rgba(155, 93, 229, .16), transparent 30rem),
    var(--bg);
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-shell {
  width: min(100%, 1120px);
  min-height: min(760px, calc(100vh - 48px));
  display: flex;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
}

.auth-hero,
.login-card {
  flex: 1;
  padding: 46px;
}

.auth-hero {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 40px;
  background:
    linear-gradient(135deg, rgba(109, 94, 245, .20), rgba(255, 255, 255, .025)),
    rgba(255, 255, 255, .02);
}

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

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: white;
  font-weight: 900;
  letter-spacing: -.06em;
  box-shadow: 0 14px 34px rgba(109, 94, 245, .32);
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  line-height: 1;
  font-size: 16px;
  letter-spacing: -.03em;
}

.brand span {
  margin-top: 4px;
  color: var(--muted-2);
  font-size: 12px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  color: #c7c2ff;
  background: rgba(109, 94, 245, .13);
  border: 1px solid rgba(109, 94, 245, .24);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.eyebrow.compact {
  min-height: 28px;
  padding: 0 10px;
}

.eyebrow i {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 6px rgba(34, 197, 94, .11);
}

.hero-copy h1 {
  max-width: 560px;
  margin: 22px 0 16px;
  font-size: clamp(38px, 5vw, 62px);
  line-height: .98;
  letter-spacing: -.07em;
}

.hero-copy p {
  max-width: 520px;
  margin: 0;
  color: var(--muted);
  font-size: 16px;
}

.security-grid {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.security-card {
  flex: 1 1 130px;
  min-height: 94px;
  padding: 17px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .05);
}

.security-card strong,
.security-card span {
  display: block;
}

.security-card strong {
  font-size: 18px;
  letter-spacing: -.035em;
}

.security-card span {
  margin-top: 5px;
  color: var(--muted-2);
  font-size: 12px;
}

.login-card {
  max-width: 454px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: var(--panel-strong);
  border-left: 1px solid var(--line);
}

.login-head h2 {
  margin: 14px 0 6px;
  font-size: 30px;
  line-height: 1.1;
  letter-spacing: -.05em;
}

.login-head p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 30px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.field input,
.field select,
.user-channel-row input {
  width: 100%;
  height: 50px;
  padding: 0 15px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  outline: none;
  color: var(--text);
  background: rgba(255, 255, 255, .045);
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.field select {
  appearance: none;
}

.field input::placeholder,
.user-channel-row input::placeholder {
  color: rgba(146, 162, 196, .62);
}

.field input:focus,
.field select:focus,
.user-channel-row input:focus {
  border-color: var(--brand);
  background: rgba(255, 255, 255, .065);
  box-shadow: 0 0 0 4px rgba(109, 94, 245, .22);
}

.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  color: var(--muted);
  font-size: 13px;
}

.form-row a {
  color: #c7c2ff;
  font-weight: 700;
}

.form-row a:hover {
  color: white;
}

.remember {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.remember input {
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
}

.submit-btn {
  height: 50px;
  border: 0;
  border-radius: var(--radius-md);
  color: white;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 12px 32px rgba(109, 94, 245, .34);
  transition: transform .18s ease, filter .18s ease;
}

.submit-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.submit-btn:active {
  transform: translateY(0);
}

.login-footer {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.login-footer p {
  margin: 0 0 10px;
  color: var(--muted-2);
  font-size: 12px;
}

.login-footer a {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.login-footer a:hover {
  color: white;
}

.alert {
  margin-top: 20px;
  padding: 13px 15px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.alert.error {
  border-color: rgba(251, 113, 133, .35);
  background: rgba(251, 113, 133, .12);
}

.alert.success {
  border-color: rgba(34, 197, 94, .35);
  background: rgba(34, 197, 94, .12);
}

.alert.warning {
  border-color: rgba(245, 158, 11, .35);
  background: rgba(245, 158, 11, .12);
}

.admin-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.admin-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding: 28px;
  border-right: 1px solid var(--line);
  background: rgba(8, 15, 30, .78);
  backdrop-filter: blur(20px);
}

.admin-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-nav a {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 14px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.admin-nav a.is-active,
.admin-nav a:hover {
  border-color: rgba(109, 94, 245, .28);
  color: var(--text);
  background: rgba(109, 94, 245, .15);
}

.admin-user {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.admin-user > span {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: white;
  background: rgba(255, 255, 255, .08);
  font-weight: 900;
}

.admin-user strong,
.admin-user small {
  display: block;
}

.admin-user strong {
  font-size: 14px;
}

.admin-user small {
  max-width: 170px;
  overflow: hidden;
  color: var(--muted-2);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-main {
  width: min(100%, 1040px);
  padding: 42px;
}

.admin-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.admin-topbar h1 {
  margin: 14px 0 6px;
  font-size: 38px;
  line-height: 1.05;
  letter-spacing: -.05em;
}

.admin-topbar p {
  margin: 0;
  color: var(--muted);
}

.logout-link {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.logout-link:hover {
  border-color: rgba(255, 255, 255, .24);
  background: rgba(255, 255, 255, .05);
}

.provision-card {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

.form-section {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.form-section + .form-section {
  padding-top: 26px;
  border-top: 1px solid var(--line);
}

.form-section h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

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

.field-error {
  color: var(--danger);
  font-size: 12px;
  font-weight: 800;
}

.provision-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 4px;
}

.provision-actions .submit-btn {
  min-width: 210px;
  padding: 0 20px;
}

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

.channel-card {
  min-height: 238px;
  display: flex;
  flex-direction: column;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

.channel-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
}

.channel-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  color: #c7c2ff;
  background: rgba(109, 94, 245, .16);
  border: 1px solid rgba(109, 94, 245, .26);
  font-size: 12px;
  font-weight: 900;
}

.channel-status {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, .055);
  border: 1px solid var(--line);
  font-size: 11px;
  font-weight: 900;
}

.channel-card h2 {
  margin: 0 0 8px;
  font-size: 20px;
  letter-spacing: -.04em;
}

.channel-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.channel-action {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  margin-top: auto;
  padding: 0 16px;
  border-radius: 14px;
  color: white;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  font-size: 13px;
  font-weight: 900;
}

.channel-action.disabled {
  color: var(--muted-2);
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--line);
}

.telegram-dashboard {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
  gap: 18px;
}

.telegram-dashboard .full-span {
  grid-column: 1 / -1;
}

.channel-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.channel-summary h2,
.provision-card h2 {
  margin: 0;
  font-size: 18px;
}

.channel-summary p,
.section-copy {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.summary-count {
  min-width: 128px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, .045);
}

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

.summary-count strong {
  font-size: 30px;
  line-height: 1;
}

.summary-count span {
  margin-top: 7px;
  color: var(--muted-2);
  font-size: 12px;
  font-weight: 800;
}

.toggle-line {
  min-height: 50px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.toggle-line.compact {
  min-height: 0;
}

.toggle-line input {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
}

.user-channel-list {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
}

.user-channel-row {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) 130px minmax(160px, .75fr);
  gap: 12px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.user-channel-row strong,
.user-channel-row small {
  display: block;
}

.user-channel-row small {
  margin-top: 3px;
  color: var(--muted-2);
  font-size: 12px;
}

.test-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(260px, 1.2fr) auto;
  gap: 14px;
  align-items: end;
}

.fiscal-org-row {
  grid-template-columns: minmax(180px, 1fr) 118px 120px minmax(150px, .7fr) minmax(190px, .9fr) minmax(190px, .9fr) auto;
}

.fiscal-org-row select {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  color: var(--text);
  background: rgba(255, 255, 255, .045);
}

.compact-btn {
  width: auto;
  min-width: 92px;
  height: 44px;
  padding: 0 14px;
}

.fiscal-log-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.log-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 10px 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, .035);
}

.log-row strong,
.log-row small {
  display: block;
}

.log-row small,
.log-row p {
  color: var(--muted-2);
  font-size: 12px;
}

.log-row p {
  grid-column: 1 / -1;
  margin: 0;
}

@media (max-width: 900px) {
  .auth-page {
    padding: 16px;
  }

  .auth-shell {
    flex-direction: column;
    min-height: auto;
  }

  .auth-hero,
  .login-card {
    max-width: none;
    padding: 32px 26px;
  }

  .login-card {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .admin-page {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    position: static;
    height: auto;
  }

  .admin-main {
    padding: 26px 18px;
  }

  .admin-topbar {
    flex-direction: column;
  }

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

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

  .telegram-dashboard,
  .test-form,
  .user-channel-row,
  .fiscal-org-row,
  .log-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .auth-page {
    align-items: stretch;
    padding: 0;
  }

  .auth-shell {
    width: 100%;
    min-height: 100vh;
    border: 0;
    border-radius: 0;
  }

  .auth-hero {
    display: none;
  }

  .login-card {
    justify-content: center;
    min-height: 100vh;
    padding: 26px 20px;
  }

  .form-row {
    align-items: flex-start;
    flex-direction: column;
  }
}
