﻿/* =====================================================================
   THEME VARIABLES
   ===================================================================== */

:root {
  --sidebar-collapsed-width: 56px;
  --sidebar-expanded-width: 260px;

  --bg: #fff2e1;                 /* ivory */
  --panel: #fff8ed;              /* чуть светлее, чтобы карточки читались */
  --text: #2b2620;               /* тёплый тёмный текст */
  --muted: #8a7f70;
  --line: #d2c3af;

  /* основной акцент (усилен, а не чистый donkey brown) */
  --accent: #7a644f;
  --accent-hover: #6a5644;
  --accent-text: #ffffff;

  --danger-bg: #fbe4e6;
  --danger-text: #9b3a3a;
  --ok-bg: #e8f5ef;
  --ok-text: #2f7a5a;
  --warn-text: #7a4f10;

  --panel-border: #d8cbb7;
  --table-head-bg: #fffaf2;
  --table-head-line: #e2d6c5;
  --row-hover: #f6ecdc;
  --add-row-bg: #fdf7ee;

  --field-bg: #fffaf2;
  --field-focus-border: #a89276;
  --field-focus-ring: rgba(142, 119, 92, 0.18);

  --nav-hover: rgba(142, 119, 92, 0.10);

  --btn-hover: #8e775c;
  --btn-alt: #a79277;            /* твой donkey brown как вторичный */
  --btn-alt-hover: #8e775c;

  --open-row-bg: #f2e6d6;
  --edit-row-bg: #fdf7ee;
  --soft-accent-bg: #f3e8d9;
  --inner-panel-border: #e0d4c2;
  --schedule-holiday-bg: #ead8c1;
  --schedule-holiday-text: #7a4b25;
  --schedule-holiday-border: #c79a63;

  --shadow-sm: 0 1px 2px rgba(60, 40, 20, 0.08);

  /* статусы — слегка теплее под палитру */
  --status-green-bg: rgba(82, 148, 112, 0.18);
  --status-green-text: #3c7d5d;
  --status-green-border: rgba(82, 148, 112, 0.35);

  --status-yellow-bg: rgba(176, 138, 74, 0.22);
  --status-yellow-text: #8a6a2f;
  --status-yellow-border: rgba(176, 138, 74, 0.40);

  --status-red-bg: rgba(176, 92, 107, 0.20);
  --status-red-text: #9b4a5a;
  --status-red-border: rgba(176, 92, 107, 0.35);

  /* режимы */
  --mode-bw-bg: rgba(167, 146, 119, 0.12);
  --mode-bw-text: #7d6f5c;
  --mode-bw-border: rgba(167, 146, 119, 0.22);

  --mode-color-bg: rgba(142, 119, 92, 0.16);
  --mode-color-text: #8e775c;
  --mode-color-border: rgba(142, 119, 92, 0.28);

  --danger-subtle-bg: rgba(176, 80, 80, 0.05);

  --link: var(--accent);
  --link-hover: var(--accent-hover);
}

.theme-dark {
  --bg: #0F172A;
  --panel: #1A2338;
  --text: #DDE9F5;
  --muted: #6B7A8F;
  --line: #2A344A;
  --accent: #5C73D8;
  --accent-hover:  #4F63C0;
  --accent-text: #DDE9F5;
  --danger-bg: #402633;
  --danger-text: #ffd3db;
  --ok-bg: #1d3a32;
  --ok-text: #b9ecd1;
  --warn-text: #e8a74a;

  --panel-border: #2A344A;
  --table-head-bg: #18213A;
  --table-head-line: #2A344A;
  --row-hover: rgba(124, 158, 255, 0.06);
  --add-row-bg: #141842;

  --field-bg: #161E30; 
  --field-focus-border: #9FB3FF;
  --field-focus-ring: rgba(159, 179, 255, 0.18);
  --nav-hover: rgba(124, 158, 255, 0.08);

  --btn-hover: #6B8BEB;
  --btn-alt: #8FA8FF;
  --btn-alt-hover: #7C9EFF;
  --open-row-bg: #24306b;
  --edit-row-bg: #151a44;
  --soft-accent-bg: rgba(124, 158, 255, 0.08);
  --inner-panel-border: #2A344A;
  --schedule-holiday-bg: rgba(182, 110, 130, 0.16);
  --schedule-holiday-text: #ffd3db;
  --schedule-holiday-border: rgba(182, 110, 130, 0.48);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);

  --status-green-bg: rgba(104, 187, 145, 0.18);
  --status-green-text: #b9ecd1;
  --status-green-border: rgba(104, 187, 145, 0.38);

  --status-yellow-bg: rgba(201, 167, 102, 0.20);
  --status-yellow-text: #f0d28f;
  --status-yellow-border: rgba(201, 167, 102, 0.42);

  --status-red-bg: rgba(182, 110, 130, 0.18);
  --status-red-text: #ffd3db;
  --status-red-border: rgba(182, 110, 130, 0.38);

  --mode-bw-bg: rgba(236, 239, 241, 0.10);
  --mode-bw-text: #d8dde2;
  --mode-bw-border: rgba(236, 239, 241, 0.18);

  --mode-color-bg: rgba(143, 162, 255, 0.16);
  --mode-color-text: #c5d1ff;
  --mode-color-border: rgba(143, 162, 255, 0.28);

  --danger-subtle-bg: rgba(220, 100, 110, 0.07);

  --link: var(--accent);
  --link-hover: var(--accent-hover);
}

/* =====================================================================
   BASE / RESET
   ===================================================================== */

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  color: var(--text);
  background: var(--bg);
}

/* Base link colors — low specificity (0,0,1), overridden by all class-based rules */
a { color: var(--link); }
a:hover { color: var(--link-hover); }

/* =====================================================================
   CHECKBOX
   ===================================================================== */

input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  min-width: 16px;
  min-height: 16px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--field-bg);
  display: inline-grid;
  place-content: center;
  cursor: pointer;
  padding: 0;
  transition:
    border-color 0.15s ease,
    background 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.05s ease;
}
input[type="checkbox"]::before {
  content: "";
  width: 9px;
  height: 9px;
  transform: scale(0);
  transition: transform 0.12s ease;
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0, 43% 62%);
  background: white;
}
input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
input[type="checkbox"]:checked::before {
  transform: scale(1);
}
input[type="checkbox"]:hover {
  border-color: var(--accent);
}
input[type="checkbox"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--field-focus-ring);
}



/* =====================================================================
   LAYOUT
   ===================================================================== */

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

body {
  overflow-x: hidden;
}

.app-shell {
  min-height: 100vh;
}

.user-sidebar {
  position: fixed;
  z-index: 300;
  inset: 0 auto 0 0;
  width: var(--sidebar-collapsed-width);
  overflow: hidden;
  border-right: 0;
  box-shadow: none;
  background: var(--panel);
  transition: width 0.2s ease;
}

.app-shell.sidebar-open .user-sidebar {
  width: var(--sidebar-expanded-width);
}

.app-main {
  min-width: 0;
  margin-left: 0;
  transition: margin-left 0.2s ease;
}

.app-shell.has-sidebar .app-main {
  margin-left: var(--sidebar-collapsed-width);
}

.app-shell.has-sidebar.sidebar-open .app-main {
  margin-left: var(--sidebar-expanded-width);
}

.user-sidebar-header {
  display: flex;
  align-items: center;
  height: 64px;
  padding: 12px 8px;
  border-bottom: 1px solid var(--line);
}

.user-sidebar-title {
  width: 0;
  overflow: hidden;
  color: var(--text);
  font-weight: 700;
  opacity: 0;
  white-space: nowrap;
  transition: width 0.2s ease, opacity 0.15s ease;
}

.app-shell.sidebar-open .user-sidebar-title {
  width: auto;
  opacity: 1;
}

.user-sidebar-content {
  min-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
}

.user-sidebar-nav {
  display: grid;
  gap: 4px;
  padding: 12px 8px;
}

