/* Shared audit drawer and full history. */
.page-head-actions { display:flex; align-items:center; justify-content:flex-end; flex-wrap:wrap; gap:8px; margin-left:auto; }
.page-head-actions > .model-actions { flex-wrap:wrap; max-width:100%; }
.page-head.has-module-audit > :first-child { flex:1; min-width:0; }
.page-head-actions .audit-open { gap:8px; min-width:156px; color:var(--text-2); background:transparent; box-shadow:none; }
.page-head-actions > [data-model-new] { min-width:156px; justify-content:center; }
.page-head-actions .audit-open:hover { color:var(--text); background:var(--surface); border-color:var(--border-strong); }
.audit-chip.audit-scope { cursor:default; background:var(--surface-sunk); }
.audit-filters label[hidden] { display:none; }
.audit-drawer { position:fixed; inset:0 0 0 auto; margin:0; width:min(900px,94vw); max-width:none; height:100dvh; max-height:100dvh; padding:0; border:0; border-left:1px solid var(--border); background:var(--bg); color:var(--text); box-shadow:-20px 0 80px #0003; }
.audit-drawer::backdrop { background:#14110d66; backdrop-filter:blur(2px); }
.audit-is-open { overflow:hidden; }
.audit-head { display:flex; align-items:center; gap:12px; padding:22px 26px; border-bottom:1px solid var(--border); background:var(--surface); position:sticky; top:0; z-index:2; }
.audit-head > div { flex:1; }
.audit-head h2 { margin:4px 0 0; font-size:25px; letter-spacing:-.7px; }
.audit-eyebrow { color:var(--accent); font-size:10px; font-weight:600; letter-spacing:1.6px; }
.audit-body { padding:22px 26px; }
.audit-page { padding:24px; max-width:1300px; }
.audit-filters { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:12px; align-items:end; }
.audit-filters label { display:flex; flex-direction:column; gap:6px; font-size:11px; font-weight:500; color:var(--text-2); min-width:0; }
.audit-filters .input { width:100%; min-width:0; font-size:12px; height:38px; }
.audit-filters .btn { height:38px; }
.audit-search { grid-column:span 2; }
.audit-filterbar { display:flex; align-items:center; gap:12px; justify-content:space-between; margin:17px 0; }
.audit-filter-actions { display:flex; gap:4px; flex-shrink:0; }
.audit-chips { display:flex; flex-wrap:wrap; gap:6px; }
.audit-chip { display:inline-flex; align-items:center; border:1px solid var(--border); border-radius:6px; background:var(--surface); color:var(--text-2); padding:5px 8px; font:inherit; font-size:11px; cursor:pointer; max-width:100%; overflow-wrap:anywhere; text-align:left; }
.audit-chip:hover { border-color:var(--accent); color:var(--accent); }
.audit-all,.audit-status { font-size:12px; color:var(--text-2); }
.audit-status { min-height:20px; }
.audit-day { font-size:12px; font-weight:500; color:var(--text-2); margin:23px 0 10px; }
.audit-group { border:1px solid var(--border); background:var(--surface); margin-bottom:8px; border-radius:var(--radius); overflow:hidden; }
.audit-group > summary { display:flex; gap:12px; padding:16px; cursor:pointer; list-style:none; align-items:center; }
.audit-group > summary::-webkit-details-marker { display:none; }
.audit-group > summary:hover { background:var(--surface-2); }
.audit-group[open] > summary { background:var(--surface-2); border-bottom:1px solid var(--border); }
.audit-dot { width:32px; height:32px; flex:0 0 32px; display:grid; place-items:center; border-radius:50%; background:var(--accent-soft); color:var(--accent); font-size:12px; font-weight:600; }
.audit-dot.is-deleted { background:var(--danger-soft); color:var(--danger); }
.audit-dot.is-created { background:var(--success-soft); color:var(--success); }
.audit-dot.is-ip_denied { background:var(--danger-soft); color:var(--danger); }
.audit-summary-body { flex:1; min-width:0; }
.audit-summary-title { display:flex; flex-wrap:wrap; column-gap:7px; font-size:13px; line-height:1.5; overflow-wrap:anywhere; }
.audit-summary-title strong { font-weight:600; }
.audit-meta { display:block; color:var(--text-2); font-size:11px; margin-top:4px; line-height:1.6; overflow-wrap:anywhere; }
.audit-time { color:var(--text-3); font-size:11px; font-variant-numeric:tabular-nums; white-space:nowrap; }
.audit-chevron { color:var(--text-3); }
.audit-group[open] .audit-chevron { transform:rotate(180deg); }
.audit-group-content { padding:0 18px; }
.audit-entry { padding:17px 0; border-bottom:1px solid var(--border); }
.audit-entry:last-child { border-bottom:0; }
.audit-entry-head { display:flex; flex-wrap:wrap; gap:8px; align-items:center; font-size:12px; margin-bottom:10px; }
.audit-entry-head strong { font-weight:600; overflow-wrap:anywhere; }
.audit-action { background:var(--surface-sunk); color:var(--text-2); font-size:10px; border-radius:4px; padding:3px 6px; }
.audit-entity-link { display:inline-block; color:var(--accent); font-size:12px; margin-bottom:10px; }
.audit-diff-wrap { overflow-x:auto; margin-bottom:12px; }
.audit-diff { width:100%; border-collapse:collapse; table-layout:fixed; font-size:12px; }
.audit-diff th,.audit-diff td { text-align:left; vertical-align:top; padding:9px 10px; border-bottom:1px solid var(--border); overflow-wrap:anywhere; white-space:pre-wrap; }
.audit-diff thead th { color:var(--text-2); font-size:10px; font-weight:500; text-transform:uppercase; letter-spacing:.6px; }
.audit-diff tbody th { width:26%; font-weight:400; color:var(--text-2); }
.audit-before { background:color-mix(in srgb,var(--danger-soft) 40%,transparent); }
.audit-after { background:color-mix(in srgb,var(--success-soft) 50%,transparent); }
.audit-note { display:flex; align-items:center; gap:6px; font-size:11px; line-height:1.6; color:var(--text-2); margin:17px 0 0; }
.audit-note .icon { flex-shrink:0; }
.audit-impact { font-size:12px; }
.audit-impact-links { display:flex; flex-wrap:wrap; gap:6px; margin:9px 0 15px; }
.audit-empty { padding:50px 20px; text-align:center; }
.audit-empty-mark { color:var(--accent); font-size:32px; }
.audit-empty h3 { font-size:16px; font-weight:500; margin:12px 0 8px; }
.audit-empty p { font-size:12px; color:var(--text-2); line-height:1.7; }
.audit-more { margin:18px auto 0; display:flex; }
.audit-more[hidden] { display:none; }
@media(max-width:640px) {
  .page-head-actions { width:100%; }
  .page-head-actions .audit-open { min-width:120px; }
  .page-head-actions:has(> [data-model-new]) > .btn { flex:1; min-width:0; justify-content:center; }
  .audit-drawer { width:100vw; }
  .audit-head { padding:16px; gap:8px; }
  .audit-head h2 { font-size:22px; }
  .audit-eyebrow { font-size:8px; letter-spacing:1px; }
  .audit-body,.audit-page { padding:16px; }
  .audit-filters { grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
  .audit-time { font-size:10px; }
  .audit-group > summary { gap:8px; padding:12px; }
  .audit-dot { width:26px; height:26px; flex-basis:26px; }
  .audit-group-content { padding:0 10px; }
  .audit-diff th,.audit-diff td { padding:8px 6px; font-size:11px; }
}
/* Standard process pricing */
.price-tabs { display:flex; gap:8px; margin-bottom:16px; flex-wrap:wrap; }
.price-guide { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); padding:18px 20px; gap:20px; margin-bottom:18px; }
.price-guide strong,.price-guide span { display:block; }
.price-guide strong { font-size:13px; margin-bottom:6px; }
.price-guide span { font-size:12px; color:var(--text-2); line-height:1.6; }
.price-toolbar { padding:0 0 18px; gap:16px; align-items:end; flex-wrap:wrap; }
.price-toolbar label { display:flex; flex-direction:column; gap:6px; font-size:12px; color:var(--text-2); }
.price-search { flex:1; min-width:180px; }
.price-search input { width:100%; }
.price-toolbar select { min-width:170px; }
.price-control { min-width:190px; max-width:230px; font-size:12px; }
.price-control .input { width:190px; max-width:190px; font-size:12px; padding:6px; }
.price-table { min-width:960px; }
.price-table .c-proc { min-width:230px; }
.price-footer { display:flex; justify-content:space-between; gap:16px; padding:12px 20px; background:var(--surface-2); font-size:12px; color:var(--text-2); }
.price-empty { padding:32px; text-align:center; margin-bottom:16px; }
[data-price-groups] .tcell[readonly] { border-color:transparent; background:transparent; }
[data-price-groups] { margin-bottom:18px; }
@media(max-width:640px) {
  .price-guide { grid-template-columns:1fr; gap:12px; }
  .price-toolbar label { width:100%; }
  .price-toolbar select { width:100%; }
  .price-footer { flex-direction:column; gap:6px; }
}
/* =========================================================
   Bianki Office — UI
   ========================================================= */

@font-face { font-family: 'Onest'; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url(/assets/fonts/onest-cyrillic.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Onest'; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url(/assets/fonts/onest-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Onest'; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url(/assets/fonts/onest-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --font: 'Onest', 'Segoe UI', system-ui, -apple-system, sans-serif;

  --bg:            #f5f3ef;
  --surface:       #ffffff;
  --surface-2:     #faf9f6;
  --surface-sunk:  #eeebe5;
  --border:        #e4e0d8;
  --border-strong: #d3cec4;
  --text:          #1b1a18;
  --text-2:        #5d5a54;
  --text-3:        #8f8b83;
  --ink:           #161513;
  --ink-text:      #f3efe7;

  --accent:        #9a4f2a;   /* коняк / кожа */
  --accent-hover:  #83411f;
  --accent-soft:   #f4e9e1;
  --accent-text:   #ffffff;

  --success:       #2f7a4b;  --success-soft: #e6f2ea;
  --danger:        #b3372e;  --danger-soft:  #f9e7e5;
  --warning:       #a86a0c;  --warning-soft: #fbf0dc;
  --info:          #2f5f9a;  --info-soft:    #e6eef8;

  --radius-sm: 6px;  --radius: 10px;  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgb(27 26 24 / .06);
  --shadow:    0 1px 2px rgb(27 26 24 / .05), 0 4px 16px rgb(27 26 24 / .06);
  --shadow-lg: 0 8px 24px rgb(27 26 24 / .10), 0 24px 64px rgb(27 26 24 / .14);
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent);

  --ease: cubic-bezier(.2, .8, .2, 1);

  --text-xs: .75rem; --text-sm: .8125rem; --text-base: .9375rem; --text-lg: 1.125rem; --text-xl: 1.5rem;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg:            #121110;
  --surface:       #1a1918;
  --surface-2:     #1f1e1c;
  --surface-sunk:  #0d0c0b;
  --border:        #2b2926;
  --border-strong: #3a3733;
  --text:          #ece8e1;
  --text-2:        #a9a49b;
  --text-3:        #77736b;
  --ink:           #0b0a09;
  --ink-text:      #ece8e1;

  --accent:        #d08a5c;
  --accent-hover:  #e09b6d;
  --accent-soft:   #2e211a;
  --accent-text:   #1a1009;

  --success: #5fb57f; --success-soft: #16261c;
  --danger:  #e5736a; --danger-soft:  #2c1715;
  --warning: #dba44a; --warning-soft: #2a2010;
  --info:    #7aa6dc; --info-soft:    #15202e;

  --shadow-sm: 0 1px 2px rgb(0 0 0 / .4);
  --shadow:    0 1px 2px rgb(0 0 0 / .4), 0 4px 16px rgb(0 0 0 / .3);
  --shadow-lg: 0 8px 24px rgb(0 0 0 / .45), 0 24px 64px rgb(0 0 0 / .5);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: var(--text-base); line-height: 1.5;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'ss01', 'cv11';
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
button { cursor: pointer; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; font-weight: 600; letter-spacing: -.01em; }
p { margin: 0; }
.icon { flex-shrink: 0; display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.tabular { font-variant-numeric: tabular-nums; }
:focus-visible { outline: none; box-shadow: var(--ring); }
::selection { background: color-mix(in srgb, var(--accent) 25%, transparent); }

kbd {
  font-family: var(--font); font-size: 11px; font-weight: 500; line-height: 1;
  padding: 3px 6px; border-radius: 5px; color: var(--text-3);
  background: var(--surface-2); border: 1px solid var(--border); box-shadow: 0 1px 0 var(--border);
}

/* ---------- Бутони ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; font-size: var(--text-sm); font-weight: 550; white-space: nowrap;
  transition: background .15s var(--ease), border-color .15s var(--ease), color .15s, transform .1s, box-shadow .15s;
  user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink); color: var(--ink-text); }
[data-theme="dark"] .btn-primary { background: var(--text); color: var(--bg); }
.btn-primary:hover { background: color-mix(in srgb, var(--ink) 86%, var(--accent)); }
[data-theme="dark"] .btn-primary:hover { background: #fff; }
.btn-accent { background: var(--accent); color: var(--accent-text); }
.btn-accent:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--text-3); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-sunk); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 88%, #000); }
.btn-lg { height: 48px; font-size: var(--text-base); border-radius: var(--radius); padding: 0 20px; }
.btn-icon { width: 36px; height: 36px; padding: 0; }
.btn-sm { height: 30px; padding: 0 10px; font-size: var(--text-xs); }
.btn[disabled], .btn.is-loading { pointer-events: none; opacity: .75; }
.btn .spinner { display: none; }
.btn.is-loading .spinner { display: block; }
.btn.is-loading .btn-label-icon { display: none; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Полета ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field + .field { margin-top: 16px; }
.label { font-size: var(--text-sm); font-weight: 550; color: var(--text); display: flex; justify-content: space-between; align-items: baseline; }
.label .hint { font-weight: 400; color: var(--text-3); font-size: var(--text-xs); }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap > .icon { position: absolute; left: 13px; color: var(--text-3); pointer-events: none; transition: color .15s; }
.input, .select {
  width: 100%; height: 42px; padding: 0 13px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border-strong); color: var(--text);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.input::placeholder { color: var(--text-3); }
.input:hover, .select:hover { border-color: var(--text-3); }
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.input-wrap:focus-within > .icon { color: var(--accent); }
.input-wrap > .icon + .input { padding-left: 40px; }
.input-wrap .input-action {
  position: absolute; right: 6px; width: 32px; height: 32px; border-radius: var(--radius-sm);
  display: grid; place-items: center; background: none; border: 0; color: var(--text-3);
}
.input-wrap .input-action:hover { color: var(--text); background: var(--surface-sunk); }
.input-wrap .input-action + .input, .input-wrap .input:has(+ .input-action) { padding-right: 44px; }
.select { appearance: none; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238f8b83' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
.field.has-error .input, .field.has-error .select { border-color: var(--danger); }
.field.has-error .input:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 22%, transparent); }
.field-error { font-size: var(--text-xs); color: var(--danger); display: flex; gap: 5px; align-items: center; }
.field-help { font-size: var(--text-xs); color: var(--text-3); }

.check { display: inline-flex; align-items: center; gap: 9px; font-size: var(--text-sm); color: var(--text-2); cursor: pointer; user-select: none; }
.check input { appearance: none; width: 18px; height: 18px; margin: 0; border-radius: 5px; border: 1.5px solid var(--border-strong); background: var(--surface); display: grid; place-items: center; transition: all .15s; cursor: pointer; }
.check input::after { content: ''; width: 10px; height: 10px; clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%); background: var(--ink-text); transform: scale(0); transition: transform .15s var(--ease); }
.check input:checked { background: var(--ink); border-color: var(--ink); }
[data-theme="dark"] .check input:checked { background: var(--accent); border-color: var(--accent); }
.check input:checked::after { transform: scale(1); }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: var(--text-sm); }
.switch input { appearance: none; width: 36px; height: 20px; border-radius: 999px; background: var(--border-strong); position: relative; margin: 0; cursor: pointer; transition: background .2s; }
.switch input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .2); transition: transform .2s var(--ease); }
.switch input:checked { background: var(--success); }
.switch input:checked::after { transform: translateX(16px); }

/* ---------- Известия ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: var(--radius-sm); font-size: var(--text-sm); line-height: 1.45; }
.alert .icon { margin-top: 1px; }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-warning { background: var(--warning-soft); color: var(--warning); }

.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; min-width: 260px; max-width: 420px;
  padding: 12px 14px 12px 12px; border-radius: var(--radius); background: var(--ink); color: var(--ink-text);
  box-shadow: var(--shadow-lg); font-size: var(--text-sm); animation: toast-in .35s var(--ease);
}
[data-theme="dark"] .toast { background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong); }
.toast .toast-icon { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; }
.toast-success .toast-icon { background: var(--success); color: #fff; }
.toast-error .toast-icon { background: var(--danger); color: #fff; }
.toast.is-leaving { animation: toast-out .25s var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.97); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(20px); } }

/* =========================================================
   ВХОД
   ========================================================= */
.auth { min-height: 100dvh; display: grid; grid-template-columns: minmax(380px, 1fr) minmax(420px, 560px); background: var(--bg); }
.auth-brand {
  position: relative; overflow: hidden; background: var(--ink); color: var(--ink-text);
  display: flex; flex-direction: column; justify-content: space-between; padding: 48px 56px;
}
.auth-brand::before { /* шев */
  content: ''; position: absolute; inset: 18px; border: 1.5px dashed rgb(243 239 231 / .14); border-radius: 22px; pointer-events: none;
}
.auth-brand .logo { width: 132px; height: auto; color: var(--ink-text); position: relative; }
.auth-brand-mid { position: relative; max-width: 520px; margin-top: -12vh; }
.auth-eyebrow { font-size: var(--text-xs); letter-spacing: .18em; text-transform: uppercase; color: #c9926c; font-weight: 600; margin-bottom: 20px; display: flex; align-items: center; gap: 12px; }
.auth-eyebrow::before { content: ''; width: 28px; height: 1.5px; background: currentColor; }
.auth-headline { font-size: clamp(2.25rem, 1.2rem + 2.8vw, 3.75rem); font-weight: 500; letter-spacing: -.035em; line-height: 1.02; }
.auth-headline em { font-style: normal; color: #c9926c; }
.auth-sub { margin-top: 20px; color: rgb(243 239 231 / .62); font-size: var(--text-base); max-width: 40ch; line-height: 1.6; }
.auth-brand-foot { position: relative; display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; font-size: var(--text-xs); color: rgb(243 239 231 / .45); }
.auth-clock { font-size: 1.75rem; font-weight: 500; letter-spacing: -.02em; color: var(--ink-text); line-height: 1; font-variant-numeric: tabular-nums; }
.auth-clock-date { margin-top: 6px; }
.auth-clock-date::first-letter { text-transform: uppercase; }

/* Анимиран контур на обувка */
.auth-art { position: absolute; right: 56px; bottom: 96px; width: min(48%, 440px); pointer-events: none; }
.auth-art path { fill: none; stroke: rgb(243 239 231 / .22); stroke-width: 1.2; stroke-linecap: round; stroke-linejoin: round; }
.auth-art .stitch { stroke: #c9926c; stroke-opacity: .55; stroke-dasharray: 3 6; }
.auth-art .draw { stroke-dasharray: 1400; stroke-dashoffset: 1400; animation: draw 2.4s var(--ease) .2s forwards; }
.auth-art .stitch.draw-s { opacity: 0; animation: fade-in 1s ease 1.8s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fade-in { to { opacity: 1; } }

.auth-panel { display: flex; flex-direction: column; justify-content: center; padding: 48px clamp(28px, 6vw, 72px); position: relative; }
.auth-panel-top { position: absolute; top: 24px; right: 24px; left: 24px; display: flex; justify-content: space-between; align-items: center; }
.auth-panel-top .logo-mobile { display: none; width: 92px; color: var(--text); }
.auth-form-wrap { width: 100%; max-width: 380px; margin: 0 auto; animation: rise .6s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
.auth-title { font-size: 1.75rem; font-weight: 600; letter-spacing: -.025em; }
.auth-desc { color: var(--text-2); margin-top: 8px; margin-bottom: 32px; }
.auth-row { display: flex; justify-content: space-between; align-items: center; margin: 20px 0 24px; }
.auth-form .btn-lg { width: 100%; }
.auth-form .btn-lg .btn-label-icon { transition: transform .2s var(--ease); }
.auth-form .btn-lg:hover .btn-label-icon { transform: translateX(3px); }
.auth-form .btn.is-success { background: var(--success); color: #fff; }
.auth-foot { margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 8px; font-size: var(--text-xs); color: var(--text-3); }
.capslock { display: none; font-size: var(--text-xs); color: var(--warning); align-items: center; gap: 5px; }
.capslock.is-on { display: inline-flex; }
.shake { animation: shake .4s cubic-bezier(.36,.07,.19,.97); }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.auth-alert { margin-bottom: 20px; }

/* =========================================================
   ПРИЛОЖЕНИЕ
   ========================================================= */

.avatar {
  --h: 28; width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center;
  font-size: 12.5px; font-weight: 650; letter-spacing: .02em;
  background: hsl(var(--h) 45% 90%); color: hsl(var(--h) 45% 30%);
}
[data-theme="dark"] .avatar { background: hsl(var(--h) 25% 22%); color: hsl(var(--h) 55% 78%); }
.avatar-lg { width: 56px; height: 56px; font-size: 18px; }

.menu {
  position: absolute; z-index: 40; min-width: 220px; padding: 6px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(4px) scale(.98); pointer-events: none; transition: opacity .14s, transform .14s var(--ease);
}
.menu.is-open { opacity: 1; transform: none; pointer-events: auto; }
.menu-up { bottom: calc(100% + 6px); left: 0; right: 0; }
.menu a, .menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 34px; padding: 0 10px; border-radius: var(--radius-sm);
  font-size: var(--text-sm); color: var(--text-2); background: none; border: 0; text-align: left;
}
.menu a:hover, .menu button:hover { background: var(--surface-sunk); color: var(--text); }
.menu .danger { color: var(--danger); }
.menu .danger:hover { background: var(--danger-soft); color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 5px 0; }
.menu kbd { margin-left: auto; }

/* ---------- Горна лента ---------- */
.appbar {
  position: sticky; top: 0; z-index: 50; height: 52px; display: flex; align-items: center; gap: 16px;
  padding: 0 12px 0 20px; background: var(--ink); color: var(--ink-text);
}
.appbar-brand { display: flex; align-items: center; gap: 10px; width: 292px; flex-shrink: 0; }
.appbar-brand .logo { width: 92px; color: var(--ink-text); }
.appbar-brand .tag { font-size: 10px; font-weight: 650; letter-spacing: .16em; text-transform: uppercase; color: #c9926c; border: 1px solid rgb(201 146 108 / .4); padding: 2px 6px; border-radius: 4px; }
.appbar-search {
  display: flex; align-items: center; gap: 9px; width: min(380px, 100%); height: 34px; padding: 0 8px 0 12px;
  border-radius: var(--radius-sm); border: 1px solid rgb(243 239 231 / .1); background: rgb(243 239 231 / .06);
  color: rgb(243 239 231 / .5); font-size: var(--text-sm); text-align: left; transition: background .15s, border-color .15s;
}
.appbar-search:hover { background: rgb(243 239 231 / .1); border-color: rgb(243 239 231 / .18); color: rgb(243 239 231 / .75); }
.appbar-search span { flex: 1; }
.appbar-search kbd { background: transparent; border-color: rgb(243 239 231 / .18); color: rgb(243 239 231 / .5); box-shadow: none; }
.appbar-actions { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.bar-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; min-width: 36px; padding: 0 10px;
  border-radius: var(--radius-sm); border: 0; background: none; color: rgb(243 239 231 / .72); font-size: var(--text-sm); font-weight: 500;
  transition: background .12s, color .12s; position: relative;
}
.bar-btn:hover, .bar-btn[aria-expanded="true"] { background: rgb(243 239 231 / .09); color: var(--ink-text); }
.bar-btn .avatar { width: 28px; height: 28px; font-size: 11px; }
.bar-user { padding: 0 6px 0 4px; margin-left: 6px; }
.bar-user .bar-user-name { max-width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-sep { width: 1px; height: 20px; background: rgb(243 239 231 / .14); margin: 0 6px; }
.bar-menu { position: relative; }
.bar-menu .menu { right: 0; top: calc(100% + 8px); }
.menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 5px; }
.menu-head strong { display: block; font-size: var(--text-sm); color: var(--text); }
.menu-head span { font-size: var(--text-xs); color: var(--text-3); }
.nav-toggle { display: none; }

/* ---------- Обвивка ---------- */
.shell { display: grid; grid-template-columns: 64px 256px minmax(0, 1fr); min-height: calc(100dvh - 52px); transition: grid-template-columns .25s var(--ease); }
[data-subnav="collapsed"] .shell { grid-template-columns: 64px 0 minmax(0, 1fr); }

/* Лента с модули */
.rail {
  position: sticky; top: 52px; height: calc(100dvh - 52px); z-index: 30;
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 0;
  background: var(--surface-sunk); border-right: 1px solid var(--border);
}
.rail-link {
  position: relative; width: 44px; height: 44px; border-radius: 11px; display: grid; place-items: center;
  color: var(--text-2); transition: background .12s, color .12s;
}
.rail-link:hover { background: var(--surface); color: var(--text); }
.rail-link.is-active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }
.rail-link.is-active::before { content: ''; position: absolute; left: -10px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.rail-link.is-muted { color: var(--text-3); }
.rail-link.is-muted .icon { opacity: .6; }
.rail-link.is-muted.is-active .icon { opacity: 1; }
.rail-link[data-tip]::after {
  content: attr(data-tip); position: absolute; left: calc(100% + 12px); top: 50%; transform: translate(-4px, -50%);
  white-space: nowrap; padding: 5px 9px; border-radius: 6px; font-size: var(--text-xs); font-weight: 550;
  background: var(--ink); color: var(--ink-text); box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .12s, transform .12s;
}
[data-theme="dark"] .rail-link[data-tip]::after { background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong); }
.rail-link[data-tip]:hover::after { opacity: 1; transform: translate(0, -50%); }
.rail-sep { width: 24px; height: 1px; background: var(--border-strong); margin: 6px 0; }
.rail-foot { margin-top: auto; }
.rail-collapse { border: 0; background: none; cursor: pointer; }
.rail-collapse .icon { transition: transform .25s var(--ease); }
[data-subnav="collapsed"] .rail-collapse .icon { transform: rotate(180deg); }

/* Меню на модула */
.subnav {
  position: sticky; top: 52px; height: calc(100dvh - 52px); overflow: hidden auto; z-index: 20;
  background: var(--surface); border-right: 1px solid var(--border); scrollbar-width: thin;
}
[data-subnav="collapsed"] .subnav { visibility: hidden; border-right: 0; }
.subnav-inner { width: 256px; padding-bottom: 24px; }
.subnav-head { padding: 22px 22px 16px; }
.subnav-head h2 { font-size: 1.0625rem; font-weight: 650; letter-spacing: -.015em; }
.subnav-head p { font-size: var(--text-xs); color: var(--text-3); margin-top: 3px; }
.subnav-group { padding: 8px 10px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 1px; }
.subnav-link {
  position: relative; display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--radius-sm);
  font-size: var(--text-sm); line-height: 1.35; color: var(--text); font-weight: 500; transition: background .12s, color .12s;
}
.subnav-link:hover { background: var(--surface-sunk); }
.subnav-link.is-muted { color: var(--text-3); font-weight: 450; }
.subnav-link.is-muted:hover { color: var(--text-2); }
.subnav-link.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.subnav-link.is-active::after { content: ''; position: absolute; right: -10px; top: 6px; bottom: 6px; width: 3px; border-radius: 3px 0 0 3px; background: var(--accent); }

.nav-overlay { display: none; }

/* Съдържание */
.main { min-width: 0; }
.content { padding: 28px 40px 64px; max-width: 1320px; width: 100%; }
.crumb { display: flex; align-items: center; gap: 6px; font-size: var(--text-xs); color: var(--text-3); margin-bottom: 6px; }
.crumb a:hover { color: var(--text); }
.page-title-lg { font-size: 1.875rem; font-weight: 600; letter-spacing: -.03em; line-height: 1.15; }

/* Страница в разработка */
.wip { padding: 56px 24px; text-align: center; display: flex; flex-direction: column; align-items: center; }
.wip-icon { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--surface-sunk); color: var(--text-3); margin-bottom: 18px; border: 1px dashed var(--border-strong); }
.wip h2 { font-size: var(--text-lg); }
.wip p { color: var(--text-2); font-size: var(--text-sm); margin-top: 6px; max-width: 46ch; }
.wip .badge { margin-top: 18px; }

/* Плочки с модули / страници */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.tile {
  display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  font-size: var(--text-sm); color: var(--text); transition: border-color .15s, transform .15s var(--ease), box-shadow .15s;
}
.tile:hover { border-color: var(--border-strong); transform: translateY(-1px); box-shadow: var(--shadow); }
.tile .tile-icon { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex-shrink: 0; }
.tile strong { display: block; font-weight: 600; line-height: 1.3; }
.tile small { display: block; font-size: var(--text-xs); color: var(--text-3); margin-top: 2px; }
.tile.is-muted { background: var(--surface-2); border-style: dashed; box-shadow: none; color: var(--text-3); }
.tile.is-muted strong { color: var(--text-2); font-weight: 550; }
.tile.is-muted .tile-icon { background: var(--surface-sunk); color: var(--text-3); }
.section-title { font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); margin: 28px 0 12px; }
.section-title:first-child { margin-top: 0; }

@media (max-width: 1100px) {
  .appbar-brand { width: auto; }
}
@media (max-width: 860px) {
  .appbar { padding: 0 8px 0 6px; gap: 6px; }
  .appbar-brand .logo { width: 78px; }
  .appbar-brand .tag, .appbar-search, .bar-user-name, .bar-help-label, .bar-sep { display: none; }
  .nav-toggle { display: inline-flex; }
  .shell, [data-subnav="collapsed"] .shell { grid-template-columns: minmax(0, 1fr); }
  .rail, .subnav { position: fixed; top: 52px; bottom: 0; height: auto; transform: translateX(calc(-100% - 80px)); visibility: hidden; transition: transform .28s var(--ease), visibility 0s .28s; }
  .rail { left: 0; z-index: 71; }
  .subnav, [data-subnav="collapsed"] .subnav { left: 64px; width: min(272px, calc(100vw - 64px)); z-index: 70; border-right: 1px solid var(--border); box-shadow: var(--shadow-lg); }
  .subnav-inner { width: auto; }
  .rail-foot { display: none; }
  [data-nav-open] .rail, [data-nav-open] .subnav { transform: none; visibility: visible; transition: transform .28s var(--ease); }
  .nav-overlay { display: block; position: fixed; inset: 52px 0 0 0; z-index: 60; background: rgb(15 14 12 / .38); opacity: 0; pointer-events: none; transition: opacity .2s; }
  [data-nav-open] .nav-overlay { opacity: 1; pointer-events: auto; }
  .content { padding: 20px 16px 48px; }
  .page-title-lg { font-size: 1.5rem; }
}


.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 12px 0 28px; flex-wrap: wrap; }
.page-title { font-size: var(--text-xl); font-weight: 600; letter-spacing: -.025em; }
.page-sub { color: var(--text-2); margin-top: 4px; font-size: var(--text-sm); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.card-title { font-size: var(--text-base); font-weight: 600; }
.card-body { padding: 20px; }

/* Табло */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.stat-top { display: flex; align-items: center; justify-content: space-between; color: var(--text-2); font-size: var(--text-sm); font-weight: 500; }
.stat-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-sunk); color: var(--text-2); }
.stat-value { font-size: 1.875rem; font-weight: 600; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: var(--text-sm); color: var(--text-3); font-weight: 500; letter-spacing: 0; margin-left: 4px; }
.stat.is-warn .stat-icon { background: var(--danger-soft); color: var(--danger); }

.dash-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 20px; }
.hero-card { position: relative; overflow: hidden; padding: 26px 28px; background: var(--ink); color: var(--ink-text); border: 0; margin-bottom: 20px; }
.hero-card::after { content: ''; position: absolute; inset: 10px; border: 1.5px dashed rgb(243 239 231 / .12); border-radius: 12px; pointer-events: none; }
.hero-card h2 { font-size: 1.5rem; font-weight: 500; letter-spacing: -.025em; }
.hero-card p { color: rgb(243 239 231 / .62); margin-top: 6px; font-size: var(--text-sm); }
.hero-card .hero-meta { display: flex; gap: 24px; margin-top: 20px; font-size: var(--text-xs); color: rgb(243 239 231 / .5); flex-wrap: wrap; }
.hero-card .hero-meta strong { display: block; color: var(--ink-text); font-size: var(--text-sm); font-weight: 500; margin-top: 2px; }

.feed { list-style: none; margin: 0; padding: 6px 0; }
.feed li { display: flex; gap: 12px; padding: 10px 20px; align-items: center; }
.feed .avatar { width: 30px; height: 30px; font-size: 11px; }
.feed .feed-text { flex: 1; min-width: 0; font-size: var(--text-sm); color: var(--text-2); }
.feed .feed-text strong { color: var(--text); font-weight: 600; }
.feed time { font-size: var(--text-xs); color: var(--text-3); white-space: nowrap; }

.modules { display: grid; gap: 10px; padding: 16px; }
.module { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--radius); border: 1px dashed var(--border-strong); color: var(--text-2); font-size: var(--text-sm); }
.module .stat-icon { width: 34px; height: 34px; }
.module strong { display: block; color: var(--text); font-weight: 600; }
.module.is-ready { border-style: solid; background: var(--surface-2); }
.module.is-ready:hover { border-color: var(--text-3); }

/* Таблица потребители */
.toolbar { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.toolbar .input-wrap { flex: 1; min-width: 220px; max-width: 360px; }
.toolbar .input { height: 36px; }
.toolbar .input-wrap kbd { position: absolute; right: 10px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  font-size: var(--text-xs); font-weight: 550; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; transition: all .12s;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.is-active { background: var(--ink); border-color: var(--ink); color: var(--ink-text); }
[data-theme="dark"] .chip.is-active { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip .count { opacity: .6; font-variant-numeric: tabular-nums; }

.table-wrap { position: relative; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th { text-align: left; font-size: 11.5px; font-weight: 600; color: var(--text-3); letter-spacing: .04em; text-transform: uppercase; padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background .1s; cursor: pointer; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr.is-inactive .person, .table tr.is-inactive td:not(:last-child) { opacity: .55; }
.person { display: flex; align-items: center; gap: 12px; min-width: 0; }
.person .name { font-weight: 600; color: var(--text); white-space: nowrap; }
.person .sub { font-size: var(--text-xs); color: var(--text-3); }
.you { font-size: 10px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); background: var(--accent-soft); padding: 2px 6px; border-radius: 4px; margin-left: 6px; vertical-align: 1px; }
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 999px; font-size: var(--text-xs); font-weight: 550; white-space: nowrap; background: var(--surface-sunk); color: var(--text-2); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-blue { background: var(--info-soft); color: var(--info); }
.badge-green { background: var(--success-soft); color: var(--success); }
.status { display: inline-flex; align-items: center; gap: 7px; font-size: var(--text-sm); color: var(--text-2); white-space: nowrap; }
.status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.status.off::before { background: var(--text-3); box-shadow: 0 0 0 3px var(--surface-sunk); }
.row-actions { display: flex; justify-content: flex-end; gap: 2px; position: relative; }
.row-actions .menu { right: 0; top: calc(100% + 4px); }
.empty { padding: 56px 20px; text-align: center; color: var(--text-3); }
.empty .icon { margin: 0 auto 12px; color: var(--text-3); }
.empty strong { display: block; color: var(--text); font-size: var(--text-base); margin-bottom: 4px; }

/* Чекмедже (drawer) */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgb(15 14 12 / .38); opacity: 0; pointer-events: none; transition: opacity .2s; }
.overlay.is-open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 61; width: min(480px, 100vw); display: flex; flex-direction: column;
  background: var(--surface); box-shadow: var(--shadow-lg); transform: translateX(104%); transition: transform .3s var(--ease);
}
.drawer.is-open { transform: none; }
.drawer-head { display: flex; align-items: center; gap: 14px; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.drawer-head h2 { font-size: var(--text-lg); }
.drawer-head p { font-size: var(--text-sm); color: var(--text-3); margin-top: 2px; }
.drawer-head .btn-icon { margin-left: auto; }
.drawer-body { flex: 1; overflow-y: auto; padding: 24px; }
.drawer-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 24px; border-top: 1px solid var(--border); background: var(--surface-2); }
.form-section + .form-section { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--border); }
.form-section-title { font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); margin-bottom: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-2 .field + .field { margin-top: 0; }
.role-options { display: grid; gap: 8px; }
.role-option { position: relative; display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; transition: border-color .15s, background .15s; }
.role-option:hover { border-color: var(--border-strong); }
.role-option input { position: absolute; opacity: 0; }
.role-option .radio { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--border-strong); flex-shrink: 0; margin-top: 1px; display: grid; place-items: center; transition: all .15s; }
.role-option .radio::after { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); transform: scale(0); transition: transform .15s var(--ease); }
.role-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.role-option:has(input:checked) .radio { border-color: var(--accent); }
.role-option:has(input:checked) .radio::after { transform: scale(1); }
.role-option:has(input:focus-visible) { box-shadow: var(--ring); }
.role-option strong { display: block; font-size: var(--text-sm); }
.role-option span.desc { font-size: var(--text-xs); color: var(--text-3); }
.role-option .lvl { margin-left: auto; font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.pw-meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 2px; }
.pw-meter i { height: 3px; border-radius: 2px; background: var(--border); transition: background .2s; }
.pw-meter[data-score="1"] i:nth-child(-n+1) { background: var(--danger); }
.pw-meter[data-score="2"] i:nth-child(-n+2) { background: var(--warning); }
.pw-meter[data-score="3"] i:nth-child(-n+3) { background: #7a9a3a; }
.pw-meter[data-score="4"] i { background: var(--success); }

/* Диалог */
dialog.confirm { border: 0; padding: 0; border-radius: var(--radius-lg); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); width: min(420px, calc(100vw - 32px)); }
dialog.confirm::backdrop { background: rgb(15 14 12 / .45); }
dialog.confirm[open] { animation: pop .2s var(--ease); }
@keyframes pop { from { opacity: 0; transform: scale(.96); } }
.confirm-body { padding: 24px; display: flex; gap: 16px; }
.confirm-icon { width: 40px; height: 40px; border-radius: 50%; background: var(--danger-soft); color: var(--danger); display: grid; place-items: center; flex-shrink: 0; }
.confirm-body h3 { font-size: var(--text-base); margin-bottom: 6px; }
.confirm-body p { font-size: var(--text-sm); color: var(--text-2); }
.confirm-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 24px; background: var(--surface-2); border-top: 1px solid var(--border); }

/* Команди (Ctrl+K) */
.palette { position: fixed; inset: 0; z-index: 90; display: none; align-items: flex-start; justify-content: center; padding-top: 14vh; background: rgb(15 14 12 / .38); }
.palette.is-open { display: flex; animation: fade-in-fast .12s ease; }
@keyframes fade-in-fast { from { opacity: 0; } }
.palette-box { width: min(560px, calc(100vw - 32px)); background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden; border: 1px solid var(--border); animation: pop .18s var(--ease); }
.palette-input { display: flex; align-items: center; gap: 12px; padding: 0 18px; border-bottom: 1px solid var(--border); color: var(--text-3); }
.palette-input input:focus-visible { box-shadow: none; }
.palette-input input { flex: 1; height: 54px; border: 0; background: none; font-size: var(--text-lg); outline: none; color: var(--text); }
.palette-list { list-style: none; margin: 0; padding: 8px; max-height: 340px; overflow-y: auto; }
.palette-list .group { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); padding: 8px 10px 4px; }
.palette-list a { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: var(--radius-sm); font-size: var(--text-sm); color: var(--text-2); }
.palette-list a.is-active { background: var(--surface-sunk); color: var(--text); }
.palette-list a .icon { color: var(--text-3); }
.palette-list a span.hint { margin-left: auto; font-size: var(--text-xs); color: var(--text-3); }
.palette-foot { display: flex; gap: 16px; padding: 10px 18px; border-top: 1px solid var(--border); font-size: var(--text-xs); color: var(--text-3); background: var(--surface-2); }
.palette-foot span { display: inline-flex; gap: 6px; align-items: center; }

