/* Fregat Owl — дизайн-система операторки. Бренд #6022b4, світла/темна тема. */

:root {
  --brand: #6022b4;
  --brand-ink: #ffffff;
  --brand-soft: #f3edfd;

  --bg: #f6f5f9;
  --surface: #ffffff;
  --surface-2: #fbfafd;
  --border: #e5e1ec;
  --text: #1c1a22;
  --muted: #6b6676;

  --ok: #16a34a;
  --warn: #f59e0b;
  --danger: #dc2626;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(28, 26, 34, .06), 0 8px 24px rgba(28, 26, 34, .06);
  --rail: 288px;   /* як w-72 в Atlas — інакше імʼя в футері пережимається */
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Темна тема. Два блоки з однаковими значеннями — тримати синхронно:
   (1) системна тема, якщо користувач не змусив світлу;
   (2) явний вибір користувача перемикачем у меню. */
@media (prefers-color-scheme: dark) {
  :root:not([data-scheme="light"]) {
    --brand: #8b5cf6;
    --brand-soft: #241b38;
    --bg: #131118;
    --surface: #1b1922;
    --surface-2: #221f2b;
    --border: #322d3f;
    --text: #eceaf1;
    --muted: #9a94a8;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
  }
}
:root[data-scheme="dark"] {
  --brand: #8b5cf6;
  --brand-soft: #241b38;
  --bg: #131118;
  --surface: #1b1922;
  --surface-2: #221f2b;
  --border: #322d3f;
  --text: #eceaf1;
  --muted: #9a94a8;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
}

/* ── Анімований фон (canvas, порт з Atlas) ────────────────────────────────── */

#app-bg-canvas {
  position: fixed; inset: 0; z-index: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}

/* Контент — над фоном */
.layout, /* ── Сторінка входу — стиль Atlas (тёмний градієнт + трикутники + скло) ────── */

