:root {
  --ink: #101635;
  --muted: #68708b;
  --line: #dfe4f4;
  --blue: #514cff;
  --blue-soft: #eef0ff;
  --green: #16825d;
  --amber: #a66b11;
  --surface: #ffffff;
  --shadow: 0 22px 70px rgba(20, 31, 79, .09);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { overflow-x: clip; background: #f5f7fd; -webkit-text-size-adjust: 100%; }
body { margin: 0; min-width: 0; overflow-x: clip; color: var(--ink); background: linear-gradient(180deg, #f8faff 0, #f3f5fb 100%); font-family: "Manrope", system-ui, sans-serif; }
button, input { font: inherit; }
a { color: inherit; text-decoration: none; }

.admin-header { width: min(calc(100% - 40px), 1180px); min-height: 82px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.admin-header > div { display: flex; align-items: center; gap: 12px; }
.brand { font-size: 1.7rem; font-weight: 800; letter-spacing: .05em; }
.brand b { color: var(--blue); }
.environment, .back-link { min-height: 42px; padding: 0 13px; display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.8); font-size: .78rem; font-weight: 700; }
.environment i { width: 8px; height: 8px; border-radius: 50%; background: #1fc889; box-shadow: 0 0 0 4px #ddf8ed; }
.back-link:hover { border-color: #b9c1e8; color: var(--blue); }

main { width: min(calc(100% - 40px), 1180px); margin: 32px auto 80px; }
.admin-hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 390px); align-items: end; gap: 40px; }
.eyebrow { margin: 0 0 12px; color: var(--blue); font-size: .72rem; font-weight: 800; letter-spacing: .15em; }
h1 { max-width: 700px; margin: 0; font-size: clamp(2.2rem, 5vw, 4.7rem); line-height: .98; letter-spacing: -.055em; }
.admin-hero > div > p:last-child { max-width: 650px; margin: 22px 0 0; color: var(--muted); font-size: 1rem; line-height: 1.7; }
.policy-lock { min-height: 142px; padding: 25px; display: grid; grid-template-columns: auto 1fr; align-content: center; gap: 4px 12px; border-radius: 25px; color: #fff; background: var(--ink); box-shadow: var(--shadow); }
.policy-lock > span { grid-row: span 2; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; color: #9c98ff; background: rgba(255,255,255,.08); font-size: 1.5rem; }
.policy-lock strong { font-size: .92rem; }
.policy-lock small { color: #aeb7db; font-size: .72rem; line-height: 1.5; }

.auth-panel { margin-top: 48px; padding: 30px; border: 1px solid var(--line); border-radius: 24px; text-align: center; background: var(--surface); box-shadow: var(--shadow); }
.auth-panel p { margin: 0; color: var(--muted); }
.auth-panel a { min-height: 46px; margin-top: 16px; padding: 0 18px; display: inline-flex; align-items: center; border-radius: 13px; color: #fff; background: var(--blue); font-size: .84rem; font-weight: 800; }
.dashboard { margin-top: 48px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stats article { min-width: 0; padding: 22px; border: 1px solid var(--line); border-radius: 20px; background: rgba(255,255,255,.9); box-shadow: 0 12px 40px rgba(20,31,79,.05); }
.stats span { display: block; min-height: 2.7em; color: var(--muted); font-size: .76rem; line-height: 1.45; }
.stats strong { display: block; margin-top: 12px; font-size: 2rem; }
.stats small { display: block; margin-top: 8px; color: var(--muted); font-size: .62rem; line-height: 1.4; }

.source-grid { margin-top: 18px; display: grid; gap: 16px; }
.source-card { padding: 25px; display: grid; grid-template-columns: 240px minmax(0, 1fr) auto; gap: 26px; border: 1px solid var(--line); border-radius: 24px; background: var(--surface); box-shadow: var(--shadow); }
.source-title-row { display: flex; align-items: center; gap: 9px; }
.source-title-row h2 { margin: 0; font-size: 1.18rem; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #1fc889; box-shadow: 0 0 0 5px #e1faef; }
.status-dot--off { background: #a6acc0; box-shadow: 0 0 0 5px #eef0f5; }
.source-meta { margin: 13px 0 0; display: grid; gap: 7px; color: var(--muted); font-size: .72rem; line-height: 1.45; }
.permission { width: fit-content; padding: 6px 9px; border-radius: 999px; color: var(--amber); background: #fff4de; font-size: .66rem; font-weight: 800; }
.permission--manual { color: var(--green); background: #e8f8f1; }
.account-status { width: fit-content; color: var(--blue); font-weight: 800; }
.account-status:hover { text-decoration: underline; }

.control-grid { display: grid; grid-template-columns: repeat(3, minmax(140px, 1fr)); gap: 13px; }
.toggle-control { min-height: 46px; padding: 10px 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid var(--line); border-radius: 13px; color: #39415f; font-size: .75rem; font-weight: 700; }
.toggle-control input { width: 38px; height: 22px; margin: 0; accent-color: var(--blue); cursor: pointer; }
.field { display: grid; gap: 7px; color: var(--muted); font-size: .7rem; font-weight: 700; }
.field--wide { grid-column: span 2; }
.field input { width: 100%; min-height: 46px; padding: 0 12px; border: 1px solid var(--line); border-radius: 13px; color: var(--ink); background: #f9faff; font-size: 16px; outline: none; }
.field input:focus { border-color: #8f8aff; box-shadow: 0 0 0 3px #ecebff; }
.save-source { align-self: end; min-width: 122px; min-height: 46px; padding: 0 16px; border: 0; border-radius: 13px; color: #fff; background: var(--blue); font-size: .78rem; font-weight: 800; cursor: pointer; }
.save-source:disabled { opacity: .5; cursor: wait; }
.save-status { min-height: 1.5em; margin: 18px 0 0; color: var(--muted); text-align: right; font-size: .78rem; }

@media (max-width: 900px) {
  .admin-hero { grid-template-columns: 1fr; align-items: start; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .source-card { grid-template-columns: 1fr; gap: 20px; }
  .save-source { justify-self: stretch; }
}

@media (max-width: 600px) {
  .admin-header, main { width: min(calc(100% - 28px), 1180px); }
  .admin-header { min-height: 72px; }
  .environment { display: none; }
  main { margin-top: 20px; }
  h1 { font-size: 2.55rem; }
  .policy-lock { min-height: 126px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stats article { padding: 17px; }
  .control-grid { grid-template-columns: 1fr; }
  .field--wide { grid-column: auto; }
  .source-card { padding: 20px; }
}
