/* SalesRep License — адмінка. Палітра: індиго-акцент на холодних сірих,
   темний хедер, картки з м'якою тінню. Жодних зовнішніх шрифтів — CSP 'self'. */

:root {
  --bg: #f3f5f9;
  --surface: #fff;
  --line: #e4e8ef;
  --line-strong: #d4dae3;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --danger: #dc2626;
  --warn: #b45309;
  --ok: #059669;
  --header-bg: #111827;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .06);
  --shadow-lg: 0 10px 32px rgba(15, 23, 42, .14);
}

* { box-sizing: border-box; }

/* Атрибут hidden ставить display:none лише з нульовою специфічністю, тому будь-який
   наш display: grid/flex його перебивав — і форма входу лишалася поверх адмінки. */
[hidden] { display: none !important; }

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

/* ---------- вхід ---------- */

.login-wrap {
  display: grid; place-items: center; min-height: 100vh; padding: 20px;
  background:
    radial-gradient(700px 420px at 18% 8%, rgba(79, 70, 229, .16), transparent 60%),
    radial-gradient(640px 420px at 85% 92%, rgba(37, 99, 235, .13), transparent 60%),
    var(--bg);
}
.login-card {
  width: 380px; padding: 36px 32px 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.login-brand { text-align: center; margin-bottom: 26px; }
.login-brand h1 { font-size: 20px; margin: 14px 0 0; letter-spacing: -.01em; }
.login-brand h1 span {
  display: block; font-size: 13px; font-weight: 400; color: var(--muted); margin-top: 2px;
}

/* ---------- каркас ---------- */

header {
  display: flex; align-items: center; gap: 24px;
  padding: 0 20px; height: 56px;
  background: var(--header-bg);
  position: sticky; top: 0; z-index: 10;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .06), 0 2px 8px rgba(15, 23, 42, .25);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 650; white-space: nowrap; color: #fff; letter-spacing: -.01em;
}
.brand em { font-style: normal; font-weight: 400; color: #94a3b8; }
.logo-mark { display: block; flex: none; }

header nav { display: flex; gap: 2px; flex: 1; }
header nav a {
  padding: 7px 14px; border-radius: 8px;
  color: #cbd5e1; text-decoration: none; white-space: nowrap;
  transition: background .15s ease, color .15s ease;
}
header nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
header nav a.active { background: var(--accent); color: #fff; }

.who { display: flex; align-items: center; gap: 10px; color: #94a3b8; font-size: 13px; }
.who .link { color: #cbd5e1; }
.who .link:hover { color: #fff; }
.badge.dark {
  background: rgba(255, 255, 255, .09); color: #cbd5e1;
  border-color: rgba(255, 255, 255, .14);
}

main { padding: 24px 20px; max-width: 1280px; margin: 0 auto; }

/* ---------- елементи ---------- */

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 18px; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 15px; margin: 0 0 12px; letter-spacing: -.01em; }
.card h2 .sub { font-weight: 400; color: var(--muted); margin-left: 8px; font-size: 13px; }
.card.danger-zone { border-color: #fecaca; }
.card.danger-zone h2 { color: var(--danger); font-size: 15px; margin: 0 0 12px; }

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

label { display: block; margin-bottom: 12px; color: var(--muted); font-size: 13px; font-weight: 500; }
input, select, textarea {
  width: 100%; margin-top: 5px; padding: 8px 11px;
  border: 1px solid var(--line-strong); border-radius: 8px;
  font: inherit; font-weight: 400; color: var(--text); background: var(--surface);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .15);
}

button { font: inherit; cursor: pointer; border-radius: 8px; transition: background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease; }
button.primary {
  background: var(--accent); color: #fff; border: 0; padding: 9px 18px; font-weight: 550;
  box-shadow: 0 1px 2px rgba(79, 70, 229, .35);
}
button.primary:hover { background: var(--accent-hover); }
button.primary.wide { width: 100%; padding: 10px; }
button.danger { background: var(--danger); color: #fff; border: 0; padding: 8px 14px; font-weight: 550; }
button.danger:hover { background: #b91c1c; }
button.ghost { background: var(--surface); border: 1px solid var(--line-strong); padding: 7px 14px; color: var(--text); }
button.ghost:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
button.link { background: none; border: 0; color: var(--accent); padding: 4px 6px; }
button.link:hover { text-decoration: underline; }
button:disabled { opacity: .5; cursor: not-allowed; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); }
th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 600; background: #f8fafc;
  text-align: center;
}
th:first-child { border-top-left-radius: 8px; }
th:last-child { border-top-right-radius: 8px; }
tr:last-child td { border-bottom: 0; }
/* .c — центровані значення: стани, дати, лічильники. Текстові колонки лишаються зліва. */
td.c { text-align: center; }
td.actions { text-align: center; white-space: nowrap; }
td.actions .link { padding: 4px 8px; }
tbody tr { transition: background .1s ease; }
tbody tr:hover { background: #f8fafc; }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 500; white-space: nowrap;
  background: #f1f5f9; color: var(--muted); border: 1px solid var(--line);
}
.badge.ok { background: #ecfdf5; color: var(--ok); border-color: #a7f3d0; }
.badge.warn { background: #fffbeb; color: var(--warn); border-color: #fde68a; }
.badge.danger { background: #fef2f2; color: var(--danger); border-color: #fecaca; }

.muted { color: var(--muted); }
.error { color: var(--danger); margin-bottom: 12px; font-size: 13px; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12px; }
.empty { color: var(--muted); padding: 28px; text-align: center; }
.tiny { font-size: 11px; line-height: 1.3; }

.metric {
  font-size: 23px; font-weight: 650; letter-spacing: -.02em;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow);
}
.metric small {
  display: block; font-size: 12px; font-weight: 500; color: var(--muted);
  margin-top: 3px; letter-spacing: 0;
}

.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 50;
  background: var(--header-bg); color: #fff; padding: 12px 18px;
  border-radius: var(--radius); max-width: 420px;
  box-shadow: var(--shadow-lg);
}
.toast.bad { background: var(--danger); }

dialog {
  border: 0; border-radius: var(--radius-lg); padding: 24px;
  width: min(520px, 92vw); box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgba(15, 23, 42, .5); backdrop-filter: blur(2px); }
dialog h2 { margin: 0 0 16px; font-size: 16px; letter-spacing: -.01em; }
dialog menu { display: flex; justify-content: flex-end; gap: 8px; margin: 20px 0 0; padding: 0; }

.hint {
  background: var(--accent-soft); border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  padding: 9px 13px; margin: 8px 0; font-size: 13px; color: #3730a3;
}
.hint.warn { border-left-color: var(--warn); background: #fffbeb; color: #92400e; }

/* ---------- вкладки картки тенанта ---------- */

.page-title { font-size: 21px; margin: 0; letter-spacing: -.02em; }

.tabs {
  display: flex; gap: 2px; margin: 4px 0 18px;
  border-bottom: 1px solid var(--line-strong);
}
.tabs a {
  padding: 9px 16px; color: var(--muted); text-decoration: none; font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .15s ease, border-color .15s ease;
}
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.filter { margin: 0; min-width: 160px; flex: 0 1 auto; }
.filter input, .filter select { min-width: 160px; }

/* ---------- чекбокси модулів ---------- */

.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px; margin: 6px 0 12px; }
.checks label {
  display: flex; align-items: center; gap: 8px; margin: 0;
  padding: 8px 11px; border: 1px solid var(--line-strong); border-radius: 8px;
  color: var(--text); font-weight: 400; cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.checks label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.checks input { width: auto; margin: 0; accent-color: var(--accent); }
.checks .mod-hint { color: var(--muted); font-size: 12px; }

textarea { resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }

/* Розшифровка синхронізацій: кожна подія — окремий «чіп» з датою і часом. */
.sync-chip {
  display: inline-block; margin: 2px 3px 2px 0; padding: 2px 9px;
  background: #f8fafc; border: 1px solid var(--line); border-radius: 6px;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12px;
}
.rep-detail td { background: #f8fafc; }

/* ---------- друк звітів ---------- */

@media print {
  header, .tabs, .toast, .no-print, button, .spread a { display: none !important; }
  body { background: #fff; font-size: 10px; line-height: 1.25; }
  main { padding: 0; max-width: none; }

  .page-title { font-size: 14px; }

  .card { box-shadow: none; border: 0; padding: 0; margin-bottom: 8px; break-inside: avoid; }
  .card h2 { font-size: 11px; margin: 0 0 4px; }

  /* Метрики — компактний рядок «підпис: значення», а не великі картки. */
  .grid { display: flex; flex-wrap: wrap; gap: 4px 20px; margin: 4px 0 !important; }
  .metric {
    box-shadow: none; border: 0; padding: 0;
    font-size: 11px; font-weight: 600;
    display: flex; gap: 5px; align-items: baseline; flex-direction: row-reverse;
  }
  .metric small { font-size: 10px; margin: 0; }
  .metric small::after { content: ':'; }

  table { font-size: 10px; }
  th, td { padding: 2px 6px; }
  th { font-size: 9px; background: none; }
  tr { break-inside: avoid; }

  /* Бейдж на папері — просто текст: рамки-пігулки роздувають рядки. */
  .badge { padding: 0; border: 0; background: none !important; font-size: 10px; }
  .tiny { display: none; }              /* «скільки тому» на папері зайве — дата вже є */
  .mono { font-size: 9px; }

  .sync-chip { padding: 0 4px; margin: 0 2px 0 0; font-size: 9px; border-color: #ccc; }
  .rep-detail td { background: #fff; }

  a { color: inherit; text-decoration: none; }
}
