/* Фирменный стиль «Орион»: тёмно-синий #052b44, голубой #00b3e4, светло-голубой #78dff7 */
/* Шрифт Oswald скачивается на сервер при установке (deploy/install.sh); если его нет — берутся узкие системные */
@font-face { font-family: "Oswald"; font-weight: 200 700; font-display: swap;
  src: url("/static/fonts/oswald-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Oswald"; font-weight: 200 700; font-display: swap;
  src: url("/static/fonts/oswald-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212; }

:root {
  --navy: #052b44;
  --navy-2: #0a3a5a;
  --cyan: #00b3e4;
  --cyan-light: #78dff7;
  --display: "Oswald", "Bahnschrift SemiCondensed", "Bahnschrift", "Avenir Next Condensed", "Roboto Condensed", "Arial Narrow", "DejaVu Sans Condensed", sans-serif;

  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f1f6f9;
  /* шапка и логотип */
  --head-bg: #072c47;
  --head-line: #0d3b5b;
  --head-ink: #ffffff;
  --head-muted: #dbe6ee;
  /* ключевые кнопки — тёмно-синие, остальные — голубые */
  --key-bg: #052b44;
  --key-ink: #ffffff;
  --key-hover: #0b3f63;
  --sec-bg: #00b3e4;
  --sec-ink: #052b44;
  --sec-hover: #1cc0ec;
  --text: #0b2436;
  --muted: #56697a;
  --line: #d9e1e8;
  --accent: #00b3e4;        /* кнопки */
  --accent-ink: #052b44;    /* текст на кнопках */
  --accent-text: #00759b;   /* ссылки, активные элементы на светлом */
  --accent-soft: #dcf3fb;
  --ok: #1e7a4c;
  --ok-soft: #e2f4ea;
  --bad: #b3261e;
  --bad-soft: #fbe9e7;
  --warn: #8a5a00;
  --warn-soft: #fdf3dc;
  --code-bg: #e9eff4;
  --shadow: 0 1px 2px rgba(5, 43, 68, .06), 0 2px 6px rgba(5, 43, 68, .06);
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #03192a;
    --surface: #072a42;
    --surface-2: #0b3552;
    --head-bg: #072c47;
    --head-line: #0d3b5b;
    --head-ink: #ffffff;
    --head-muted: #dbe6ee;
    --key-bg: #00b3e4;
    --key-ink: #03192a;
    --key-hover: #1cc0ec;
    --sec-bg: #0f4a70;
    --sec-ink: #e8f6fc;
    --sec-hover: #135a86;
    --text: #e8f1f7;
    --muted: #9db2c2;
    --line: #154565;
    --accent: #00b3e4;
    --accent-ink: #03192a;
    --accent-text: #78dff7;
    --accent-soft: #0c3f5e;
    --ok: #5fd39a;
    --ok-soft: #0f3a33;
    --bad: #ff8a80;
    --bad-soft: #3a1d24;
    --warn: #f3c669;
    --warn-soft: #3a3014;
    --code-bg: #0e3a58;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
h2 { font-family: var(--display); font-weight: 500; font-size: 22px; letter-spacing: .01em; margin: 0 0 4px; }
h3 { font-family: var(--display); font-weight: 500; font-size: 21px; letter-spacing: .01em; margin: 0 0 12px; }
h4 { font-size: 14px; margin: 18px 0 8px; color: var(--muted); font-weight: 600; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono, code, pre, textarea#iid-input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ---------- раскладка ---------- */
.row { display: flex; align-items: center; }
.row.gap { gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; min-width: 0; }
.page { max-width: 880px; margin: 0 auto; padding: 20px 16px 40px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px;
}
.foot { text-align: center; padding: 0 16px 24px; }

/* ---------- шапка ---------- */
.topbar { background: var(--head-bg); border-bottom: 1px solid var(--head-line); position: sticky; top: 0; z-index: 5; }
.topbar-in { max-width: 880px; margin: 0 auto; padding: 12px 16px 6px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.logo { display: flex; align-items: center; gap: 10px; color: var(--head-ink); line-height: 1; }
.logo .stars { fill: var(--cyan); flex: none; }
.logo .word { display: flex; flex-direction: column; align-items: center; }
.logo .w1 { font-family: var(--display); font-weight: 500; letter-spacing: .02em; }
.logo .w2 { font-family: var(--display); color: var(--cyan-light); letter-spacing: .55em; margin-right: -.55em; font-weight: 400; }
.logo-sm .stars { width: 34px; height: 22px; }
.logo-sm .w1 { font-size: 24px; }
.logo-sm .w2 { font-size: 10px; margin-top: 3px; }
.logo-lg { gap: 18px; margin-bottom: 26px; }
.logo-lg .stars { width: 78px; height: 52px; }
.logo-lg .w1 { font-size: 56px; }
.logo-lg .w2 { font-size: 17px; margin-top: 8px; }
.top-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pill { background: rgba(0, 179, 228, .14); color: #5fd2f5; border-radius: 999px; padding: 3px 10px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.menu { position: relative; }
.menu summary { color: var(--head-ink); list-style: none; cursor: pointer; padding: 4px 8px; border-radius: 8px; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary::after { content: " ▾"; color: var(--head-muted); }
.menu summary:hover { background: rgba(255, 255, 255, .08); }
.menu-pop { position: absolute; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.14); padding: 6px; min-width: 170px; }
.menu-pop button { display: block; width: 100%; text-align: left; background: none; border: 0; color: var(--text); padding: 8px 10px; border-radius: 6px; font: inherit; cursor: pointer; }
.menu-pop button:hover { background: var(--surface-2); }

.tabs { max-width: 880px; margin: 0 auto; padding: 4px 12px 12px; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  background: none; border: 1px solid transparent; border-radius: 10px; color: var(--head-muted);
  padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.tabs button:hover { color: #fff; background: rgba(255, 255, 255, .06); }
.tabs button.active { color: #4cc9f0; background: rgba(0, 179, 228, .12); border-color: rgba(0, 179, 228, .45); }

/* ---------- формы ---------- */
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
label > input, label > select { margin-top: 4px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent-text); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; margin-bottom: 10px; display: block; }
#iid-input { font-size: 15px; letter-spacing: .3px; }
.search { width: 180px; padding: 7px 10px; }
.form-error { color: var(--bad); font-size: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 10px; padding: 9px 16px;
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn.primary { background: var(--key-bg); color: var(--key-ink); }
.btn.primary:hover { background: var(--key-hover); filter: none; }
.btn.ghost { background: var(--sec-bg); color: var(--sec-ink); }
.btn.ghost:hover { background: var(--sec-hover); }
.btn.ghost.danger { background: var(--surface); color: var(--bad); border-color: var(--bad); }
.btn.ghost.danger:hover { background: var(--bad-soft); }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn.danger { color: var(--bad); }
.btn[disabled] { opacity: .55; cursor: default; }
.btn.loading::before { content: ""; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.icon-btn:hover { background: var(--surface-2); }
.file-btn { cursor: pointer; margin: 0; font-size: 15px; color: var(--text); }

/* ---------- IID: группы ---------- */
.groups { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; min-height: 0; }
.groups:empty { margin: 0; }
.grp { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; padding: 3px 7px; border-radius: 6px; background: var(--surface-2); color: var(--muted); }
.grp.ok { background: var(--ok-soft); color: var(--ok); }
.grp.bad { background: var(--bad-soft); color: var(--bad); font-weight: 700; }
.drag-over { outline: 2px dashed var(--accent-text); outline-offset: 4px; }

/* ---------- результаты ---------- */
.result { border-left: 4px solid var(--cyan); }
.result.ok { border-left-color: var(--ok); }
.result.bad { border-left-color: var(--bad); }
.result.warn { border-left-color: var(--warn); }
.rich { white-space: pre-wrap; word-wrap: break-word; }
.rich code, .kv code, .copyable {
  background: var(--code-bg); padding: 1px 6px; border-radius: 5px; font-size: 13.5px;
  cursor: pointer; word-break: break-all;
}
.rich code:hover, .copyable:hover { outline: 1px solid var(--accent-text); }
.guide summary { cursor: pointer; font-weight: 600; }
.guide[open] summary { margin-bottom: 12px; }

.cid-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.cid-big {
  font: 600 19px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .5px;
  background: var(--code-bg); border-radius: 10px; padding: 12px 14px; word-break: break-all; cursor: pointer;
}
.cid-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0; }
.cid-cell { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; cursor: pointer; text-align: center; }
.cid-cell:hover { border-color: var(--accent-text); }
.cid-cell b { display: block; font-size: 11px; color: var(--muted); font-weight: 600; }
.cid-cell span { font: 600 15px ui-monospace, SFMono-Regular, Menlo, monospace; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; margin: 6px 0 12px; }
.seg button { border: 0; background: none; color: var(--muted); font: inherit; font-weight: 600; padding: 7px 14px; border-radius: 8px; cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.note { background: var(--surface-2); border-radius: 8px; padding: 8px 12px; font-size: 14px; margin-top: 10px; }

.drop {
  display: flex; align-items: center; justify-content: center; text-align: center;
  border: 1.5px dashed var(--line); border-radius: 10px; padding: 22px; margin-bottom: 10px;
  cursor: pointer; color: var(--muted); font-size: 14px;
}
.drop:hover, .drop.drag-over { border-color: var(--accent-text); color: var(--accent-text); outline: none; }
.downloads { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }

/* ---------- таблицы и списки ---------- */
.table-wrap { overflow-x: auto; margin: 10px -20px -20px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; padding: 8px 20px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px 20px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr.off td { opacity: .5; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.badge.own { background: var(--accent-soft); color: var(--accent-text); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }

.hist { display: grid; grid-template-columns: 108px 1fr; gap: 4px 14px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.hist:last-child { border-bottom: 0; }
.hist .when { color: var(--muted); font-size: 13px; }
.hist .what { min-width: 0; }
.hist .inp { color: var(--muted); font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }
.empty { color: var(--muted); padding: 16px 0; text-align: center; }

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.tile .lbl { color: var(--muted); font-size: 13px; }
.tile .val { font-family: var(--display); font-size: 32px; font-weight: 500; font-variant-numeric: tabular-nums; line-height: 1.2; margin-top: 2px; }
.tile .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.tile .val.low { color: var(--warn); }
.tile .val.zero { color: var(--bad); }
.tile button { margin-top: 6px; }

/* ---------- диалоги ---------- */
dialog { border: 0; border-radius: 16px; padding: 0; background: var(--surface); color: var(--text); width: min(460px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(10, 12, 18, .45); }
.dlg { padding: 22px; }
.wide-dlg { width: min(640px, calc(100vw - 32px)); }
dialog:has(.wide-dlg) { width: min(640px, calc(100vw - 32px)); }
.cred { background: var(--code-bg); border-radius: 10px; padding: 12px 14px; white-space: pre-wrap; font-size: 14px; margin: 0 0 16px; user-select: all; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 14px; margin: 4px 0 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.inline-form { display: flex; gap: 6px; }
.inline-form input { width: 90px; padding: 6px 10px; }
.scroll { max-height: 280px; overflow-y: auto; }

/* ---------- вход ---------- */
.login-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px; background: var(--bg); }
.login-title { font-family: var(--display); font-weight: 500; font-size: 26px; margin: 0 0 6px; }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 28px; }
.login-card .btn { margin: 4px 0 14px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 10px; font-size: 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,.2); z-index: 50; max-width: calc(100vw - 32px);
}

@media (max-width: 640px) {
  .page { padding: 14px 16px 32px; }
  .card { padding: 16px; }
  .table-wrap { margin: 10px -16px -16px; }
  .table th, .table td { padding: 8px 12px; }
  .cid-grid { grid-template-columns: repeat(2, 1fr); }
  .cid-big { font-size: 16px; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .hide-sm { display: none; }
  .search { width: 120px; }
  .hist { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 0 0; }
  .kv dd { margin-bottom: 8px; }
  #balance-pill { display: none; }
}

@media (max-width: 640px) {
  .logo-lg .stars { width: 60px; height: 40px; }
  .logo-lg .w1 { font-size: 44px; }
  .logo-lg .w2 { font-size: 14px; }
}

/* логотип на белой странице входа — тёмно-синий, как на основном сайте на светлом фоне */
.login-wrap .logo { color: var(--text); }
.login-wrap .logo .w2 { color: var(--cyan); }

/* ---------- реестр ключей ---------- */
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.form-grid label { margin-bottom: 12px; }
.switch { display: flex; gap: 10px; align-items: flex-start; color: var(--text); font-size: 14px; margin: 0 0 6px; }
.switch input { width: auto; margin-top: 3px; }
.claim-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.claim-row:last-child { border-bottom: 0; }
.found { margin-top: 14px; }
.table td .btn { white-space: nowrap; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; gap: 0; } }
.days-input { width: 80px; padding: 5px 8px; text-align: right; }
.table tbody tr.static { cursor: default; }
.table tbody tr.static:hover { background: none; }

/* форма возврата по браку */
.claim-form { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.claim-opts { display: flex; flex-direction: column; gap: 6px; }
.claim-opt { display: flex; align-items: center; gap: 8px; cursor: pointer; margin: 0; font-size: 15px; color: var(--text); }
.claim-opt input { margin-top: 0; }
.claim-opt input { width: auto; margin: 0; }
.claim-form textarea { width: 100%; margin-bottom: 0; }

/* ---------- платная версия: пакеты и оплата ---------- */
.packages { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin: 8px 0 14px; }
.package { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; text-align: left; cursor: pointer;
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); transition: border-color .15s, transform .15s; }
.package:hover { border-color: var(--accent); transform: translateY(-1px); }
.package .p-title { font-weight: 600; }
.package .p-price { font-family: var(--display); font-size: 26px; font-weight: 500; }
.pay-box h3 { margin-bottom: 8px; }
.pay-details { white-space: pre-wrap; font: inherit; background: var(--surface-2); border-radius: 10px; padding: 10px 12px; margin: 0 0 12px; }
.order-row { padding: 10px 0; border-bottom: 1px solid var(--line); gap: 8px; flex-wrap: wrap; }
.order-row:last-child { border-bottom: 0; }
.pill.clickable { cursor: pointer; }

/* ---------- платная версия: своя цветовая схема (без фирменных цветов Ориона) ---------- */
html.theme-alt {
  --navy: #1b1f2e; --navy-2: #262b3f; --cyan: #7c5cff; --cyan-light: #b9a8ff;
  --head-bg: #1b1f2e; --head-line: #2b3048;
  --key-bg: #1b1f2e; --key-hover: #2b3048;
  --sec-bg: #7c5cff; --sec-ink: #ffffff; --sec-hover: #6a48f5;
  --accent: #7c5cff; --accent-ink: #ffffff; --accent-text: #5b3ee6; --accent-soft: #ece7ff;
  --text: #171a26; --line: #e0e2ec; --surface-2: #f4f4fa; --code-bg: #eeeef6;
}
@media (prefers-color-scheme: dark) {
  html.theme-alt {
    --bg: #11131c; --surface: #1a1d2a; --surface-2: #222638; --head-bg: #1a1d2a; --head-line: #2b3048;
    --key-bg: #7c5cff; --key-ink: #ffffff; --key-hover: #8f74ff;
    --sec-bg: #2b3048; --sec-ink: #ecebff; --sec-hover: #363c5a;
    --text: #eceef7; --muted: #a1a6bd; --line: #2e3350;
    --accent: #8f74ff; --accent-ink: #ffffff; --accent-text: #b9a8ff; --accent-soft: #2a2550; --code-bg: #262a3e;
  }
}
.login-card a { color: var(--accent-text); font-weight: 600; }
html.theme-alt .pill { background: rgba(124, 92, 255, .18); color: #c9bbff; }
html.theme-alt .tabs button.active { color: #c9bbff; background: rgba(124, 92, 255, .16); border-color: rgba(124, 92, 255, .5); }
.auth-links { text-align: center; margin-top: 14px; }
.auth-links a { color: var(--muted); }
.pay-row { flex-wrap: wrap; margin-bottom: 12px; }
.pay-row input { flex: 1 1 260px; width: auto; }