.sidebar-nav-link {
  box-sizing: border-box;
  display: grid;
  grid-template-columns: 40px 0;
  align-items: center;
  gap: 0;
  width: 100%;
  height: 40px;
  min-height: 40px;
  padding: 0;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.sidebar-nav-link:hover {
  background: var(--row-hover);
  color: var(--text);
}

.sidebar-nav-link.is-active {
  border-color: var(--line);
  background: var(--soft-accent-bg);
  color: var(--accent);
}

.sidebar-nav-icon {
  display: block;
  width: 22px;
  height: 22px;
  object-fit: contain;
  justify-self: center;
  align-self: center;
}

.sidebar-nav-label {
  min-width: 0;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.15s ease, visibility 0.15s ease;
}

.app-shell.sidebar-open .sidebar-nav-link {
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 10px;
  padding: 0;
}

.app-shell.sidebar-open .sidebar-nav-label {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.user-sidebar-account {
  position: relative;
  margin-top: auto;
  padding: 8px;
  display: block;
}

.user-sidebar-account-trigger {
  box-sizing: border-box;
  display: grid;
  grid-template-columns: 40px 0 0;
  align-items: center;
  gap: 0;
  width: 100%;
  height: 52px;
  min-width: 0;
  margin: 0;
  padding: 6px 0;
  overflow: hidden;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
  transition: background 0.15s ease;
}

.app-shell.sidebar-open .user-sidebar-account-trigger {
  grid-template-columns: 40px minmax(0, 1fr) 16px;
  gap: 12px;
  padding: 6px 0;
}
.user-sidebar-account-trigger:hover {
  background: var(--row-hover);
}
.user-sidebar-account-info,
.user-sidebar-account-chevron {
  min-width: 0;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease, visibility 0.12s ease;
}

.app-shell.sidebar-open .user-sidebar-account-info,
.app-shell.sidebar-open .user-sidebar-account-chevron {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.user-sidebar-account-info strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-sidebar-avatar {
  display: inline-grid;
  width: 40px;
  min-width: 40px;
  height: 40px;
  min-height: 40px;
  margin: 0;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--soft-accent-bg);
  color: var(--accent);
  font-weight: 700;
}

.user-sidebar-role {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78em;
  line-height: 1.15;
}

.user-sidebar-account-chevron {
  align-self: center;
  justify-self: center;
  width: 8px;
  height: 8px;
  border-right: 1px solid var(--muted);
  border-bottom: 1px solid var(--muted);
  transform: rotate(45deg);
}

.app-shell.sidebar-open .user-sidebar-account-chevron {
  transform: rotate(45deg);
}

.user-sidebar-popover {
  position: fixed;
  z-index: 500;
  left: 8px;
  bottom: 72px;
  width: calc(var(--sidebar-expanded-width) - 16px);
  padding: 10px;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: var(--field-bg);
  box-shadow: var(--shadow-sm);
}

.user-sidebar-popover[hidden] {
  display: none;
}

.user-sidebar-popover-identity {
  display: grid;
  gap: 2px;
  padding: 2px 4px 8px;
}

.user-sidebar-popover-divider {
  height: 1px;
  margin: 0 0 6px;
  background: var(--line);
}

.user-sidebar-logout-form {
  margin: 0;
}

.user-sidebar-popover-action {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  margin: 0;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--danger-text);
  text-align: left;
}

.user-sidebar-popover-action:hover {
  background: var(--danger-bg);
}

.user-sidebar-popover-action:focus-visible,
.user-sidebar-account-trigger:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--field-focus-ring);
}



.user-sidebar-toggle {
  width: 40px;
  min-width: 40px;
  height: 40px;
  min-height: 40px;
  margin-left: auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--field-bg);
  color: var(--text);
}

.user-sidebar-toggle:hover {
  background: var(--row-hover);
}

.user-sidebar-toggle-icon,
.user-sidebar-toggle-icon::before,
.user-sidebar-toggle-icon::after {
  display: block;
  width: 14px;
  height: 2px;
  margin: 0 auto;
  border-radius: 2px;
  background: var(--text);
  content: "";
  transition: transform 0.2s ease;
}

.user-sidebar-toggle-icon::before {
  transform: translateY(-4px);
}

.user-sidebar-toggle-icon::after {
  transform: translateY(2px);
}

.app-shell.sidebar-open .user-sidebar-toggle-icon {
  background: transparent;
}

.app-shell.sidebar-open .user-sidebar-toggle-icon::before {
  transform: translateY(0) rotate(45deg);
}

.app-shell.sidebar-open .user-sidebar-toggle-icon::after {
  transform: translateY(-2px) rotate(-45deg);
}

/* Saved state is applied in <head>, before the sidebar can paint collapsed. */
html[data-sidebar-state="open"] .app-shell.has-sidebar .user-sidebar {
  width: var(--sidebar-expanded-width);
}

html[data-sidebar-state="open"] .app-shell.has-sidebar .app-main {
  margin-left: var(--sidebar-expanded-width);
}

html[data-sidebar-state="open"] .app-shell .user-sidebar-title {
  width: auto;
  opacity: 1;
}

html[data-sidebar-state="open"] .app-shell .sidebar-nav-link {
  grid-template-columns: 40px minmax(0, 1fr);
  justify-content: start;
  gap: 10px;
  padding: 0 8px;
}

html[data-sidebar-state="open"] .app-shell .sidebar-nav-label,
html[data-sidebar-state="open"] .app-shell .user-sidebar-account-info,
html[data-sidebar-state="open"] .app-shell .user-sidebar-account-chevron {
  opacity: 1;
  visibility: visible;
}

html[data-sidebar-state="open"] .app-shell .user-sidebar-account-trigger {
  padding: 6px 8px;
}

html[data-sidebar-state="open"] .app-shell .user-sidebar-account-chevron {
  transform: rotate(45deg);
}

html[data-sidebar-state="open"] .app-shell .user-sidebar-toggle-icon {
  background: transparent;
}

html[data-sidebar-state="open"] .app-shell .user-sidebar-toggle-icon::before {
  transform: translateY(0) rotate(45deg);
}

html[data-sidebar-state="open"] .app-shell .user-sidebar-toggle-icon::after {
  transform: translateY(-2px) rotate(-45deg);
}

html.sidebar-preload .user-sidebar,
html.sidebar-preload .app-main,
html.sidebar-preload .user-sidebar * {
  transition: none !important;
}

@media (max-width: 720px) {
  .app-shell.has-sidebar .app-main,
  .app-shell.has-sidebar.sidebar-open .app-main {
    margin-left: 0;
  }

  .app-shell.sidebar-open .user-sidebar {
    width: min(var(--sidebar-expanded-width), calc(100vw - 16px));
    box-shadow: var(--shadow-sm);
  }

  html[data-sidebar-state="open"] .app-shell.has-sidebar .app-main {
    margin-left: 0;
  }

  html[data-sidebar-state="open"] .app-shell.has-sidebar .user-sidebar {
    width: min(var(--sidebar-expanded-width), calc(100vw - 16px));
  }
}

.panel-filter h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 10px;
}

/* =====================================================================
   NAVIGATION
   ===================================================================== */

.nav {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  align-items: center;
  min-height: 40px;
}

.nav-spacer {
  flex: 1 1 auto;
}

.nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 12px;
  box-sizing: border-box;
  border: 1px solid transparent;
  border-radius: 10px;
  line-height: 1;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  transition: background 0.15s ease;
  white-space: nowrap;
}

.nav a:hover {
  background: var(--nav-hover);
}

.nav a.active {
  background: var(--accent);
  color: var(--accent-text);
  border-color: transparent;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
}
.nav a.active:hover {
  background: var(--accent-hover); 
}

.nav-user {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  font-weight: 600;
}

.nav-logout-form {
  margin: 0;
}


/* =====================================================================
   THEME TOGGLE
   ===================================================================== */

