:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #eef3f8;
  --line: #d6dee8;
  --text: #17202a;
  --muted: #64748b;
  --blue: #2463eb;
  --green: #16803c;
  --amber: #b86b00;
  --red: #b42318;
  --shadow: 0 10px 30px rgba(25, 38, 60, 0.08);
  --queue-number-width: 28px;
  --queue-product-left: 30px;
  --queue-product-width: 158px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, Arial, sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

.login-view {
  align-items: center;
  background: #101820;
  display: none;
  inset: 0;
  justify-content: center;
  padding: 18px;
  position: fixed;
  z-index: 100;
}

.login-view.active {
  display: flex;
}

.login-card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
  display: grid;
  gap: 12px;
  max-width: 360px;
  padding: 22px;
  width: 100%;
}

.login-card p {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}

.password-field {
  align-items: stretch;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
}

.password-field input {
  border-bottom-right-radius: 0;
  border-top-right-radius: 0;
}

.password-toggle {
  background: #eef3f8;
  border-color: var(--line);
  border-bottom-left-radius: 0;
  border-top-left-radius: 0;
  color: #334155;
  font-size: 15px;
  min-height: 38px;
  padding: 0;
}

.login-hint {
  background: #fff1f0;
  border: 1px solid #fecaca;
  border-radius: 6px;
  color: #b42318 !important;
  font-weight: 700;
  padding: 8px 10px;
}

button,
input,
select {
  font: inherit;
}

button,
.button-link {
  align-items: center;
  background: var(--blue);
  border: 1px solid var(--blue);
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font-weight: 700;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  text-decoration: none;
  white-space: nowrap;
}

button:hover,
.button-link:hover {
  filter: brightness(0.96);
}

button:disabled {
  background: #d8e0ea;
  border-color: #d8e0ea;
  color: #8390a2;
  cursor: not-allowed;
}

button.secondary {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}

input,
select {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  min-height: 38px;
  padding: 0 10px;
}

input[type="color"] {
  cursor: pointer;
  min-width: 54px;
  padding: 4px;
  width: 64px;
}

label {
  color: var(--muted);
  display: grid;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
}

main {
  margin: 0 auto;
  max-width: none;
  padding: 12px 12px 42px;
}

.app-header {
  align-items: center;
  background: #101820;
  color: #fff;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  min-height: 76px;
  padding: 14px 22px;
}

.brand {
  align-items: center;
  display: flex;
  gap: 12px;
  min-width: 240px;
}

.brand-mark {
  align-items: center;
  background: #27c27a;
  border-radius: 8px;
  color: #0d1b13;
  display: flex;
  font-size: 15px;
  font-weight: 900;
  height: 42px;
  justify-content: center;
  width: 42px;
}

h1,
h2 {
  letter-spacing: 0;
  margin: 0;
}

h1 {
  font-size: 20px;
  line-height: 1.1;
}

h2 {
  font-size: 16px;
  margin-bottom: 12px;
}

.brand span {
  color: #b9c6d3;
  display: block;
  font-size: 13px;
  margin-top: 4px;
}

.session-bar {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.color-dot {
  border: 2px solid #fff;
  border-radius: 999px;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.18);
  display: inline-block;
  height: 22px;
  width: 22px;
}

.session-bar .color-dot {
  align-self: end;
  margin-bottom: 8px;
}

.session-bar label {
  color: #cdd8e5;
  min-width: 210px;
}

.user-label {
  align-self: end;
  color: #dbe6f2;
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 9px;
}

.session-bar input,
.session-bar select {
  border-color: #263444;
}

.tabs {
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 2px;
  overflow-x: auto;
  padding: 0 18px;
}

.tab {
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  color: var(--muted);
  min-height: 48px;
}

