:root {
  color-scheme: dark;
  --bg: #090a0b;
  --panel: #111214;
  --line: #302d27;
  --text: #eee9df;
  --muted: #8f897e;
  --gold: #c2a064;
  --soft: #211d16;
  --ok: #9dba87;
  --bad: #d8786f;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 Inter, "Segoe UI", sans-serif; }
a { color: inherit; }
button, input, select { font: inherit; }
button:disabled { opacity: .45; cursor: not-allowed; }
.shell { max-width: 1240px; margin: auto; padding: 0 28px; }
.top { height: 76px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 700; letter-spacing: .08em; }
.brand img { width: 38px; height: 38px; }
.chip { font: 11px Consolas, monospace; color: var(--gold); border: 1px solid #4a3d28; padding: 5px 8px; border-radius: 5px; }
.public-nav a { color: var(--muted); text-decoration: none; }
.public-nav a:hover, .text-link:hover { color: var(--text); }
.hero { min-height: 620px; display: grid; grid-template-columns: 1.25fr .75fr; align-items: center; gap: 70px; }
.eyebrow { font: 12px Consolas, monospace; color: var(--gold); letter-spacing: .16em; }
.hero h1 { font-size: clamp(46px, 5vw, 66px); line-height: 1.03; margin: 18px 0 22px; max-width: 720px; }
.hero p { font-size: 18px; color: var(--muted); max-width: 620px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 30px; }
.button { display: inline-flex; align-items: center; justify-content: center; padding: 15px 24px; background: var(--gold); color: #17140f; text-decoration: none; font-weight: 750; border: 1px solid var(--gold); border-radius: 9px; cursor: pointer; }
.button.secondary { background: transparent; color: var(--text); border-color: var(--line); }
.button.small { padding: 11px 16px; margin: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 26px; }
.brand-card { padding: 38px; }
.mark { width: 100%; max-width: 310px; display: block; margin: auto; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 28px 0 70px; }
.fact { padding: 20px; border-top: 1px solid var(--line); color: var(--muted); }
.fact b { display: block; color: var(--text); margin-bottom: 5px; }
.message, .muted { color: var(--muted); }
.message { margin: 12px 0; white-space: pre-wrap; }
.download-hero { min-height: calc(100vh - 76px); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 60px 0 120px; }
.download-mark { width: 150px; height: 150px; object-fit: contain; }
.download-hero h1 { margin: 18px 0 4px; font-size: clamp(42px, 6vw, 64px); }
.download-hero .hero-actions { justify-content: center; }
.mono { font-family: Consolas, monospace; }
.hidden { display: none !important; }
.row, .toolbar, .panel-tools { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.toolbar { justify-content: space-between; margin-bottom: 24px; }
.toolbar h1, .section-head h2 { margin: 5px 0 0; }
.input, select { min-height: 43px; background: #0c0d0e; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 10px 13px; }
.input { min-width: 250px; }
.ghost, .tab { background: transparent; border: 1px solid var(--line); color: var(--muted); padding: 9px 12px; border-radius: 8px; cursor: pointer; }
.ghost { text-decoration: none; }
.ghost:hover, .tab:hover, .tab.active { background: var(--soft); color: var(--text); }
.danger { color: var(--bad); }

.guide { padding-bottom: 80px; }
.guide-head { padding: 74px 0 42px; max-width: 720px; }
.guide-head h1 { font-size: 48px; margin: 9px 0 8px; }
.guide-head p { color: var(--muted); font-size: 18px; }
.requirements h2, .troubles h2 { margin-top: 0; }
.requirement-grid, .trouble-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 26px; }
.requirement-grid span { display: block; font: 12px Consolas, monospace; color: var(--gold); margin-bottom: 14px; }
.requirement-grid b, .trouble-grid b { display: block; }
.requirement-grid p, .trouble-grid p { color: var(--muted); margin-bottom: 0; }
.steps { margin: 24px 0; border-top: 1px solid var(--line); }
.steps article { display: grid; grid-template-columns: 80px 1fr; gap: 24px; padding: 32px 4px; border-bottom: 1px solid var(--line); }
.steps article > span { font: 14px Consolas, monospace; color: var(--gold); }
.steps h2 { margin: 0 0 8px; font-size: 23px; }
.steps p { color: var(--muted); margin: 0; max-width: 760px; }
.text-link { display: inline-block; color: var(--gold); margin-top: 13px; }
.compact-guide { max-width: 920px; }
.compact-guide .guide-head { padding-bottom: 20px; }
.guide-block { border-top: 1px solid var(--line); padding: 28px 0; }
.guide-block h2 { margin: 0 0 15px; font-size: 24px; }
.guide-block p, .guide-block li { color: var(--muted); }
.guide-block li { margin: 10px 0; padding-left: 6px; }
.guide-block strong { color: var(--text); }
.guide-block .button { margin-top: 14px; }
.note { background: var(--panel); border-left: 3px solid var(--gold); padding: 14px 16px; border-radius: 0 8px 8px 0; }

.admin { padding: 38px 0 80px; }
.auth-card { min-height: 360px; display: grid; grid-template-columns: 1fr 430px; gap: 70px; align-items: center; margin-top: 50px; }
.auth-card h1 { font-size: 42px; margin: 10px 0; }
.auth-card p { color: var(--muted); }
.auth-form { display: grid; gap: 10px; }
.auth-form .input { width: 100%; }
.grid { display: grid; gap: 12px; margin-bottom: 22px; }
.metrics { grid-template-columns: repeat(5, 1fr); }
.metric strong { display: block; font-size: 29px; font-weight: 500; }
.metric span { display: block; font: 11px Consolas, monospace; color: var(--muted); margin-top: 7px; }
.admin-columns { display: grid; grid-template-columns: .9fr 1.1fr; gap: 14px; }
.section-head { margin-bottom: 20px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; }
.form-grid label { display: grid; gap: 7px; color: var(--muted); font-size: 14px; }
.form-grid select, .form-grid .input { width: 100%; min-width: 0; }
.key-output { min-height: 64px; border: 1px dashed var(--line); border-radius: 10px; padding: 14px; margin-top: 18px; display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.key-output span, .key-output strong { display: block; }
.key-output strong { color: var(--text); margin-top: 4px; }
.product-list { display: grid; gap: 8px; }
.product-row { display: flex; align-items: center; justify-content: space-between; gap: 15px; border-top: 1px solid #292720; padding: 14px 0; }
.product-row:first-child { border-top: 0; padding-top: 0; }
.product-row > div { display: flex; align-items: center; gap: 10px; }
.product-row > div:first-child { display: grid; gap: 2px; }
.product-row span { color: var(--muted); font-size: 13px; }
.tabs { display: flex; gap: 8px; margin: 24px 0 10px; }
.data-panel { padding: 0; overflow: hidden; }
.panel-tools { padding: 18px; border-bottom: 1px solid var(--line); }
.panel-tools .muted { margin-left: auto; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; border-bottom: 1px solid #252521; padding: 13px 12px; vertical-align: middle; white-space: nowrap; }
th { color: var(--muted); font: 11px Consolas, monospace; }
td:last-child { white-space: normal; }
.actions { display: flex; gap: 6px; }
.pill { display: inline-flex; padding: 4px 8px; border-radius: 999px; border: 1px solid var(--line); font: 11px Consolas, monospace; }
.pill.ok { color: var(--ok); border-color: #3d4c35; background: #151b13; }
.pill.bad { color: var(--bad); border-color: #53332f; background: #1c1312; }
.pill.gold { color: var(--gold); border-color: #55462d; background: #1f1a12; }
.empty { padding: 30px; color: var(--muted); text-align: center; }
.switch { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }

/* Control surface */
.admin-body { min-width: 320px; }
.control-head { margin-bottom: 18px; }
.control-head h1 { margin: 4px 0 0; font-size: 32px; }
.metrics-wide { grid-template-columns: repeat(7, 1fr); }
.metric-button { appearance: none; color: inherit; text-align: left; cursor: pointer; font: inherit; }
.metric-button:hover { border-color: #5c4b30; background: #15140f; transform: translateY(-1px); }
.metric-button { transition: border-color .16s ease, background .16s ease, transform .16s ease; }
.control-nav { position: sticky; top: 0; z-index: 20; display: flex; gap: 6px; padding: 10px; margin: 22px 0 14px; background: rgba(9,10,11,.94); border: 1px solid var(--line); border-radius: 12px; backdrop-filter: blur(14px); }
.control-tab { border: 0; color: var(--muted); background: transparent; padding: 10px 14px; border-radius: 8px; cursor: pointer; }
.control-tab:hover, .control-tab.active { color: var(--text); background: var(--soft); }
.tab-count { display: inline-flex; min-width: 23px; justify-content: center; margin-left: 6px; padding: 2px 6px; border-radius: 999px; background: #0c0d0e; color: var(--gold); font: 11px Consolas, monospace; }
.control-view { animation: control-in .16s ease-out; }
@keyframes control-in { from { opacity: 0; transform: translateY(4px); } }
.overview-columns { grid-template-columns: 1.1fr .9fr; }
.overview-lower { display: grid; grid-template-columns: .8fr 1.2fr; gap: 14px; margin-top: 14px; }
.section-head-row, .panel-title { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.factory-grid { display: grid; grid-template-columns: 1.3fr 1fr .8fr auto; gap: 10px; align-items: end; }
.factory-grid label { display: grid; gap: 7px; color: var(--muted); font-size: 14px; }
.factory-grid input, .factory-grid select { width: 100%; min-width: 0; }
.key-result { width: 100%; display: grid; gap: 10px; }
.key-result textarea { width: 100%; min-height: 110px; resize: vertical; color: var(--text); background: #090a0b; border: 1px solid var(--line); border-radius: 8px; padding: 11px; }
.compact-panel { min-height: 316px; }
.health-list { display: grid; gap: 19px; }
.health-row > div:first-child { display: flex; justify-content: space-between; margin-bottom: 7px; }
.health-row span { color: var(--muted); }
.health-track { height: 7px; overflow: hidden; background: #090a0b; border-radius: 99px; }
.health-track i { display: block; height: 100%; background: var(--gold); border-radius: inherit; }
.health-track i.ok { background: var(--ok); }
.health-track i.bad { background: var(--bad); }
.activity-list { display: grid; }
.activity-item { display: grid; grid-template-columns: 9px 1fr auto; align-items: center; gap: 12px; width: 100%; padding: 12px 0; border: 0; border-top: 1px solid #292720; color: var(--text); background: transparent; text-align: left; cursor: pointer; }
.activity-item:first-child { border-top: 0; }
.activity-item:hover b { color: var(--gold); }
.activity-item span:nth-child(2) { display: grid; min-width: 0; }
.activity-item small { color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.activity-item time { color: var(--muted); font: 12px Consolas, monospace; }
.activity-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.activity-dot.bad { background: var(--bad); }
.panel-title { padding: 22px 18px 16px; border-bottom: 1px solid var(--line); }
.panel-title h2 { margin: 4px 0 0; }
.filter-grid { display: grid; grid-template-columns: minmax(260px, 1fr) repeat(3, minmax(150px, auto)); gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.filter-grid .input { min-width: 0; width: 100%; }
.bulk-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 12px 18px; background: var(--soft); border-bottom: 1px solid #4a3d28; }
.bulk-bar b { margin-right: 8px; color: var(--gold); }
.clickable-row:hover { background: #13130f; }
.message-cell { max-width: 420px; overflow: hidden; text-overflow: ellipsis; }
.key-cell { display: flex; align-items: center; gap: 8px; }
.key-cell .mono { color: var(--gold); }
.copy-mini { flex: 0 0 auto; padding: 3px 7px; color: var(--muted); background: transparent; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; }
.copy-mini:hover { color: var(--text); background: var(--soft); }
.pager { display: flex; justify-content: center; align-items: center; gap: 14px; padding: 15px; }
.control-dialog { width: min(680px, calc(100vw - 32px)); color: var(--text); background: var(--panel); border: 1px solid #51452f; border-radius: 16px; padding: 28px; box-shadow: 0 24px 90px rgba(0,0,0,.65); }
.control-dialog::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(4px); }
.control-dialog h2 { margin: 6px 0 22px; }
.control-dialog form { position: absolute; right: 14px; top: 12px; }
.dialog-close { color: var(--muted); background: transparent; border: 0; font-size: 28px; cursor: pointer; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; overflow: hidden; margin: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--line); }
.detail-grid div { min-width: 0; padding: 13px; background: #0c0d0e; }
.detail-grid dt { color: var(--muted); font-size: 12px; }
.detail-grid dd { margin: 5px 0 0; overflow-wrap: anywhere; }
.detail-grid .detail-key { grid-column: 1 / -1; }
.detail-key dd { display: flex; align-items: center; gap: 9px; }
.dialog-section { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.dialog-section h3 { margin-top: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }
.log-dialog { width: min(900px, calc(100vw - 32px)); }
.log-actions { display: flex; gap: 8px; margin: -10px 0 12px; }
.log-dialog pre { max-height: 62vh; overflow: auto; color: #d8d1c5; background: #070809; border: 1px solid var(--line); border-radius: 10px; padding: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.diagnostic-strip { padding: 11px 18px; color: var(--muted); background: #0d0e0f; border-bottom: 1px solid var(--line); font-size: 13px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 100; max-width: 420px; padding: 12px 16px; color: #111; background: var(--ok); border-radius: 9px; box-shadow: 0 16px 50px rgba(0,0,0,.4); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .18s ease; }
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { color: #fff; background: var(--bad); }

@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; padding: 65px 0; }
  .hero .brand-card { display: none; }
  .metrics { grid-template-columns: repeat(3, 1fr); }
  .admin-columns, .auth-card { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .metrics-wide { grid-template-columns: repeat(3, 1fr); }
  .overview-lower { grid-template-columns: 1fr; }
  .factory-grid, .filter-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 700px) {
  .shell { padding: 0 18px; }
  .facts, .requirement-grid, .trouble-grid, .metrics { grid-template-columns: 1fr; }
  .hero { min-height: auto; }
  .guide-head h1 { font-size: 38px; }
  .steps article { grid-template-columns: 45px 1fr; gap: 12px; }
  .auth-card { margin-top: 24px; padding: 20px; }
  .auth-card h1 { font-size: 34px; }
  .panel-tools .input, .panel-tools select { width: 100%; min-width: 0; }
  .panel-tools .muted { margin-left: 0; }
  .metrics-wide, .factory-grid, .filter-grid, .detail-grid { grid-template-columns: 1fr; }
  .control-nav { overflow-x: auto; position: static; }
  .control-tab { white-space: nowrap; }
  .control-head .row { align-items: flex-start; }
  .section-head-row, .panel-title { align-items: flex-start; }
  .dialog-actions { justify-content: flex-start; flex-wrap: wrap; }
  .toast { left: 18px; right: 18px; bottom: 18px; }
}