.lg-page {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  background: linear-gradient(135deg, #131118 0%, #2e1065 50%, #131118 100%);
}
.lg-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
.lg-glow {
  position: absolute; width: 26rem; height: 26rem; border-radius: 50%;
  filter: blur(80px); pointer-events: none; z-index: 0;
}
.lg-glow-1 { top: -4rem; left: 22%; background: rgba(124, 58, 237, .22); }
.lg-glow-2 { bottom: -4rem; right: 22%; background: rgba(79, 70, 229, .20); }

.lg-container { position: relative; z-index: 10; width: 100%; max-width: 28rem; padding: 0 16px; }

.lg-head { text-align: center; margin-bottom: 22px; }
.lg-badge {
  width: 64px; height: 64px; margin: 0 auto 12px;
  border-radius: 18px; display: grid; place-items: center; font-size: 32px;
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  box-shadow: 0 12px 32px -8px rgba(124, 58, 237, .6);
}
.lg-title-row { display: flex; align-items: center; justify-content: center; gap: 8px; }
.lg-title-row h1 { font-size: 30px; font-weight: 800; color: #fff; letter-spacing: -.02em; }
.lg-beta {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  padding: 2px 7px; border-radius: 6px;
  background: rgba(251, 191, 36, .2); color: #fcd34d; border: 1px solid rgba(251, 191, 36, .3);
}
.lg-sub { color: rgba(196, 181, 253, .8); font-size: 13px; margin-top: 6px; }

.lg-card {
  position: relative; overflow: hidden;
  padding: 32px; border-radius: 16px;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .18);
  backdrop-filter: blur(18px);
  box-shadow: 0 24px 64px rgba(0, 0, 0, .4);
}
.lg-owl {
  position: absolute; right: -12px; bottom: -22px;
  font-size: 110px; line-height: 1; opacity: .06; pointer-events: none; user-select: none;
}
.lg-card-head { position: relative; margin-bottom: 18px; }
.lg-card-head h2 { font-size: 20px; font-weight: 700; color: #fff; }
.lg-card-head p { font-size: 12px; color: rgba(255, 255, 255, .5); margin-top: 2px; }

.lg-error {
  position: relative; padding: 11px 14px; margin-bottom: 14px;
  font-size: 13px; color: #fca5a5;
  background: rgba(127, 29, 29, .3); border: 1px solid rgba(185, 28, 28, .5); border-radius: 12px;
}

.lg-form { position: relative; display: flex; flex-direction: column; gap: 15px; }
.lg-field { display: flex; flex-direction: column; gap: 6px; }
.lg-field label { font-size: 13px; font-weight: 500; color: rgba(255, 255, 255, .7); }
.lg-input {
  box-sizing: border-box; width: 100%; max-width: 100%;
  padding: 10px 16px; border-radius: 12px;
  background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .2);
  color: #fff; outline: none; transition: border-color .15s, box-shadow .15s;
}
.lg-input::placeholder { color: rgba(255, 255, 255, .3); }
.lg-input:focus { border-color: transparent; box-shadow: inset 0 0 0 2px #a78bfa; }
.lg-btn {
  width: 100%; padding: 13px; margin-top: 4px; border: none; border-radius: 12px;
  font-size: 15px; font-weight: 600; color: #fff; cursor: pointer;
  background: linear-gradient(90deg, #7c3aed, #4f46e5);
  box-shadow: 0 12px 28px -8px rgba(124, 58, 237, .5);
  transition: transform .15s, filter .15s;
}
.lg-btn:hover { transform: scale(1.02); filter: brightness(1.08); }
.lg-btn:active { transform: scale(.98); }
.lg-btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }

.lg-foot {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  padding: 16px; text-align: center;
}
.lg-foot-1 { font-size: 11px; color: rgba(196, 181, 253, .5); }
.lg-foot-2 { font-size: 10px; color: rgba(255, 255, 255, .2); margin-top: 2px; }

.toast {.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 50;
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--brand);
  border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 12px 16px; max-width: 380px;
}
.toast.err { border-left-color: var(--danger); }

/* ── Мобільний: шапка з гамбургером + меню-дровер ─────────────────────────── */

.topbar { display: none; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }

  .topbar {
    display: flex; align-items: center; gap: 10px;
    position: sticky; top: 0; z-index: 30;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px) * 0);
    background: var(--surface); border-bottom: 1px solid var(--border);
  }
  .topbar .burger {
    width: 38px; height: 38px; border-radius: 10px; flex: 0 0 auto;
    border: 1px solid var(--border); background: var(--surface-2);
    display: grid; place-items: center; font-size: 17px; cursor: pointer;
  }
  .topbar .sb-search { flex: 1; min-width: 0; }
  .topbar .avatar { width: 34px; height: 34px; }

  /* Сайдбар їде збоку, а не тисне контент */
  .rail {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 45;
    width: 288px; height: 100vh;
    transition: transform .28s ease;
    box-shadow: var(--shadow);
  }
  .rail.sidebar-rail { width: 68px; }
  .rail { transform: translateX(0); }
  .rail.closed { transform: translateX(-100%); }

  .sb-overlay.show { opacity: 1; pointer-events: auto; }

  .split { grid-template-columns: 1fr; }
  .main { padding: 14px; }
  .page-head h1 { font-size: 18px; }
  .desks { grid-template-columns: 1fr; }
  .board { padding-bottom: 8px; }
  .column { flex-basis: 84vw; max-height: none; }
  .toolbar .input { min-width: 0; width: 100%; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dt { margin-top: 8px; }
  .staff-card, .card[style*="position: fixed"] {
    left: 12px !important; right: 12px !important; width: auto !important;
    top: 64px !important; max-height: calc(100vh - 90px) !important;
  }
  .collapse-btn { display: none; }
}

/* ── Планшет ──────────────────────────────────────────────────────────────── */
@media (min-width: 901px) and (max-width: 1200px) {
  .split { grid-template-columns: 1fr; }          /* бокові картки — під контент */
  .desks { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
  .column { flex-basis: 240px; }
}

/* ── Таблиці на вузькому екрані стають картками ───────────────────────────── */
@media (max-width: 900px) {
  table.grid, table.grid tbody, table.grid tr, table.grid td { display: block; width: 100%; }
  table.grid thead { display: none; }             /* заголовки переїхали в підписи клітинок */
  table.grid tr {
    border: 1px solid var(--border); border-radius: var(--radius);
    margin: 10px; padding: 10px; background: var(--surface);
  }
  table.grid tr:hover td { background: transparent; }
  table.grid td {
    display: flex; align-items: flex-start; gap: 10px;
    border: none; padding: 5px 0;
  }
  table.grid td::before {
    content: attr(data-label);
    flex: 0 0 84px; color: var(--muted); font-size: 11.5px; text-transform: uppercase;
    letter-spacing: .03em; padding-top: 2px;
  }
  /* значенню — уся решта ширини, інакше довге ПІБ ламається по словах */
  table.grid td > * { min-width: 0; }
  table.grid td > div, table.grid td > span { flex: 1; }
  table.grid td:empty, table.grid td:has(> :empty:only-child) { display: none; }
  .grid-wrap { overflow-x: visible; }
}

@media (max-width: 560px) {
  /* на вузькому — підпис зверху, значення під ним на всю ширину */
  table.grid td { flex-direction: column; gap: 2px; }
  table.grid td::before { flex: none; }
  .desk-stats { gap: 12px; }
  .btn { padding: 8px 11px; }
  .page-head { gap: 8px; }
}