.theme-toggle-btn {
  width: auto;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  margin-top: 0;
  margin-left: auto;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field-bg, #fff);
  color: var(--text);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.theme-toggle-btn:hover {
  background: var(--table-head-bg, #f8fafc);
}

.theme-switch {
  width: auto;
  min-width: auto;
  height: auto;
  min-height: auto;
  margin-top: 0;
  margin-left: auto;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.theme-switch:hover {
  background: transparent;
}

.theme-switch-track {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr; /* вместо фиксированных 40px */
  align-items: center;
  justify-content: center;

  width: 80px;
  height: 40px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--field-bg, #fff);
  overflow: hidden;
}

.theme-switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 34px;
  height: 32px;
  border-radius: 9px;
  background: var(--accent);
  opacity: 0.16;
  transition: transform 0.22s ease;
  pointer-events: none;
}

.theme-switch.is-dark .theme-switch-thumb {
  transform: translateX(38px);
}

.theme-switch-option {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 32px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  user-select: none;
  transition: color 0.22s ease;
}

.theme-switch:not(.is-dark) .theme-switch-option-sun {
  color: var(--text);
}

.theme-switch.is-dark .theme-switch-option-moon {
  color: var(--text);
}

/* =====================================================================
   PANELS & FLASH
   ===================================================================== */

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

/* =====================================================================
   TABLES
   ===================================================================== */

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.table th, .table td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  vertical-align: top;
}
.table th {
  background: var(--table-head-bg);
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 1;
  border-bottom: 2px solid var(--table-head-line);
  font-size: 13px;
  letter-spacing: 0.01em;
}

.table td {
  line-height: 1.4;
  word-break: break-word;
  padding: 14px 10px;
}

.form-grid > div:last-child {
  display: flex;
  align-items: end;
}

.cartridges-table tbody tr.data-row td,
.printers-table tbody tr.data-row td,
.users-table tbody tr.data-row td,
.moves-table tbody tr.data-row:hover td {
  transition: background-color 0.15s ease;
}
.cartridges-table tbody tr.data-row:hover td,
.printers-table tbody tr.data-row:hover td,
.users-table tbody tr.data-row:hover td,
.moves-table tbody tr.data-row:hover td {
  background: var(--row-hover);
}
.cartridges-table tbody tr.data-row:hover,
.printers-table tbody tr.data-row:hover,
.users-table tbody tr.data-row:hover,
.moves-table tbody tr.data-row:hover{
  cursor: pointer;
}

.moves-table tbody tr.data-row.is-reverted td {
  color: var(--muted);
  opacity: 0.72;
}

.moves-table tbody tr.data-row.is-reverted .move-main-values {
  text-decoration: line-through;
}

.moves-table tbody tr.data-row.is-revert-entry td:first-child {
  position: relative;
}

.moves-table tbody tr.data-row.is-revert-entry .move-comment-cell {
  padding-left: 8px;
}

.move-comment-cell {
  display: grid;
  gap: 4px;
}

.move-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: fit-content;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--field-bg);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.move-status-badge.is-reverted {
  color: var(--muted);
  border-color: var(--line);
}

.move-status-badge.is-revert {
  border-color: var(--table-head-line);
  background: var(--table-head-bg);
}

.move-comment-meta {
  color: var(--muted);
  font-size: 12px;
}

.move-revert-form {
  margin: 0;
}

.move-revert-btn {
  min-width: 112px;
  margin: 0;
}

.move-revert-form button {
  padding: 2px 8px;
  margin: 0;
}

.codes-table tbody tr.data-row td {
  transition: background-color 0.15s ease;
}

.codes-table tbody tr.data-row:hover td {
  background: var(--row-hover);
}

.codes-table td a {
  color: var(--accent);
}

.codes-select-col {
  width: 94px;
  text-align: center;
}

.codes-select-col input[type="checkbox"] {
  margin: 0 auto;
}

.codes-select-all-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 24px;
  margin: 0;
}

.add-row td {
  background: var(--add-row-bg);
}

.cartridges-table td a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.cartridges-table td a:hover {
  text-decoration: underline;
}

.moves-form-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(180px, 1fr));
  gap: 14px;
  align-items: end;
}

.moves-form-grid button {
  align-self: end;
  width: auto;
  padding: 0 18px;
}

.section-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
}

.shortage {
  background: var(--danger-bg);
  color: var(--danger-text);
  font-weight: 700;
}
.flash {
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 12px;
  margin-top: 10px;
}
.flash.ok {
  background: var(--ok-bg);
  color: var(--ok-text);
}
.flash.error {
  background: var(--danger-bg);
  color: var(--danger-text);
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(240px, 1fr));
  gap: 10px;
}

.form-actions {
  grid-column: 4 / 6;   /* кнопка в конце строки */
  display: flex;
  justify-content: flex-end;
  align-items: end;
}

.form-grid button {
  align-self: end;
  width: auto;
  padding: 0 18px;
}

/* =====================================================================
   TYPOGRAPHY & FORMS & BUTTONS
   ===================================================================== */

h1, h2, h3 {
  margin-top: 0;
  margin-bottom: 16px;
  letter-spacing: -0.02em;
}

h1 {
  font-size: 25px;
}

h2 {
  font-size: 20px;
}

label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 4px;
}
input, select, textarea, button {
  width: 100%;
  min-height: 40px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  line-height: 1.35;
  background: var(--field-bg);
  color: var(--text);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--field-focus-border);
  box-shadow: 0 0 0 3px var(--field-focus-ring);
}

select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 36px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% - 3px),
                       calc(100% - 12px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

button {
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  cursor: pointer;
  margin-top: 0;
  font-weight: 600;
  transition: background 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset;
}

button:hover {
  background: var(--btn-hover);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.07) inset;
}

button:active {
  transform: translateY(1px);
}
.inline-add-form {
  margin: 0;
  margin-bottom: 16px;
}
.inline-add-row {
  display: grid;
  grid-template-columns: 1fr 1fr 140px;
  gap: 10px;
  align-items: end;
}
.inline-add-row-wide {
  grid-template-columns: 1.4fr 1.4fr 1.2fr 140px;
}
.inline-add-row button {
  margin-top: 0;
}
.cartridge-op-form {
  margin: 0;
}
.cartridge-op-grid {
  display: grid;
  grid-template-columns: 120px 64px 140px 52px;
  gap: 8px;
  align-items: center;
}
.cartridge-op-grid button {
  min-width: 61px;
  height: 40px;
  margin: 0;
  padding: 0 10px;
  font-size: 14px;
  background: var(--btn-alt);
}

.cartridge-op-grid button:hover {
  background: var(--btn-alt-hover);
}

.cartridges-table th:nth-child(7),
.cartridges-table td:nth-child(7) {
  width: 390px;
}

.small {
  color: var(--muted);
  font-size: 12px;
}

.excel-filters {
  margin-top: 8px;
}

.panel-filter {
  padding: 14px 16px;
}

.panel-title-sm {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 700;
}

.excel-filters-toolbar {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  justify-content: flex-end;
}

.excel-filters-toolbar button,
.excel-filters-toolbar .reset-btn {
  width: auto;
  min-width: 120px;
  height: 36px;
  margin: 0;
  padding: 0 16px;
}

.excel-filters-toolbar button {
  margin-top: 0;
}

.excel-filters-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 8px 12px;
  align-items: end;
}
.excel-filters label {
  margin-bottom: 4px;
  font-size: 12px;
}
.excel-filters select,
.excel-filters button,
.excel-filters .reset-btn {
  min-height: 36px;
  height: 36px;
  padding: 8px 10px;
  font-size: 14px;
}
.excel-filters-actions {
  display: flex;
  align-items: end;
}
.excel-filters-actions button {
  margin-top: 0;
}
.reset-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 40px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  background: var(--field-bg);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.reset-btn:hover {
  background: var(--table-head-bg);
  border-color: var(--table-head-line);
}
.sort-link {
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
}
.sort-link:hover {
  color: var(--accent);
}
.printers-table tbody tr.printer-row.is-open td {
  background: var(--open-row-bg);
}
.printers-table tbody tr.edit-row td {
  background: var(--edit-row-bg);
  border-top: 0;
  padding: 14px;
}
.inline-printer-form {
  margin: 0;
}
.inline-printer-grid {
  display: grid;
  grid-template-columns:
    minmax(0, 0.7fr)   /* Бренд */
    minmax(0, 0.8fr)   /* Модель */
    minmax(0, 0.5fr)   /* Цвет */
    minmax(0, 0.8fr)   /* Город */
    minmax(0, 1.1fr)   /* Место */
    minmax(140px, 0.7fr); /* Статус */
  gap: 10px;
  width: 100%;
  min-width: 0;
}