.tab.active {
  border-bottom-color: var(--blue);
  color: var(--text);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.band,
.panel,
.salary-total {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

#queueView.brand-neutral,
.queue-toolbar.brand-neutral,
.queue-brand-header.brand-neutral {
  --queue-brand-bg: #f8fafc;
  --queue-brand-strong: #334155;
  --queue-brand-soft: #eef2f7;
  --queue-brand-line: #dbe3ec;
}

#queueView.brand-froggy,
.queue-toolbar.brand-froggy,
.queue-brand-header.brand-froggy {
  --queue-brand-bg: #f1fbf2;
  --queue-brand-strong: #14532d;
  --queue-brand-soft: #daf5df;
  --queue-brand-line: #9bdcab;
}

#queueView.brand-murchan,
.queue-toolbar.brand-murchan,
.queue-brand-header.brand-murchan {
  --queue-brand-bg: #fff1f7;
  --queue-brand-strong: #9d174d;
  --queue-brand-soft: #fde2ee;
  --queue-brand-line: #f3a6c6;
}

#queueView.brand-yah,
.queue-toolbar.brand-yah,
.queue-brand-header.brand-yah {
  --queue-brand-bg: #f6f0ff;
  --queue-brand-strong: #5b21b6;
  --queue-brand-soft: #ede3ff;
  --queue-brand-line: #c4a8ff;
}

.queue-toolbar {
  background: var(--queue-brand-bg, #fbfdff);
  border-color: var(--queue-brand-line, #dbe5ef);
  box-shadow: none;
}

.queue-brand-header {
  align-items: center;
  background: var(--queue-brand-bg, #f8fafc);
  border: 1px solid var(--queue-brand-line, #dbe3ec);
  border-left: 4px solid var(--queue-brand-strong, #334155);
  border-radius: 8px;
  color: var(--queue-brand-strong, #334155);
  display: flex;
  gap: 10px;
  margin: -4px 0 14px;
  padding: 10px 14px;
}

.queue-brand-mark {
  align-items: center;
  background: var(--queue-brand-soft, #eef2f7);
  border: 1px solid var(--queue-brand-line, #dbe3ec);
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 900;
  height: 30px;
  justify-content: center;
  min-width: 30px;
  padding: 0 6px;
}

.queue-brand-copy {
  display: grid;
  gap: 2px;
}

.queue-brand-copy strong {
  font-size: 15px;
}

.queue-brand-copy small {
  color: var(--queue-brand-strong, #334155);
  font-size: 12px;
  opacity: 0.72;
}

.upload-form,
.filters,
.date-filters,
.inline-form,
.inventory-form,
.schedule-editor,
.operation-add-form {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.filters {
  justify-content: flex-end;
}

.batch-buttons {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.batch-chip,
.batch-export {
  min-height: 30px;
  padding: 0 9px;
}

.batch-chip {
  align-items: center;
  background: #fff;
  border-color: var(--line);
  border-radius: 8px;
  color: var(--text);
  display: inline-grid;
  gap: 8px;
  grid-template-columns: 30px minmax(74px, auto);
  line-height: 1.05;
  min-height: 42px;
  min-width: 124px;
  padding: 6px 10px;
  text-align: left;
}

.batch-chip-mark {
  align-items: center;
  background: #f1f5f9;
  border: 1px solid #dbe3ec;
  border-radius: 999px;
  color: #475569;
  display: inline-flex;
  font-size: 11px;
  font-weight: 900;
  height: 28px;
  justify-content: center;
  letter-spacing: 0;
  width: 28px;
}

.batch-chip-text {
  display: grid;
  gap: 2px;
}

.batch-chip-text strong,
.batch-chip-text small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-chip-text strong {
  font-size: 13px;
}

.batch-chip-text small {
  color: #64748b;
  font-size: 11px;
}

.batch-chip.active,
.batch-chip-wrap.active .batch-chip {
  box-shadow: inset 0 0 0 1px currentColor;
}

.batch-chip-wrap {
  align-items: center;
  display: inline-flex;
  gap: 4px;
}

.batch-chip-wrap.brand-froggy .batch-chip {
  background: #f1fbf2;
  border-color: #b9e7c2;
  color: #14532d;
}

.batch-chip-wrap.brand-froggy .batch-chip-mark {
  background: #daf5df;
  border-color: #8ed3a0;
  color: #166534;
}

.batch-chip-wrap.brand-murchan .batch-chip {
  background: #fff1f7;
  border-color: #f8c5d9;
  color: #9d174d;
}

.batch-chip-wrap.brand-murchan .batch-chip-mark {
  background: #fde2ee;
  border-color: #f3a6c6;
  color: #be185d;
}

.batch-chip-wrap.brand-yah .batch-chip {
  background: #f6f0ff;
  border-color: #dac5ff;
  color: #5b21b6;
}

.batch-chip-wrap.brand-yah .batch-chip-mark {
  background: #ede3ff;
  border-color: #c4a8ff;
  color: #6d28d9;
}

.batch-chip-wrap.brand-neutral .batch-chip {
  background: #f8fafc;
  border-color: #dbe3ec;
  color: #334155;
}

.batch-chip-wrap.active .batch-chip {
  border-width: 2px;
}

.batch-chip-wrap.active .batch-chip-text small {
  color: currentColor;
  opacity: 0.75;
}

.batch-export {
  align-items: center;
  background: #e8f7ef;
  border: 1px solid #b7e4c7;
  border-radius: 6px;
  color: #166534;
  display: inline-flex;
  font-size: 12px;
  font-weight: 900;
  text-decoration: none;
}

#searchInput {
  min-width: 240px;
}

.kpis {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  margin-bottom: 14px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-height: 78px;
  padding: 13px 14px;
}

.kpi:nth-child(2) {
  border-left-color: var(--green);
}

.kpi:nth-child(3) {
  border-left-color: var(--amber);
}

.kpi:nth-child(4) {
  border-left-color: #7c3aed;
}

.kpi span,
.salary-total span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.kpi strong {
  display: block;
  font-size: 28px;
  line-height: 1.2;
  margin-top: 4px;
}

.table-wrap,
.panel {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-width: 100%;
  max-height: 68vh;
}

.table-wrap::-webkit-scrollbar,
.panel::-webkit-scrollbar {
  height: 10px;
  width: 10px;
}

.table-wrap::-webkit-scrollbar-thumb,
.panel::-webkit-scrollbar-thumb {
  background: #b8c6d6;
  border: 2px solid #f8fafc;
  border-radius: 999px;
}

table {
  border-collapse: collapse;
  min-width: 100%;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 6px 7px;
  text-align: left;
  vertical-align: middle;
}

th {
  background: #f1f5f9;
  color: #334155;
  font-size: 12px;
  font-weight: 900;
  position: sticky;
  text-transform: uppercase;
  top: 0;
  z-index: 1;
}

tbody tr:hover {
  background: #f9fbfd;
}

.queue-table th:nth-child(1) {
  min-width: 150px;
}

.queue-table th:nth-child(2) {
  min-width: 70px;
}

.queue-table th:nth-child(3) {
  min-width: 260px;
}

.queue-table th:nth-child(4) {
  min-width: 135px;
}

.queue-table th:nth-child(5) {
  min-width: 190px;
}

.queue-table th:nth-child(6),
.queue-table th:nth-child(7) {
  min-width: 82px;
}

.queue-table th:nth-child(8) {
  min-width: 180px;
}

.op-cell {
  display: grid;
  gap: 7px;
  min-width: 150px;
}

.op-line {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.op-line strong {
  font-size: 13px;
  white-space: nowrap;
}

.progress {
  background: #e8edf3;
  border-radius: 999px;
  height: 7px;
  overflow: hidden;
  width: 100%;
}

.progress span {
  background: var(--green);
  display: block;
  height: 100%;
  width: 0;
}

.op-cell.print .progress span {
  background: var(--blue);
}

.op-cell.assemble .progress span {
  background: var(--amber);
}

.op-cell.cut .progress span {
  background: #0891b2;
}

.op-cell.pack .progress span {
  background: #7c3aed;
}

.op-cell.defect .progress span {
  background: var(--red);
}

.op-cell button {
  min-height: 32px;
  padding: 0 10px;
  width: 100%;
}

.performers {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 20px;
}

.employee-chip {
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-left: 6px solid var(--chip-color, var(--blue));
  border-radius: 6px;
  color: #263343;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  gap: 5px;
  min-height: 22px;
  max-width: 100%;
  padding: 2px 7px 2px 5px;
}

.employee-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stock-cell {
  display: grid;
  gap: 5px;
  min-width: 170px;
}

.stock-total {
  color: var(--green);
  font-weight: 900;
}

.stock-empty {
  color: var(--muted);
  font-size: 13px;
}

.stock-chip {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 6px;
  color: #166534;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  margin: 2px 4px 2px 0;
  padding: 3px 7px;
  white-space: nowrap;
}

.cell-info {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.cell-info strong {
  color: var(--text);
  font-size: 12px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.cell-info span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.source-block {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 12px;
  padding-top: 12px;
}

.source-block.hidden {
  display: none;
}

.inventory-form input {
  min-width: 130px;
}

.inventory-form #inventoryArticle {
  min-width: 220px;
}

.inventory-form #inventoryQty {
  min-width: 90px;
  width: 110px;
}

.inventory-form #inventoryPiecesPerTable {
  min-width: 110px;
  width: 130px;
}

.inventory-form #inventoryNote {
  min-width: 180px;
}

.inventory-bulk-form {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
}

.inventory-bulk-form input {
  min-width: 0;
}

.inventory-bulk-form input[type="text"] {
  flex: 1 1 150px;
  min-width: 150px;
}

.inventory-bulk-form input[type="number"] {
  flex: 0 1 120px;
  width: 120px;
}

#inventoryBulkSubmit {
  white-space: nowrap;
}

.bulk-operation-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 240px;
}

.bulk-operation-list label {
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 5px;
  display: inline-flex;
  gap: 5px;
  min-height: 30px;
  padding: 0 8px;
}

.employee-name {
  align-items: center;
  display: inline-flex;
  gap: 8px;
  min-width: 0;
}

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

.complete {
  color: var(--green);
  font-weight: 800;
}

.empty-row {
  color: var(--muted);
  height: 90px;
  text-align: center;
}

.split {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  margin: 14px 0;
}

.panel {
  padding: 14px;
}

.panel.narrow {
  max-width: 520px;
}

.salary-total {
  align-items: center;
  display: flex;
  gap: 14px;
  justify-content: space-between;
  margin-bottom: 14px;
  padding: 16px;
}

.salary-total-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  width: min(620px, 100%);
}

.salary-total strong {
  font-size: 28px;
}

.salary-pay-form {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.salary-pay-form input,
.salary-pay-form select {
  min-height: 36px;
}

.salary-pay-form input[type="number"] {
  width: 120px;
}

.salary-pay-form input[type="date"] {
  width: 145px;
}

.salary-pay-form input[type="text"] {
  width: 170px;
}

.salary-calendar-table th,
.salary-calendar-table td {
  text-align: right;
}

.salary-calendar-table th:first-child,
.salary-calendar-table td:first-child {
  text-align: left;
}

.salary-calendar-table .employee-name {
  justify-content: flex-end;
}

.salary-total-row td {
  background: #f8fafc;
  border-top: 2px solid #94a3b8;
}

.salary-cell-amount {
  font-weight: 700;
}

.front-money {
  color: #64748b;
  display: block;
  font-size: 11px;
  margin-top: 2px;
}

.front-day-toolbar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.front-day-toolbar input[type="date"] {
  min-height: 36px;
  width: 150px;
}

.front-date-label {
  color: #475569;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.calendar-icon-btn {
  align-items: center;
  aspect-ratio: 1;
  background: #eef6ff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  display: inline-flex;
  height: 36px;
  justify-content: center;
  padding: 0;
}

.calendar-icon-btn::before {
  background:
    linear-gradient(#3b82f6, #3b82f6) 0 4px / 100% 2px no-repeat,
    linear-gradient(90deg, transparent 4px, #bfdbfe 4px 6px, transparent 6px 10px, #bfdbfe 10px 12px, transparent 12px) 0 9px / 100% 8px no-repeat;
  border: 2px solid #2563eb;
  border-radius: 4px;
  content: "";
  height: 16px;
  width: 16px;
}

.calendar-icon-btn:hover {
  background: #dbeafe;
}

.salary-rate-off {
  color: #94a3b8;
}

.salary-rate-off td {
  background: #f8fafc;
}

.employee-week-panel {
  margin-top: 14px;
}

.backup-toolbar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.week-check-cell {
  text-align: center;
}

.week-check-cell input {
  height: 18px;
  width: 18px;
}

.schedule-badge {
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  color: #475569;
  display: inline-block;
  font-size: 11px;
  margin-top: 4px;
  padding: 2px 7px;
  white-space: nowrap;
}

.schedule-badge.off {
  background: #f1f5f9;
  color: #64748b;
}

.schedule-badge.swap {
  background: #fff7ed;
  border-color: #fed7aa;
  color: #9a3412;
}

.read-only-user .operation-rate-grid input:disabled,
.read-only-user .operation-rate-grid select:disabled {
  background: #f8fafc;
  color: #475569;
  opacity: 1;
}

.salary-calendar-panel {
  max-height: 420px;
  overflow: auto;
}

.panel-title-row {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.inline-form {
  margin-bottom: 14px;
  padding: 14px;
}

.employee-list {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
}

.employee-item {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  min-height: 58px;
  padding: 12px 14px;
}

.employee-item strong {
  overflow-wrap: anywhere;
}

.employee-item input[type="color"] {
  min-height: 34px;
}

.employee-card {
  align-items: stretch;
  flex-direction: column;
  gap: 10px;
}

.employee-card.inactive {
  opacity: 0.62;
}

.employee-edit-grid,
.employee-schedule-grid,
.employee-account-grid {
  align-items: end;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(170px, 1fr) 72px minmax(92px, auto);
  width: 100%;
}

.employee-schedule-grid {
  grid-template-columns: minmax(130px, 160px) minmax(120px, 160px) minmax(150px, auto);
}

.employee-account-panel {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 7px;
  width: 100%;
}

.employee-account-panel summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  list-style: none;
  padding: 9px 10px;
}

.employee-account-panel summary::-webkit-details-marker {
  display: none;
}

.employee-account-panel summary span {
  color: var(--text);
  font-weight: 800;
}

.employee-account-panel summary strong {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.employee-account-panel[open] summary {
  border-bottom: 1px solid var(--line);
}

.employee-account-grid {
  grid-template-columns: minmax(150px, 1fr) minmax(150px, 1fr) minmax(140px, auto) minmax(136px, auto);
  padding: 10px;
}

.account-save-btn {
  align-self: end;
}

#employeesView .inline-form > input {
  flex: 1 1 170px;
  min-width: 0;
}

#employeesView .inline-form > button {
  flex: 1 1 210px;
}

.employee-edit-grid label,
.employee-account-grid label,
.employee-schedule-grid input,
.employee-schedule-grid select,
.employee-account-grid button,
.employee-edit-grid button,
.employee-schedule-grid button {
  min-width: 0;
}

.employee-edit-grid input[type="text"],
.employee-account-grid input[type="text"],
.employee-account-grid input[type="password"],
.employee-schedule-grid input,
.employee-schedule-grid select {
  width: 100%;
}

.employee-edit-grid button,
.employee-schedule-grid button {
  white-space: nowrap;
}

.employee-active-label {
  align-items: center;
  display: flex;
  gap: 6px;
}

.log-edit {
  align-items: center;
  display: flex;
  gap: 6px;
}

.log-edit select,
.log-edit input {
  min-height: 30px;
}

.log-edit button {
  min-height: 30px;
  padding: 0 8px;
}

.log-cell-entry {
  display: grid;
  gap: 4px;
  min-width: 190px;
}

.log-cell-entry + .log-cell-entry {
  border-top: 1px solid var(--border);
  margin-top: 7px;
  padding-top: 7px;
}

.log-cell-entry span {
  color: var(--muted);
  font-size: 12px;
}

.badge {
  background: var(--surface-2);
  border-radius: 999px;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
  padding: 5px 9px;
}

.operation-settings {
  display: grid;
  gap: 12px;
}

.setting-row {
  align-items: end;
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 130px 96px;
}

dialog {
  border: 0;
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.3);
  max-width: 440px;
  padding: 0;
  width: calc(100% - 28px);
}

dialog:has(.wide-dialog) {
  max-width: 820px;
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

dialog form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

dialog p {
  color: var(--muted);
  margin: 0;
}

dialog menu {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin: 0;
  padding: 0;
}

#toast {
  background: #101820;
  border-radius: 8px;
  bottom: 18px;
  box-shadow: var(--shadow);
  color: #fff;
  left: 50%;
  max-width: min(520px, calc(100% - 28px));
  opacity: 0;
  padding: 12px 14px;
  pointer-events: none;
  position: fixed;
  transform: translate(-50%, 12px);
  transition: 0.18s ease;
  z-index: 10;
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

#toast.error {
  background: var(--red);
}

@media (max-width: 900px) {
  .app-header,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .session-bar,
  .filters,
  .upload-form,
  .date-filters {
    justify-content: stretch;
  }

  .session-bar > *,
  .filters > *,
  .upload-form > *,
  .date-filters > * {
    flex: 1 1 180px;
  }

  .kpis,
  .split {
    grid-template-columns: 1fr;
  }

  #searchInput {
    min-width: 0;
  }

  .employee-edit-grid,
  .employee-schedule-grid,
  .employee-account-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .employee-edit-grid label:first-child,
  .employee-schedule-grid input[type="text"],
  .employee-edit-grid button,
  .employee-schedule-grid button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 620px) {
  :root {
    --queue-number-width: 26px;
    --queue-product-left: 33px;
    --queue-product-width: 132px;
  }

  main {
    padding: 12px 10px 36px;
  }

  .tabs {
    padding: 0 8px;
  }

  .brand {
    min-width: 0;
  }

  .brand-mark {
    height: 38px;
    width: 38px;
  }

  h1 {
    font-size: 18px;
  }

  .setting-row {
    grid-template-columns: 1fr;
  }

  .employee-edit-grid,
  .employee-schedule-grid,
  .employee-account-grid {
    grid-template-columns: 1fr;
  }

  .employee-edit-grid label:first-child,
  .employee-schedule-grid input[type="text"],
  .employee-edit-grid button,
  .employee-schedule-grid button {
    grid-column: auto;
  }
}

.hidden {
  display: none !important;
}

.operation-add-form {
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
  padding-bottom: 14px;
}

.item-type-form {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 10px;
}

.item-type-form input {
  min-width: 260px;
}

.item-type-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.item-type-chip {
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 5px;
  color: #3730a3;
  font-size: 12px;
  font-weight: 800;
  padding: 5px 8px;
}

.operation-add-form input:first-child {
  min-width: 240px;
}

.setting-row {
  grid-template-columns: minmax(160px, 1fr) 110px 120px minmax(190px, 1fr) minmax(150px, auto);
}

.setting-row input[type="text"] {
  width: 100%;
}

.setting-actions {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.subject-rules-input {
  min-height: 54px;
  min-width: 220px;
  resize: vertical;
  width: 100%;
}

.queue-table {
  font-size: 13px;
  min-width: var(--queue-table-min-width, 1360px);
  table-layout: fixed;
  width: max(100%, var(--queue-table-min-width, 1360px));
}

.queue-table th,
.queue-table td {
  padding: 7px 8px;
}

.queue-table th:nth-child(1),
.queue-table th:nth-child(2),
.queue-table th:nth-child(3),
.queue-table th:nth-child(4),
.queue-table th:nth-child(5),
.queue-table th:nth-child(6),
.queue-table th:nth-child(7),
.queue-table th:nth-child(8) {
  min-width: 0;
}

.queue-table th:nth-child(1) {
  width: 25%;
}

.queue-table th:nth-child(2) {
  width: 12%;
}

.queue-table th:nth-child(3) {
  width: 8%;
}

.queue-table th:nth-child(4) {
  width: 13%;
}

.queue-table th:nth-child(5),
.queue-table th:nth-child(6),
.queue-table th:nth-child(7) {
  width: 11%;
}

.queue-table th:nth-child(8) {
  width: 9%;
}

.product-cell,
.qty-cell,
.extra-cell {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.product-title {
  color: var(--text);
  font-weight: 900;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.meta-line {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.qty-cell strong {
  font-size: 17px;
}

.op-cell {
  gap: 5px;
  min-width: 0;
}

.op-line {
  gap: 5px;
}

.op-line strong,
.op-line span,
.op-cell .muted {
  font-size: 12px;
}

.op-cell button,
.extra-cell button {
  min-height: 30px;
  padding: 0 8px;
  width: 100%;
}

.stock-cell {
  min-width: 0;
}

.stock-chip,
.employee-chip {
  max-width: 100%;
}

@media (max-width: 1180px) {
  .queue-table {
    font-size: 12px;
  }

  .queue-table th,
  .queue-table td {
    padding: 6px;
  }

  .product-title {
    font-size: 12px;
  }

  .meta-line,
  .op-line strong,
  .op-line span,
  .op-cell .muted {
    font-size: 11px;
  }

  .performers,
  .progress {
    display: none;
  }
}

.queue-table th.city-head,
.queue-table td.city-qty {
  text-align: center;
  width: 5.4%;
}

.queue-table th.order-head,
.queue-table td.order-cell {
  background: #fff7d6;
  border-left: 2px solid #f5b700;
  border-right: 2px solid #f5b700;
  color: #3d2f00;
  text-align: center;
  width: 7%;
}

.queue-table th.stock-head {
  width: 9%;
}

.queue-table th.subject-head,
.queue-table td.subject-cell {
  background: #f8fafc;
  font-weight: 800;
  text-align: center;
  width: 7%;
}

.queue-table th.op-head {
  width: 8.4%;
}

.queue-table th.defect-head {
  width: 7%;
}

.queue-table th.cell-head {
  width: 7%;
}

.city-qty {
  font-weight: 800;
}

.city-allocate-btn {
  background: transparent;
  border: 0;
  color: inherit;
  display: grid;
  gap: 1px;
  min-height: 30px;
  padding: 0;
  width: 100%;
}

.city-allocate-btn span {
  font-size: 12px;
  font-weight: 900;
}

.city-allocate-btn small {
  color: var(--muted);
  font-size: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.city-complete .city-allocate-btn {
  color: var(--green);
  text-decoration: line-through;
}

.empty-city {
  background: #f8fafc;
}

.order-cell strong {
  font-size: 18px;
}

.inventory-form #inventoryCategory {
  min-width: 140px;
}

/* Compact Excel-like queue */
.queue-table {
  border: 1px solid #cbd5e1;
  border-collapse: collapse;
  font-size: 12px;
  min-width: var(--queue-table-min-width, 1360px);
  table-layout: fixed;
  width: max(100%, var(--queue-table-min-width, 1360px));
}

.queue-table th,
.queue-table td {
  background: #fff;
  border: 1px solid #cbd5e1;
  height: 38px;
  padding: 3px 5px;
  vertical-align: middle;
}

.queue-table th {
  background: #eef2f7;
  color: #1f2937;
  font-size: 11px;
  letter-spacing: 0;
  line-height: 1.15;
  text-transform: none;
}

#queueView.brand-froggy .queue-table th,
#queueView.brand-murchan .queue-table th,
#queueView.brand-yah .queue-table th,
#queueView.brand-neutral .queue-table th {
  background: var(--queue-brand-soft, #eef2f7);
  border-color: var(--queue-brand-line, #cbd5e1);
  color: var(--queue-brand-strong, #1f2937);
}

#queueView.brand-froggy .kpi,
#queueView.brand-murchan .kpi,
#queueView.brand-yah .kpi,
#queueView.brand-neutral .kpi {
  border-color: var(--queue-brand-line, #dbe3ec);
}

#queueView.brand-froggy .kpi span,
#queueView.brand-murchan .kpi span,
#queueView.brand-yah .kpi span,
#queueView.brand-neutral .kpi span {
  color: var(--queue-brand-strong, #334155);
}

.queue-table th.number-head,
.queue-table td.row-number {
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
  min-width: var(--queue-number-width);
  text-align: center;
  width: var(--queue-number-width);
}

.queue-table th.number-head {
  max-width: var(--queue-number-width);
}

.queue-table th:nth-child(2),
.queue-table td.product-cell-wrap {
  min-width: var(--queue-product-width);
  width: var(--queue-product-width);
}

.queue-table td.product-cell-wrap {
  cursor: context-menu;
}

.queue-table td.product-cell-wrap.print-sheet-taken {
  background: #e5e7eb;
}

.queue-table tbody tr:hover td.product-cell-wrap.print-sheet-taken {
  background: #dbe1e8;
}

.print-sheet-note {
  align-items: center;
  color: #475569;
  display: flex;
  font-size: 10px;
  margin-top: 2px;
}

.queue-table tbody tr:hover td {
  background: #f8fafc;
}

.queue-table .product-cell,
.queue-table .stock-cell,
.queue-table .cell-info,
.queue-table .op-cell {
  gap: 2px;
}

.queue-table .product-title {
  font-size: 12px;
  font-weight: 800;
  line-height: 1.15;
}

.queue-table .meta-line,
.queue-table .stock-empty,
.queue-table .cell-info span,
.queue-table .op-detail,
.queue-table .op-dates,
.queue-table .op-line span {
  color: #64748b;
  font-size: 10px;
  line-height: 1.1;
}

.queue-table .op-dates {
  color: #334155;
  font-weight: 700;
  white-space: nowrap;
}

.queue-table .op-cell {
  align-content: center;
  min-height: 34px;
  min-width: 0;
}

.queue-table .op-na {
  color: #94a3b8;
  font-size: 14px;
  font-weight: 800;
  justify-content: center;
  text-align: center;
}

.queue-table .op-line {
  gap: 4px;
}

.queue-table .op-line strong {
  font-size: 11px;
}

.queue-table .progress {
  display: none;
}

.queue-table .op-cell button,
.queue-table .extra-cell button,
.queue-table .city-allocate-btn {
  border-radius: 4px;
  font-size: 11px;
  min-height: 22px;
  padding: 0 5px;
}

.queue-table .edit-work-btn {
  background: #f8fafc;
  color: #475569;
}

button.danger {
  background: #fee2e2;
  color: #991b1b;
}

.queue-table .performers,
.queue-table .employee-chip {
  display: none;
}

.performer-dots {
  display: flex;
  gap: 3px;
  min-height: 8px;
}

.performer-dot {
  background: var(--chip-color, var(--blue));
  border: 1px solid rgba(15, 23, 42, 0.16);
  border-radius: 999px;
  display: inline-block;
  height: 8px;
  width: 8px;
}

.queue-table .stock-total {
  color: #15803d;
  font-size: 12px;
  line-height: 1;
}

.queue-table .stock-list {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}

.queue-table .stock-chip {
  border-radius: 3px;
  font-size: 10px;
  margin: 0;
  padding: 1px 3px;
}

.queue-table th.order-head,
.queue-table td.order-cell {
  background: #fff7d6;
  border: 2px solid #eab308;
}

.queue-table .order-cell strong {
  font-size: 14px;
}

.queue-table td.order-cell.order-complete {
  background: #ecfdf3;
  border-color: #22c55e;
  color: #15803d;
}

.queue-table td.order-cell.order-complete strong {
  color: #15803d;
  text-decoration: line-through;
}

.queue-table td.order-cell.order-complete small {
  color: #15803d;
  display: block;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.1;
  margin-top: 2px;
}

.queue-table .city-allocate-btn {
  gap: 0;
  min-height: 24px;
}

.queue-table .city-allocate-btn span {
  font-size: 11px;
}

.queue-table .city-allocate-btn small {
  display: none;
}

.queue-table .city-complete .city-allocate-btn {
  color: #15803d;
  text-decoration: line-through;
}

.queue-table td.city-complete {
  background: #ecfdf3;
}

.queue-table td.city-prepared {
  background: #edf6ff;
}

.queue-table td.city-prepared .city-allocate-btn {
  color: #1d4ed8;
  text-decoration: none;
}

.queue-table td.city-partial {
  background: #f8fafc;
}

.queue-table td.city-partial .city-allocate-btn {
  color: #475569;
}

.queue-table td.city-shortage {
  background: #fff7ed;
}

.queue-table td.city-shortage .city-allocate-btn {
  color: #9a5a00;
}

.queue-table .op-cell.op-stock-warning {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  padding: 4px;
}

.stock-warning-badge,
.stock-taken-badge {
  border-radius: 999px;
  display: inline-flex;
  font-size: 10px;
  font-weight: 900;
  line-height: 1.2;
  padding: 2px 7px;
  width: fit-content;
}

.stock-warning-badge {
  background: #fff7ed;
  border: 1px solid #fdba74;
  color: #9a3412;
}

.stock-taken-badge {
  background: #ecfdf3;
  border: 1px solid #86efac;
  color: #166534;
}

.queue-table td.cell-stock-highlight {
  background: #ecfdf3;
  box-shadow: inset 0 0 0 1px #86efac;
}

.operation-settings .setting-row {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

.operation-rate-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  gap: 10px;
  padding: 10px;
}

.operation-rate-head {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(140px, 1fr) auto auto;
}

.operation-rate-head span {
  color: var(--muted);
  font-size: 13px;
}

.operation-rate-details summary {
  cursor: pointer;
  font-weight: 800;
  padding: 6px 0;
}

.operation-rate-grid {
  align-items: center;
  display: grid;
  gap: 6px 8px;
  grid-template-columns: minmax(170px, 1fr) 74px 110px 120px;
}

.rate-grid-head {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.rate-item-type {
  font-weight: 700;
}

.rate-active {
  align-items: center;
  display: flex;
  justify-content: center;
}

.operation-items-field input {
  border-color: #94a3b8;
}

.operation-type-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.operation-type-dropdown {
  margin-top: 6px;
}

.operation-type-dropdown summary {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 5px;
  cursor: pointer;
  font-weight: 800;
  min-height: 32px;
  padding: 7px 9px;
}

.operation-type-dropdown[open] summary {
  border-color: #94a3b8;
}

.operation-type-picker label {
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 5px;
  display: inline-flex;
  gap: 5px;
  min-height: 28px;
  padding: 0 7px;
}

.subject-operation-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.subject-operation-list label {
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 5px;
  display: inline-flex;
  gap: 5px;
  min-height: 30px;
  padding: 0 8px;
}

@media (max-width: 900px) {
  .setting-row {
    grid-template-columns: 1fr;
  }

  .operation-rate-head,
  .operation-rate-grid {
    grid-template-columns: 1fr;
  }

  .rate-grid-head {
    display: none;
  }
}

/* Pro readability pass */
:root {
  --bg: #eef3f8;
  --surface: #ffffff;
  --surface-2: #f5f8fb;
  --line: #c9d4e1;
  --line-strong: #9fb0c4;
  --text: #111827;
  --muted: #5b6b7f;
  --blue: #1f5fd6;
  --green: #147a3d;
  --amber: #a85f00;
  --red: #b42318;
  --shadow: 0 8px 22px rgba(24, 39, 63, 0.07);
}

body {
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.app-header {
  background: #17202b;
  border-bottom: 1px solid #243244;
  min-height: 68px;
}

.brand-mark {
  background: #e9f8ef;
  border: 1px solid #9edbb6;
  color: #14532d;
}

.tabs {
  background: #f8fafc;
  border-bottom: 1px solid var(--line-strong);
  gap: 0;
  padding: 0 12px;
}

.tab {
  border-left: 1px solid transparent;
  border-right: 1px solid transparent;
  color: #48576a;
  font-size: 13px;
  min-height: 42px;
  padding: 0 14px;
}

.tab.active {
  background: #fff;
  border-left-color: var(--line);
  border-right-color: var(--line);
  color: #0f172a;
}

.band,
.panel,
.salary-total,
.table-wrap,
.kpi {
  border-color: var(--line);
  border-radius: 7px;
  box-shadow: var(--shadow);
}

.toolbar,
.inline-form {
  padding: 10px;
}

button,
.button-link,
input,
select {
  border-radius: 5px;
  min-height: 34px;
}

button,
.button-link {
  font-size: 13px;
  font-weight: 800;
  padding: 0 12px;
}

button.secondary {
  background: #f8fafc;
  border-color: #b9c6d6;
}

input,
select {
  border-color: #b8c6d6;
  box-shadow: inset 0 1px 0 rgba(15, 23, 42, 0.03);
}

input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(31, 95, 214, 0.14);
  outline: none;
}

.kpis {
  gap: 8px;
  margin-bottom: 10px;
}

.kpi {
  min-height: 66px;
  padding: 10px 12px;
}

.kpi strong {
  font-size: 24px;
}

.table-wrap {
  max-height: 72vh;
}

table {
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  border-bottom: 1px solid var(--line);
}

th {
  background: #e8eef6;
  border-bottom: 1px solid var(--line-strong);
  color: #233044;
}

tbody tr:nth-child(even) td {
  background: #fbfdff;
}

tbody tr:hover td {
  background: #edf5ff;
}

.queue-table {
  border-color: var(--line-strong);
  color: #172033;
  font-size: 12px;
}

.queue-table th,
.queue-table td {
  border-color: #b8c5d3;
  height: 34px;
  padding: 3px 5px;
}

.queue-table th {
  background: #dfe8f3;
  color: #172033;
  font-weight: 900;
}

#queueView.brand-froggy .queue-table th {
  background: #e4f6e8;
  border-color: #a9dcb6;
  color: #14532d;
}

#queueView.brand-murchan .queue-table th {
  background: #fde7f1;
  border-color: #efb4cd;
  color: #9d174d;
}

#queueView.brand-yah .queue-table th {
  background: #efe7ff;
  border-color: #c8b6f6;
  color: #5b21b6;
}

.queue-table td.product-cell-wrap {
  background: #fff;
}

.queue-table td.product-cell-wrap.print-sheet-taken {
  background: #e1e5eb;
}

.queue-table th.number-head,
.queue-table td.row-number {
  left: 0;
  position: sticky;
}

.queue-table th:nth-child(2),
.queue-table td.product-cell-wrap {
  left: var(--queue-product-left);
  position: sticky;
}

.queue-table th.number-head,
.queue-table th:nth-child(2) {
  z-index: 7;
}

.queue-table td.row-number {
  background: #f8fafc;
  z-index: 4;
}

.queue-table td.product-cell-wrap {
  box-shadow: 1px 0 0 #b8c5d3;
  z-index: 4;
}

.queue-table tbody tr:hover td.row-number,
.queue-table tbody tr:hover td.product-cell-wrap {
  background: #edf5ff;
}

.queue-table tbody tr:hover td.product-cell-wrap.print-sheet-taken {
  background: #dbe1e8;
}

.queue-table .product-title {
  color: #0f172a;
  font-size: 12px;
}

.queue-table .meta-line {
  color: #596a80;
}

.queue-table td.subject-cell {
  background: #f2f6fb;
  color: #26364b;
}

.queue-table th.order-head,
.queue-table td.order-cell {
  background: #fff4bd;
  border-color: #d8a400;
}

.queue-table td.city-complete {
  background: #e8f6ee;
}

.queue-table td.city-prepared {
  background: #eaf4ff;
}

.queue-table td.city-partial {
  background: #f8fafc;
}

.queue-table td.city-shortage {
  background: #fff4e2;
}

.queue-table .op-cell button {
  min-height: 23px;
}

.queue-table .op-line strong {
  color: #111827;
}

.queue-table .stock-chip {
  background: #edf6ff;
  border-color: #c7dff8;
  color: #17466d;
}

.inventory-form,
.inventory-bulk-form,
#employeesView .inline-form {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px;
}

.employee-card {
  border-color: #b9c6d6;
  box-shadow: 0 4px 14px rgba(24, 39, 63, 0.06);
}

.employee-edit-grid,
.employee-schedule-grid,
.employee-account-grid {
  background: #f8fafc;
  border: 1px solid #d8e1ec;
  border-radius: 6px;
  padding: 8px;
}

.employee-edit-grid {
  grid-template-columns: minmax(160px, 1fr) 76px minmax(110px, auto);
}

.employee-account-grid {
  background: #fff;
  border: 0;
  grid-template-columns: minmax(150px, 1fr) minmax(150px, 1fr) minmax(140px, auto) minmax(136px, auto);
  padding: 10px;
}

.activity-panel {
  max-height: 68vh;
  overflow: auto;
}

.activity-table {
  min-width: 920px;
}

.activity-table td small {
  color: var(--muted);
  display: block;
  font-size: 11px;
  margin-top: 3px;
  max-width: 420px;
  overflow-wrap: anywhere;
}

.employee-schedule-grid {
  background: #fff;
}

.salary-total-grid > div,
.backup-toolbar {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

#salaryView.view.active {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(380px, 0.9fr) minmax(520px, 1.35fr);
}

#salaryView > .toolbar,
#salaryView > .salary-total,
#salaryView > .salary-payments-panel,
#salaryView > .salary-rates-panel,
#salaryView > .salary-log-panel {
  grid-column: 1 / -1;
}

.salary-calendar-panel {
  max-height: 560px;
  order: 3;
}

.front-work-panel {
  max-height: 560px;
  order: 4;
}

.salary-payments-panel {
  order: 5;
}

.salary-rates-panel {
  order: 6;
}

.salary-log-panel {
  order: 7;
}

.salary-calendar-table th,
.salary-calendar-table td {
  border-color: #b8c5d3;
  padding: 6px 8px;
}

.salary-calendar-day {
  cursor: pointer;
}

.salary-calendar-day td:first-child {
  color: #1f5fd6;
}

.salary-calendar-day.selected td {
  background: #dcecff;
  box-shadow: inset 0 0 0 1px #8bbcff;
}

.salary-calendar-day:hover td {
  background: #edf6ff;
}

.salary-calendar-table {
  table-layout: fixed;
}

.salary-calendar-table th {
  text-align: center;
}

.salary-month-empty {
  background: #f8fafc;
}

.salary-month-day {
  height: 118px;
  padding: 0 !important;
  vertical-align: top;
}

.salary-month-day.selected {
  box-shadow: inset 0 0 0 2px #2563eb;
}

.salary-month-button {
  align-items: flex-start;
  background: transparent;
  border: 0;
  color: inherit;
  display: grid;
  gap: 5px;
  height: 100%;
  justify-items: start;
  padding: 8px;
  text-align: left;
  width: 100%;
}

.salary-month-button:hover {
  background: #f8fafc;
}

.salary-month-number {
  align-items: center;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  color: #1e3a8a;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  height: 24px;
  justify-content: center;
  width: 24px;
}

.salary-month-day.has-money .salary-month-number {
  background: #dcfce7;
  border-color: #86efac;
  color: #166534;
}

.salary-month-button strong {
  color: #0f172a;
  font-size: 13px;
}

.salary-month-workers {
  align-content: start;
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  min-height: 18px;
}

.salary-mini-person {
  border-left: 3px solid var(--chip-color, #64748b);
  color: #334155;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.1;
  padding-left: 4px;
}

.salary-month-button small {
  color: #64748b;
  font-size: 10px;
  margin-top: auto;
}

.salary-day-dialog-form {
  max-width: 760px;
}

.salary-day-summary {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 10px 0 14px;
}

.salary-day-summary div {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px;
}

.salary-day-summary span {
  color: #64748b;
  display: block;
  font-size: 12px;
}

.salary-day-workers {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.salary-day-person {
  align-items: center;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  display: grid;
  gap: 4px;
  grid-template-columns: minmax(0, 1fr) auto auto;
  padding: 8px;
}

.salary-day-person.off {
  background: #f8fafc;
  color: #64748b;
}

.salary-day-person.working {
  background: #f0fdf4;
}

.salary-day-person span {
  font-size: 12px;
}

.salary-day-swap {
  border-top: 1px solid #e2e8f0;
  margin-top: 14px;
  padding-top: 12px;
}

.salary-day-swap h3 {
  font-size: 14px;
  margin: 0 0 8px;
}

.salary-day-swap-row {
  align-items: end;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
}

@media (max-width: 900px) {
  .salary-month-day {
    height: 96px;
  }

  .salary-month-button {
    padding: 6px;
  }

  .salary-day-summary,
  .salary-day-workers,
  .salary-day-swap-row {
    grid-template-columns: 1fr;
  }
}

.front-summary {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, minmax(110px, 1fr));
  margin: 0 0 10px;
}

.front-summary div {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
}

.front-summary span {
  color: var(--muted);
  display: block;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.front-summary strong {
  display: block;
  font-size: 15px;
  margin-top: 3px;
}

.front-work-panel table th:first-child,
.front-work-panel table td:first-child,
.front-work-panel table th:nth-child(2),
.front-work-panel table td:nth-child(2) {
  position: sticky;
  z-index: 1;
}

.front-work-panel table th:first-child,
.front-work-panel table td:first-child {
  left: 0;
}

.front-work-panel table th:nth-child(2),
.front-work-panel table td:nth-child(2) {
  left: 132px;
}

.front-work-panel table td:first-child,
.front-work-panel table td:nth-child(2) {
  background: #fff;
}

.front-work-panel table th:first-child,
.front-work-panel table th:nth-child(2) {
  background: #e8eef6;
  z-index: 3;
}

.employee-schedule-grid {
  grid-template-columns: minmax(150px, 180px) minmax(130px, 170px);
}

.employee-schedule-grid button {
  grid-column: 1;
  grid-row: 2;
  width: 100%;
}

.employee-schedule-grid select {
  grid-column: 2;
  grid-row: 1;
}

.filters #inventorySearch {
  min-width: 220px;
}

.filters #inventoryCategoryFilter {
  min-width: 170px;
}

.filters #inventorySort,
.filters #inventoryDirection {
  min-width: 150px;
}

.filters {
  background: #eef5ff;
  border: 1px solid #b9d3f5;
  border-radius: 7px;
  padding: 8px;
}

.sort-caption {
  color: #1e3a5f;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.inventory-table-panel {
  overflow: auto;
}

.compact-front-table {
  table-layout: fixed;
}

.compact-front-table th:nth-child(1),
.compact-front-table td:nth-child(1) {
  width: 24%;
}

.compact-front-table th:nth-child(2),
.compact-front-table td:nth-child(2) {
  width: 52%;
}

.compact-front-table th:nth-child(3),
.compact-front-table td:nth-child(3) {
  width: 24%;
}

.compact-front-table td strong {
  display: block;
}

.compact-front-table td small,
.salary-log-panel td small {
  color: var(--muted);
  display: block;
  font-size: 11px;
  line-height: 1.25;
  margin-top: 2px;
}

.front-details summary {
  color: var(--blue);
  cursor: pointer;
  font-weight: 900;
}

.front-detail-list {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.front-detail-line {
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 5px;
  display: grid;
  gap: 6px;
  grid-template-columns: minmax(120px, 1fr) auto auto auto;
  padding: 6px 8px;
}

.employee-front-table .front-detail-list {
  gap: 8px;
}

.front-operation-group {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  gap: 5px;
  padding: 7px;
}

.front-operation-group > strong {
  color: #0f172a;
  font-size: 12px;
}

.front-work-item {
  align-items: baseline;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 5px;
  display: grid;
  gap: 5px;
  grid-template-columns: minmax(70px, auto) minmax(0, 1fr);
  padding: 5px 7px;
}

.front-work-item span {
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 900;
}

.front-work-item b {
  color: #0f172a;
  font-size: 12px;
  min-width: 0;
}

.front-work-item small {
  grid-column: 2;
  margin-top: 0;
}

.front-work-file {
  background: #eef6ff;
  border: 1px solid #c7dff8;
  border-radius: 999px;
  color: #17466d;
  display: inline-flex;
  font-size: 10px;
  font-weight: 900;
  line-height: 1.2;
  margin-right: 2px;
  padding: 1px 6px;
}

.conflicts-table td small {
  color: var(--muted);
  display: block;
  font-size: 11px;
  line-height: 1.25;
  margin-top: 2px;
}

.conflicts-table tbody tr {
  background: #fff7ed;
}

.conflicts-table tbody tr:nth-child(even) td {
  background: #fffaf2;
}

.conflicts-table td:nth-child(7) strong {
  color: #b42318;
}

.front-work-panel .employee-front-table th:first-child,
.front-work-panel .employee-front-table td:first-child,
.front-work-panel .employee-front-table th:nth-child(2),
.front-work-panel .employee-front-table td:nth-child(2) {
  left: auto;
  position: static;
  z-index: auto;
}

.front-articles {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.front-articles span {
  background: #eef2f7;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #334155;
  font-size: 11px;
  padding: 2px 7px;
}

.salary-people-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.salary-person-chip {
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  gap: 5px;
  min-height: 28px;
  padding: 3px 8px;
}

.salary-person-chip .employee-name {
  gap: 5px;
}

.salary-person-chip .color-dot {
  height: 14px;
  width: 14px;
}

.salary-person-chip strong {
  font-size: 12px;
}

#salaryView.view.active {
  grid-template-columns: 1fr;
}

.salary-calendar-panel,
.front-work-panel {
  max-height: none;
}

.front-work-panel,
.salary-calendar-panel {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.front-work-panel table th:first-child,
.front-work-panel table td:first-child,
.front-work-panel table th:nth-child(2),
.front-work-panel table td:nth-child(2) {
  left: auto;
  position: static;
  z-index: auto;
}

.salary-log-panel {
  max-height: 460px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.salary-payments-panel,
.salary-rates-panel {
  max-height: 360px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

#salaryView .salary-calendar-table {
  min-width: 720px;
}

#salaryView .front-work-panel table {
  min-width: 820px;
}

#salaryView .salary-payments-panel table,
#salaryView .salary-rates-panel table {
  min-width: 720px;
}

#salaryView .salary-log-panel table {
  min-width: 980px;
}

@media (max-width: 1180px) {
  #salaryView.view.active {
    grid-template-columns: 1fr;
  }

  #salaryView > * {
    grid-column: 1;
  }
}

@media (max-width: 760px) {
  body {
    overflow-x: hidden;
  }

  main {
    padding: 8px 8px 28px;
  }

  .app-header {
    align-items: stretch;
    display: grid;
    gap: 10px;
    min-height: 0;
    padding: 10px;
  }

  .brand {
    min-width: 0;
  }

  .session-bar,
  .toolbar,
  .filters,
  .salary-pay-form,
  .upload-form {
    align-items: stretch;
    display: grid;
    grid-template-columns: 1fr;
  }

  .session-bar label,
  .session-bar input,
  .session-bar select,
  .session-bar button,
  .toolbar input,
  .toolbar select,
  .toolbar button,
  .filters input,
  .filters select,
  .filters button {
    min-width: 0;
    width: 100%;
  }

  .tabs {
    padding: 0 8px;
  }

  .tab {
    flex: 0 0 auto;
  }

  .kpis,
  .salary-total-grid,
  .front-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .table-wrap {
    max-height: calc(100dvh - 310px);
    min-height: 280px;
  }

  .queue-table {
    font-size: 11px;
  }

  .salary-calendar-panel,
  .front-work-panel,
  .salary-log-panel,
  .salary-payments-panel,
  .salary-rates-panel,
  .inventory-table-panel {
    max-width: 100%;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .salary-calendar-panel,
  .front-work-panel {
    max-height: 72dvh;
  }

  .salary-payments-panel,
  .salary-rates-panel,
  .salary-log-panel {
    max-height: 58dvh;
  }
}

@media (max-width: 620px) {
  :root {
    --queue-number-width: 26px;
    --queue-product-left: 33px;
    --queue-product-width: 132px;
  }

  .employee-edit-grid,
  .employee-account-grid,
  .employee-schedule-grid {
    grid-template-columns: 1fr;
  }

  .employee-edit-grid button {
    width: 100%;
  }

  .account-save-btn {
    width: 100%;
  }

  .employee-account-panel summary {
    align-items: flex-start;
    flex-direction: column;
  }

  .employee-schedule-grid button,
  .employee-schedule-grid select {
    grid-column: 1;
    grid-row: auto;
  }
}
