/* Тёплые поигрульки — общая тема сайта и панели.
   Светлая «дневная» и тёмная «вечерняя» палитры на CSS-переменных.
   Тема переключается атрибутом data-theme="dark" на <html>. */

:root {
  --page-1: #fff9ee;
  --page-2: #fbe6c0;
  --page-3: #f2d09c;
  --page-glow-1: #ffe9bd;
  --page-glow-2: #ffd9a0;
  --page-glow-3: #f2c98f;
  --app-glow: #fff1d6;
  --app-1: #fdf7ea;
  --app-2: #f8efdd;

  --surface: #fffdf8;
  --surface-soft: #fdefd6;
  --surface-hover: #f8e3c0;
  --topbar: rgba(255, 251, 242, 0.86);

  --text: #4a2c17;
  --text-soft: #6b4b33;
  --muted: #8a735f;

  --accent: #c97b3c;
  --accent-2: #a65f2a;
  --accent-soft: rgba(201, 123, 60, 0.14);
  --gold: #e0a458;
  --cherry: #b3413c;
  --sage: #7a8b5c;

  --line: rgba(74, 44, 23, 0.14);
  --line-soft: rgba(74, 44, 23, 0.08);
  --dots: rgba(166, 95, 42, 0.16);
  --shadow: 0 24px 60px -24px rgba(74, 44, 23, 0.38);
  --card-shadow: 0 14px 34px -26px rgba(74, 44, 23, 0.5);

  --input-bg: #fffdf8;
  --input-focus: rgba(201, 123, 60, 0.16);
  --code-bg: #fff8ec;
  --alert-bg: rgba(179, 65, 60, 0.09);
  --alert-line: rgba(179, 65, 60, 0.22);
  --alert-text: #7d2a26;
  --notice-bg: rgba(224, 164, 88, 0.13);
  --notice-line: rgba(224, 164, 88, 0.35);
  --dot-off: #c9b9a7;
  --dot-on: #5f9e57;
  --radius: 18px;
}

html[data-theme="dark"] {
  --page-1: #17110c;
  --page-2: #241812;
  --page-3: #120d0a;
  --page-glow-1: rgba(87, 52, 24, 0.55);
  --page-glow-2: rgba(63, 35, 16, 0.5);
  --page-glow-3: rgba(38, 21, 12, 0.6);
  --app-glow: rgba(90, 54, 24, 0.28);
  --app-1: #171210;
  --app-2: #120e0b;

  --surface: #221913;
  --surface-soft: #2b2018;
  --surface-hover: #35271c;
  --topbar: rgba(24, 18, 14, 0.88);

  --text: #f2e6d6;
  --text-soft: #d8c3ab;
  --muted: #a99078;

  --accent: #d98a4a;
  --accent-2: #b96f34;
  --accent-soft: rgba(217, 138, 74, 0.16);
  --gold: #e0a458;
  --cherry: #e06a63;
  --sage: #93a86f;

  --line: rgba(255, 235, 210, 0.16);
  --line-soft: rgba(255, 235, 210, 0.08);
  --dots: rgba(255, 214, 160, 0.10);
  --shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.75);
  --card-shadow: 0 14px 34px -26px rgba(0, 0, 0, 0.6);

  --input-bg: #19120d;
  --input-focus: rgba(217, 138, 74, 0.22);
  --code-bg: #19120d;
  --alert-bg: rgba(224, 106, 99, 0.12);
  --alert-line: rgba(224, 106, 99, 0.32);
  --alert-text: #f3b4af;
  --notice-bg: rgba(224, 164, 88, 0.10);
  --notice-line: rgba(224, 164, 88, 0.28);
  --dot-off: #5c4a3a;
  --dot-on: #79c06f;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  color: var(--text);
  font: 15px/1.55 "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-2); }
html[data-theme="dark"] a { color: var(--accent); }

.serif {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

/* ------------------------------------------------------------ toggle */

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  color: var(--text-soft);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}
.theme-toggle:hover { background: var(--surface-hover); }
.theme-toggle .i-moon, .theme-toggle .i-sun { display: grid; place-items: center; }
.theme-toggle .i-sun { display: none; }
html[data-theme="dark"] .theme-toggle .i-sun { display: grid; }
html[data-theme="dark"] .theme-toggle .i-moon { display: none; }