.printers-table tbody tr.edit-row td {
  overflow: hidden;
}
.inline-printer-inventory {
  grid-column: 1 / 3;
  min-width: 0;
  align-self: start;
}
.inline-printer-comment {
  grid-column: 3 / 6;
  min-width: 0;
  align-self: start;
}
.inline-printer-actions {
  grid-column: 6 / 7;
  display: flex;
  justify-content: flex-end;
  align-items: start;
}
.inline-printer-actions button {
  width: 100%;
  min-width: 120px;
  margin-top: 24px;
}
.cartridges-table tbody tr.cartridge-row.is-open td {
  background: var(--soft-accent-bg);
}
.cartridges-table tbody tr.cartridge-row.is-archived td {
  opacity: 0.5;
}
.cartridges-table tbody tr.cartridge-row.is-archived td:first-child a {
  color: var(--muted);
}
.cartridges-table tbody tr.cartridge-edit-row td {
  background: var(--panel);
  border-top: 0;
  padding: 10px 14px 10px;
}
.inline-cartridge-section {
  display: grid;
  gap: 20px;
  align-items: start;
  width: 100%;
  margin-left: 20px;
  transition: max-width 0.25s ease, grid-template-columns 0.25s ease;
}
.inline-cartridge-section.compat-open {
  max-width: 1160px;
  grid-template-columns: minmax(0, 700px) 420px;
} 
.inline-cartridge-main {
  min-width: 0;
  width: 100%;
}
.inline-cartridge-side {
  min-width: 0;
  max-width: 430px;
  overflow: hidden;
  opacity: 0;
  transform: translateX(-20px);
  pointer-events: none;
  transition:
    opacity 0.22s ease,
    transform 0.22s ease;
}
.inline-cartridge-section.compat-open .inline-cartridge-side {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}
.inline-cartridge-form,
.inline-balance-form {
  margin: 0;
}
.inline-cartridge-grid {
  display: grid;
  grid-template-columns: 320px 140px;
  gap: 10px;
  align-items: end;
}

.cartridge-last-move-cell {
  min-width: 220px;
  line-height: 1.35;
}

.cartridge-last-move-cell .small {
  display: block;
  margin-top: 2px;
}
.inline-balance-grid {
  display: grid;
  grid-template-columns: 160px 60px 240px 120px;
  gap: 10px;
  align-items: end;
  margin-top: 10px;
}
.inline-cartridge-actions {
  display: flex;
  justify-content: flex-end;
  align-items: end;
}
.inline-cartridge-actions button {
  margin-top: 0;
  width: 100%;
  min-width: 120px;
}
/* =====================================================================
   FILTERS & SEARCH
   ===================================================================== */

.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.filter-toggle-btn {
  width: auto;
  min-width: 110px;
  margin: 0;
  padding: 0 16px;
}

.filter-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--soft-accent-bg);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.filters-panel {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transform: translateY(-8px);

  padding-top: 0;
  padding-bottom: 0;
  margin-bottom: 0;
  border-width: 0;

  transition:
    max-height 0.35s ease,
    opacity 0.25s ease,
    transform 0.25s ease,
    padding 0.25s ease,
    margin 0.25s ease,
    border-width 0.25s ease;
}

.filters-panel.is-open {
  max-height: 500px;
  opacity: 1;
  transform: translateY(0);

  padding-top: 14px;
  padding-bottom: 14px;
  margin-bottom: 16px;
  border-width: 1px;
}

.filter-fab {
  width: 40px;
  min-width: 40px;
  height: 40px;
  min-height: 40px;
  margin: 0;
  padding: 0;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
}

.table-section {
  position: relative;
}

.table-panel {
  margin-bottom: 0;
  
}
#addPanel.is-open {
  max-height: 900px;
}

#filtersPanel.is-open {
  max-height: 500px;
}

.table-toolbar-left {
  display: flex;
  gap: 8px;
  align-items: center;
}

.table-search {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 280px;
  max-width: 360px;
  flex: 1 1 320px;
}

.table-search-input {
  width: 100%;
  padding-right: 44px;
}

.table-search-clear {
  position: absolute;
  top: 50%;
  right: 6px;
  width: 30px;
  min-width: 30px;
  height: 30px;
  min-height: 30px;
  margin: 0;
  padding: 0;
  transform: translateY(-50%);
  border-radius: 8px;
  font-size: 18px;
  line-height: 1;
}

.table-search-clear[hidden] {
  display: none;
}

.table-toolbar {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin-bottom: 12px;
}

/* =====================================================================
   PAGINATION
   ===================================================================== */

.pagination-summary {
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.pagination-link,
.pagination-gap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
}

.pagination-link {
  border: 1px solid var(--line);
  background: var(--field-bg);
  color: var(--text);
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.pagination-link:hover {
  background: var(--table-head-bg);
  border-color: var(--table-head-line);
}

.pagination-link.is-current {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.pagination-link.is-disabled {
  color: var(--muted);
  background: var(--panel);
  cursor: default;
  pointer-events: none;
}

.pagination-gap {
  color: var(--muted);
}

.universal-move-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.universal-move-form .form-actions {
  grid-column: 4 / 5;
  justify-content: flex-end;
}

.universal-move-form .form-actions button {
  margin-top: 0;
  width: auto;
  min-width: 140px;
}

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.auth-shell {
  max-width: 560px;
  margin: 64px auto 0;
}

.auth-panel {
  margin-bottom: 0;
}

.auth-form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.universal-move-form input[name="qty"] {
  width: 80px;
  justify-self: start;
}.move-scenarios {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.scenario-tab {
  width: auto;
  min-height: 36px;
  padding: 8px 12px;
  margin-top: 0;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--field-bg);
  color: var(--text);
  cursor: pointer;
}
.scenario-tab.active {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
}
.scenario-panel {
  display: none;
}
.scenario-panel.active {
  display: block;
}
.scenario-form-grid {
  display: grid;
  grid-template-columns: 160px minmax(220px, 1fr) 160px minmax(220px, 1fr);
  gap: 12px;
  align-items: end;
}

.scenario-checkbox-row {
  grid-column: 1 / -1;
}
.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text);
  margin: 0;
}
.checkbox-label input {
  width: auto;
  min-height: auto;
}

.scenario-subgrid {
  grid-column: 1 / -1;
  display: grid;
  gap: 12px;
}
.scenario-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
}
.scenario-actions button {
  width: auto;
  min-width: 170px;
  margin-top: 12px;
}

.free-move-form {
  display: grid;
  gap: 12px;
}

.free-route-row {
  display: grid;
  grid-template-columns: max-content max-content minmax(260px, 1fr);
  gap: 12px;
  align-items: start;
}

.free-endpoint-group {
  display: grid;
  grid-template-columns: 150px;
  gap: 10px;
  align-items: end;
  width: max-content;
}

.free-endpoint-group.has-place {
  grid-template-columns: 150px 260px;
}

.free-comment-field {
  min-width: 0;
}

.free-move-form select,
.free-move-form input[type="text"],
.free-move-form input[type="number"] {
  width: 100%;
}

.free-move-form .issue-rows {
  grid-column: auto;
}

.free-move-form .scenario-actions {
  grid-column: auto;
}

@media (max-width: 1100px) {
  .free-route-row {
    grid-template-columns: 1fr;
  }
}

#scenario-actions-button {
  margin-top: 0;
}

.place-hint {
  grid-column: 1 / -1;
  font-size: 13px;
  color: var(--muted);
}
.refill-manual-block {
  grid-column: 1 / -1;
}
.refill-source-row {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.refill-source-row > div {
  min-width: 200px;
}
.refill-row {
  display: grid;
  grid-template-columns: 1fr 110px 44px;
  gap: 10px;
  align-items: end;
  margin-bottom: 10px;
}
.refill-row-actions {
  display: flex;
  justify-content: center;
  align-items: end;
}
.refill-row-btn {
  width: 44px;
  min-width: 44px;
  height: 40px;
  min-height: 40px;
  margin: 0;
  padding: 0;
  line-height: 1;
}

.refill-row-btn-add {
  font-size: 20px;
}

.refill-row-btn-remove {
  font-size: 16px;
}

.refill-qty-hint {
  display: block;
  min-height: 14px;
  margin-top: 3px;
  font-size: 12px;
  color: var(--ok-text);
}

.secondary-btn {
  width: auto;
  min-height: 36px;
  margin-top: 0;
  padding: 8px 12px;
  background: var(--field-bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset;
}
.secondary-btn:hover {
  background: var(--table-head-bg);
}

.users-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.users-add-panel {
  margin-bottom: 16px;
}

.users-add-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(220px, 1.2fr) minmax(180px, 0.8fr) auto auto minmax(140px, auto);
  gap: 12px;
  align-items: end;
}

.users-add-grid .form-actions {
  grid-column: auto;
}

.users-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  color: var(--text);
}

