:root {
  --bg: #e8eef3;
  --bg-2: #f7fafc;
  --ink: #152033;
  --muted: #5c6b7d;
  --line: #c5d0db;
  --panel: #ffffff;
  --accent: #1f3a5f;
  --accent-2: #c45c26;
  --ok: #1f6b4a;
  --bad: #9b2c2c;
  --shadow: 0 10px 30px rgba(21, 32, 51, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", "Candara", "Trebuchet MS", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1000px 420px at 10% -10%, #d7e5f2 0%, transparent 60%),
    linear-gradient(180deg, #dfe7ee 0%, var(--bg) 40%, #edf2f6 100%);
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1.5rem;
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow);
}

.brand {
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 1.05rem;
  text-decoration: none;
}

.topbar nav,
.topbar .top-nav {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.topbar nav a,
.topbar .top-nav a {
  color: #d7e4f2;
  text-decoration: none;
  font-size: 0.95rem;
}

.topbar nav a:hover,
.topbar .top-nav a:hover { color: #fff; }

.container {
  width: min(1180px, calc(100% - 2rem));
  margin: 1.4rem auto 2.5rem;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.2rem;
  flex-wrap: wrap;
}

.page-head.slim { margin-bottom: 0.6rem; }
.page-head h1, .page-head h2 { margin: 0 0 0.25rem; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

.actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 0.55rem 0.9rem;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  text-decoration: none;
}

.btn:hover { text-decoration: none; border-color: #9eb0c2; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.accent { background: var(--accent-2); color: #fff; border-color: var(--accent-2); }
.btn.success { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn.success:hover { background: #18553a; border-color: #18553a; }
.btn.warn { background: #d4a017; color: #fff; border-color: #d4a017; }
.btn.warn:hover { background: #b8860b; border-color: #b8860b; }
.btn.danger { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.danger:hover { border-color: #7a1f1f; background: #7a2222; }

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.table th, .table td {
  padding: 0.7rem 0.8rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.table th {
  background: #243f63;
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
}

.table.compact th, .table.compact td {
  padding: 0.45rem 0.6rem;
  font-size: 0.92rem;
}

.table tr.bad { background: #fff1f1; }
.table tbody tr:hover { background: #f4f8fb; }

.card-form, .panel, .empty {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
}

.card-form label {
  display: block;
  margin-bottom: 0.85rem;
  font-size: 0.92rem;
  color: var(--muted);
}

.card-form input,
.card-form select,
.card-form textarea {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  color: var(--ink);
  background: var(--bg-2);
}

.grid-2, .grid-3, .meta-grid {
  display: grid;
  gap: 0.9rem;
}

.grid-2, .meta-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.inline-form {
  display: grid;
  grid-template-columns: 2fr 1fr auto;
  gap: 0.8rem;
  align-items: end;
}

.inline-form.materials-pick {
  grid-template-columns: 1.3fr 1.7fr 0.9fr auto;
}

.card-form.inline-form.materials-pick {
  display: grid;
}

.inline-form label { margin: 0; }

select:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.checks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.55rem;
  margin-bottom: 0.35rem;
}

.btn-new-employee {
  margin-top: 1rem;
}

.executors-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-height: 280px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.55rem;
  margin: 0.5rem 0 0;
  background: #f3f7fb;
  border: 1px solid var(--line);
  border-radius: 12px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #9eb0c2 transparent;
}

.executors-list::-webkit-scrollbar {
  width: 8px;
}

.executors-list::-webkit-scrollbar-thumb {
  background: #9eb0c2;
  border-radius: 999px;
}

.executors-list .check {
  flex-shrink: 0;
  width: 100%;
  margin: 0 !important;
  background: #fff;
}

.check-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.check-name {
  font-weight: 600;
  color: var(--ink);
}

.executors-list .check .muted {
  margin: 0;
}

.check {
  display: flex !important;
  gap: 0.75rem;
  align-items: center;
  color: var(--ink) !important;
  margin: 0 !important;
  padding: 0.65rem 0.8rem;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.check:hover {
  border-color: #9eb0c2;
  background: #fff;
}

.check:has(input:checked) {
  border-color: #7a9bc0;
  background: #eef4fb;
  box-shadow: inset 0 0 0 1px rgba(31, 58, 95, 0.08);
}

.check input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 2.75rem;
  height: 1.5rem;
  margin: 0 !important;
  flex-shrink: 0;
  border-radius: 999px;
  background: #b7c4d2;
  position: relative;
  cursor: pointer;
  transition: background 0.2s ease;
  outline: none;
}

.check input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 1.2rem;
  height: 1.2rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(21, 32, 51, 0.25);
  transition: transform 0.2s ease;
}

.check input[type="checkbox"]:checked {
  background: var(--accent);
}

.check input[type="checkbox"]:checked::after {
  transform: translateX(1.25rem);
}

.check input[type="checkbox"]:focus-visible {
  box-shadow: 0 0 0 3px rgba(31, 58, 95, 0.25);
}

.check .muted {
  display: block;
  font-size: 0.82rem;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 10px;
  margin: 0 0 1rem;
  padding: 0.8rem 1rem;
}

fieldset.form-block {
  background: var(--bg-2);
}

legend { padding: 0 0.3rem; color: var(--muted); font-weight: 600; }

.hidden { display: none !important; }

.hint {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.82rem;
  color: var(--accent-2);
}

.custom-work-fields {
  margin-top: 0.2rem;
}

.meta {
  display: grid;
  gap: 0.45rem;
  margin: 0 0 1rem;
}

.meta div {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 0.5rem;
}

.meta dt { color: var(--muted); margin: 0; }
.meta dd { margin: 0; }

.plain { padding-left: 1.1rem; margin: 0; }
.section { margin-top: 1.4rem; }
.danger-zone { margin-top: 2rem; }
.scroll { max-height: 360px; overflow: auto; border-radius: 12px; box-shadow: var(--shadow); }

.flash-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.flash {
  padding: 0.7rem 0.9rem;
  border-radius: 8px;
  margin-bottom: 0.4rem;
}
.flash.ok { background: #e5f6ee; color: var(--ok); }
.flash.err { background: #fde8e8; color: var(--bad); }

.tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}
.tag.ok { background: #e5f6ee; color: var(--ok); }
.tag.bad { background: #fde8e8; color: var(--bad); }
.tag.warn { background: #fff3e0; color: #9a5b00; }

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.tab {
  display: inline-block;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
  font-size: 0.95rem;
}

.tab:hover { background: #f4f8fb; text-decoration: none; }
.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.tab-count {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.08);
  font-size: 0.8rem;
}

.tab.active .tab-count {
  background: rgba(255, 255, 255, 0.22);
}

.ok-hint {
  background: #e5f6ee;
  border-color: #b7e0c8;
  color: var(--ok);
}

.materials-topup .grid-3 {
  margin-bottom: 0.6rem;
}

.editing-row {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.voucher-sheet {
  max-width: 900px;
}

.voucher-signs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-top: 2.5rem;
  padding-top: 1rem;
}

.sign-title {
  font-weight: 700;
  margin-bottom: 1.5rem;
}

.sign-line {
  border-bottom: 1px solid var(--ink);
  min-height: 1.5rem;
  margin-bottom: 0.35rem;
}

.sign-hint {
  font-size: 0.8rem;
  color: var(--muted);
}

@media print {
  .topbar, .page-head .actions, .flash-list { display: none !important; }
  .container { width: 100%; margin: 0; }
  .voucher-sheet { box-shadow: none; border: none; }
}

@media (max-width: 860px) {
  .voucher-signs { grid-template-columns: 1fr; }
}

.slim-panel { padding: 0.8rem 1rem; margin-bottom: 1rem; }
.warn-panel { border-left: 4px solid var(--accent-2); }
.help-box.warn, .field-tip.warn { color: #9a5b00; }
.submit-final { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.object-report-block { margin-bottom: 0.8rem; }
.inline-actions { display: inline; }

.login-page {
  display: flex;
  justify-content: center;
  padding: 3rem 0 2rem;
}

.login-form {
  width: min(420px, 100%);
}

.login-form h1 { margin: 0 0 0.35rem; }

.nav-user {
  color: #d7e4f2;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.login-fields { margin-top: 0.6rem; }
.hidden { display: none !important; }
.employee-card { margin-bottom: 0.8rem; }
.admin-status { margin-bottom: 1rem; }
.status-form {
  display: inline-flex;
  gap: 0.5rem;
  align-items: stretch;
  flex-wrap: wrap;
  margin: 0;
}
.status-form .status-select,
.status-form select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  box-sizing: border-box;
  min-width: 11rem;
  height: auto;
  padding: 0.55rem 2.2rem 0.55rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background-color: var(--panel);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%235c6b7d' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 12px 8px;
  color: var(--ink);
  font: inherit;
  line-height: 1.2;
  cursor: pointer;
}
.status-form .status-select:hover,
.status-form select:hover {
  border-color: #9eb0c2;
}
.status-form .status-select:focus,
.status-form select:focus {
  outline: 2px solid rgba(31, 58, 95, 0.25);
  outline-offset: 1px;
  border-color: var(--accent);
}
.status-form .btn {
  white-space: nowrap;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.chips li {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  list-style: none;
}

.material-draft-actions {
  margin: 0.25rem 0 1rem;
}

.draft-section {
  margin: 0.5rem 0 1rem;
}

.draft-section h2 {
  margin-top: 0;
  font-size: 1.05rem;
}


.search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: stretch;
  margin-bottom: 0.75rem;
}

.search-input {
  flex: 1 1 220px;
  min-width: 0;
  height: 2.6rem;
  padding: 0 0.9rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}

.search-input:focus {
  outline: 2px solid rgba(31, 58, 95, 0.25);
  outline-offset: 1px;
  border-color: #1f3a5f;
}

.search-row .btn {
  height: 2.6rem;
  box-sizing: border-box;
  padding-top: 0;
  padding-bottom: 0;
}

.period-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.period-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.period-label input[type="month"] {
  height: 2.2rem;
  padding: 0 0.55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}

.list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0.35rem 0 0.65rem;
}

.list-toolbar .sort-dropdown {
  position: relative;
  display: inline-flex;
}

.list-count {
  font-size: 0.9rem;
}

.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: flex-end;
  margin-bottom: 1rem;
}

.filter-field {
  display: grid;
  grid-template-rows: auto 1.15em 2.5rem;
  gap: 0.3rem;
  font-size: 0.9rem;
  min-width: 180px;
  flex: 1 1 180px;
  color: var(--muted);
  margin: 0;
}

.filter-label {
  display: block;
  line-height: 1.25;
  color: var(--muted);
  font-size: 0.9rem;
}

.filter-field input,
.filter-field select {
  box-sizing: border-box;
  width: 100%;
  height: 2.5rem;
  padding: 0 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}

.period-row {
  display: flex;
  gap: 0.4rem;
  align-items: stretch;
  height: 2.5rem;
  min-width: 0;
}

.period-row input[type="month"] {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}

.period-row .btn-sm {
  flex: 0 0 auto;
  height: 100%;
  min-width: 3.2rem;
  padding: 0 0.75rem;
  box-sizing: border-box;
}

.filter-field .field-tip {
  margin: 0;
  line-height: 1.15;
  font-size: 0.78rem;
  min-height: 1.15em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filter-tip-spacer {
  visibility: hidden;
  user-select: none;
}

.filter-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0.5rem;
  flex: 0 0 auto;
  height: 2.5rem;
  margin-left: auto;
}

.filter-actions .btn,
.filter-actions .sort-btn {
  height: 100%;
  box-sizing: border-box;
  padding-top: 0;
  padding-bottom: 0;
  white-space: nowrap;
}

.sort-dropdown {
  position: relative;
  display: inline-flex;
}

.sort-btn {
  white-space: nowrap;
}

.sort-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 40;
  min-width: 220px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.sort-menu[hidden] { display: none !important; }

.sort-option {
  border: none;
  background: transparent;
  text-align: left;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
  color: var(--ink);
}

.sort-option:hover { background: #f4f8fb; }
.sort-option.active {
  background: #e8eef5;
  font-weight: 600;
  color: var(--accent);
}

.slim-hint { margin: 0 0 0.8rem; font-size: 0.9rem; }

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.15rem;
  height: 2.15rem;
  border-radius: 8px;
  background: rgba(255,255,255,0.12);
  color: #fff !important;
  text-decoration: none !important;
  line-height: 1;
}

.nav-btn:hover { background: rgba(255,255,255,0.22); }

.nav-ico {
  width: 1.15rem;
  height: 1.15rem;
  display: block;
}

.field-tip {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 400;
}

.help-box {
  background: #eef4fa;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.8rem 1rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

.readonly-contractor {
  background: var(--bg-2);
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin: 0 0 1rem;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(21, 32, 51, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal {
  background: #fff;
  border-radius: 12px;
  padding: 1.2rem 1.3rem;
  width: min(420px, 100%);
  box-shadow: var(--shadow);
}

.modal h3 { margin: 0 0 0.8rem; }

.modal-form label {
  display: block;
  margin-bottom: 0.75rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.modal-form input, .modal-form select, .modal-form textarea {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.modal-reports {
  width: min(480px, 100%);
}

.report-opt-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin: 0.6rem 0 1rem;
}

.report-opt {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  margin: 0;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  color: inherit;
  background: #f8fafc;
  transition: border-color 0.15s, background 0.15s;
}

.report-opt:hover {
  border-color: #7a93b0;
  background: #fff;
}

.report-opt:has(input:checked) {
  border-color: #1f3a5f;
  background: #eef4fb;
  box-shadow: inset 0 0 0 1px #1f3a5f;
}

.report-opt input {
  margin-top: 0.2rem;
  flex-shrink: 0;
}

.report-opt-body {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.report-opt-body strong {
  color: var(--text, #152033);
  font-size: 0.98rem;
}

.report-opt-hint {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.inner-set {
  margin-top: 0.8rem;
  background: #fff;
}

.customer-check {
  display: flex !important;
  align-items: center;
  gap: 0.75rem;
  color: var(--ink) !important;
  margin-bottom: 0.5rem !important;
  max-width: 320px;
}

.customer-check input { width: auto; margin: 0; }

.material-row {
  margin-bottom: 0.7rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--line);
}

.qty-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.qty-row input { flex: 1; }

.sticky-panel {
  position: sticky;
  top: 1rem;
  align-self: start;
  max-height: calc(100vh - 2rem);
  overflow: auto;
}

.floating-cloud {
  position: fixed;
  z-index: 900;
  right: 24px;
  top: 100px;
  width: min(420px, calc(100vw - 2rem));
  max-height: min(480px, calc(100vh - 120px));
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(21, 32, 51, 0.18), 0 4px 12px rgba(21, 32, 51, 0.08);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.floating-cloud.dragging {
  box-shadow: 0 24px 56px rgba(21, 32, 51, 0.28);
  cursor: grabbing;
}

.floating-cloud-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  background: linear-gradient(180deg, #eef4fa 0%, #e4edf5 100%);
  border-bottom: 1px solid var(--line);
  user-select: none;
}

.floating-cloud-handle {
  flex: 1;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--accent);
  cursor: grab;
}

.floating-cloud.dragging .floating-cloud-handle {
  cursor: grabbing;
}

.floating-cloud-btn {
  width: 1.75rem;
  height: 1.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0;
}

.floating-cloud-btn:hover {
  background: var(--bg-2);
  color: var(--ink);
}

#stock-cloud-table tr.stock-used .stock-rest-value {
  color: #1a5f8a;
}

#stock-cloud-table tr.bad .stock-rest-value {
  color: #b42318;
}

.floating-cloud-body {
  padding: 0.75rem;
  overflow: auto;
  flex: 1;
}

.floating-cloud-body .table {
  box-shadow: none;
  font-size: 0.88rem;
}

.floating-cloud-fab {
  position: fixed;
  z-index: 899;
  right: 24px;
  bottom: 24px;
  padding: 0.65rem 1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  box-shadow: var(--shadow);
  cursor: pointer;
  font: inherit;
  color: var(--accent);
  font-weight: 600;
}

.floating-cloud-fab:hover {
  background: var(--bg-2);
}

.link-btn {
  background: none;
  border: none;
  color: var(--bad);
  cursor: pointer;
  font: inherit;
  padding: 0;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 12px;
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
  background: var(--panel);
}

.table-wrap .table {
  box-shadow: none;
  margin: 0;
  border-radius: 0;
}

.edit-row-cell { padding: 0.4rem 0.5rem !important; }

.edit-row {
  display: grid;
  grid-template-columns: 1.2fr 1.6fr 0.6fr auto;
  gap: 0.45rem;
  align-items: center;
}

.edit-row-2 {
  grid-template-columns: 1fr auto;
}

.edit-row input,
.edit-row select {
  width: 100%;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  background: var(--bg-2);
}

.edit-row .unit-input { max-width: 5rem; }

.row-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.85rem;
}

.dir-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.2rem;
}

.dir-nav a {
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  text-decoration: none;
  font-size: 0.9rem;
}

.dir-nav a:hover { background: #f4f8fb; }

.forms-grid { margin-bottom: 1rem; }

.nav-toggle {
  display: none;
  margin-left: auto;
  width: 2.4rem;
  height: 2.4rem;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 8px;
  background: rgba(255,255,255,0.12);
  color: #fff;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.page-head .actions .btn,
.actions .btn {
  white-space: nowrap;
}

@media (max-width: 960px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .edit-row {
    grid-template-columns: 1fr 1fr;
  }
  .edit-row .row-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
  .edit-row .unit-input { max-width: none; }
}

@media (max-width: 860px) {
  .grid-2, .grid-3, .meta-grid,
  .card-form.inline-form,
  .card-form.inline-form.materials-pick {
    grid-template-columns: 1fr;
  }

  .container {
    width: calc(100% - 1rem);
    margin: 0.8rem auto 2rem;
  }

  .topbar {
    flex-wrap: wrap;
    padding: 0.7rem 0.85rem;
    gap: 0.5rem;
    position: sticky;
    top: 0;
    z-index: 950;
  }

  .topbar-left {
    width: 100%;
  }

  .brand {
    font-size: 0.95rem;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .nav-toggle.open {
    background: rgba(255,255,255,0.28);
  }

  .topbar .top-nav,
  .topbar nav.top-nav {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0.2rem;
    padding: 0.4rem 0 0.15rem;
    border-top: 1px solid rgba(255,255,255,0.18);
    margin-top: 0.15rem;
  }

  .topbar .top-nav.open,
  .topbar nav.top-nav.open {
    display: flex;
  }

  .top-nav a,
  .top-nav .nav-user {
    padding: 0.65rem 0.75rem;
    border-radius: 8px;
    color: #e8f0f8;
  }

  .top-nav a:hover {
    background: rgba(255,255,255,0.12);
    color: #fff;
  }

  .top-nav .nav-user {
    color: #c5d6e8;
    font-size: 0.9rem;
  }

  .page-head {
    flex-direction: column;
    align-items: stretch;
  }

  .page-head .actions {
    width: 100%;
  }

  .page-head .actions .btn,
  .actions .btn {
    flex: 1 1 calc(50% - 0.35rem);
    min-height: 2.6rem;
    white-space: normal;
    text-align: center;
  }

  .filters-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-field {
    min-width: 0;
    width: 100%;
    flex: 1 1 auto;
  }

  .filter-actions {
    margin-left: 0;
    width: 100%;
    height: auto;
    min-height: 2.5rem;
  }

  .filter-actions .btn {
    flex: 1;
    height: 2.5rem;
  }

  .filter-actions .sort-dropdown {
    flex: 1 1 100%;
  }

  .filter-actions .sort-btn {
    width: 100%;
  }

  .search-row .btn {
    flex: 1 1 auto;
  }

  .list-toolbar {
    flex-wrap: wrap;
  }

  .list-toolbar .sort-btn {
    width: 100%;
  }

  .list-toolbar .sort-dropdown {
    flex: 1 1 100%;
  }

  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.25rem;
  }

  .tab { flex: 0 0 auto; }

  .meta div { grid-template-columns: 1fr; gap: 0.15rem; }
  .meta dt { font-size: 0.8rem; }

  .checks { grid-template-columns: 1fr; }

  .floating-cloud {
    left: 12px !important;
    right: 12px !important;
    width: auto !important;
    top: auto !important;
    bottom: 72px;
    max-height: 45vh;
  }

  .floating-cloud-fab {
    right: 12px;
    bottom: 12px;
  }

  .login-page { padding: 1.5rem 0; }

  .edit-row, .edit-row-2 {
    grid-template-columns: 1fr;
  }

  .table th, .table td {
    padding: 0.55rem 0.5rem;
    font-size: 0.88rem;
  }

  .btn, .card-form input, .card-form select, .card-form textarea {
    font-size: 16px; /* без зума iOS */
  }
}

@media (max-width: 480px) {
  .page-head .actions .btn,
  .actions .btn {
    flex: 1 1 100%;
  }

  .status-form {
    width: 100%;
    display: flex;
  }

  .status-form .status-select,
  .status-form select {
    flex: 1;
    min-width: 0;
  }

  .status-form .btn {
    flex: 0 0 auto;
  }
}