/* Профил */
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.profile-head { display: flex; align-items: center; gap: 16px; }
.session-list { list-style: none; margin: 0; padding: 0; }
.session-list li { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--border); font-size: var(--text-sm); }
.session-list li:first-child { border-top: 0; }
.session-list .ok { color: var(--success); } .session-list .bad { color: var(--danger); }
.session-list .meta { flex: 1; min-width: 0; }
.session-list .meta small { display: block; color: var(--text-3); font-size: var(--text-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-foot { display: flex; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

.error-page { min-height: 60vh; display: grid; place-items: center; text-align: center; }
.error-page .code { font-size: 4.5rem; font-weight: 600; letter-spacing: -.05em; line-height: 1; color: var(--border-strong); }
.error-page h1 { font-size: var(--text-xl); margin: 12px 0 8px; }
.error-page p { color: var(--text-2); margin-bottom: 24px; }

/* ---------- Адаптивност ---------- */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .dash-grid, .profile-grid { grid-template-columns: 1fr; }
}
@media (max-width: 960px) {
  .auth { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .auth-panel-top .logo-mobile { display: block; }
  .auth-panel { padding-top: 96px; }
}
@media (max-width: 860px) {
  .hide-sm { display: none !important; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-2 .field + .field { margin-top: 16px; }
  .toolbar .input-wrap { max-width: none; }
}
@media (max-width: 520px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 14px; }
  .stat-value { font-size: 1.5rem; }
  .toasts { left: 16px; right: 16px; bottom: 16px; }
  .toast { min-width: 0; max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .auth-art .draw { stroke-dashoffset: 0; }
  .auth-art .stitch.draw-s { opacity: 1; }
}

/* Иконки за тема */
[data-theme="dark"] [data-theme-icon="light"], [data-theme="light"] [data-theme-icon="dark"] { display: none; }
[data-theme-icon] { display: contents; }
@media (max-width: 520px) {
  .table td, .table th { padding-left: 10px; padding-right: 10px; }
  .person .sub { display: none; }
}
[data-mobile-search] { display: none; }
@media (max-width: 860px) { [data-mobile-search] { display: inline-flex; } }

/* ---------- Номенклатури ---------- */
.lk { max-width: 760px; }
.lk-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); font-size: var(--text-sm); color: var(--text-2); }
.lk-count strong { color: var(--text); font-weight: 650; font-variant-numeric: tabular-nums; }
.lk-keys { display: flex; align-items: center; gap: 6px; font-size: var(--text-xs); color: var(--text-3); }
.lk-keys kbd + * { margin-right: 6px; }
.lk-keys kbd { margin-left: 6px; }
.lk-add { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.lk-add .input-wrap { flex: 1; min-width: 0; }
.lk-add .input { height: 40px; }
.lk-add .btn { height: 40px; }
.lk-add .field-error { flex-basis: 100%; margin-top: 0; }
.lk-add.has-error .input { border-color: var(--danger); }
.lk-list { list-style: none; margin: 0; padding: 0; }
.lk-row {
  display: flex; align-items: center; gap: 12px; min-height: 54px; padding: 8px 12px 8px 16px;
  transition: background .15s;
}
.lk-row + .lk-row { border-top: 1px solid var(--border); }
.lk-row:last-child { border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.lk-row:hover { background: var(--surface-2); }
.lk-num {
  width: 30px; height: 30px; flex-shrink: 0; border-radius: 8px; display: grid; place-items: center;
  background: var(--surface-sunk); color: var(--text-2); font-size: var(--text-xs); font-weight: 650; font-variant-numeric: tabular-nums;
}
.lk-name { flex: 1; min-width: 0; font-size: var(--text-sm); font-weight: 550; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: default; }
.lk-name[data-lk-edit] { cursor: text; }
.lk-actions { display: flex; align-items: center; gap: 2px; opacity: 0; transition: opacity .15s; }
.lk-row:hover .lk-actions, .lk-row:focus-within .lk-actions { opacity: 1; }
.lk-actions .btn-icon { width: 32px; height: 32px; }
.lk-actions .btn[disabled] { opacity: .3; }
.lk-move { display: flex; gap: 2px; margin-right: 4px; padding-right: 6px; border-right: 1px solid var(--border); }
.lk-del:hover { color: var(--danger); background: var(--danger-soft); }
.lk-edit { display: none; flex: 1; align-items: center; gap: 6px; }
.lk-edit .input { height: 36px; flex: 1; min-width: 0; }
.lk-row.is-editing { background: var(--accent-soft); }
.lk-row.is-editing .lk-name, .lk-row.is-editing .lk-actions { display: none; }
.lk-row.is-editing .lk-edit { display: flex; }
.lk-row.is-editing .lk-num { background: var(--surface); color: var(--accent); }
.lk-row.is-new { animation: lk-flash 1.6s var(--ease); }
@keyframes lk-flash { 0%, 30% { background: var(--accent-soft); } 100% { background: transparent; } }

.flow { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.flow-step {
  display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px 0 5px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); font-size: var(--text-sm); font-weight: 550; box-shadow: var(--shadow-sm);
}
.flow-step span { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: var(--ink-text); font-size: 11px; font-weight: 650; }
[data-theme="dark"] .flow-step span { background: var(--accent); color: var(--accent-text); }
.flow-step + .flow-step::before { content: ''; width: 14px; height: 1px; border-top: 1.5px dashed var(--border-strong); margin-left: -21px; margin-right: 1px; }
.flow-step + .flow-step { margin-left: 14px; }
.flow-step.is-new { border-color: var(--accent); }

@media (hover: none) { .lk-actions { opacity: 1; } }
@media (max-width: 860px) {
  .lk-move { display: none; }
  .flow-step + .flow-step { margin-left: 0; }
  .flow-step + .flow-step::before { display: none; }
  .lk-row { padding-left: 8px; gap: 10px; }
}

/* ---------- Табове ---------- */
.kbd-on-dark { background: transparent; border-color: rgb(255 255 255 / .2); color: inherit; opacity: .7; box-shadow: none; }
.tabs { display: flex; align-items: flex-end; gap: 4px; border-bottom: 1px solid var(--border-strong); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative; display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 14px; border: 0; background: none;
  font-size: var(--text-sm); font-weight: 550; color: var(--text-2); white-space: nowrap; cursor: pointer; transition: color .15s;
}
.tab:hover { color: var(--text); }
.tab::after { content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px 2px 0 0; background: var(--accent); transform: scaleX(0); transition: transform .2s var(--ease); }
.tab[aria-selected="true"] { color: var(--text); font-weight: 650; }
.tab[aria-selected="true"]::after { transform: scaleX(1); }
.tabs:not(.is-ready) .tab::after { transition: none; }
.tab-num { width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; font-size: 11px; font-weight: 650; background: var(--surface-sunk); color: var(--text-2); }
.tab[aria-selected="true"] .tab-num { background: var(--accent); color: var(--accent-text); }
.tab-count { font-size: 11px; font-weight: 600; color: var(--text-3); font-variant-numeric: tabular-nums; }
.tabs-link { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; height: 44px; padding: 0 10px; font-size: var(--text-xs); color: var(--text-3); white-space: nowrap; }
.tabs-link:hover { color: var(--accent); }

/* ---------- Процеси ---------- */
.proc-panel .toolbar { gap: 14px; }
.proc-title { font-size: var(--text-base); font-weight: 650; order: -1; margin-right: auto; white-space: nowrap; }
.proc-title span { color: var(--accent); }
.save-state { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-xs); color: var(--text-3); white-space: nowrap; transition: color .2s; }
.save-state.is-saving { color: var(--text-2); }
.save-state.is-saved { color: var(--success, #2f7d4f); }
.save-state.is-error { color: var(--danger); }
.ptable tbody tr { cursor: default; }
.ptable td, .ptable th { padding-top: 0; padding-bottom: 0; }
.ptable th { height: 44px; }
.ptable td { height: 46px; }
.ptable .c-grip { width: 36px; padding: 0 0 0 8px; }
.ptable .c-ord { width: 56px; color: var(--text-3); }
.ptable .c-code { width: 84px; font-weight: 600; color: var(--text-2); }
.ptable .c-name { font-weight: 550; min-width: 200px; }
.ptable .c-cat { width: 104px; text-align: center; }
.ptable th.c-cat { color: var(--text-2); }
.ptable th.c-cat small { display: block; font-size: 10.5px; font-weight: 550; letter-spacing: 0; text-transform: none; color: var(--text-3); margin-top: 1px; font-variant-numeric: tabular-nums; }
.ptable .c-act { width: 92px; text-align: right; padding-right: 10px; }
.ptable tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.ptable tbody tr:hover { background: var(--surface-2); }
.ptable tbody tr.is-editing { background: var(--accent-soft); }
.ptable tbody tr.is-new { animation: lk-flash 1.6s var(--ease); }
.ptable tbody tr.is-dragging { opacity: .45; }
.ptable tbody tr.drop-before td { box-shadow: inset 0 2px 0 var(--accent); }
.ptable tbody tr.drop-after td { box-shadow: inset 0 -2px 0 var(--accent); }
.ptable tbody tr[hidden] { display: none; }
.grip { width: 26px; height: 30px; border: 0; background: none; border-radius: 6px; display: grid; place-items: center; color: var(--text-3); cursor: grab; opacity: .5; transition: opacity .15s, background .15s; }
.ptable tr:hover .grip, .grip:focus-visible { opacity: 1; }
.grip:hover { background: var(--surface-sunk); color: var(--text); }
.grip:active { cursor: grabbing; }
.row-tools { display: inline-flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.ptable tr:hover .row-tools, .ptable tr:focus-within .row-tools { opacity: 1; }
.row-tools .btn-icon { width: 30px; height: 30px; }
.ptable tr.is-editing .row-tools { opacity: 1; }
.c-name[data-name-cell] { cursor: text; }
.input-sm { height: 32px; font-size: var(--text-sm); padding: 0 10px; border-radius: 7px; }
.ptable .c-code .input-sm { width: 70px; }
.ptable .c-name .input-sm { width: 100%; max-width: 420px; }

/* Отметка */
.tick { position: relative; display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; cursor: pointer; vertical-align: middle; }
.tick:hover { background: var(--surface-sunk); }
.tick input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: inherit; }
.tick span {
  width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--border-strong); background: var(--surface);
  display: grid; place-items: center; transition: background .12s, border-color .12s, transform .12s var(--ease);
}
.tick span::after { content: ''; width: 10px; height: 6px; border: solid var(--accent-text); border-width: 0 0 2px 2px; transform: translateY(-1px) rotate(-45deg) scale(0); transition: transform .15s var(--ease); }
.tick input:checked + span { background: var(--accent); border-color: var(--accent); }
.tick input:checked + span::after { transform: translateY(-1px) rotate(-45deg) scale(1); }
.tick input:focus-visible + span { box-shadow: var(--ring); }
.tick input:active + span { transform: scale(.88); }
.tick input:disabled { cursor: default; }
.tick input:disabled + span { opacity: .75; }
.tick:has(input:disabled):hover { background: none; }
.tick.is-saving span { animation: tick-pulse .6s ease infinite alternate; }
@keyframes tick-pulse { to { opacity: .55; } }

.add-row td { background: var(--surface-2); border-top: 1px solid var(--border); border-bottom: 0; height: 54px; }
.add-plus { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.add-row .input.is-invalid, .ptable .input.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }

@media (max-width: 860px) {
  .proc-title { display: none; }
  .ptable .c-ord { display: none; }
  .ptable .c-cat { width: 72px; }
  .row-tools { opacity: 1; }
}

@media (max-width: 560px) {
  .ptable .c-grip { display: none; }
  .ptable th, .ptable td { padding-left: 6px; padding-right: 6px; }
  .ptable .c-code { width: 40px; padding-left: 12px; font-size: 12.5px; }
  .ptable .c-code .input-sm { width: 46px; padding-left: 6px; padding-right: 4px; }
  .ptable .c-name { min-width: 0; font-size: 13px; line-height: 1.25; }
  .ptable .c-cat { width: 46px; padding-left: 1px; padding-right: 1px; }
  .ptable th.c-cat { font-size: 9px; letter-spacing: 0; white-space: normal; }
  .ptable th.c-cat small { font-size: 9px; white-space: nowrap; }
  .ptable .c-act { width: 40px; padding: 0 6px 0 2px; }
  .ptable .row-tools { flex-direction: column; gap: 2px; }
  .ptable .c-act .btn-icon { width: 30px; height: 22px; }
  .ptable [data-add-submit] { width: 30px; height: 30px; padding: 0; justify-content: center; }
  .ptable [data-add-submit] span { display: none; }
}

/* ---------- Детайли: клетки за редакция ---------- */
.dtable .c-name { min-width: 220px; }
.dtable .c-qty { width: 110px; }
.dtable .c-knife { width: 200px; }
.dtable .c-unit { width: 150px; }
.dtable .c-act { width: 56px; }
.no-knife .c-knife, .no-unit .c-unit { display: none; }
.cell {
  width: 100%; height: 34px; padding: 0 10px; margin-left: -10px; border: 1px solid transparent; border-radius: 7px; background: transparent;
  font: inherit; color: inherit; transition: background .12s, border-color .12s, box-shadow .12s;
}
.c-name .cell { font-weight: 550; }
.cell-num { width: 72px; }
.cell::placeholder { color: var(--text-3); opacity: .6; }
.cell:hover { background: var(--surface); border-color: var(--border); }
.cell:focus { outline: none; background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.cell.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.cell.is-saving { background: var(--surface-sunk); }
.cell.is-saved { border-color: var(--success, #2f7d4f); }
.cell-select { appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 26px; width: 110px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a857d' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; }
.cell-select option { color: var(--text); background: var(--surface); }
.dtable .add-row .c-qty .input { width: 72px; }
.dtable .add-row .c-knife .input, .dtable .add-row .c-unit .input { width: 100%; max-width: 140px; }
.dtable td.muted, .dtable .muted { color: var(--text-3); }
.col-toggles { display: inline-flex; align-items: center; gap: 6px; }
.col-toggles-label { display: inline-flex; align-items: center; gap: 5px; font-size: var(--text-xs); color: var(--text-3); margin-right: 2px; }
.chip-toggle {
  height: 28px; padding: 0 11px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface);
  font-size: var(--text-xs); font-weight: 600; color: var(--text-2); cursor: pointer; transition: all .15s;
}
.chip-toggle:hover { border-color: var(--accent); color: var(--text); }
.chip-toggle[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip-toggle[aria-pressed="true"]::before { content: '✓ '; }
@media (max-width: 860px) {
  .dtable .c-knife { width: 120px; }
  .dtable .c-unit { width: 100px; }
  .cell-select { width: 86px; }
}
@media (max-width: 560px) {
  .dtable .c-name { min-width: 0; }
  .dtable .c-qty { width: 54px; }
  .cell-num, .dtable .add-row .c-qty .input { width: 46px; }
  .cell { padding: 0 6px; margin-left: -6px; font-size: 13px; }
  .dtable .c-knife { width: 80px; }
  .dtable .c-unit { width: 74px; }
  .cell-select { width: 70px; padding-right: 18px; background-position: right 4px center; }
  .col-toggles .chip-toggle { padding: 0 8px; }
}

/* ================= Модели ================= */
.mtable .num { text-align: right; }
.mtable .m-code { font-weight: 650; color: var(--text); letter-spacing: -.01em; }
.mtable .m-code:hover { color: var(--accent); }
.mtable .m-notes { font-size: var(--text-xs); color: var(--text-3); margin-top: 2px; max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mtable td.muted, .muted { color: var(--text-3); }
.mtable tbody tr:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Стъпки */
.stepper { display: flex; gap: 10px; list-style: none; margin: 0 0 18px; padding: 0; counter-reset: s; }
.stepper li { flex: 1; display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); color: var(--text-3); position: relative; }
.stepper li strong { display: block; font-size: var(--text-sm); color: var(--text-2); font-weight: 600; }
.stepper li small { display: block; font-size: var(--text-xs); }
.step-dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 650; background: var(--surface-sunk); color: var(--text-2); flex-shrink: 0; }
.stepper li.is-current { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.stepper li.is-current strong { color: var(--text); }
.stepper li.is-current .step-dot { background: var(--accent); color: var(--accent-text); }
.stepper li.is-done .step-dot { background: var(--success-soft); color: var(--success); }
.stepper li.is-done strong { color: var(--text); }
.stepper.is-compact li { padding: 9px 14px; }
.stepper.is-compact .step-dot { width: 24px; height: 24px; font-size: 12px; }

/* Форма стъпка 1 */
.model-form { max-width: 680px; }
.model-form-body { padding: 24px; }
.model-form-body .field + .field { margin-top: 22px; }
.model-form-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 24px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.input-lg { height: 48px; font-size: 1.125rem; font-weight: 600; letter-spacing: -.01em; }
.textarea { height: auto; min-height: 96px; padding: 10px 13px; resize: vertical; line-height: 1.5; }
fieldset.field { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.field legend { padding: 0; margin-bottom: 6px; }
.cat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.cat-card { position: relative; cursor: pointer; }
.cat-card input { position: absolute; opacity: 0; pointer-events: none; }
.cat-card-box { display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 14px; border: 1.5px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); transition: border-color .15s, background .15s, transform .1s; }
.cat-card:hover .cat-card-box { border-color: var(--text-3); }
.cat-card:active .cat-card-box { transform: scale(.98); }
.cat-card-key { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; font-size: 11px; font-weight: 650; background: var(--surface-sunk); color: var(--text-3); }
.cat-card-name { font-weight: 600; font-size: var(--text-base); }
.cat-card-check { margin-left: auto; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-text); transform: scale(0); transition: transform .18s var(--ease); }
.cat-card input:checked + .cat-card-box { border-color: var(--accent); background: var(--accent-soft); }
.cat-card input:checked + .cat-card-box .cat-card-check { transform: scale(1); }
.cat-card input:checked + .cat-card-box .cat-card-key { background: var(--accent); color: var(--accent-text); }
.cat-card input:focus-visible + .cat-card-box { box-shadow: var(--ring); }
.field.has-error .cat-card-box { border-color: var(--danger); }
.cat-cards.is-compact .cat-card-box { height: 42px; }
.cat-cards.is-compact .cat-card-name { font-size: var(--text-sm); }
.btn.is-loading { opacity: .7; pointer-events: none; }

/* Глава на модел */
.model-head { align-items: flex-start; }
.model-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.model-title .muted-word { color: var(--text-3); font-weight: 500; }
.model-notes { white-space: pre-line; max-width: 720px; }
.model-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.confirm-switch { height: 38px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); font-weight: 550; }
.lock-banner { margin-bottom: 14px; }
.m-panel.is-locked .dopt { cursor: default; }

/* Детайли на модел */
.total-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 12px 16px; margin-bottom: 14px; }
.total-field { display: inline-flex; align-items: center; gap: 8px; font-size: var(--text-sm); font-weight: 600; }
.total-field .input { width: 72px; text-align: center; font-weight: 650; }
.total-hint { font-size: var(--text-xs); color: var(--text-3); }
.total-hint strong { color: var(--text); font-variant-numeric: tabular-nums; }
.total-search { margin-left: auto; width: 280px; }
.total-search > .icon + .input { padding-left: 34px; }
.total-search > .icon { left: 11px; }
.total-search kbd { position: absolute; right: 8px; }
.dgroups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.dgroup { display: flex; flex-direction: column; min-width: 0; }
.dgroup-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px 8px; }
.dgroup-head h2 { font-size: var(--text-base); font-weight: 650; }
.dgroup-count { font-size: var(--text-xs); color: var(--text-3); font-variant-numeric: tabular-nums; margin-right: auto; }
.dgroup-count strong { color: var(--accent); font-weight: 700; }
.dgroup-search { padding: 0 14px 8px; }
.dgroup-search > .icon { left: 25px; }
.dgroup-search > .icon + .input { padding-left: 32px; width: 100%; }
.dlist { list-style: none; margin: 0; padding: 4px 6px 8px; max-height: 380px; overflow-y: auto; border-top: 1px solid var(--border); }
.dopt { display: flex; align-items: center; gap: 6px; padding: 1px 8px 1px 2px; border-radius: 8px; cursor: pointer; font-size: var(--text-sm); transition: background .1s; }
.dopt:hover { background: var(--surface-2); }
.dopt .tick:hover { background: none; }
.dopt.is-on { background: var(--accent-soft); }
.dopt.is-on .dopt-name { font-weight: 600; }
.dopt-name { flex: 1; min-width: 0; }
.dopt-meta { font-size: var(--text-xs); color: var(--text-3); white-space: nowrap; }
.dgroup-empty { padding: 18px; text-align: center; font-size: var(--text-sm); color: var(--text-3); border-top: 1px solid var(--border); }
.dgroup.is-filtered { opacity: .6; }

/* Процеси на модел */
.mstats { display: flex; align-items: stretch; flex-wrap: wrap; margin-bottom: 14px; }
.mstat { padding: 12px 20px; display: flex; flex-direction: column; gap: 3px; border-right: 1px solid var(--border); min-width: 130px; }
.mstat span { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); }
.mstat strong { font-size: 1.375rem; font-weight: 650; letter-spacing: -.02em; }
.mstat-help { margin-left: auto; align-self: center; padding: 10px 16px; font-size: var(--text-xs); color: var(--text-3); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.mstat-help kbd { font-size: 11px; }
.ptype { margin-bottom: 14px; }
.ptype-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.ptype-head .tab-num { background: var(--accent); color: var(--accent-text); }
.ptype-head h2 { font-size: var(--text-base); font-weight: 650; }
.ptype-meta { font-size: var(--text-xs); color: var(--text-3); margin-right: auto; font-variant-numeric: tabular-nums; }
.proctable th, .proctable td { padding-top: 6px; padding-bottom: 6px; }
.proctable th small { display: block; font-size: 10.5px; text-transform: none; letter-spacing: 0; font-weight: 500; }
.proctable tbody tr { cursor: default; }
.proctable .c-proc { width: 100%; min-width: 220px; }
.proctable .c-t, .proctable .c-n { text-align: right; white-space: nowrap; width: 1%; }
.table.proctable thead th { text-align: center; }
.proctable .c-x { width: 1%; padding-left: 4px; padding-right: 8px; }
.proctable .strong { font-weight: 650; }
.proctable tfoot td { padding-top: 10px; padding-bottom: 10px; background: var(--surface-2); font-weight: 600; border-top: 1px solid var(--border); font-size: var(--text-sm); }
.proctable tr.is-removing { opacity: .4; }
.pcode { display: inline-block; min-width: 34px; font-size: var(--text-xs); font-weight: 650; color: var(--text-3); }
.pname { font-weight: 550; }
.tcell { width: 72px; height: 32px; text-align: right; padding: 0 9px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); font-weight: 600; transition: border-color .15s, box-shadow .15s, background .15s; }
.tcell::placeholder { color: var(--text-3); opacity: .55; font-weight: 500; }
.tcell:hover { border-color: var(--text-3); }
.tcell:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tcell.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.tcell.is-saving { background: var(--surface-sunk); }
.tcell.is-saved { border-color: var(--success); }
.tcell:disabled { background: transparent; border-color: transparent; color: var(--text); }
.table.proctable tbody td, .table.proctable tfoot td,
.table.proctable .tcell, .table.proctable .price-control .input {
  text-align: center;
  font-weight: 400;
}
.table.proctable .price-control select { text-align-last: center; }
.table.proctable tr > :first-child { text-align: left; }
.table.proctable .pcode, .table.proctable .pname { font-weight: 400; }
.table.proctable td.strong { font-weight: 700; }
.price-footer [data-duration] { font-weight: 700; }
.price-footer [data-total] { font-weight: 400; }
.ptype-empty { padding: 22px; text-align: center; font-size: var(--text-sm); color: var(--text-3); }
.linkbtn { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

/* Диалог за процеси / редакция */
dialog.pdlg { border: 0; padding: 0; border-radius: var(--radius-lg); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); width: min(640px, calc(100vw - 24px)); max-height: min(760px, calc(100vh - 32px)); display: none; flex-direction: column; overflow: hidden; }
dialog.pdlg[open] { display: flex; animation: pop .2s var(--ease); }
dialog.pdlg::backdrop { background: rgb(15 14 12 / .45); }
dialog.pdlg-sm { width: min(480px, calc(100vw - 24px)); }
dialog.pdlg form { display: flex; flex-direction: column; min-height: 0; }
.pdlg-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 12px; }
.pdlg-head h3 { font-size: var(--text-lg); }
.pdlg-head p { font-size: var(--text-xs); color: var(--text-3); margin-top: 2px; }
.pdlg-head .btn-icon { margin-left: auto; }
.pdlg-tools { display: flex; align-items: center; gap: 6px; padding: 0 20px 12px; border-bottom: 1px solid var(--border); }
.pdlg-tools .input-wrap { flex: 1; }
.pdlg-tools .input-wrap > .icon { left: 11px; }
.pdlg-tools .input-wrap > .icon + .input { padding-left: 34px; width: 100%; }
.pdlg-list { overflow-y: auto; padding: 6px 10px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 6px; align-content: start; flex: 1; min-height: 120px; }
.pdlg-body { padding: 4px 20px 18px; overflow-y: auto; }
.popt { display: flex; align-items: center; gap: 4px; padding-right: 8px; border-radius: 8px; cursor: pointer; font-size: var(--text-sm); min-width: 0; }
.popt:hover { background: var(--surface-2); }
.popt .tick:hover { background: none; }
.popt.is-on { background: var(--accent-soft); }
.popt .pname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.popt.is-on .pname { font-weight: 600; }
.std-mark { color: var(--accent); font-size: 12px; }
.pdlg-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 20px; background: var(--surface-2); border-top: 1px solid var(--border); }
.pdlg-sum { margin-right: auto; font-size: var(--text-xs); color: var(--text-3); font-variant-numeric: tabular-nums; }
.pdlg-sum.is-warn { color: var(--warning); font-weight: 600; }

@media (max-width: 860px) {
  .dgroups { grid-template-columns: 1fr; }
  .total-search { margin-left: 0; width: 100%; }
  .mstat-help { margin-left: 0; width: 100%; border-top: 1px solid var(--border); }
  .model-head { flex-direction: column; }
}
@media (max-width: 560px) {
  .stepper li small { display: none; }
  .stepper li { padding: 10px 12px; gap: 8px; }
  .mstat { min-width: 50%; border-bottom: 1px solid var(--border); padding: 10px 14px; }
  .mstat:nth-child(2n) { border-right: 0; }
  .mstat strong { font-size: 1.125rem; }
  .pdlg-list { grid-template-columns: 1fr; }
  .pdlg-tools { flex-wrap: wrap; }
  .pdlg-tools .input-wrap { flex-basis: 100%; }
  .proctable .c-proc { min-width: 150px; }
  .proctable .pcode { display: block; min-width: 0; }
  .tcell { width: 62px; }
  .model-actions { width: 100%; }
  .confirm-switch { flex: 1; }
  .model-form-body { padding: 18px; }
}

/* ================= Продукти ================= */
.link-quiet { color: var(--text-2); font-weight: 550; text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
.link-quiet:hover { color: var(--accent); text-decoration-color: currentColor; }
.text-danger { color: var(--danger); }
.badge-link { text-decoration: none; transition: background .15s, color .15s; }
.badge-link:hover { background: var(--accent-soft); color: var(--accent); }
.mtable .c-act { width: 1%; white-space: nowrap; text-align: right; padding-right: 12px; }
.add-product { gap: 4px; }
select.input.select { appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; height: 44px; font-weight: 550; }

/* Код с префикс от модела */
.code-group { display: flex; align-items: stretch; border: 1.5px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); overflow: hidden; transition: border-color .15s, box-shadow .15s; position: relative; }
.code-group:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.code-group.is-ok { border-color: var(--success); }
.code-group.is-ok:focus-within { box-shadow: 0 0 0 3px var(--success-soft); }
.code-group.is-bad { border-color: var(--danger); }
.code-group.is-bad:focus-within { box-shadow: 0 0 0 3px var(--danger-soft); }
.code-prefix { display: flex; align-items: center; padding: 0 2px 0 14px; font-size: 1.125rem; font-weight: 650; color: var(--text-2); background: var(--surface-2); white-space: nowrap; letter-spacing: -.01em; user-select: none; border-right: 1px dashed var(--border); padding-right: 10px; }
.code-group .input { border: 0; box-shadow: none !important; background: transparent; flex: 1; min-width: 0; padding-left: 10px; padding-right: 40px; }
.code-group .input:disabled { cursor: not-allowed; }
.code-state { position: absolute; right: 12px; top: 50%; width: 20px; height: 20px; margin-top: -10px; border-radius: 50%; display: none; }
.code-group.is-ok .code-state { display: block; background: var(--success) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center no-repeat; animation: pop .2s var(--ease); }
.code-group.is-bad .code-state { display: block; background: var(--danger) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round'%3E%3Cpath d='M18 6 6 18M6 6l12 12'/%3E%3C/svg%3E") center no-repeat; }
.code-group.is-checking .code-state { display: block; border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: spin .7s linear infinite; }
.code-msg { margin-top: 7px; font-size: var(--text-xs); color: var(--text-3); min-height: 1.2em; }
.code-msg.is-ok { color: var(--success); font-weight: 600; }
.code-msg.is-bad { color: var(--danger); font-weight: 600; }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; transform: none; }

.model-summary { display: grid; grid-template-columns: repeat(4, 1fr); margin: -8px 0 22px; padding: 12px 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.model-summary div { padding: 0 14px; border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.model-summary div:last-child { border-right: 0; }
.model-summary span { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); }
.model-summary strong { font-size: var(--text-base); font-weight: 650; font-variant-numeric: tabular-nums; }

/* Основни данни на продукт */
.pfields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 32px; padding: 10px 20px; margin-bottom: 14px; }
.pf-row { display: grid; grid-template-columns: 130px 1fr; align-items: center; gap: 10px; min-height: 42px; border-bottom: 1px solid var(--border); }
.pf-col .pf-row:last-child { border-bottom: 0; }
.pf-label { font-size: var(--text-xs); font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .03em; }
.pf-static { padding: 0 9px; font-size: var(--text-sm); }
.pf-static.strong { font-weight: 650; }
.pf-input { width: 100%; }
.pf-input:disabled { color: var(--text); }

/* Таблици детайли на продукт */
.pgroups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.pgroup { min-width: 0; }
.pgroup .dgroup-head { border-bottom: 1px solid var(--border); padding-bottom: 12px; }
.pdtable th, .pdtable td { padding-top: 4px; padding-bottom: 4px; }
.pdtable th { padding-top: 8px; padding-bottom: 8px; }
.pdtable .c-dname { font-weight: 600; font-size: var(--text-sm); white-space: nowrap; width: 1%; padding-right: 6px; }
.pdtable .c-color { width: 100%; min-width: 140px; }
.pdtable .c-color .cell { width: 100%; }
.pdtable .c-qty, .pdtable .c-knife, .pdtable .c-unit, .pdtable .c-x { width: 1%; white-space: nowrap; }
.pdtable .c-qty .cell { width: 56px; text-align: right; }
.pdtable .c-knife .cell { width: 70px; }
.pdtable .c-unit .cell-select { width: 86px; }
.pdtable .c-x { padding-left: 2px; padding-right: 8px; }
.pdtable tr.is-removing { opacity: .4; }
.pdtable tbody tr { cursor: default; }
.cell:disabled { color: var(--text); background: transparent; border-color: transparent; }

@media (max-width: 1100px) { .pgroups { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .pfields { grid-template-columns: 1fr; }
  .pf-col + .pf-col { border-top: 1px solid var(--border); }
}
@media (max-width: 560px) {
  .model-summary { grid-template-columns: 1fr 1fr; gap: 10px 0; }
  .model-summary div:nth-child(2) { border-right: 0; }
  .pf-row { grid-template-columns: 104px 1fr; }
  .pfields { padding: 6px 12px; }
  .code-prefix { font-size: 1rem; padding-left: 10px; }
}
.pgroup .table-wrap { overflow-x: auto; max-width: 100%; }
@media (max-width: 560px) {
  .pdtable .c-color { min-width: 96px; }
  .pdtable .c-dname { white-space: normal; min-width: 80px; }
  .pdtable .c-qty .cell { width: 44px; }
  .pdtable .c-knife .cell { width: 56px; }
  .pdtable .c-unit .cell-select { width: 72px; }
}

/* ---------- Продукт: материал и разход (етап B1) ---------- */
.pdtable .c-mat { width: 100%; min-width: 160px; }
.pdtable .c-mat .cell { width: 100%; text-overflow: ellipsis; }
.pdtable .c-mat .cell.is-warn { color: var(--danger); }
.pdtable .c-cons { width: 1%; white-space: nowrap; }
.pdtable .cons-cell { display: inline-flex; align-items: center; gap: 4px; }
.pdtable .c-cons .cell { width: 92px; text-align: right; }
.pdtable .c-cons .cell::placeholder { font-size: var(--text-xs); }
.pdtable .cons-unit { min-width: 24px; font-size: var(--text-xs); color: var(--text-3); }
.pmat-summary { margin-top: 14px; }
.pmat-summary .dgroup-head { border-bottom: 1px solid var(--border); padding-bottom: 12px; }
.pmtable .c-num { text-align: right; white-space: nowrap; width: 1%; }
.pmat-help { font-size: var(--text-xs); margin: 10px 0 0; }
.pm-state { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: var(--text-xs); font-weight: 600; white-space: nowrap; }
.pm-state.is-ok { background: var(--success-soft); color: var(--success); }
.pm-state.is-warn { background: var(--warning-soft); color: var(--warning); }
.pm-state.is-bad { background: var(--danger-soft); color: var(--danger); }
.pm-tag { display: inline-block; padding: 0 6px; border-radius: 4px; font-size: var(--text-xs); background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap; }
@media (max-width: 560px) {
  .pdtable .c-mat { min-width: 120px; }
  .pdtable .c-cons .cell { width: 64px; }
}
/* Каталог „Детайли“: колоната „Нож“ е заменена от „Разход“ в продукта; данните и API остават */
.dtable .c-knife { display: none !important; }

/* ---------- Процеси - контрола ---------- */
/* Процеси - проценти: промените се записват след преглед. */
.percent-actions { display: flex; gap: 8px; }
.percent-state, .percent-range { font-size: var(--text-sm); color: var(--text-2); }
.percent-state.is-error { color: var(--danger); }
.percent-range { margin-left: auto; white-space: nowrap; }
.percent-table { min-width: 600px; }
.percent-table th:first-child { width: 40%; }
.percent-table tbody th { font-size: var(--text-sm); font-weight: 600; color: var(--text); text-transform: none; letter-spacing: normal; }
.percent-order { display: inline-block; width: 28px; color: var(--text-2); font-weight: 400; }
.percent-cell { display: flex; align-items: center; gap: 4px; max-width: 120px; }
.percent-cell .cell { width: 88px; height: 44px; text-align: right; }
.percent-cell > span { color: var(--text-2); }
.percent-editing .percent-cell .cell { border-color: var(--border); background: var(--surface); }
.percent-table .percent-dirty { background: var(--accent-soft); }
.percent-note { border-top: 1px solid var(--border); padding: 20px; color: var(--text-2); font-size: var(--text-sm); }
.percent-note strong { color: var(--text); }
.percent-note p { margin: 6px 0 0; line-height: 1.6; max-width: 85ch; }
.percent-changes { padding-left: 20px; margin: 12px 0; max-height: 35vh; overflow-y: auto; }
.percent-changes li { margin-bottom: 8px; }
@media (max-width: 640px) {
  .percent-range { margin-left: 0; }
  .percent-table { min-width: 550px; }
}
.pctable .c-id { width: 64px; color: var(--text-3); padding-left: 16px; }
.pctable .c-val { width: 130px; }
.pctable .c-val .cell, .pctable .c-val .input { width: 96px; text-align: right; }
.pctable .c-name { min-width: 220px; }
.pctable .c-name .cell, .pctable .c-name .input { width: 100%; max-width: 360px; }
.pctable .c-act { width: 120px; }
.pctable .lk-del:disabled { opacity: .3; cursor: not-allowed; }
.pc-note { display: flex; align-items: center; gap: 8px; margin: 0; padding: 12px 16px; border-top: 1px solid var(--border); color: var(--text-3); font-size: var(--text-sm); }
.pc-note .icon { flex: none; }
@media (max-width: 640px) {
  .pctable .c-id { width: 40px; padding-left: 10px; }
  .pctable .c-val { width: 80px; }
  .pctable .c-val .cell, .pctable .c-val .input { width: 64px; }
  .pctable .c-name { min-width: 160px; }
  .pctable .c-cat { width: 64px; }
}
.permission-roles { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:10px; margin-bottom:22px; }
.permission-role { display:flex; flex-direction:column; gap:6px; padding:17px; color:var(--text); text-decoration:none; border:1px solid var(--border); }
.permission-role strong { font-size:13px; line-height:1.4; }
.permission-role span { font-size:12px; color:var(--text-2); }
.permission-role:hover,.permission-role.is-active { border-color:var(--accent); }
.permission-role.is-active { background:var(--accent-soft); }
.permission-intro { padding:22px 24px 16px; }
.permission-intro h2 { margin:0 0 8px; font-size:18px; }
.permission-intro p { margin:5px 0; color:var(--text-2); font-size:13px; line-height:1.6; }
.permission-matrix { min-width:780px; }
.permission-matrix th:first-child { min-width:215px; max-width:260px; white-space:normal; }
.permission-matrix th:not(:first-child),.permission-matrix td { text-align:center; }
.permission-matrix tbody th { color:var(--text); font-size:13px; font-weight:500; text-transform:none; letter-spacing:normal; }
.permission-matrix .tick { justify-content:center; }
.permission-matrix .permission-select { min-width:115px; font-size:12px; }
.permission-footer { padding:18px 24px 24px; border-top:1px solid var(--border); }
.permission-footer p { max-width:900px; font-size:12px; line-height:1.7; }
.permission-buttons { display:flex; justify-content:flex-end; gap:10px; margin-top:16px; }
body[data-can-delete="0"] :is([data-proc-delete],[data-pc-delete],[data-lk-delete]) { display:none; }
body[data-can-create="0"] :is([data-add-row],.lk-add) { display:none; }
@media(max-width:900px) { .permission-roles { grid-template-columns:repeat(2,minmax(0,1fr)); } }
@media(max-width:480px) { .permission-role { padding:13px; } .permission-intro,.permission-footer { padding:16px; } }
.product-thumb { width:54px; height:54px; min-width:54px; object-fit:contain; border-radius:7px; background:var(--surface-2); border:1px solid var(--border); }
.photo-empty { display:flex; align-items:center; justify-content:center; flex-direction:column; gap:10px; color:var(--text-3); }
.product-thumb.photo-empty > span { display:none; }
.product-photo { display:flex; width:100%; height:auto; aspect-ratio:1; object-fit:contain; background:var(--surface-2); border-radius:var(--radius-sm); border:1px solid var(--border); font-size:12px; }
.pfields.pfields--photo { grid-template-columns:180px minmax(0,1fr) minmax(0,1fr); gap:24px; padding:20px; }
.pfields--photo .pf-row { grid-template-columns:105px minmax(0,1fr); }
.pfields--photo .pf-input { min-width:0; }
.pf-photo { min-width:0; text-align:center; }
.photo-upload-link { display:inline-flex; align-items:center; justify-content:center; gap:7px; background:none; border:0; color:var(--accent); margin-top:12px; padding:6px 0; cursor:pointer; font-size:12px; }
.photo-upload-link:hover { text-decoration:underline; }
.photo-upload-link:focus-visible { outline:2px solid var(--accent); outline-offset:4px; }
.product-photo-dialog { max-width:520px; }
.product-photo-dialog form { display:contents; }
.photo-upload-body { padding:22px; overflow:auto; }
.photo-upload-body input[type=file] { height:auto; padding:12px; max-width:100%; }
.photo-preview { width:100%; max-height:280px; object-fit:contain; margin-top:16px; border-radius:8px; background:var(--surface-2); }
.wc-count { display:inline-flex; align-items:center; justify-content:center; gap:8px; min-width:48px; min-height:36px; padding:5px 9px; border-radius:6px; background:var(--accent-soft); color:var(--accent); font-weight:600; text-decoration:none; }
.wc-count:hover { box-shadow:inset 0 0 0 1px var(--accent); }
.wc-add { color:var(--accent); }
.wc-context { display:flex; gap:15px; align-items:center; margin:-4px 0 18px; font-size:12px; }
.wc-filters { display:flex; gap:12px; flex-wrap:wrap; }
.wc-filters .input-wrap { flex:1; min-width:220px; }
.wc-filters select { width:170px; }
.wc-table { min-width:1040px; }
.wc-table .row-actions { justify-content:flex-start; }
.wc-table .wc-date { margin-top:4px; font-size:12px; }
.wc-row-badges { margin-top:5px; }
.wc-pagination { display:flex; align-items:center; justify-content:flex-end; gap:18px; border-top:1px solid var(--border); padding:16px 22px; font-size:12px; }
.wc-editor { display:grid; grid-template-columns:250px minmax(0,1fr); gap:24px; align-items:start; max-width:1050px; }
.wc-editor:not(:has(aside)) { grid-template-columns:minmax(0,760px); }
.wc-product-summary { padding:20px; display:flex; flex-direction:column; gap:10px; }
.wc-product-summary .product-photo { margin-bottom:8px; }
.wc-product-summary .eyebrow { color:var(--text-3); font-size:11px; text-transform:uppercase; letter-spacing:.06em; }
.wc-product-summary .m-code { font-size:18px; overflow-wrap:anywhere; }
.wc-product-summary p { margin:0; font-size:13px; line-height:1.5; }
.wc-product-summary > .link-quiet { margin-top:10px; font-size:12px; line-height:1.6; }
.wc-form { overflow:hidden; }
.wc-content-caption { font-size:12px; color:var(--text-2); margin:16px 0; line-height:1.6; }
.wc-legacy { display:flex; align-items:center; justify-content:space-between; gap:24px; padding:20px 24px; margin:18px 0; }
.wc-legacy h2 { font-size:16px; margin:0 0 8px; }
.wc-legacy p { font-size:13px; color:var(--text-2); max-width:760px; line-height:1.6; margin:0; }
.wc-legacy form { flex-shrink:0; }
.wc-fields { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px; margin-bottom:28px; }
.wc-fields .field { min-width:0; margin:0; }
.wc-fields .input:disabled { opacity:1; color:var(--text); }
.wc-detail-groups { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); align-items:start; gap:20px; margin-top:28px; }
.wc-group-head { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:18px 20px; border-bottom:1px solid var(--border); }
.wc-group-head h2 { margin:0; font-size:17px; font-weight:600; }
.wc-group-head > span { font-size:12px; color:var(--text-2); }
.wc-group-empty { padding:18px 20px; margin:0; font-size:13px; color:var(--text-2); }
.wc-details-table { min-width:460px; }
.wc-details-table th { color:var(--text-2); }
.wc-details-table td { white-space:normal; overflow-wrap:anywhere; }
.wc-details-table td:nth-child(n+3) { text-align:center; }
.wc-process-group { margin:10px 0; overflow:hidden; }
.wc-print-button { background:#201f1c; color:#fff; border:1px solid #5d5b55; }
.wc-print-button:hover { background:#38362f; color:#fff; }
.wc-process-summary { display:flex; align-items:center; gap:20px; padding:14px 20px; cursor:pointer; list-style:none; }
.wc-process-summary::-webkit-details-marker { display:none; }
.wc-process-summary:hover { background:var(--surface-2); }
.wc-process-summary:focus-visible { outline:2px solid var(--text-2); outline-offset:-3px; }
.wc-process-title { flex:1; min-width:0; font-size:15px; font-weight:600; overflow-wrap:anywhere; }
.wc-process-title small { display:block; margin-top:4px; font-size:12px; font-weight:400; color:var(--text-2); }
.wc-process-metrics { display:flex; gap:28px; text-align:right; }
.wc-process-metrics > span { display:grid; gap:4px; min-width:115px; font-size:14px; }
.wc-process-metrics small { color:var(--text-2); font-size:12px; font-weight:400; }
.wc-process-chevron { display:flex; color:var(--text-2); }
.wc-process-group[open] > summary { border-bottom:1px solid var(--border); }
.wc-process-group[open] .wc-process-chevron { transform:rotate(180deg); }
@media(max-width:600px) {
  .wc-process-summary { display:grid; grid-template-columns:minmax(0,1fr) 18px; gap:12px; padding:14px 16px; }
  .wc-process-metrics { grid-row:2; grid-column:1 / -1; gap:20px; text-align:left; }
  .wc-process-metrics > span { min-width:0; flex:1; }
  .wc-process-chevron { grid-row:1; grid-column:2; }
}
.wc-process-table { min-width:600px; }
.wc-process-table.has-finance { min-width:980px; }
.wc-process-table th,.wc-process-table td { text-align:center; font-weight:400; }
.wc-process-table th { font-size:12px; font-weight:600; color:var(--text-2); }
.wc-process-table th small { font-size:12px; font-weight:400; text-transform:none; }
.wc-process-table th:first-child,.wc-process-table td:first-child { text-align:left; min-width:245px; white-space:normal; }
.wc-process-table .wc-total-time { font-weight:700; }
.wc-percent { display:block; font-size:12px; color:var(--text-2); margin-top:4px; }
.wc-dialog-fields { display:grid; gap:16px; }
.wc-dialog-fields > p,.wc-dialog-fields .field { margin:0; }
.wc-dialog-fields select { width:100%; }
@media(max-width:1000px) { .wc-detail-groups { grid-template-columns:minmax(0,1fr); } }
@media(max-width:700px) { .wc-legacy { flex-direction:column; align-items:flex-start; padding:18px; } }
@media(max-width:480px) { .wc-fields { grid-template-columns:minmax(0,1fr); } }
.wc-quantities { min-width:0; margin:0 0 24px; padding:0; border:0; }
.wc-quantities legend { padding:0; margin-bottom:8px; font-size:17px; font-weight:600; }
.wc-quantities .wc-help { margin:0 0 16px; color:var(--text-2); }
.wc-size-grid { display:grid; grid-template-columns:repeat(8,minmax(0,1fr)); gap:8px; }
.wc-size-cell { display:flex; flex-direction:column; align-items:stretch; gap:8px; min-width:0; text-align:center; font-size:13px; font-variant-numeric:tabular-nums; }
.wc-size-cell > span:first-child { color:var(--text-2); }
.wc-size-cell .input { width:100%; min-width:0; height:44px; padding:8px 4px; text-align:center; font-variant-numeric:tabular-nums; }
.wc-size-cell .input::placeholder { color:var(--text-2); opacity:1; }
.wc-size-cell .input[aria-invalid=true] { border-color:var(--danger); }
.wc-size-value { display:flex; align-items:center; justify-content:center; min-height:44px; border-radius:var(--radius-sm); background:var(--surface-2); }
.wc-size-total .wc-size-value { font-weight:700; }
.wc-table .wc-total-column { text-align:center; }
@media(max-width:1100px) and (min-width:701px), (max-width:480px) {
  .wc-size-grid { grid-template-columns:repeat(4,minmax(0,1fr)); row-gap:16px; }
}
.wc-form-body { padding:24px; }
.wc-form h2,.wc-snapshot h2 { font-size:17px; font-weight:600; margin:0 0 18px; }
.wc-form-body > p { font-size:13px; line-height:1.65; margin-bottom:18px; }
.wc-form-foot { display:flex; gap:10px; justify-content:flex-end; padding:16px 24px; border-top:1px solid var(--border); background:var(--surface-2); }
.tick.wc-test { display:inline-flex; width:auto; height:auto; min-height:32px; align-items:center; gap:9px; margin-top:20px; font-size:13px; }
.wc-context .link-quiet,.wc-product-summary > .link-quiet { display:inline-flex; align-items:center; gap:6px; }
.wc-help { font-size:12px; line-height:1.6; margin:8px 0 0; }
.wc-snapshot { padding:24px; margin-bottom:18px; }
.wc-snapshot dl { margin:0; }
.wc-snapshot dl > div { display:grid; grid-template-columns:110px 1fr; gap:16px; padding:10px 0; border-bottom:1px solid var(--border); font-size:13px; }
.wc-snapshot dt { color:var(--text-3); }
.wc-snapshot dd { margin:0; overflow-wrap:anywhere; }
.wc-snapshot dl > div:last-child { border-bottom:0; }
@media(max-width:1200px) {
  .pfields.pfields--photo { grid-template-columns:180px minmax(0,1fr); }
  .pfields--photo .pf-photo { grid-row:span 2; }
}
@media(max-width:700px) {
  .pfields.pfields--photo { grid-template-columns:minmax(0,1fr); padding:16px; gap:12px; }
  .pfields--photo .pf-photo { grid-row:auto; max-width:240px; width:100%; margin:auto; }
  .wc-editor { grid-template-columns:minmax(0,1fr); gap:16px; }
  .wc-product-summary { display:grid; grid-template-columns:90px minmax(0,1fr); gap:5px 16px; }
  .wc-product-summary .product-photo { grid-row:span 5; margin:0; }
  .wc-product-summary .m-code { font-size:16px; }
  .wc-product-summary > .link-quiet { margin-top:0; }
  .wc-form-body,.wc-snapshot { padding:18px; }
  .wc-form-foot { padding:14px 18px; }
  .wc-filters .input-wrap { min-width:100%; }
  .wc-filters select { flex:1; width:140px; }
  .wc-context { flex-wrap:wrap; }
  .wc-snapshot dl > div { grid-template-columns:80px minmax(0,1fr); }
}

/* Етап B2: норми в работната карта и „Необходими материали“ */
.wc-mat .m-code, .wc-needs .m-code { margin-right: 4px; }
.wc-old { display: block; font-size: var(--text-xs); margin-top: 2px; }
.wc-no-norm { color: var(--warning); font-size: var(--text-xs); font-weight: 600; white-space: nowrap; }
.wc-partial { color: var(--warning); font-weight: 600; margin-left: 2px; }
.wc-over { color: var(--danger, #b42318); font-weight: 600; }
.wc-details-table .num, .wc-needs-table .num { text-align: right; white-space: nowrap; }
.wc-needs { margin-top: var(--space-4, 16px); }
.wc-needs .wc-group-head { align-items: flex-start; gap: 12px; }
.wc-needs-sub, .wc-needs-foot { font-size: var(--text-xs); margin: 4px 0 0; }
.wc-needs-foot { margin-top: 10px; }
.wc-needs-table tr.wc-extra td { background: var(--warning-soft); }
.wc-norms-legacy { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin: 8px 16px 12px; background: var(--warning-soft); color: inherit; }
.wc-norm-info p { margin: 2px 0; }
.wc-needs-foot { padding: 0 20px 16px; }
@media (max-width: 1000px) { .wc-needs-table .wc-c-io { display: none; } }
/* „Необходими материали“ на телефон: всеки материал е карта с етикети, без хоризонтален скрол */
@media (max-width: 640px) {
  .wc-needs .wc-group-head { flex-direction: column; align-items: stretch; }
  .wc-needs .wc-group-head .btn { align-self: flex-start; }
  .wc-needs .table-wrap { overflow: visible; }
  .wc-needs-table, .wc-needs-table tbody, .wc-needs-table tr, .wc-needs-table td { display: block; width: auto; }
  .wc-needs-table thead { display: none; }
  .wc-needs-table tr { padding: 12px 16px; border-top: 1px solid var(--border, #e7e2da); }
  .wc-needs-table td { border: 0; padding: 3px 0; }
  .wc-needs-table td.num { display: block; text-align: right; white-space: normal; overflow: hidden; }
  .wc-needs-table td.num::before { content: attr(data-label); float: left; margin-right: 12px; color: var(--text-muted, #7a746c); font-size: var(--text-xs); line-height: 1.9; text-transform: uppercase; letter-spacing: .04em; }
  .wc-needs-table td.wc-need-mat { padding-bottom: 6px; font-weight: 500; }
  .wc-needs-table td.wc-need-main { font-size: 1.05em; }
  .wc-needs-table .wc-c-io { display: block !important; }
  .wc-needs-foot { padding: 0 16px 16px; }
}

/* Работна карта · таб „Изработка“ и регистър „Отчет на операции“ */
.badge-warn { background: var(--warning-soft); color: var(--warning); }
.wr-table { min-width: 760px; }
.wr-table th, .wr-table td { padding-left: 12px; padding-right: 12px; }
.wr-empty-row { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.wr-table td { vertical-align: top; }
.wr-table th:first-child { width: 30%; }
.wr-table td.wr-empty { vertical-align: middle; }
.wr-table td.wr-emp { white-space: normal; min-width: 170px; overflow-wrap: anywhere; }
.wr-table td:last-child { width: 1%; }
.wr-table tbody td { padding-top: 9px; padding-bottom: 9px; }
.wr-table .wr-num { text-align: right; white-space: nowrap; }
.wr-table td.wr-process { width: 30%; min-width: 220px; white-space: normal; overflow-wrap: anywhere; border-right: 1px solid var(--border); }
.wr-table tr:not(.wr-first) > td { border-top-style: dashed; }
.wr-progress { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 6px; font-size: var(--text-xs); color: var(--text-2); }
.wr-progress .is-done { color: var(--success); font-weight: 600; }
.wr-sub { display: block; margin-top: 3px; font-size: var(--text-xs); color: var(--text-3); white-space: normal; }
.wr-empty { color: var(--text-3); font-size: var(--text-xs); }
.wr-over { color: var(--warning); }
.wr-source { font-size: var(--text-xs); color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.wr-table tr.is-reversed > td:not(.wr-process) { color: var(--text-3); }
.wr-table tr.is-reversed .wr-qty { text-decoration: line-through; }
.wr-table tr.is-reversed .wr-reason { color: var(--text-2); }
.wr-table .row-actions { justify-content: flex-end; flex-wrap: nowrap; }
.wr-pair { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 12px; align-items: end; }
.wr-out { min-height: 40px; display: flex; flex-direction: column; justify-content: center; gap: 2px; font-size: var(--text-sm); overflow-wrap: anywhere; }
.wr-out small { font-size: var(--text-xs); color: var(--text-3); }
.wr-warn { padding: 9px 12px; border-radius: var(--radius-sm); background: var(--warning-soft); color: var(--warning); font-size: var(--text-xs); line-height: 1.45; }
.error-text { color: var(--danger); font-size: var(--text-sm); line-height: 1.45; }
.wr-saved { padding: 9px 12px; border-radius: var(--radius-sm); background: var(--success-soft); color: var(--success); font-size: var(--text-xs); line-height: 1.45; }
.wc-states { margin-bottom: 12px; }
.wc-units { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.wc-units .badge-link.is-active { background: var(--accent); color: var(--accent-text); }
.wc-progress-cell { white-space: nowrap; }
.wc-progress-cell small { display: block; margin-top: 3px; font-size: var(--text-xs); color: var(--text-3); }
.or-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.or-filters .field { margin: 0; min-width: 0; }
.or-filters .field > span { font-size: var(--text-xs); color: var(--text-3); }
.or-filters .input { width: 150px; }
.or-filters .or-short { width: 110px; }
.or-table { min-width: 900px; }
.or-table th, .or-table td { padding-left: 12px; padding-right: 12px; }
.or-table td.or-process { min-width: 170px; }
.or-table .wr-num { text-align: right; white-space: nowrap; }
.or-table tr.is-reversed > td { color: var(--text-3); }
.or-table tr.is-reversed .wr-qty { text-decoration: line-through; }
@media (max-width: 640px) {
  .wr-pair { grid-template-columns: 110px minmax(0, 1fr); }
  .wr-table td.wr-process { min-width: 170px; }
  [data-wr-dialog] .pdlg-foot { flex-wrap: wrap; }
  [data-wr-dialog] .pdlg-foot .btn { flex: 1 1 auto; }
  [data-wr-dialog] .pdlg-foot .btn-primary { flex-basis: 100%; order: -1; }
  .or-filters .field { flex: 1 1 calc(50% - 10px); }
  .or-filters .input, .or-filters .or-short { width: 100%; }
}

/* Отказан достъп от непозната мрежа */
.error-network { min-height:100dvh; padding:24px; }
.error-network > div { max-width:520px; }
.error-network p { margin-bottom:14px; }
.error-actions { display:flex; flex-wrap:wrap; gap:10px; justify-content:center; margin-top:24px; }
.error-actions form { margin:0; }

/* Познати IP адреси */
.kip-current { display:flex; flex-wrap:wrap; align-items:center; gap:10px 14px; margin-bottom:12px; }
.kip-ip { font-variant-numeric:tabular-nums; overflow-wrap:anywhere; }
strong.kip-ip { font-size:var(--text-lg); font-weight:600; }
.kip-none { color:var(--text-2); }
.kip-users { list-style:none; margin:0; padding:0; display:grid; gap:8px; }
.kip-users li { padding:10px 14px; border:1px solid var(--border); border-radius:8px; background:var(--surface); }
.kip-users span { color:var(--text-2); font-size:var(--text-sm); }
.user-net { margin-top:3px; font-size:var(--text-xs); color:var(--text-2); }
@media (min-width: 901px) { .kip td.kip-ip { white-space:nowrap; overflow-wrap:normal; } }
/* Стартирани в момента (S2.2г) */
.os-help { margin: 0; padding: 14px 18px; font-size: var(--text-sm); color: var(--text-2); line-height: 1.5; border-bottom: 1px solid var(--border); }
.os-table { min-width: 860px; }
.os-table td { vertical-align: top; }
.os-table tr.is-stale > td { background: var(--warning-soft); }
.os-procs > div { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 6px; }
.os-procs > div + div { margin-top: 4px; }
.os-procs small { color: var(--text-3); font-size: var(--text-xs); }
.os-age { white-space: nowrap; font-weight: 600; }
.os-act { text-align: right; }
.os-cancel > summary { list-style: none; cursor: pointer; }
.os-cancel > summary::-webkit-details-marker { display: none; }
.os-cancel form { display: flex; flex-direction: column; align-items: stretch; gap: 8px; width: 230px; margin: 8px 0 0 auto; text-align: left; }
.os-cancel .field { margin: 0; }
.os-cancel .field > span { font-size: var(--text-xs); color: var(--text-3); }
@media (max-width: 700px) {
  .os-table { min-width: 0; display: block; }
  .os-table thead { display: none; }
  .os-table tbody { display: block; }
  .os-table tbody tr { display: block; padding: 10px 0; border-bottom: 1px solid var(--border); }
  .os-table tbody tr:last-child { border-bottom: 0; }
  .os-table tbody td { display: block; position: relative; padding: 6px 16px 6px 122px; border: 0; }
  .os-table tbody td[data-label]::before { content: attr(data-label); position: absolute; left: 16px; top: 8px; width: 96px; font-size: var(--text-xs); color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
  .os-table tbody td.os-act { display: block; text-align: left; padding-top: 10px; }
  .os-cancel form { width: 100%; margin: 8px 0 0; }
}

/* ---------- Контролно време: засечено време, история на процеса, регистър на нормовремето ---------- */
.nr-green { color: var(--success); font-weight: 700; }
.tcell.is-study, .table.proctable .tcell.is-study { color: var(--success); font-weight: 700; border-color: color-mix(in srgb, var(--success) 45%, var(--border)); background: var(--success-soft); }
.tcell.is-study:disabled { color: var(--success); background: var(--success-soft); border-color: transparent; -webkit-text-fill-color: var(--success); opacity: 1; }
button.phist { appearance: none; border: 0; background: none; padding: 0; margin: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; border-radius: 4px; }
button.phist:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
button.phist:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* The whole process row opens „История на времето“; locked fields let the click through to the row. */
.table.proctable tbody tr[data-pid] { cursor: pointer; }
.table.proctable tbody tr[data-pid] .tcell:disabled, .table.proctable tbody tr[data-pid] select:disabled { pointer-events: none; }
dialog.phist-dlg { width: min(620px, calc(100vw - 24px)); }
.phist-dlg .pdlg-head p b { font-variant-numeric: tabular-nums; }
.phist-body { padding: 4px 20px 16px; min-height: 120px; border-top: 1px solid var(--border); }
.phist-wait { padding: 26px 0; text-align: center; color: var(--text-3); font-size: var(--text-sm); }
.phist-list { list-style: none; margin: 0; padding: 0; }
.phist-list li { display: grid; grid-template-columns: 118px minmax(0, 1fr); gap: 14px; padding: 12px 0 12px 14px; border-bottom: 1px solid var(--border); position: relative; }
.phist-list li:last-child { border-bottom: 0; }
.phist-list li::before { content: ''; position: absolute; left: 0; top: 18px; width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); }
.phist-list li.is-study::before { background: var(--success); }
.phist-list li.is-loose::before { background: transparent; box-shadow: inset 0 0 0 2px var(--success); }
.phist-list li.is-manual::before { background: var(--accent); }
.phist-list time { font-size: var(--text-xs); color: var(--text-3); font-variant-numeric: tabular-nums; padding-top: 2px; white-space: nowrap; }
.phist-list strong { display: block; font-size: var(--text-sm); font-weight: 600; }
.phist-list li.is-study strong { color: var(--success); }
.phist-list span, .phist-list small { display: block; margin-top: 3px; font-size: var(--text-xs); color: var(--text-2); line-height: 1.45; }
.phist-list small { color: var(--text-3); }
.nr-bar { justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.nr-legend { font-size: var(--text-xs); color: var(--text-3); }
.nr-table { min-width: 1040px; }
.nr-table td { vertical-align: top; }
.nr-table .nr-date { white-space: nowrap; }
.nr-table .nr-where { min-width: 150px; }
.nr-table .nr-where .wr-sub { overflow-wrap: anywhere; }
.nr-source { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: var(--text-xs); font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.nr-source.nr-study { background: var(--success-soft); color: var(--success); border-color: transparent; }
.nr-source.nr-loose { color: var(--success); }
.nr-less { color: var(--success); font-weight: 600; }
.nr-more { color: var(--danger); font-weight: 600; }
@media (max-width: 640px) {
  .phist-list li { grid-template-columns: 1fr; gap: 2px; }
}