.users-checkbox input {
  width: auto;
}

.users-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  font-size: 12px;
  font-weight: 700;
}

.users-badge.is-yes {
  background: var(--ok-bg);
  color: var(--ok-text);
}

.users-badge.is-no {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.users-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.users-row-form {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0;
}

.users-row-form input[type="password"] {
  width: 140px;
  margin: 0;
}

.users-delete-form {
  margin: 0;
}

/* =====================================================================
   SCHEDULE PAGE
   ===================================================================== */

.schedule-panel {
  overflow: hidden;
  padding: 14px;
}

.schedule-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.schedule-heading {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

.schedule-heading h2 {
  margin-bottom: 0;
}

.schedule-month-nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.schedule-month-nav .reset-btn {
  width: auto;
  min-width: 118px;
  min-height: 34px;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 13px;
}

.schedule-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.schedule-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.schedule-legend-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  min-width: 22px;
  height: 22px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-weight: 700;
  line-height: 1;
}

.schedule-legend-mark--empty {
  background: var(--field-bg);
  color: var(--muted);
}

.schedule-table-wrap {
  width: 100%;
  overflow-x: visible;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.schedule-table {
  width: 100%;
  table-layout: fixed;
  border-spacing: 0;
}

.schedule-user-col-width {
  width: 170px;
}

.schedule-day-col-width {
  width: 29px;
}

.schedule-total-col-width {
  width: 48px;
}

.schedule-table th,
.schedule-table td {
  padding: 3px 2px;
  text-align: center;
  vertical-align: middle;
  height: 32px;
}

.schedule-table .schedule-user-col {
  position: sticky;
  left: 0;
  z-index: 2;
  text-align: left;
  background: var(--panel);
}

.schedule-table thead .schedule-user-col {
  z-index: 4;
  background: var(--table-head-bg);
}

.schedule-day {
  position: relative;
  width: 29px;
  font-size: 11px;
}

.schedule-day span,
.schedule-day small {
  display: block;
  line-height: 1.15;
}

.schedule-day small {
  color: var(--muted);
  font-size: 10px;
}

.schedule-day--weekend {
  background: color-mix(in srgb, var(--soft-accent-bg) 58%, transparent);
}

.schedule-day--holiday {
  background: var(--schedule-holiday-bg);
  color: var(--schedule-holiday-text);
  box-shadow: inset 0 2px 0 var(--schedule-holiday-border);
}

.schedule-table td.schedule-day--holiday {
  box-shadow: inset 1px 0 0 var(--schedule-holiday-border), inset -1px 0 0 var(--schedule-holiday-border);
}

.schedule-day--today {
  background: color-mix(in srgb, var(--soft-accent-bg) 72%, transparent);
}

.schedule-table th.schedule-day--today::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 3px;
  width: 14px;
  height: 2px;
  border-radius: 999px;
  background: var(--accent);
  transform: translateX(-50%);
}

.schedule-cell {
  width: 24px;
  min-width: 24px;
  height: 24px;
  min-height: 24px;
  margin: 0 auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field-bg);
  color: var(--text);
  font-weight: 700;
  font-size: 12px;
  line-height: 1;
  box-shadow: none;
}

.schedule-cell[data-status=""]::before {
  content: "–";
  color: var(--muted);
  font-weight: 600;
}

.schedule-cell:not(.schedule-cell--readonly):hover {
  background: var(--row-hover);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.schedule-cell--work {
  background: var(--ok-bg);
  color: var(--ok-text);
  border-color: var(--ok-text);
}

.schedule-cell--vacation {
  background: var(--danger-bg);
  color: var(--accent);
  border-color: var(--accent);
}

.schedule-cell--readonly {
  cursor: default;
  opacity: 0.7;
}

.schedule-cell--readonly:hover {
  background: var(--field-bg);
  border-color: var(--line);
}

.schedule-cell--dirty {
  box-shadow: 0 0 0 2px var(--field-focus-ring);
}

.schedule-row--readonly .schedule-user-name {
  color: var(--muted);
}

.schedule-user-name {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.schedule-total-col {
  width: 48px;
  font-weight: 700;
}

.schedule-total {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  min-height: 24px;
  border-radius: 999px;
  background: var(--soft-accent-bg);
  color: var(--accent);
  font-size: 12px;
}

.schedule-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}

.schedule-actions {
  display: flex;
  justify-content: flex-end;
}

.schedule-actions button {
  width: auto;
  min-width: 124px;
  min-height: 34px;
  padding: 7px 14px;
  border-radius: 8px;
  margin-top: 0;
}

.schedule-actions button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

@media (max-width: 980px) {
  .schedule-table-wrap {
    overflow-x: auto;
  }

  .schedule-table {
    min-width: 880px;
  }

  .schedule-header,
  .schedule-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .schedule-month-nav {
    justify-content: flex-start;
  }
}

.issue-rows {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.issue-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px 44px;
  gap: 10px;
  align-items: end;
}

.issue-field {
  min-width: 0;
}

.issue-field input {
  width: 100%;
}

.issue-field-qty input {
  text-align: center;
}

.code-resolve-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
}

.code-resolve-row button {
  width: 44px;
  min-width: 44px;
  height: 40px;
  min-height: 40px;
  margin: 0;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

.code-input {
  min-height: 34px;
  height: 34px;
  padding: 6px 10px;
}

.code-resolve-btn {
  width: auto;
  min-width: 108px;
  min-height: 34px;
  height: 34px;
  margin-top: 0;
  padding: 0 10px;
}

.resolve-msg {
  min-height: 18px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.resolve-msg.is-ok {
  color: var(--ok-text);
}

.resolve-msg.is-error {
  color: var(--danger-text);
}
.resolve-msg.is-warn {
  color: var(--warn-text);
}

/* Compact barcode text input for CartridgeItem scanning */
.js-barcode-input {
  margin-top: 4px;
  padding: 4px 8px;
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field-bg);
  color: var(--text);
  width: 100%;
  box-sizing: border-box;
}
.js-barcode-input::placeholder {
  color: var(--muted);
  font-style: italic;
}
.js-barcode-input:focus {
  outline: none;
  border-color: var(--field-focus-border);
  box-shadow: 0 0 0 3px var(--field-focus-ring);
}

/* ── Batch scan "пачкой" button in tab bar ──────────────────────────────── */
.batch-scan-open-btn {
  align-self: center;
  white-space: nowrap;
}
.batch-scan-count {
  font-weight: 700;
  color: var(--accent);
}

/* ── Batch scan modal ───────────────────────────────────────────────────── */
.batch-scan-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 800;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
}
.batch-scan-modal.is-open {
  display: flex;
}

.batch-scan-dialog {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm), 0 8px 32px rgba(0,0,0,0.18);
  width: 100%;
  max-width: 760px;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
}

.batch-scan-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--panel-border);
  background: var(--table-head-bg);
}
.batch-scan-title-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 1em;
}
.batch-scan-scenario-label {
  color: var(--muted);
  font-size: 0.875em;
}

.batch-scan-body {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.batch-scan-input-area {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.batch-scan-input-label {
  font-size: 0.85em;
  color: var(--muted);
}
.batch-scan-input {
  font-size: 1.05em;
  padding: 8px 12px;
  border: 2px solid var(--accent);
  border-radius: 8px;
  background: var(--field-bg);
  color: var(--text);
  letter-spacing: 0.05em;
}
.batch-scan-input:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--field-focus-ring);
}

.batch-scan-msg {
  min-height: 16px;
  font-size: 0.85em;
  color: var(--muted);
}
.batch-scan-msg.is-ok    { color: var(--ok-text); }
.batch-scan-msg.is-error { color: var(--danger-text); }
.batch-scan-msg.is-warn  { color: var(--warn-text); }

.batch-scan-empty-note {
  margin: 0;
  padding: 8px 0;
}

.batch-scan-table-wrap {
  max-height: 340px;
  overflow-y: auto;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
}
.batch-scan-table-wrap .table {
  margin: 0;
}

.batch-scan-cell-ok   { color: var(--ok-text);       font-size: 0.875em; }
.batch-scan-cell-warn { color: var(--warn-text);      font-size: 0.875em; }