/* ============================================================= site */

body.site {
  min-height: 100vh;
  background:
    radial-gradient(1000px 420px at 12% -10%, var(--app-glow) 0%, rgba(0, 0, 0, 0) 62%),
    linear-gradient(180deg, var(--app-1) 0%, var(--app-2) 100%);
  background-attachment: fixed;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--topbar);
  border-bottom: 1px solid var(--line-soft);
  backdrop-filter: blur(10px);
}
.site-header .inner {
  max-width: 1020px;
  margin: 0 auto;
  padding: 0 22px;
  min-height: 62px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.site-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 19px;
  letter-spacing: 0.2px;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.site-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.site-nav a.plain, .site-nav button.plain {
  padding: 8px 12px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-soft);
  text-decoration: none;
  background: none;
  border: 0;
  border-radius: 9px;
  cursor: pointer;
}
.site-nav a.plain:hover, .site-nav button.plain:hover { background: var(--line-soft); }
.site-nav a.plain.on { color: var(--text); background: var(--accent-soft); }
.site-nav form { display: inline; }

.site-main {
  max-width: 820px;
  margin: 0 auto;
  padding: 34px 22px 56px;
}

.site-hero { margin-bottom: 28px; }
.site-hero h1 {
  margin: 0 0 10px;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 34px;
  line-height: 1.15;
}
.site-hero p {
  margin: 0;
  max-width: 620px;
  color: var(--muted);
  font-size: 15.5px;
}

.news-card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 22px 26px;
  margin-bottom: 16px;
  box-shadow: var(--card-shadow);
}
.news-card h2 {
  margin: 0 0 6px;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 21px;
  font-weight: 600;
}
.news-card h2 a { color: var(--text); text-decoration: none; }
.news-card h2 a:hover { color: var(--accent); }
.news-card .meta {
  margin: 0 0 10px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--muted);
}
.news-card p { margin: 0 0 12px; color: var(--text-soft); }

.more { color: var(--accent-2); text-decoration: none; font-weight: 600; font-size: 14px; }
html[data-theme="dark"] .more { color: var(--accent); }
.more:hover { text-decoration: underline; }

.post h1 {
  margin: 6px 0 18px;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 30px;
  line-height: 1.2;
}
.post .meta {
  margin: 0;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: var(--muted);
}
.post-body { font-size: 16px; line-height: 1.75; color: var(--text); }
.post-body p { margin: 14px 0; }
.post-body strong { color: var(--text); }

.site-foot {
  border-top: 1px solid var(--line-soft);
  padding: 22px;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
}

/* ---------- страница входа ---------- */

.auth-page { display: grid; place-items: center; padding: 20px 0 40px; }

.form-card {
  width: min(420px, 100%);
  padding: 28px 30px 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}
.form-card h1 {
  margin: 0 0 4px;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 26px;
}
.form-card .sub { margin: 0 0 18px; color: var(--muted); font-size: 13.5px; }

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 5px;
  margin-bottom: 18px;
  background: var(--line-soft);
  border-radius: 13px;
}
.tabs a {
  padding: 9px 4px;
  text-align: center;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-soft);
  text-decoration: none;
  border-radius: 9px;
}
.tabs a.on { background: var(--surface); color: var(--text); box-shadow: 0 2px 8px -2px rgba(0, 0, 0, 0.28); }

.auth-form { display: grid; gap: 13px; }

.field { display: grid; gap: 6px; }
.field span {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--muted);
}
.field input {
  width: 100%;
  padding: 12px 14px;
  font: inherit;
  color: var(--text);
  background: var(--input-bg);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--input-focus); }

.fine { margin: 2px 0 0; text-align: center; font-size: 12.5px; color: var(--muted); }

