/* Панель «Гонка». Стиль — по макету «Панель администратора»: светлая рамка с фиолетовым свечением
   на чёрном, тёмные обводки, серые плашки, цветные статусы. Mobile-first. */

@font-face { font-family: 'Unbounded'; src: url('../fonts/unbounded-latin-wght-normal.woff2') format('woff2'); font-weight: 200 900; font-display: swap; 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+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Unbounded'; src: url('../fonts/unbounded-cyrillic-wght-normal.woff2') format('woff2'); font-weight: 200 900; font-display: swap; unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116, U+20BD; }
@font-face { font-family: 'Manrope'; src: url('../fonts/manrope-latin-wght-normal.woff2') format('woff2'); font-weight: 200 800; font-display: swap; 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+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Manrope'; src: url('../fonts/manrope-cyrillic-wght-normal.woff2') format('woff2'); font-weight: 200 800; font-display: swap; unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116, U+20BD; }

:root {
  --font-display: 'Unbounded', 'Segoe UI', system-ui, sans-serif;
  --font-text: 'Manrope', 'Segoe UI', system-ui, sans-serif;

  --page: #050505;
  --frame: #d9d9d9;
  --frame-edge: #ececec;
  --glow: #a61cff;
  --ink: #262626;          /* тёмные обводки и текст */
  --ink-2: #3a3a3a;
  --plate: #9d9d9d;        /* серые плашки */
  --plate-2: #b4b4b4;
  --plate-text: #f4f4f4;
  --muted: #5c5c5c;

  --free: #22c55e;
  --busy: #1fb6e8;
  --booked: #a855f7;
  --interrupted: #f59e0b;
  --offline: #6b6b6b;
  --danger: #e0242d;
  --danger-ink: #fff;

  --r-frame: 28px;
  --r-card: 18px;
  --r-pill: 999px;
  --tap: 44px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font: 15px/1.4 var(--font-text);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- рамка приложения ---------- */

.frame {
  margin: 8px;
  min-height: calc(100dvh - 16px);
  background: var(--frame);
  border: 3px solid var(--frame-edge);
  border-radius: var(--r-frame);
  box-shadow: 0 0 0 1px #5d1a8a, 0 0 28px 2px color-mix(in srgb, var(--glow) 70%, transparent);
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-areas: 'top' 'main' 'nav';
  overflow: clip;
}
.top { grid-area: top; }
.main { grid-area: main; }
.nav { grid-area: nav; position: sticky; bottom: 0; z-index: 20; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.top-actions .lbl { display: none; }
.top-actions .btn-sm { width: 40px; height: 40px; padding: 0; }

.top {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px 8px;
  flex-wrap: wrap;
}
.logo {
  font: 900 26px/1 var(--font-display);
  letter-spacing: .02em;
  color: var(--ink);
  margin-right: auto;
  user-select: none;
}
.search {
  order: 3;
  flex: 1 1 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--tap);
  padding: 0 14px;
  background: var(--plate);
  border: 2px solid var(--ink);
  border-radius: var(--r-pill);
  position: relative;
}
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  outline: none;
  color: var(--plate-text);
  font-family: var(--font-display);
  font-size: 12px;
}
.search input::placeholder { color: #ececec; opacity: .8; text-transform: lowercase; }
.search svg { flex: none; }
.search-results {
  position: absolute;
  left: 0; right: 0; top: calc(100% + 6px);
  background: var(--frame);
  border: 2px solid var(--ink);
  border-radius: var(--r-card);
  z-index: 30;
  max-height: 60dvh;
  overflow: auto;
  box-shadow: 0 10px 30px #0005;
}
.search-results button {
  display: flex; justify-content: space-between; gap: 8px;
  width: 100%; padding: 12px 14px; border: 0; background: none; text-align: left;
  border-bottom: 1px solid #0001;
}
.search-results button:hover, .search-results button:focus-visible { background: #0000000d; }

.role-pill {
  height: 40px;
  padding: 0 16px;
  border-radius: var(--r-pill);
  border: 0;
  background: var(--ink);
  color: #f2f2f2;
  font: 500 12px/40px var(--font-display);
  text-transform: lowercase;
  white-space: nowrap;
}

/* ---------- навигация ---------- */

.nav {
  display: flex;
  gap: 4px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: var(--ink);
  overflow-x: auto;
  scrollbar-width: none;
}
.nav a {
  flex: 1 0 auto;
  min-width: 64px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 8px;
  border-radius: 14px;
  color: #cfcfcf;
  text-decoration: none;
  font: 500 9.5px/1.1 var(--font-display);
  text-transform: lowercase;
}
.nav a svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.7; }
.nav a[aria-current='page'] { background: var(--plate); color: #fff; }

.main { padding: 4px 8px 12px; min-width: 0; }

/* ---------- плашки, кнопки, карточки ---------- */

.box {
  border: 6px solid var(--ink);
  border-radius: 26px;
  background: var(--frame);
  padding: 14px;
}
.card {
  border: 4px solid var(--ink);
  border-radius: var(--r-card);
  background: var(--plate-2);
  padding: 14px;
}
.card + .card, .box + .box, .card + .box, .box + .card { margin-top: 10px; }

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; margin: 0 0 10px; letter-spacing: .01em; }
h1 { font-size: 19px; }
h2 { font-size: 15px; }
h3 { font-size: 13px; }
.lc { text-transform: lowercase; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-variant-numeric: tabular-nums; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap);
  padding: 0 18px;
  border-radius: var(--r-pill);
  border: 2px solid var(--ink);
  background: var(--plate);
  color: #fff;
  font: 500 12px/1.1 var(--font-display);
  text-transform: lowercase;
  text-decoration: none;
  white-space: nowrap;
  transition: transform .08s ease, filter .15s ease;
}
.btn:active { transform: scale(.98); }
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; transform: none; }
.btn-dark { background: var(--ink); border-color: var(--ink); }
.btn-danger { background: var(--danger); border-color: #8c0d13; color: var(--danger-ink); }
.btn-ghost { background: transparent; color: var(--ink); }
.btn-block { width: 100%; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 11px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-col { display: grid; gap: 8px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  border: 2px solid var(--ink); background: var(--plate);
  display: inline-grid; place-items: center; color: #fff;
}
.icon-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; }

.pills { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 12px;
  border-radius: var(--r-pill);
  background: var(--plate);
  border: 2px solid var(--ink);
  color: #fff;
  font: 500 10.5px/1 var(--font-display);
  text-transform: lowercase;
}
.pill b { font-weight: 600; }
.pill .n-free { color: #9ff5bd; } .pill .n-busy { color: #a5e8ff; }
.pill .n-interrupted { color: #ffd38a; } .pill .n-offline { color: #d6d6d6; } .pill .n-maintenance { color: #ffb36b; }

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--offline); flex: none; }
.dot.free { background: var(--free); } .dot.busy { background: var(--busy); }
.dot.interrupted { background: var(--interrupted); } .dot.maintenance { background: #f97316; }
.dot.pulse { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--interrupted) 30%, transparent); } }