.batch-scan-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--panel-border);
  background: var(--table-head-bg);
}
.batch-scan-footer-right {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

/* =====================================================================
   BARCODE SCANNER MOVE TAB
   ===================================================================== */

.barcode-scanner-panel {
  display: none;
}

.barcode-scanner-panel.active {
  display: block;
}

.barcode-scanner-panel [hidden] {
  display: none !important;
}

.barcode-scanner-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 280px) repeat(3, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.barcode-scanner-field {
  min-width: 0;
}

.barcode-scanner-fixed-dest {
  min-height: 38px;
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field-bg);
  color: var(--muted);
  font-weight: 600;
}

.barcode-scan-input-row {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.barcode-scan-input {
  min-height: 48px;
  font-size: 1.2em;
  border: 2px solid var(--accent);
}

.barcode-scan-input:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--field-focus-ring);
}

.barcode-scan-message {
  min-height: 18px;
  color: var(--muted);
  font-size: 0.9em;
}

.barcode-scan-message.is-ok {
  color: var(--ok-text);
}

.barcode-scan-message.is-warn {
  color: var(--warn-text);
}

.barcode-scan-message.is-error {
  color: var(--danger-text);
}

.barcode-scan-table-wrap {
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  overflow: auto;
  background: var(--panel);
}

.barcode-scan-table {
  margin: 0;
}

.barcode-scan-table th,
.barcode-scan-table td {
  padding: 8px 10px;
  vertical-align: middle;
}

.barcode-scan-status {
  font-size: 0.9em;
  font-weight: 600;
}

.barcode-scan-status.is-ok {
  color: var(--ok-text);
}

.barcode-scan-status.is-warn {
  color: var(--warn-text);
}

.barcode-scan-remove {
  min-width: 36px;
  width: 36px;
  padding-inline: 0;
}

.barcode-scan-empty-note {
  margin: 0;
  padding: 14px;
}

.barcode-scanner-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
}

.moves-codes-log-table tbody tr.data-row td {
  transition: background-color 0.15s ease;
}

.moves-codes-log-table tbody tr.data-row:hover td {
  background: var(--row-hover);
}

.item-detail-header,
.item-detail-title-row,
.item-detail-meta,
.item-detail-stats {
  display: flex;
  gap: 14px;
}

.item-detail-header {
  align-items: end;
  justify-content: space-between;
  margin-bottom: 12px;
}

.item-detail-header h2,
.item-detail-overview h3 {
  margin: 4px 0 0;
}

.item-detail-title-row {
  align-items: center;
  justify-content: space-between;
}

.item-detail-barcode {
  display: inline-block;
  margin-top: 4px;
}

.item-detail-status {
  margin: 12px 0;
  font-weight: 600;
}

.item-detail-meta {
  flex-wrap: wrap;
  margin: 0;
}

.item-detail-meta div {
  min-width: 170px;
}

.item-detail-meta dt {
  color: var(--muted);
  font-size: 0.85em;
}

.item-detail-meta dd {
  margin: 3px 0 0;
}

.item-detail-warnings {
  margin-bottom: 12px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--warn-text);
  border-radius: 8px;
  background: var(--add-row-bg);
}

.item-detail-warnings p {
  margin: 3px 0;
}

.item-detail-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  margin-bottom: 12px;
}

.item-detail-stat {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.item-detail-stat span {
  color: var(--muted);
  font-size: 0.84em;
}

.item-detail-stat strong {
  font-size: 1.4em;
}

.item-detail-cycle {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 22px;
}

.item-detail-cycle li {
  display: grid;
  gap: 2px;
}

.item-detail-cycle span {
  color: var(--muted);
  font-size: 0.9em;
}

.item-detail-history-wrap {
  overflow-x: auto;
}

.item-detail-history-table {
  min-width: 880px;
}

@media (max-width: 700px) {
  .item-detail-header {
    align-items: start;
    flex-direction: column;
  }
}

@media (max-width: 1000px) {
  .barcode-scanner-toolbar {
    grid-template-columns: 1fr;
  }
}

.qr-scan-panel {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  z-index: 2000;
}

.qr-scan-panel.is-open {
  display: flex;
}

.qr-scan-dialog {
  width: min(560px, 100%);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  padding: 14px;
}

.qr-scan-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.qr-scan-close-btn {
  width: auto;
  min-width: 120px;
  min-height: 36px;
  height: 36px;
  margin-top: 0;
}

.qr-reader {
  width: 100%;
  min-height: 280px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field-bg);
  overflow: hidden;
}

.qr-scan-message {
  margin-top: 10px;
  min-height: 18px;
  font-size: 13px;
  color: var(--muted);
}

.qr-scan-message.is-ok {
  color: var(--ok-text);
}

.qr-scan-message.is-error {
  color: var(--danger-text);
}

.issue-row-action {
  display: flex;
  flex-direction: column;
}

.issue-row-action button {
  width: 44px;
  min-width: 44px;
  height: 40px;
  min-height: 40px;
  margin: 0;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}


/* =====================================================================
   BADGES & STATUSES
   ===================================================================== */

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 12px;
  border: 1px solid;
  line-height: 1;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

/* точка слева */
.status-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.9;
}

.status-green {
  background: var(--status-green-bg);
  color: var(--status-green-text);
  border-color: var(--status-green-border);
}

.status-yellow {
  background: var(--status-yellow-bg);
  color: var(--status-yellow-text);
  border-color: var(--status-yellow-border);
}

.status-red {
  background: var(--status-red-bg);
  color: var(--status-red-text);
  border-color: var(--status-red-border);
}

.mode-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
  border: 1px solid transparent;
}

.mode-bw {
  background: var(--mode-bw-bg);
  color: var(--mode-bw-text);
  border-color: var(--mode-bw-border);
}

.mode-color {
  background: var(--mode-color-bg);
  color: var(--mode-color-text);
  border-color: var(--mode-color-border);
}

.locked-input-wrap {
  position: relative;
}

.locked-input-wrap .lockable-input {
  padding-right: 42px;
}

.locked-input-wrap .lockable-input[readonly] {
  background: var(--field-bg);
  color: var(--muted);
}

/* Zamochek */
.lock-toggle-btn {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  width: 28px;
  min-width: 28px;
  height: 28px;
  min-height: 28px;
  margin: 0;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.lock-toggle-btn:hover {
  background: var(--row-hover);
  color: var(--text);
}

.lock-toggle-btn.is-unlocked {
  background: var(--soft-accent-bg);
  color: var(--accent);
  border-color: var(--inner-panel-border);
}

.comment-cell {
  width: 250px;
  max-width: 250px;
}

.comment-box {
  display: grid;
  gap: 6px;
}

.comment-text {
  display: -webkit-box;
  -webkit-line-clamp: 1;      /* сколько строк показывать */
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  line-height: 1.45;
  max-height: calc(1.45em * 3);
}

.comment-box.is-expanded .comment-text {
  display: block;
  -webkit-line-clamp: unset;
  max-height: none;
}

.codes-search-form {
  margin-bottom: 12px;
}

.codes-workbench-header {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.codes-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.codes-tab-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field-bg);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.codes-tab-link:hover {
  background: var(--table-head-bg);
  border-color: var(--table-head-line);
}

.codes-tab-link.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.codes-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--soft-accent-bg);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.codes-tab-link.is-active .codes-tab-count {
  background: color-mix(in srgb, var(--accent-text) 20%, transparent);
  color: var(--accent-text);
}

.codes-toolbar-form {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.codes-toolbar-search input {
  width: 100%;
}

.codes-toolbar-actions {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.codes-toolbar-actions button,
.codes-toolbar-actions .reset-btn {
  width: auto;
  min-width: 120px;
  margin-top: 0;
}

.codes-search-row {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 140px;
  gap: 10px;
  align-items: end;
}

.codes-search-actions button {
  margin-top: 0;
}

.codes-export-form {
  margin: 0;
}

.codes-export-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.codes-export-actions button {
  width: auto;
  min-width: 290px;
  margin-top: 0;
}

.codes-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.codes-actions a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.codes-actions a:hover {
  text-decoration: underline;
}

.codes-table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.codes-table-toolbar button {
  width: auto;
  min-width: 260px;
  margin-top: 0;
}

/* =====================================================================
   MOBILE / CARDS
   ===================================================================== */

.mobile-shell {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.mobile-card {
  padding: 18px;
}

.mobile-card-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.mobile-overline {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.mobile-title {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
}

.mobile-public-id {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: var(--soft-accent-bg);
  color: var(--accent);
  font-weight: 700;
}

.mobile-info-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.mobile-info-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--field-bg);
}

.mobile-info-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.mobile-section-title {
  margin-bottom: 12px;
}

.mobile-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mobile-chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--field-bg);
  border: 1px solid var(--line);
  color: var(--text);
  font-weight: 600;
}