/* ------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.06s, background 0.15s, filter 0.15s;
}
.btn:hover { background: var(--surface-hover); }
.btn:active { transform: translateY(1px); }

.btn.primary {
  color: #fff6e6;
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-2) 100%);
  border-color: var(--accent-2);
  box-shadow: 0 10px 20px -10px rgba(120, 65, 25, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.btn.primary:hover { filter: brightness(1.06); }

.btn.block { width: 100%; padding: 13px 18px; font-size: 15.5px; }
.btn.small { padding: 7px 13px; font-size: 13px; border-radius: 9px; }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--line-soft); }
.btn.danger { color: var(--cherry); border-color: rgba(179, 65, 60, 0.35); background: rgba(179, 65, 60, 0.07); }
.btn.danger:hover { background: rgba(179, 65, 60, 0.16); }

.alert {
  margin-bottom: 14px;
  padding: 11px 14px;
  font-size: 13.5px;
  color: var(--alert-text);
  background: var(--alert-bg);
  border: 1px solid var(--alert-line);
  border-radius: 11px;
}

/* ============================================================== app */

body.app {
  min-height: 100vh;
  background:
    radial-gradient(900px 380px at 12% -10%, var(--app-glow) 0%, rgba(0, 0, 0, 0) 60%),
    linear-gradient(180deg, var(--app-1) 0%, var(--app-2) 100%);
  background-attachment: fixed;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 22px;
  min-height: 62px;
  background: var(--topbar);
  border-bottom: 1px solid var(--line-soft);
  backdrop-filter: blur(10px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 18px;
  letter-spacing: 0.2px;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.brand svg { flex: none; }

.topnav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.topnav a, .topnav button:not(.theme-toggle) {
  padding: 7px 12px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-soft);
  text-decoration: none;
  background: none;
  border: 0;
  border-radius: 9px;
  cursor: pointer;
}
.topnav a:hover, .topnav button:not(.theme-toggle):hover { background: var(--line-soft); }
.topnav a.on { color: var(--text); background: var(--accent-soft); }
.topnav form { display: inline; }

.wrap {
  max-width: 1060px;
  margin: 0 auto;
  padding: 30px 22px 60px;
}

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

h1 {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.sub { margin: 5px 0 0; color: var(--muted); font-size: 14px; }

.chips { display: flex; gap: 10px; flex-wrap: wrap; margin: 0 0 24px; }

.chip {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 9px 15px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 13px;
  font-size: 13px;
  color: var(--muted);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset;
}
.chip b { color: var(--text); font-size: 15px; }

.key-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 16px;
}

.key-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 19px 16px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  overflow: hidden;
}
.key-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--gold);
}
.key-card.t-xray::before { background: var(--accent); }
.key-card.t-xray-split::before { background: var(--sage); }
.key-card.t-awg::before { background: #8a6fb0; }
.key-card.off { opacity: 0.62; }

.key-head { display: flex; align-items: center; gap: 12px; }

.key-ico {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: none;
  font-size: 21px;
  background: var(--surface-soft);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
}

.key-title { margin: 0; font-size: 15.5px; font-weight: 700; }
.key-fam { font-size: 12px; color: var(--muted); }
.key-mail {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 11.5px;
  color: var(--muted);
  word-break: break-all;
}

.dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--dot-off);
  box-shadow: 0 0 0 3px rgba(201, 185, 167, 0.2);
}
.dot.on { background: var(--dot-on); box-shadow: 0 0 0 3px rgba(95, 158, 87, 0.2); }

.key-metrics {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 0 0;
  border-top: 1px dashed var(--line-soft);
  font-size: 13px;
}
.key-metrics .m { display: inline-flex; align-items: center; gap: 5px; }
.key-metrics .m span { color: var(--muted); }
.key-metrics .grow { margin-left: auto; color: var(--muted); font-size: 12px; }

.key-actions { display: flex; gap: 8px; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  border-radius: 99px;
  background: var(--line-soft);
  color: var(--text-soft);
}
.badge.red { background: rgba(179, 65, 60, 0.16); color: var(--cherry); }
.badge.green { background: rgba(95, 158, 87, 0.18); color: var(--dot-on); }
.badge.gold { background: rgba(224, 164, 88, 0.2); color: var(--gold); }

