/* Managment 2026 — базові стилі. Нейтральні: остаточний дизайн буде окремим етапом. */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1d2330;
  --muted: #6b7280;
  --line: #e3e6eb;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #e8efff;
  --danger: #dc2626;
  --ok: #15803d;
  --warn: #b45309;
  --sidebar: #161b26;
  --sidebar-text: #c4cad6;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f131b; --surface: #171c26; --text: #e5e8ee; --muted: #8d95a5; --line: #262d3a;
    --primary-soft: #1b2742; --sidebar: #0b0e14; --shadow: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 16px 0 8px; }
code { background: var(--primary-soft); padding: 1px 5px; border-radius: 4px; }

/* --- каркас --- */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 232px; flex: none; background: var(--sidebar); color: var(--sidebar-text); padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: block; color: #fff; font-weight: 700; font-size: 17px; padding: 4px 10px 16px; text-decoration: none !important; }
.brand span { color: #7aa2ff; }
.brand-lg { font-size: 24px; text-align: center; color: var(--text); padding-bottom: 20px; }
.nav-group { text-transform: uppercase; font-size: 11px; letter-spacing: .06em; color: #6c7488; padding: 14px 10px 6px; }
.nav-link { display: flex; justify-content: space-between; align-items: center; color: var(--sidebar-text); padding: 7px 10px; border-radius: 7px; text-decoration: none !important; }
.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-link.active { background: var(--primary); color: #fff; }
.nav-link.disabled { opacity: .45; cursor: default; }
.nav-link.disabled:hover { background: none; color: var(--sidebar-text); }
.nav-link small { font-size: 10px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.page-title { font-size: 18px; margin: 0; flex: 1; font-weight: 600; }
.crumb { color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-right form { margin: 0; }
.bell { position: relative; color: var(--muted); display: inline-flex; padding: 6px; }
.bell .badge { position: absolute; top: -2px; right: -4px; background: var(--danger); color: #fff; font-size: 10px; border-radius: 10px; padding: 0 5px; line-height: 16px; }
.user-chip { color: var(--text); font-weight: 500; }
.menu-toggle { display: none; background: none; border: 0; font-size: 20px; color: var(--text); cursor: pointer; }
.content { padding: 24px; max-width: 1280px; width: 100%; }

/* --- блоки --- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card.p0 { padding: 0; overflow-x: auto; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 + .card, .grid-2 + .actions-bar { margin-top: 16px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar p { margin: 0; }
.tabs { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 3px; }
.tabs a { padding: 5px 12px; border-radius: 6px; color: var(--muted); text-decoration: none; }
.tabs a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mt { margin-top: 14px; }
.center { text-align: center; }
.right { margin-left: auto; }
.nowrap { white-space: nowrap; }
.dim { opacity: .5; }
.tag { display: inline-block; background: var(--primary-soft); color: var(--primary); border-radius: 20px; padding: 1px 9px; font-size: 12px; margin: 1px 4px 1px 0; }
.tag-accent { background: #fde7e7; color: var(--danger); }
.plain-list { list-style: none; padding: 0; margin: 8px 0; }
.plain-list li { padding: 3px 0; }
.ua { color: var(--muted); font-size: 12px; }
.props { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 12px; }
.props dt { color: var(--muted); }
.props dd { margin: 0; }
details summary { cursor: pointer; color: var(--primary); }

/* --- таблиці --- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--bg); }
.table tr:last-child td { border-bottom: 0; }
.table-hover tbody tr { cursor: pointer; }
.table-hover tbody tr:hover { background: var(--primary-soft); }
.card .table th { background: transparent; }
.card.p0 .table th { background: var(--bg); }

/* --- форми --- */
.stack > * + * { margin-top: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.field { margin-bottom: 12px; }
.field label { display: block; font-weight: 500; margin-bottom: 4px; }
.field .req { color: var(--danger); }
.field-check label { font-weight: 400; display: flex; gap: 8px; align-items: center; }
.field .help { font-size: 12px; color: var(--muted); margin-top: 3px; }
.field .error { font-size: 12px; color: var(--danger); margin-top: 3px; }
.has-error input, .has-error select { border-color: var(--danger); }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=search], input[type=date], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; font: inherit; background: var(--surface); color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.check { display: flex; gap: 8px; align-items: flex-start; padding: 3px 0; cursor: pointer; }
.check input { margin-top: 3px; }
.check.locked { color: var(--muted); cursor: default; }
.checks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 16px; }
.rights-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.rights-group { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; margin: 0; }
.rights-group legend { font-weight: 600; padding: 0 6px; }
.actions-bar { display: flex; gap: 8px; align-items: center; position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; }
.filters { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); min-width: 150px; }
.filters-actions { display: flex; gap: 6px; }

/* --- кнопки --- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 7px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; text-decoration: none !important; }
.btn:hover { border-color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); background: #fde7e7; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; }
.btn-link { background: none; border: 0; color: var(--primary); cursor: pointer; font: inherit; padding: 0; }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }

/* --- повідомлення --- */
.messages { margin-bottom: 14px; }
.msg { padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; border: 1px solid; }
.msg-success { background: #ecfdf3; border-color: #abefc6; color: var(--ok); }
.msg-error { background: #fef3f2; border-color: #fecdca; color: var(--danger); }
.msg-warning { background: #fffaeb; border-color: #fedf89; color: var(--warn); }
.msg-info { background: var(--primary-soft); border-color: transparent; color: var(--primary); }

/* --- сповіщення, етапи, журнал --- */
.notif-list { list-style: none; padding: 0; margin: 0 0 10px; }
.notif-list li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.notif-list li:last-child { border-bottom: 0; }
.notif-list li a { color: var(--muted); }
.notif-list li.unread a { color: var(--text); font-weight: 600; }
.notif-list time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.stages { margin: 0; padding-left: 22px; }
.stages li { padding: 3px 0; color: var(--muted); }
.stages li.done { color: var(--ok); font-weight: 600; }
.stages li.done::after { content: " ✓"; }
.changes { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.changes .old { color: var(--danger); }
.changes .new { color: var(--ok); }
.act { font-size: 12px; padding: 1px 8px; border-radius: 10px; background: var(--bg); white-space: nowrap; }
.act-create { color: var(--ok); }
.act-delete { color: var(--danger); }
.act-update { color: var(--primary); }
.pager { display: flex; gap: 16px; justify-content: center; align-items: center; padding: 12px; color: var(--muted); }

/* --- вхід --- */
body.auth { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 16px; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 32px 28px; box-shadow: var(--shadow); }
.auth-card input[name=code] { font-size: 24px; letter-spacing: .4em; text-align: center; }

/* --- телефон --- */
@media (max-width: 900px) {
  .grid-2, .form-grid, .form-grid-3, .form-grid-5, .checks { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -240px; z-index: 20; transition: left .2s; }
  .sidebar.open { left: 0; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35); }
  .menu-toggle { display: block; }
  .topbar { padding: 10px 16px; }
  .content { padding: 16px; }
  .user-chip { display: none; }
}

/* --- довідники --- */
.subnav { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.subnav a { padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; text-decoration: none; }
.subnav a:hover { color: var(--text); }
.subnav a.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.subnav-2 { border-bottom: 0; margin-top: -8px; }
.subnav-2 a { border: 1px solid var(--line); border-radius: 20px; padding: 4px 12px; font-size: 13px; margin: 0; }
.subnav-2 a.active { background: var(--primary-soft); border-color: transparent; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { display: flex; flex-direction: column; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; color: var(--text); text-decoration: none !important; box-shadow: var(--shadow); }
.tile:hover { border-color: var(--primary); }
.tile b { font-size: 24px; }
.tile span { color: var(--muted); font-size: 13px; }
.tiles-sm .tile { box-shadow: none; padding: 12px; }
.tiles-sm .tile b { font-size: 18px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 0 12px; align-items: flex-start; }
.inline-form .field { min-width: 180px; flex: 1; margin-bottom: 4px; }
.inline-form .field-btn, .inline-form .field-checks { flex: 0 0 auto; min-width: 0; }
.inline-form .field-btn label { visibility: hidden; }
.inline-checks { display: flex; gap: 4px 14px; flex-wrap: wrap; padding-top: 7px; }
.inline-checks .check { white-space: nowrap; }
.gen { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; background: var(--bg); padding: 10px 12px; border-radius: 8px; margin: 10px 0; }
.gen b { flex-basis: 100%; font-size: 13px; }
.gen label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.gen input { width: 96px; }
.lengths td { padding: 4px 8px; vertical-align: middle; }
.inline-form .msg { flex-basis: 100%; }
.inline-form-sm { margin-bottom: 12px; gap: 8px; }
.inline-form-sm input[type=text] { max-width: 340px; }
.search { max-width: 320px; }
.search-sm { max-width: 200px; padding: 4px 8px !important; }
.w-drag { width: 28px; }
.w-act { width: 90px; }
.w-num { width: 160px; }
td.drag, .drag, .drag-group { cursor: grab; color: var(--muted); user-select: none; letter-spacing: -2px; }
td.drag:hover, .drag:hover, .drag-group:hover { color: var(--primary); }
.drag-ghost { opacity: .4; background: var(--primary-soft); }
.group-card { overflow-x: auto; }
.group-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--bg); }
.group-head h2 { margin: 0; }
.empty-hidden { display: none; }
.checks-tools { display: flex; gap: 10px; align-items: center; margin: 6px 0; }
.checks-scroll { max-height: 420px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }
.tag-warn { background: #fffaeb; color: var(--warn); }
.narrow { max-width: 560px; }
.table-compact td, .table-compact th { padding: 6px 10px; }
.input-num { max-width: 140px; }
.picker-row { display: flex; gap: 8px; }
.picked { list-style: none; padding: 0; margin: 10px 0 0; }
.picked li { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; background: var(--surface); }
.grow { flex: 1; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 20px); background: #1d2330; color: #fff; padding: 8px 16px; border-radius: 8px; opacity: 0; transition: .25s; z-index: 50; font-size: 13px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-bad { background: var(--danger); }
.center { text-align: center; }

/* ---- ціни ---- */
.num, .table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.plain-steps { margin: 8px 0; padding-left: 20px; }
.plain-steps li { padding: 3px 0; }
.price-old { color: var(--muted); text-decoration: line-through; }
.price-new { font-weight: 600; }
.price-up { color: var(--danger); }
.price-down { color: var(--ok); }
.warn-list { margin: 0; padding-left: 16px; color: var(--warn); font-size: 12px; }
tr.row-error td { background: #fef3f2; }
tr.winner td { background: var(--primary-soft); }
.result-big { font-size: 28px; font-weight: 700; margin: 4px 0; }
.row-form { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 0; }