/* ---------- плитки ПК ---------- */

.pcs-layout { display: grid; gap: 10px; }
.pc-map { position: relative; display: grid; gap: 10px; }
.pc-map svg.track { display: none; }

.pc-tile {
  position: relative;
  border: 6px solid var(--ink);
  border-radius: 22px;
  background: var(--frame);
  padding: 5px;
  text-align: left;
  width: 100%;
}
.pc-tile .inner {
  border: 2px solid color-mix(in srgb, var(--state, var(--offline)) 55%, #fff);
  border-radius: 14px;
  background: var(--plate);
  min-height: 84px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto 1fr auto;
  color: #fff;
}
.pc-tile.free { --state: var(--free); } .pc-tile.busy { --state: var(--busy); }
.pc-tile.interrupted { --state: var(--interrupted); } .pc-tile.maintenance { --state: #f97316; }
.pc-tile[aria-pressed='true'] { box-shadow: 0 0 0 3px var(--glow); }
.pc-tile .name { font: 500 13px/1 var(--font-display); color: #eee; }
.pc-tile .dot { justify-self: end; }
.pc-tile .status {
  grid-column: 1 / -1; align-self: end; justify-self: end; text-align: right;
  font: 600 12.5px/1.25 var(--font-display); color: color-mix(in srgb, var(--state, #ddd) 70%, #fff);
  text-transform: lowercase;
  text-shadow: 0 1px 2px #0009, 0 0 1px #000a;
}
.pc-tile .status small { display: block; font: 500 10px/1.3 var(--font-text); color: #f1f1f1; text-transform: none; }
.pc-tile .who { grid-column: 1 / -1; font-size: 12px; color: #f5f5f5; opacity: .9; align-self: center; }

/* ---------- деталь ПК / формы ---------- */

.detail { min-width: 0; }
.detail .head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.detail .head h1 { margin: 0; }
.detail .state-line { display: flex; align-items: center; gap: 6px; font-size: 12.5px; margin-bottom: 12px; }
.big-time { font: 600 34px/1.1 var(--font-display); font-variant-numeric: tabular-nums; margin: 4px 0 2px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 12.5px; margin: 8px 0 12px; }
.kv dt { color: var(--muted); text-transform: lowercase; font-family: var(--font-display); font-size: 10.5px; padding-top: 2px; }
.kv dd { margin: 0; text-align: right; }

.field { display: grid; gap: 5px; margin-bottom: 12px; }
.field > span { font: 500 10.5px/1.2 var(--font-display); text-transform: lowercase; color: var(--ink-2); }
.input, select.input, textarea.input {
  width: 100%; min-height: var(--tap);
  padding: 9px 14px;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: #f3f3f3;
  outline: none;
}
.input:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--glow) 35%, transparent); }
textarea.input { min-height: 74px; resize: vertical; }
.check { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 10px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--ink); margin: 1px 0 0; flex: none; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 0; border: 2px solid var(--ink); border-radius: var(--r-pill); overflow: hidden; }
.seg button { min-height: 40px; border: 0; background: var(--plate-2); font: 500 11px/1 var(--font-display); text-transform: lowercase; color: var(--ink); }
.seg button + button { border-left: 2px solid var(--ink); }
.seg button[aria-pressed='true'] { background: var(--ink); color: #fff; }

.pkg-row { display: flex; flex-wrap: wrap; gap: 6px; }
.pkg-row .btn { flex: 1 1 0; min-width: 76px; }
.pkg-row .btn .small { font-family: var(--font-text); text-transform: none; opacity: .85; }

.total {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  padding: 12px 14px; margin: 6px 0 12px;
  background: var(--ink); color: #fff; border-radius: 16px;
}
.total .sum { font: 600 22px/1 var(--font-display); font-variant-numeric: tabular-nums; }
.total .sub { font-size: 12px; opacity: .8; }
.hint { padding: 10px 12px; border-radius: 12px; background: #fff7d6; border: 2px solid #c9a227; font-size: 13px; margin-bottom: 12px; }
.alert { padding: 12px 14px; border-radius: 14px; border: 2px solid var(--ink); background: #fff; margin-bottom: 12px; }
.alert.warn { background: #fff1d6; border-color: #b7791f; }
.alert.err { background: #ffe1e2; border-color: #a1161d; }
.alert.ok { background: #dcfce7; border-color: #15803d; }

.charges { width: 100%; border-collapse: collapse; font-size: 12.5px; margin: 4px 0 12px; }
.charges td { padding: 6px 0; border-bottom: 1px solid #00000014; vertical-align: top; }
.charges td:last-child { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

.table-wrap { overflow-x: auto; margin: 0 -2px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; font: 500 10px/1.2 var(--font-display); text-transform: lowercase; color: var(--muted); padding: 8px 8px; border-bottom: 2px solid var(--ink); white-space: nowrap; }
table.data td { padding: 9px 8px; border-bottom: 1px solid #0000001a; vertical-align: top; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data tr.click { cursor: pointer; }
table.data tr.click:hover td { background: #0000000a; }

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.stat { background: var(--ink); color: #fff; border-radius: 16px; padding: 12px; min-width: 0; }
.stat .k { font: 500 9.5px/1.2 var(--font-display); text-transform: lowercase; opacity: .75; }
.stat .v { font: 600 18px/1.2 var(--font-display); font-variant-numeric: tabular-nums; margin-top: 6px; overflow-wrap: anywhere; }
.stat.accent { background: var(--plate); border: 2px solid var(--ink); }

.list-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 4px; border-bottom: 1px solid #0000001a; }
.list-item:last-child { border-bottom: 0; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 8px; background: var(--ink); color: #fff; font-size: 11px; }
.tag.warn { background: #b45309; } .tag.ok { background: #15803d; } .tag.off { background: #7a7a7a; }

/* ---------- модальное окно / нижний лист ---------- */

.sheet-back { position: fixed; inset: 0; background: #000a; z-index: 50; display: grid; align-items: end; }
.sheet {
  background: var(--frame);
  border-radius: 24px 24px 0 0;
  border: 3px solid var(--frame-edge);
  border-bottom: 0;
  max-height: 92dvh; overflow: auto;
  padding: 16px 14px calc(16px + env(safe-area-inset-bottom));
  box-shadow: 0 0 30px color-mix(in srgb, var(--glow) 55%, transparent);
}
.sheet .grab { width: 44px; height: 5px; border-radius: 3px; background: #0003; margin: -6px auto 10px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.sheet-head h2 { margin: 0; }

.toast-wrap { position: fixed; left: 0; right: 0; bottom: 84px; display: grid; justify-items: center; gap: 6px; z-index: 80; pointer-events: none; }
.toast { pointer-events: auto; max-width: calc(100vw - 32px); padding: 12px 16px; border-radius: 14px; background: var(--ink); color: #fff; box-shadow: 0 8px 24px #0006; font-size: 14px; }
.toast.err { background: #8f1218; }

.secret { font: 600 15px/1.4 ui-monospace, Consolas, monospace; background: #fff; border: 2px dashed var(--ink); border-radius: 12px; padding: 12px; word-break: break-all; user-select: all; }

/* ---------- вход ---------- */

.login { min-height: calc(100dvh - 16px); display: grid; place-items: center; padding: 20px; }
.login .box { width: min(400px, 100%); }
.login .logo { display: block; text-align: center; margin: 4px 0 18px; font-size: 34px; }

.empty { text-align: center; padding: 26px 10px; color: var(--muted); }
.spacer-top { margin-top: 16px; }
.ml { margin-left: 8px; }
.search { color: #f4f4f4; }
.pill.on, a.pill[aria-current='page'] { background: var(--ink); }
a.pill { text-decoration: none; }
td.warn { color: #a1161d; font-weight: 600; }
button.pick { width: 100%; border: 0; border-bottom: 1px solid #0000001a; background: none; text-align: left; cursor: pointer; padding: 12px 6px; }
button.pick:hover { background: #0000000a; }
a.list-item { color: inherit; text-decoration: none; }
.pkg-edit { padding: 8px 0; border-bottom: 1px solid #0000001a; margin-bottom: 8px; }
.hint { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.card a { color: var(--ink); }
.spacer { height: 10px; }
.grid2 { display: grid; gap: 10px; }

/* ---------- планшет и ПК у стойки ---------- */

@media (min-width: 720px) {
  .frame { margin: 14px; min-height: calc(100dvh - 28px); }
  .search { order: 0; flex: 0 1 340px; margin-left: 12px; }
  .logo { margin-right: 0; font-size: 30px; }
  .top-actions { margin-left: auto; }
  .top-actions .lbl { display: inline; }
  .top-actions .btn-sm { width: auto; height: auto; padding: 0 12px; }
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .grid2 { grid-template-columns: 1fr 1fr; }
  .sheet-back { align-items: center; justify-items: center; }
  .sheet { border-radius: 24px; border-bottom: 3px solid var(--frame-edge); width: min(560px, calc(100vw - 40px)); }
  .sheet .grab { display: none; }
}

@media (min-width: 1024px) {
  .frame {
    grid-template-columns: 200px 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas: 'top top' 'nav main';
  }
  .top { grid-area: top; padding: 18px 20px 12px; }
  .nav {
    grid-area: nav;
    flex-direction: column;
    gap: 10px;
    margin: 0 0 18px 18px;
    padding: 12px 10px;
    border-radius: 22px;
    align-self: start;
  }
  .nav a {
    flex: none;
    flex-direction: row;
    gap: 8px;
    padding: 0 12px;
    height: 38px;
    border-radius: var(--r-pill);
    background: var(--plate);
    border: 2px solid #1b1b1b;
    color: #f0f0f0;
    font-size: 10.5px;
  }
  .nav a svg { width: 16px; height: 16px; }
  .nav a[aria-current='page'] { background: #d0d0d0; color: var(--ink); }
  .main { grid-area: main; padding: 0 18px 18px 14px; overflow: auto; }
  .nav { position: static; }
  .main > .box { min-height: 100%; }

  .pcs-layout { grid-template-columns: minmax(0, 1fr) 330px; align-items: start; }
  .detail-desktop { position: sticky; top: 0; }

  /* Карта ПК как на макете: ПК соединены «трассой». */
  .pc-map { display: block; height: 470px; }
  .pc-map svg.track { display: block; position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
  .pc-map svg.track path { fill: none; stroke: var(--ink); stroke-width: 22; stroke-linecap: round; stroke-linejoin: round; }
  .pc-map .pc-tile { position: absolute; width: 27%; min-width: 170px; }
  .pc-map .pc-tile .inner { min-height: 92px; }
  .pc-map .slot-1 { right: 2%; top: 74%; }
  .pc-map .slot-2 { right: 2%; top: 39%; }
  .pc-map .slot-3 { right: 2%; top: 3%; }
  .pc-map .slot-4 { left: 3%; top: 58%; }
  .pc-map .slot-5 { left: 3%; top: 17%; }
}

@media (min-width: 1440px) {
  .pcs-layout { grid-template-columns: minmax(0, 1fr) 380px; }
  .pc-map { height: 540px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
