/* Max TV — original Cirrus-inspired presentation layer.
   Presentation only: no permissions, data, business logic, or hidden-state overrides. */
:root, html[data-theme="light"] {
  color-scheme: light;
  --app-bg: #eff7fc;
  --app-bg-soft: #edf6fc;
  --app-panel: #ffffff;
  --app-panel-raised: #f7fafc;
  --app-line: #e0eaf0;
  --app-line-strong: #c8dce8;
  --app-text: #183243;
  --app-muted: #586e7d;
  --app-accent: #0c719b;
  --app-accent-2: #309ac9;
  --app-accent-soft: #e8f5fc;
  --app-success-bg: #eaf7ee;
  --app-success-text: #216140;
  --app-warning-bg: #fff5e8;
  --app-warning-text: #805019;
  --app-danger-bg: #fff0f3;
  --app-danger-text: #9c2947;
  --app-shadow: 0 5px 12px #23425d03, 0 16px 48px #315b7810;
  --app-shadow-deep: 0 28px 90px #0b27372e;
  --cirrus-ink: #18303f;
  --cirrus-ink-hover: #224a60;
  --cirrus-on-ink: #ffffff;
  --cirrus-orange: #e78939;
  --cirrus-green: #4b9d76;
  --cirrus-radius: 26px;
  --cirrus-ease: cubic-bezier(.22,.75,.25,1);
}
html[data-theme="dark"] {
  color-scheme: dark;
  --app-bg: #0c1823;
  --app-bg-soft: #182c3d;
  --app-panel: #132432;
  --app-panel-raised: #192e3e;
  --app-line: #2a3e4e;
  --app-line-strong: #3d586c;
  --app-text: #edf5fa;
  --app-muted: #b1c2ce;
  --app-accent: #88cef2;
  --app-accent-2: #a6ddf7;
  --app-accent-soft: #1b3c50;
  --app-success-bg: #183b2d;
  --app-success-text: #b4e6c8;
  --app-warning-bg: #3b2c1c;
  --app-warning-text: #f4d4ab;
  --app-danger-bg: #432735;
  --app-danger-text: #ffc2d0;
  --app-shadow: 0 8px 30px #030b1326, 0 22px 64px #02080e24;
  --app-shadow-deep: 0 28px 90px #00000080;
  --cirrus-ink: #c9eaff;
  --cirrus-ink-hover: #a8dcfa;
  --cirrus-on-ink: #122b3c;
}
html { scroll-padding-top: 95px; }
body, html[data-theme="dark"] body {
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.85;
  color: var(--app-text);
  background-color: var(--app-bg);
  background-image:
    radial-gradient(ellipse 650px 290px at 2% 4%, #ffffffec, #ffffff00 78%),
    radial-gradient(ellipse 580px 260px at 96% 20%, #ffffffdf, #ffffff00 78%),
    radial-gradient(ellipse 680px 380px at 54% -120px, #bfe6fbad, #bfe6fb00 80%);
  background-attachment: fixed;
  min-height: 100svh;
  -webkit-font-smoothing: antialiased;
}
html[data-theme="dark"] body {
  background-image:
    radial-gradient(ellipse 650px 320px at 2% 0%, #25465d70, #25465d00 78%),
    radial-gradient(ellipse 620px 290px at 96% 23%, #1e3b4b80, #1e3b4b00 78%);
}
.wrap { max-width: 1136px; padding: 30px 28px 54px; }
.top { gap: 22px; margin-bottom: 30px; }
.brand { gap: 13px; }
.brandmark, html[data-theme="dark"] .brandmark {
  width: 48px; height: 48px; border-radius: 17px;
  background: linear-gradient(145deg, #8bd2f2, #4baddc);
  color: #143a51; box-shadow: inset 0 1px 0 #dff6ff, 0 7px 20px #2897c51c;
  font-size: 21px;
}
.brand h1 { font-size: 23px; font-weight: 700; letter-spacing: -.6px; }
.brand small { font-size: 11px; margin-top: 7px; color: var(--app-muted); }
.head-actions { gap: 9px; min-width: 0; }
.btn, #themeToggle, .providers button, .duration-choice button {
  min-height: 44px; border-radius: 999px; padding: 11px 19px;
  font-size: 12px; font-weight: 600;
  transition: background-color .18s ease, color .18s ease, border-color .18s ease,
    box-shadow .22s ease, transform .22s var(--cirrus-ease);
  touch-action: manipulation;
}
.btn.primary, .package .btn.select-plan {
  background: var(--cirrus-ink); color: var(--cirrus-on-ink);
  border: 1px solid var(--cirrus-ink); box-shadow: 0 5px 13px #15354b12;
}
.btn.quiet, #themeToggle, html[data-theme="dark"] #themeToggle {
  background: var(--app-panel); color: var(--app-text); border-color: var(--app-line);
  box-shadow: 0 3px 8px #24445e04;
}
#themeToggle[aria-pressed="true"] { background: var(--app-accent-soft); border-color: var(--app-line-strong); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--app-accent); outline-offset: 4px;
}
button:not(:disabled):active { transform: translateY(1px); }
.btn:disabled, .providers button:disabled { transform: none; box-shadow: none; }
.pill { border-radius: 999px; padding: 9px 14px; gap: 10px; }
#userPill { border-radius: 21px; padding: 8px 13px; max-width: 100%; }
.avatar { width: 34px; height: 34px; border-radius: 50%; flex: none; background: var(--app-accent-soft); color: var(--app-accent); }
.user-identity { min-width: 0; line-height: 1.6; }
#userName { display: block; font-size: 12px; }
#userRole { padding: 1px 7px; min-height: 20px; font-size: 9px; margin-top: 4px; border-color: var(--app-line); }
#userEmail { font-size: 10px; }
#appNav, html[data-theme="dark"] #appNav {
  top: 12px; padding: 7px; gap: 5px; margin: 0 0 24px;
  border-radius: 999px; background: var(--app-panel); border-color: var(--app-line);
  box-shadow: 0 5px 18px #223e5810; backdrop-filter: none;
  flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-inline: contain;
  scrollbar-width: thin; scrollbar-color: var(--app-line-strong) transparent;
  scroll-padding-inline: 8px;
}
#appNav [data-view] {
  flex: 1 0 auto; min-height: 44px; border-radius: 999px; padding: 10px 18px;
  font-size: 12px; color: var(--app-muted); white-space: nowrap;
  transition: background-color .18s ease, color .18s ease, box-shadow .18s ease;
}
#appNav [data-view][aria-selected="true"], #appNav [data-view].active {
  background: var(--cirrus-ink); color: var(--cirrus-on-ink);
  border-color: var(--cirrus-ink); box-shadow: 0 3px 9px #183c5412;
}
.banner { font-size: 11px; padding: 12px 17px; border-radius: 18px; border-color: #f0dfc5; margin-bottom: 28px; }
html[data-theme="dark"] .banner { border-color: #60492f; }
.auth, html[data-theme="dark"] .auth {
  position: relative; max-width: 480px; padding: 34px;
  margin: clamp(30px, 8vh, 94px) auto 64px;
  border: 1px solid var(--app-line); border-radius: 30px;
  background: var(--app-panel); box-shadow: var(--app-shadow);
  animation: cirrus-enter .36s var(--cirrus-ease) both;
}
.auth::before {
  content: ""; display: block; width: 42px; height: 27px; margin: 0 2px 25px;
  border-radius: 18px; background: #c3e9fa;
  box-shadow: 12px -7px 0 -2px #a4d9f2, 24px 0 0 -3px #dff3fc;
}
html[data-theme="dark"] .auth::before { background: #2c5e7c; box-shadow: 12px -7px 0 -2px #4584a7, 24px 0 0 -3px #23465d; }
.auth h2 { font-size: 29px; letter-spacing: -.7px; font-weight: 700; margin: 0 0 9px; }
.auth .sub { margin-bottom: 23px; font-size: 13px; }
.field { margin: 16px 0; gap: 8px; min-width: 0; }
.field label { font-size: 12px; font-weight: 600; }
.field input, select, textarea {
  border: 1px solid var(--app-line); border-radius: 17px;
  background: var(--app-panel-raised); color: var(--app-text);
  transition: border-color .18s ease, background-color .18s ease, box-shadow .18s ease;
}
.field input { height: 50px; padding: 11px 15px; font-size: 16px; }
.field input::placeholder, textarea::placeholder { color: var(--app-muted); opacity: .8; }
.field input:focus, select:focus, textarea:focus { background: var(--app-panel); border-color: var(--app-accent); }
select { min-height: 48px; padding: 11px 13px; }
textarea { font-family: "SFMono-Regular", Consolas, monospace; line-height: 1.9; padding: 14px; }
input[type="file"] { padding: 5px; height: auto; min-height: 48px; font-size: 12px; direction: ltr; }
input[type="file"]::file-selector-button {
  min-height: 36px; border: 0; border-radius: 999px; padding: 7px 13px; margin-inline-end: 9px;
  background: var(--app-accent-soft); color: var(--app-accent); cursor: pointer; font: inherit;
}
.auth .form-row { margin-top: 22px; }
.auth .form-row .btn { min-height: 49px; font-size: 14px; }
.switch { margin: 12px 0; font-size: 12px; }
.text-btn { min-height: 37px; color: var(--app-accent); text-decoration-thickness: 1px; }
.providers { margin-top: 17px; gap: 9px; }
.providers button { border-radius: 15px; min-height: 44px; font-size: 10px; padding: 9px; opacity: 1; color: var(--app-muted); }
.status { padding: 12px 15px; border-radius: 16px; color: var(--app-accent); }
html[data-theme="dark"] .status { color: var(--app-accent); }
.status.error, html[data-theme="dark"] .status.error { color: var(--app-danger-text); }
.status.ok, html[data-theme="dark"] .status.ok { color: var(--app-success-text); }
.section-head { align-items: center; gap: 18px; margin: 32px 0 22px; }
.section-head h2, .help-header h2 { font-size: clamp(25px, 3vw, 32px); line-height: 1.6; font-weight: 700; letter-spacing: -.6px; }
.section-head p { margin-top: 7px; font-size: 12px; }
[data-app-panel]:not([hidden]) { animation: cirrus-enter .25s var(--cirrus-ease) both; }
.packages { margin-top: 0; }
.grid { gap: 20px; align-items: stretch; }
.package, html[data-theme="dark"] .package {
  display: flex; flex-direction: column; align-items: flex-start;
  min-width: 0; padding: 29px 24px 24px; border-radius: var(--cirrus-radius);
  border-color: var(--app-line); background: var(--app-panel);
  box-shadow: var(--app-shadow); animation: cirrus-enter .3s var(--cirrus-ease) both;
  transition: transform .24s var(--cirrus-ease), box-shadow .24s ease, border-color .2s ease;
}
.package:nth-child(2) { animation-delay: .035s; }
.package:nth-child(3) { animation-delay: .07s; }
.package::before, .package:nth-child(2)::before, .package:nth-child(3)::before {
  inset: 0 26px auto; height: 3px; border-radius: 0 0 8px 8px; background: #72bee3;
}
.package[data-plan="Free"]::before { background: #83bfa0; }
.package[data-plan="Premium"]::before { background: #e7aa6c; }
.badge, .help-badge { font-size: 10px; border-radius: 999px; padding: 4px 10px; font-weight: 600; }
.package[data-plan="Free"] .badge { background: var(--app-success-bg); color: var(--app-success-text); border-color: #a8d4ba; }
.package[data-plan="Premium"] .badge { background: var(--app-warning-bg); color: var(--app-warning-text); border-color: #e7c293; }
.package h3 { font-size: 31px; font-weight: 700; letter-spacing: -.8px; line-height: 1.3; margin: 22px 0 8px; }
.package small { font-size: 12px; }
.package p { min-height: 45px; font-size: 12px; line-height: 2; margin: 20px 0; }
.duration-choice { gap: 6px; margin: 22px 0 0; width: 100%; }
.duration-choice button { min-height: 44px; padding: 7px 11px; font-size: 11px; background: var(--app-panel-raised); }
.duration-choice button[aria-pressed="true"] {
  background: var(--app-accent-soft); color: var(--app-accent);
  border-color: var(--app-line-strong); box-shadow: inset 0 0 0 1px var(--app-line-strong);
}
.selected-duration { margin: 20px 0; min-height: 44px; display: flex; align-items: center; color: var(--app-accent); font-size: 12px; }
.package .btn.select-plan { min-height: 46px; width: 100%; margin-top: auto; font-size: 12px; opacity: 1; }
.package .btn.select-plan:focus-visible { background: var(--cirrus-ink); color: var(--cirrus-on-ink); }
.safe, .session-summary { border-radius: 18px; padding: 14px 17px; font-size: 11px; border-color: var(--app-line); line-height: 2; }
.safe { margin-top: 22px; }
.session-summary { margin-top: 23px; }
#ordersPanel, #adminPanel, .help-section { margin-top: 0; }
.ticket-grid, .stock-grid { gap: 20px; }
.admin-form, html[data-theme="dark"] .admin-form {
  padding: 28px; border-radius: var(--cirrus-radius); background: var(--app-panel);
  border-color: var(--app-line); box-shadow: var(--app-shadow); margin-top: 24px;
}
.admin-form h3 { margin: 0 0 15px; font-size: 21px; font-weight: 700; }
.admin-selects { gap: 16px; }
.stock-item, html[data-theme="dark"] .stock-item,
.admin-orders, html[data-theme="dark"] .admin-orders { border-radius: 22px; background: var(--app-panel); border-color: var(--app-line); box-shadow: var(--app-shadow); }
.stock-item { padding: 20px; gap: 13px; }
.stock-item details { border: 1px solid var(--app-line); padding: 13px; border-radius: 15px; }
.stock-item summary, .admin-orders summary { min-height: 28px; padding: 3px 0; }
.stock-item code { padding: 9px 0; font-size: 13px; }
.admin-orders { padding: 20px; }
.selfmade-test-confirm { border-width: 1px; border-color: var(--app-line-strong); border-radius: 18px; padding: 17px; }
.selfmade-test-confirm label { line-height: 1.9; }
.selfmade-test-confirm input { width: 22px; height: 22px; margin-top: 3px; cursor: pointer; }
.selfmade-test-confirm p { margin-inline-start: 32px; }
.import-tools { gap: 9px; }
.import-preview { border-radius: 20px; border-color: var(--app-line); padding: 18px; box-shadow: none; }
.import-table-scroll { border-radius: 14px; border-color: var(--app-line); }
#importSubmit { margin-top: 22px; }
.summary-dialog { border-radius: 29px; max-height: calc(100svh - 34px); width: min(92vw, 480px); }
.summary-dialog[open] { animation: cirrus-dialog-enter .22s var(--cirrus-ease); }
.summary-dialog-inner { padding: 28px; }
.summary-dialog h2 { font-size: 26px; font-weight: 700; }
.summary-box, html[data-theme="dark"] .summary-box { border-radius: 20px; padding: 18px; background: var(--app-bg-soft); }
.summary-dialog::backdrop { background: #102b425c; }
.dialog-actions { margin-top: 23px; gap: 8px; }
#dialogEdit { background: var(--app-panel); color: var(--app-text); border-color: var(--app-line-strong); box-shadow: none; }
.help-section, html[data-theme="dark"] .help-section { border-radius: var(--cirrus-radius); background: var(--app-panel); padding: 30px; }
.help-header { padding-bottom: 14px; }
.help-header h2 { margin: 9px 0; }
.help-lead, .help-official, .help-copy, .help-steps { font-size: 13px; line-height: 2.05; }
.help-note { border-radius: 18px; padding: 15px 18px; border-color: var(--app-line); }
.help-grid, .help-cards { gap: 14px; }
.help-panel, html[data-theme="dark"] .help-panel { border-radius: 20px; box-shadow: none; background: var(--app-panel); }
.help-panel summary { padding: 17px 18px; min-height: 52px; font-size: 13px; }
.help-panel summary::marker { color: var(--app-accent); }
.help-panel[open] summary { background: var(--app-bg-soft); }
.help-card, html[data-theme="dark"] .help-card { border-style: solid; padding: 21px; border-radius: 22px; background: var(--app-panel-raised); box-shadow: none; border-color: var(--app-line); }
.help-card h4 { font-size: 17px; margin: 14px 0 7px; }
.help-card p { line-height: 2; }
.help-subtitle { margin-top: 30px; }
.foot { max-width: 800px; margin: 42px auto 0; padding-top: 20px; font-size: 10px; border-color: var(--app-line); }
@media (hover: hover) and (pointer: fine) {
  .btn:not(:disabled):hover, #themeToggle:hover { transform: translateY(-1px); }
  .btn.primary:not(:disabled):hover, .package .btn.select-plan:hover,
  html[data-theme="dark"] .package .btn.select-plan:hover {
    background: var(--cirrus-ink-hover); border-color: var(--cirrus-ink-hover); color: var(--cirrus-on-ink);
    box-shadow: 0 8px 19px #173c541c;
  }
  .package:hover { transform: translateY(-3px); box-shadow: 0 17px 40px #24456015; border-color: var(--app-line-strong); }
  html[data-theme="dark"] .package:hover { box-shadow: 0 17px 40px #02090f42; }
  #appNav [data-view]:not([aria-selected="true"]):hover { background: var(--app-bg-soft); color: var(--app-text); }
}
@keyframes cirrus-enter { from { opacity: 1; transform: translateY(7px); } to { opacity: 1; transform: none; } }
@keyframes cirrus-dialog-enter { from { opacity: .97; transform: translateY(9px) scale(.985); } to { opacity: 1; transform: none; } }
@media (max-width: 820px) and (min-width: 721px) {
  .grid { gap: 13px; }
  .package { padding: 25px 17px 20px; }
  .duration-choice { gap: 4px; }
  .duration-choice button { padding: 7px 9px; }
}
@media (max-width: 720px) {
  .wrap { padding: 22px 18px 38px; }
  .top { gap: 17px; margin-bottom: 23px; }
  .brand h1 { font-size: 22px; }
  .head-actions { gap: 8px; }
  body[data-auth="guest"] .top { flex-wrap: nowrap; }
  body[data-auth="guest"] .head-actions { width: auto; flex: none; }
  #themeToggle, #logout { padding: 9px 13px; font-size: 11px; }
  #userPill { flex-basis: 170px; }
  #appNav { top: 8px; border-radius: 27px; padding: 6px; gap: 4px; }
  #appNav [data-view] { flex: 0 0 auto; padding: 10px 17px; font-size: 12px; }
  .banner { padding: 12px 14px; margin-bottom: 22px; line-height: 1.9; }
  .banner b { display: inline; }
  .auth { padding: 27px 23px; border-radius: 27px; margin-top: 40px; margin-bottom: 36px; }
  .auth h2 { font-size: 28px; }
  .auth .sub { font-size: 12px; }
  .section-head { align-items: flex-start; gap: 12px; margin: 25px 0 19px; }
  .section-head h2 { font-size: 27px; }
  .section-head .btn { align-self: flex-start; }
  .grid { gap: 18px; }
  .package { padding: 26px 24px 23px; }
  .package p { min-height: 0; }
  .ticket-grid, .stock-grid { gap: 16px; }
  .admin-form { padding: 21px 18px; }
  .admin-selects { gap: 8px; }
  .help-section { padding: 24px 20px; }
  .help-grid, .help-cards { gap: 12px; }
  .selfmade-test-confirm { padding: 14px; }
  .selfmade-test-confirm label { font-size: 12px; }
  .selfmade-test-confirm p { margin-inline-start: 0; }
  .import-tools .btn { width: 100%; }
  .import-preview { padding: 13px; }
  .summary-dialog-inner { padding: 24px 21px; }
  .foot { margin-top: 30px; }
}
@media (max-width: 720px) {
  .top { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 14px; }
  .top .head-actions { display: contents; }
  .brand { grid-column: 1; grid-row: 1; }
  #themeToggle { grid-column: 2; grid-row: 1; justify-self: end; }
  #userPill { grid-column: 1 / -1; grid-row: 2; width: 100%; padding-inline-end: 110px; }
  #logout { grid-column: 2; grid-row: 2; justify-self: end; margin-inline-end: 9px; border-color: transparent; background: transparent; }
  #packages .section-head { flex-direction: row; align-items: flex-start; }
  #packages .section-head > .pill { flex: none; margin-top: 7px; padding: 6px 10px; font-size: 10px; }
  html[data-theme="dark"] .auth { padding: 27px 23px; margin-top: 40px; margin-bottom: 36px; border-radius: 27px; }
  html[data-theme="dark"] .package { padding: 26px 24px 23px; }
  html[data-theme="dark"] .admin-form { padding: 21px 18px; }
  html[data-theme="dark"] .help-section { padding: 24px 20px; }
}
@media (max-width: 360px) {
  .wrap { padding-inline: 13px; }
  .brand { gap: 8px; }
  .brandmark { width: 41px; height: 41px; border-radius: 14px; }
  .brand h1 { font-size: 20px; }
  .brand small { font-size: 9px; }
  #themeToggle { font-size: 10px; padding-inline: 11px; }
  .auth { padding-inline: 20px; }
  .package { padding-inline: 20px; }
  .duration-choice button { padding-inline: 9px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto !important; }
  *, *::before, *::after {
    animation: none !important; transition: none !important; scroll-behavior: auto !important;
  }
  .btn:not(:disabled):hover, .package:hover { transform: none !important; }
}
@media (forced-colors: active) {
  .btn, #appNav [aria-selected="true"], .duration-choice [aria-pressed="true"] { border: 1px solid ButtonText; }
}