.mobile-admin-form {
  display: grid;
  gap: 12px;
}

.mobile-admin-form button {
  margin-top: 0;
}

.mobile-code {
  word-break: break-word;
}

@media (max-width: 640px) {
  .mobile-card-header {
    flex-direction: column;
    align-items: start;
  }

  .mobile-title {
    font-size: 24px;
  }

  .codes-toolbar-form {
    grid-template-columns: 1fr;
  }

  .codes-table-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .codes-table-toolbar button {
    width: 100%;
    min-width: 0;
  }
}

/* =====================================================================
   TELEGRAM MINI APP
   ===================================================================== */

.miniapp-shell {
  padding: 0 0 24px;
}

.miniapp-search-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}

.miniapp-search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 14px;
  font-size: 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  outline: none;
}

.miniapp-search-input:focus {
  border-color: var(--accent);
}

.miniapp-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.miniapp-printer-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: var(--text);
  background: var(--panel);
  transition: background 0.1s;
}

.miniapp-printer-card:hover,
.miniapp-printer-card:active {
  background: var(--soft-accent-bg);
}

.miniapp-card-main {
  flex: 1;
  min-width: 0;
}

.miniapp-card-title {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.miniapp-card-location {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.miniapp-card-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.miniapp-card-id {
  font-size: 12px;
  color: var(--muted);
}

.miniapp-card-status {
  font-size: 12px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--soft-accent-bg);
  color: var(--accent);
}

.miniapp-card-status.miniapp-status-repair {
  background: var(--ok-bg);
  color: var(--warn-text);
}

.miniapp-card-status.miniapp-status-written_off {
  background: var(--danger-subtle-bg);
  color: var(--danger-text);
}

.miniapp-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
}

/* =====================================================================
   QR / CODES
   ===================================================================== */

.qr-thumb {
  width: 92px;
  height: 92px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 4px;
}

.qr-inline-preview {
  margin-top: 8px;
}

.codes-resolve-preview {
  margin-top: 8px;
}

.inline-link {
  margin-left: 8px;
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.inline-link:hover {
  text-decoration: underline;
}

.comment-toggle {
  width: auto;
  min-width: 0;
  min-height: 0;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.comment-toggle:hover {
  text-decoration: underline;
}

/* =====================================================================
   HISTORY & COMPAT PANEL
   ===================================================================== */

.history-change-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.history-undo-form {
  margin: 0;
}

.history-undo-btn {
  width: 28px;
  min-width: 28px;
  height: 28px;
  min-height: 28px;
  margin: 0;
  padding: 0;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.history-panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  margin-top: 1px;
  overflow: hidden;
}

.history-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  cursor: pointer;
  font-weight: 700;
  user-select: none;
}

.history-summary-hint {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.history-panel-body {
  padding: 0 18px 18px;
}

.history-extra-row {
  opacity: 1;
  transition: opacity 0.2s ease;
}

.history-panel.is-collapsed .history-extra-row {
  display: none;
}

.printers-history-table tbody {
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.history-panel.is-animating .printers-history-table tbody {
  opacity: 0.85;
  transform: translateY(-2px);
}




.compat-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding-top: 5px;
  padding-bottom: 3px;
}

.compat-row label {
  margin-bottom: 0;
}

.compat-row-main {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.compat-view {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.compat-edit-btn {
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field-bg);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.compat-edit-btn:hover {
  background: var(--row-hover);
}

.compat-expand {
  width: 100%;
}
.compat-expand-inner {
  border: 1px solid var(--inner-panel-border);
  border-radius: 12px;
  background: var(--panel);
  padding: 12px 14px;
  max-height: 250px;
  overflow: hidden;
  opacity: 0;
  transform: translateX(-20px);
  transition:
    opacity 0.22s ease,
    transform 0.22s ease;
}
.inline-cartridge-section.compat-open .compat-expand-inner {
  opacity: 1;
  transform: translateX(0);
}

.compat-check-item input {
  width: auto;
  height: auto;
  min-width: auto;
  min-height: auto;
  margin: 0;
}
.compat-check-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(140px, 1fr));
  gap: 8px 16px;
  flex: 1 1 auto;
  min-height: 100px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--muted) transparent;
}
.compat-check-list::-webkit-scrollbar {
  width: 10px;
}

.compat-check-list::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 999px;
}

.compat-check-list::-webkit-scrollbar-thumb {
  background: rgba(154, 164, 178, 0.55);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.compat-check-list::-webkit-scrollbar-thumb:hover {
  background: rgba(154, 164, 178, 0.8);
  border: 2px solid transparent;
  background-clip: padding-box;
}
.compat-check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.compat-expand-actions {
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
  flex: 0 0 auto;
}

.inline-cartridge-side,
.compat-expand,
.compat-expand-inner {
  align-self: start;
}

.compat-expand-form {
  margin: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 155px;
}

.compat-expand-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 10px;
  padding-right: 2px;
}

.compat-expand-title button {
  width: 30px;
  min-width: 30px;
  height: 30px;
  min-height: 30px;
  margin: 0 0 0 auto;
  padding: 0;
  border-radius: 8px;
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}


.cartridge-danger-zone {
  margin-top: 0px;
  padding-top: 0px;
}

.cartridge-danger-zone button {
  margin-top: 10px;
  width: 160px;
}

.danger-toggle-btn,
.danger-submit-btn {
  min-height: 36px;
}

.danger-toggle-btn {
  background: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid transparent;
  margin: 0;
  width: 100px;
}

.cartridge-delete-confirm {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--danger-subtle-bg);
  max-width: 300px;
}

.cartridge-delete-row {
  display: grid;
  grid-template-columns: 1fr;
  margin-top: 10px;
}

.cartridge-delete-row input {
  width: 100%;
  min-width: 0;
}

.danger-submit-btn {
  width: 100%;
}

.danger-submit-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.cartridge-delete-confirm .small {
  display: block;
  line-height: 1.4;
}
.danger-toggle-btn.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.cartridge-restore-form {
  display: inline;
}

.delete-block-reason {
  margin-top: 8px;
}

.printers-table {
  width: 100%;
  table-layout: fixed;
}

.printers-table th,
.printers-table td {
  min-width: 0;
}

.printers-table tbody tr.edit-row td {
  overflow: hidden;
}

.inline-printer-grid > div,
.inline-printer-form,
.inline-printer-inventory,
.inline-printer-comment,
.locked-input-wrap {
  min-width: 0;
}

.inline-printer-grid input,
.inline-printer-grid select,
.inline-printer-grid textarea,
.locked-input-wrap .lockable-input {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}


.moves-table {
  table-layout: fixed;
}

.moves-table th:nth-child(1),
.moves-table td:nth-child(1) {
  width: 150px;
}

.moves-table th:nth-child(2),
.moves-table td:nth-child(2) {
  width: 230px;
}

.moves-table th:nth-child(3),
.moves-table td:nth-child(3) {
  width: 260px;
}

.moves-table th:nth-child(4),
.moves-table td:nth-child(4) {
  width: 120px;
}

.moves-table th:nth-child(5),
.moves-table td:nth-child(5) {
  width: 220px;
}

.moves-table th:nth-child(6),
.moves-table td:nth-child(6) {
  width: 130px;
}

.move-operation,
.move-items,
.move-comment-cell {
  min-width: 0;
}

.move-comment-box {
  display: grid;
  gap: 4px;
}

.move-comment-text {
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.move-comment-box.is-expanded .move-comment-text {
  display: block;
  overflow: visible;
}

.move-comment-toggle {
  width: fit-content;
  min-height: 0;
  height: auto;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  box-shadow: none;
  font-size: 12px;
}

.move-comment-toggle:hover {
  background: transparent;
  text-decoration: underline;
}

.inline-comment-wrap {
  position: relative;
}

.inline-comment-wrap textarea {
  width: 100%;
  min-height: 44px;
  max-height: 44px;
  padding-right: 42px;
  resize: none;
  overflow: hidden;
}

.inline-comment-wrap.is-expanded textarea {
  min-height: 96px;
  max-height: 160px;
  overflow: auto;
  resize: vertical;
}
.inline-comment-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 0;
}
.inline-comment-label-row button {
  margin-bottom: 0;
}
.inline-comment-toggle {
  width: auto;
  min-width: 0;
  min-height: 0;
  height: auto;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  box-shadow: none;
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
}