.empty {
  padding: 40px 26px;
  text-align: center;
  background: var(--surface);
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
}
.empty .big { font-size: 40px; line-height: 1; margin-bottom: 10px; }
.empty h3 { margin: 0 0 6px; font-size: 17px; }
.empty p { margin: 0 0 18px; color: var(--muted); font-size: 14px; }

/* ---------- выбор типа ключа ---------- */

.type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 16px;
}

.type-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  transition: transform 0.12s, box-shadow 0.12s;
}
.type-card:hover { transform: translateY(-2px); box-shadow: 0 22px 44px -26px rgba(0, 0, 0, 0.55); }

.type-card .key-ico { width: 48px; height: 48px; font-size: 24px; }
.type-card h3 { margin: 0; font-size: 17px; }
.type-card .fam { font-size: 12px; color: var(--muted); margin-top: -8px; }
.type-card p { margin: 0; font-size: 13.5px; color: var(--text-soft); }
.type-card .tagline { font-weight: 600; color: var(--text); font-size: 13.5px; }
.type-card form { margin-top: auto; }

/* ---------- страница ключа ---------- */

.back {
  display: inline-block;
  margin-bottom: 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
}
.back:hover { color: var(--text); }

.panel-card {
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  margin-bottom: 16px;
}

.key-hero { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.key-hero .key-ico { width: 56px; height: 56px; font-size: 28px; }
.key-hero h1 { font-size: 24px; }
.key-hero .sub { margin-top: 3px; }

.steps { margin: 0; padding: 0; list-style: none; counter-reset: s; }
.steps li { position: relative; padding: 8px 0 8px 38px; counter-increment: s; font-size: 14px; }
.steps li::before {
  content: counter(s);
  position: absolute;
  left: 0; top: 7px;
  display: grid;
  place-items: center;
  width: 25px; height: 25px;
  font-size: 12.5px;
  font-weight: 700;
  color: #fff6e6;
  background: var(--accent);
  border-radius: 50%;
}

.codebox { display: grid; gap: 8px; margin-top: 6px; }
.codebox textarea {
  width: 100%;
  min-height: 88px;
  padding: 11px 12px;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
  color: var(--text);
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 11px;
  resize: vertical;
}

.notes { font-size: 13px; color: var(--muted); }
.notes b { color: var(--text-soft); }

/* ---------- таблицы ---------- */

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

table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
  padding: 9px 12px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }
.tbl form { display: inline; }

/* ---------- дерево приглашений ---------- */

.tree, .tree ul { list-style: none; margin: 0; padding-left: 20px; }
.tree { padding-left: 0; }
.tree li { position: relative; padding: 3px 0; font-size: 13.5px; }
.tree li::before { content: ""; position: absolute; left: -12px; top: 0; bottom: 0; border-left: 1px solid var(--line); }
.tree > li::before { border: 0; }
.tree li::after { content: ""; position: absolute; left: -12px; top: 16px; width: 9px; border-top: 1px solid var(--line); }
.tree > li::after { border: 0; }
.tree .who { font-weight: 600; }
.tree .when { color: var(--muted); font-size: 12px; margin-left: 8px; }

/* ---------- служебное ---------- */

.notice {
  padding: 14px 16px;
  background: var(--notice-bg);
  border: 1px solid var(--notice-line);
  border-radius: 12px;
  font-size: 13.5px;
}

.foot {
  padding: 26px 0 34px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.error-page { display: grid; place-items: center; min-height: 60vh; text-align: center; }
.error-page .code {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 74px;
  line-height: 1;
  color: var(--accent);
}
.error-page p { color: var(--muted); }

@media (max-width: 640px) {
  .wrap { padding: 20px 14px 48px; }
  .site-main { padding: 24px 14px 44px; }
  .topbar { height: auto; padding: 10px 14px; flex-wrap: wrap; }
  .topnav { width: 100%; justify-content: flex-start; }
  h1 { font-size: 23px; }
  .site-hero h1 { font-size: 26px; }
  .post h1 { font-size: 24px; }
}