.inline-comment-toggle:hover {
  background: transparent;
  text-decoration: underline;
}

/* ─── ADMIN PANEL ─────────────────────────────────────────────────────────── */

.admin-nav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.admin-nav-card {
  display: block;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}
.admin-nav-card:hover {
  background: var(--soft-accent-bg);
  border-color: var(--accent);
}
.admin-nav-card-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.breadcrumb-link {
  color: var(--muted);
  text-decoration: none;
  font-weight: 400;
}
.breadcrumb-link:hover {
  text-decoration: underline;
}

.admin-page-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 12px;
}
.admin-back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.875em;
}
.admin-back-link:hover {
  color: var(--accent);
  text-decoration: underline;
}
.admin-page-title {
  margin: 0;
}

.admin-inline-rename-form {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.admin-rename-input {
  flex: 1;
  min-width: 120px;
}

.admin-balance-current {
  font-size: 1.1em;
  font-weight: 600;
  padding: 4px 10px;
  background: var(--soft-accent-bg);
  border-radius: 6px;
  min-width: 36px;
  display: inline-block;
  text-align: center;
}

.health-block-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.health-ok {
  color: var(--ok-text);
  font-size: 0.875em;
}
.health-warn {
  color: var(--error-text, #c0392b);
  font-size: 0.875em;
}

.ok-text {
  color: var(--ok-text);
}
.error-text {
  color: var(--error-text, #c0392b);
}

.filter-select {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--input-bg, var(--panel));
  color: var(--text);
  font-size: 0.9em;
}

/* Monospace barcode value display in codes table */
.barcode-code-text {
  font-family: "Courier New", Courier, monospace;
  font-size: 0.9em;
  letter-spacing: 0.04em;
  background: var(--soft-accent-bg);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ── Cartridge tracking mode badge ─────────────────────────────────────── */
.tracking-mode-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 6px;
  font-size: 0.8em;
  font-weight: 600;
}
.tracking-mode-badge.is-quantity {
  background: var(--mode-bw-bg);
  color: var(--mode-bw-text);
  border: 1px solid var(--mode-bw-border);
}
.tracking-mode-badge.is-item {
  background: var(--mode-color-bg);
  color: var(--mode-color-text);
  border: 1px solid var(--mode-color-border);
}

/* ── CartridgeItem state badge ──────────────────────────────────────────── */
.item-state-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 6px;
  font-size: 0.8em;
  font-weight: 600;
}
.item-state-badge.is-full {
  background: var(--status-green-bg);
  color: var(--status-green-text);
  border: 1px solid var(--status-green-border);
}
.item-state-badge.is-empty {
  background: var(--status-yellow-bg);
  color: var(--status-yellow-text);
  border: 1px solid var(--status-yellow-border);
}
.item-state-badge.is-refilling {
  background: var(--mode-color-bg);
  color: var(--mode-color-text);
  border: 1px solid var(--mode-color-border);
}
.item-state-badge.is-written_off,
.item-state-badge.is-lost {
  background: var(--status-red-bg);
  color: var(--status-red-text);
  border: 1px solid var(--status-red-border);
}

/* =====================================================================
   CARTRIDGE ITEM MANAGEMENT — modals, stats, row actions
   ===================================================================== */

/* Items table header with toggle link */
.ci-items-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.ci-items-header h3 {
  margin: 0;
}

/* Per-row action buttons */
.ci-row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.ci-bulk-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field-bg);
}

.ci-bulk-toolbar .danger-btn {
  margin: 0;
}

.ci-select-column {
  width: 34px;
  text-align: center;
}

.ci-select-column input {
  width: auto;
  min-width: 0;
  min-height: 0;
  margin: 0;
}

/* Inline link-style buttons */
.link-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--accent);
  font-size: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.link-btn:hover {
  color: var(--accent-hover);
}
.link-btn.danger {
  color: var(--danger-text);
}
.link-btn.danger:hover {
  opacity: 0.8;
}
.link-btn.small {
  font-size: 0.82em;
}

/* Danger submit button (archive confirm) */
.danger-btn {
  background: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid var(--danger-text);
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9em;
}
.danger-btn:hover {
  opacity: 0.85;
}

/* Available-count info strip below create form */
.ci-stats-block {
  padding: 6px 10px;
  background: var(--add-row-bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  display: inline-flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}
.ci-avail-value {
  color: var(--ok-text);
}

/* Modal overlay */
.ci-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ci-modal-overlay[hidden] {
  display: none;
}

/* Modal dialog box */
.ci-modal-dialog {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  width: min(480px, 94vw);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 4px 24px rgba(0,0,0,0.18);
}

.ci-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--line);
}
.ci-modal-header h3 {
  margin: 0;
  font-size: 1em;
}
.ci-modal-close {
  background: none;
  border: none;
  font-size: 1.4em;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
  padding: 0 2px;
}
.ci-modal-close:hover {
  color: var(--text);
}

.ci-modal-body {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ci-modal-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ci-modal-field label {
  font-size: 0.85em;
  color: var(--muted);
}
.ci-modal-field input,
.ci-modal-field select {
  width: 100%;
  box-sizing: border-box;
}

.ci-modal-footer {
  padding: 10px 18px 16px;
  display: flex;
  gap: 10px;
  border-top: 1px solid var(--line);
}

/* =====================================================================
   ADMIN COMPATIBILITY PAGE
   ===================================================================== */

/* Header panel — tighter than default .panel */
.admin-compat-header-panel {
  padding: 12px 18px;
  margin-bottom: 10px;
}
.admin-compat-header-panel .admin-page-header {
  margin-bottom: 0;
}
.admin-compat-header-panel .flash {
  margin-top: 8px;
  margin-bottom: 0;
}

/* Main panel: tabs + search + table — no padding (each section has its own) */
.admin-compat-main-panel {
  padding: 0;
  overflow: hidden;
  margin-bottom: 10px;
}

/* Toolbar row: tabs on the left, search on the right */
.admin-compat-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

/* Search form — stays in one line */
.admin-compat-search-form {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 180px;
  min-width: 0;
}
.admin-compat-search-form input[type="search"] {
  flex: 1;
  min-width: 0;
}

/* Compact table for compat page — less row height */
.admin-compat-table th,
.admin-compat-table td {
  padding: 7px 12px;
}
.admin-compat-table thead th {
  font-size: 0.78em;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

/* "Изменить" action — compact button-style anchor */
.admin-compat-action-btn {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  font-size: 0.8125em;
  font-weight: 500;
  background: var(--field-bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.admin-compat-action-btn:hover {
  background: var(--soft-accent-bg);
  border-color: var(--accent);
  color: var(--accent);
}

/* Edit panel (appears above main table when editing) */
.compat-edit-panel {
  border-left: 3px solid var(--accent);
  margin-bottom: 10px;
}
.compat-edit-panel h3 {
  margin-top: 0;
  font-size: 1em;
}

/* Grid of checkboxes in edit form */
.compat-check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 5px 14px;
  margin: 10px 0 14px;
  max-height: 360px;
  overflow-y: auto;
  padding-right: 4px;
}

.compat-edit-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Diagnostics panel */
.admin-compat-diag-panel {
  margin-bottom: 10px;
}
.admin-compat-diag-panel > h3 {
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 0.95em;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Diagnostic problem block — warning card with left accent */
.compat-diag-block {
  margin-bottom: 8px;
  padding: 10px 14px;
  background: var(--add-row-bg);
  border: 1px solid var(--line);
  border-left: 3px solid var(--warn-text);
  border-radius: 6px;
}
.compat-diag-block:last-child {
  margin-bottom: 0;
}
.compat-diag-block h4 {
  font-size: 0.85em;
  font-weight: 600;
  margin: 0 0 6px;
  color: var(--warn-text);
}
.compat-diag-list {
  margin: 0;
  padding-left: 16px;
  list-style: disc;
}
.compat-diag-list li {
  font-size: 0.85em;
  line-height: 1.6;
  padding: 1px 0;
}

/* Hint text below CartridgeItem list header */
.ci-items-hint {
  margin: 0 0 10px;
}
