@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700&display=swap');

:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --border: #2d3f56;
  --text: #e8edf4;
  --text-muted: #8b9cb3;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --accent: #10b981;
  --accent-dim: rgba(16, 185, 129, 0.15);
  --danger: #ef4444;
  --highlight: #fbbf24;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Vazirmatn', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  direction: rtl;
  line-height: 1.6;
}

.app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

header {
  text-align: center;
  margin-bottom: 32px;
}

header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

header p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

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

.tabs {
  display: flex;
  gap: 8px;
  background: var(--surface);
  padding: 6px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.tab-btn {
  padding: 10px 20px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn:hover {
  color: var(--text);
  background: var(--surface2);
}

.tab-btn.active {
  background: var(--primary);
  color: white;
}

.actions {
  display: flex;
  gap: 10px;
}

.btn {
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-accent {
  background: var(--accent);
  color: white;
}

.btn-accent:hover {
  background: #0d9668;
}

.btn-sm {
  padding: 7px 14px;
  font-size: 0.8rem;
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  font-size: 0.8rem;
  padding: 8px 14px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.card-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-group label {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

select.inp,
input.inp {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  padding: 8px 12px;
  transition: border-color 0.2s;
}

select.inp:focus,
input.inp:focus {
  outline: none;
  border-color: var(--primary);
}

input.inp {
  width: 100%;
}

input.inp.inp-num {
  width: auto;
  max-width: 100%;
  min-width: 0;
  text-align: left;
  direction: ltr;
  font-variant-numeric: tabular-nums;
  field-sizing: content;
  padding-inline: 10px;
}

#work-days.inp-num,
.month-work-days.inp-num {
  min-width: 6.5ch;
  width: 6.5ch;
  font-size: 0.95rem;
  text-align: center;
  padding-inline: 12px;
}

.emp-work-days.inp-num {
  min-width: 5.5ch;
  width: 5.5ch;
  font-size: 0.95rem;
  text-align: center;
}

input.inp[type='number'] {
  width: auto;
  text-align: left;
  direction: ltr;
  font-variant-numeric: tabular-nums;
}

table td:has(> .inp-num),
table td:has(.inp-num) {
  width: 1%;
  white-space: nowrap;
}

table.col-resizable td:has(> .inp-num),
table.col-resizable td:has(.inp-num) {
  width: auto;
  white-space: nowrap;
}

table.col-resizable {
  table-layout: fixed;
}

table.col-resizable th {
  position: relative;
  overflow: visible;
}

.col-resize-handle {
  position: absolute;
  left: -3px;
  top: 0;
  bottom: 0;
  width: 7px;
  cursor: col-resize;
  z-index: 4;
  touch-action: none;
}

.col-resize-handle::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 18%;
  bottom: 18%;
  width: 2px;
  border-radius: 1px;
  background: transparent;
  transition: background 0.15s;
}

.col-resize-handle:hover::after,
body.col-resizing .col-resize-handle::after {
  background: var(--primary);
}

body.col-resizing {
  cursor: col-resize !important;
  user-select: none;
}

body.col-resizing * {
  cursor: col-resize !important;
}

.col-resize-hint {
  margin-bottom: 12px !important;
  font-size: 0.8rem;
  color: var(--text-muted);
}

table.col-resizable td .inp,
table.col-resizable td .inp.inp-num {
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  box-sizing: border-box;
}

table.col-resizable.codes-table .code-input,
table.col-resizable .code-input {
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
}

input.inp.inp-hours {
  font-weight: 600;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  direction: ltr;
  text-align: center;
}

.table-wrap {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead {
  background: var(--surface2);
}

th {
  padding: 12px 10px;
  text-align: right;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 10px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:hover {
  background: rgba(59, 130, 246, 0.05);
}

tbody tr:last-child td {
  border-bottom: none;
}

.name-col {
  text-align: right;
  font-weight: 500;
  white-space: nowrap;
}

.num {
  font-variant-numeric: tabular-nums;
  direction: ltr;
  text-align: right;
  unicode-bidi: isolate;
  cursor: copy;
}

.num:has(input),
.num:has(button),
.num:has(a),
.num:has(label) {
  cursor: default;
}

.num.copied-flash,
.summary-item strong.copied-flash,
.ps-value.copied-flash {
  background: rgba(34, 197, 94, 0.22);
  outline: 1px solid rgba(34, 197, 94, 0.55);
  border-radius: 4px;
  transition: background 0.15s ease;
}

.num.calc {
  color: var(--accent);
}

.num.highlight,
td.highlight {
  color: var(--highlight);
  font-weight: 600;
}

tfoot td {
  background: var(--surface2);
  font-weight: 600;
  border-top: 2px solid var(--border);
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 1rem;
  padding: 4px 8px;
  border-radius: 4px;
  opacity: 0.7;
}

.btn-icon:hover {
  opacity: 1;
  background: rgba(239, 68, 68, 0.1);
}

.toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  cursor: pointer;
}

.toggle input {
  accent-color: var(--primary);
}

.hint {
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--accent-dim);
  border-radius: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
  border-right: 3px solid var(--accent);
}

.percent-layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sales-form {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px 12px;
}

.sales-form h3 {
  font-size: 0.95rem;
  margin-bottom: 14px;
  color: var(--text-muted);
}

.sales-resize-hint {
  margin: 0 0 10px;
}

.sales-table-wrap {
  overflow-x: auto;
  margin-bottom: 0;
  border: none;
  background: transparent;
}

table.sales-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

table.sales-table thead th {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-align: right;
  padding: 0 8px 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
  border: none;
  background: transparent;
}

table.sales-table tbody td {
  padding: 0 4px 4px;
  vertical-align: top;
  border: none;
}

table.sales-table .sales-inp {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  field-sizing: fixed;
  height: 40px;
  padding-inline: 10px;
}

.sales-adv-deduct {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--accent-dim);
  border: 1px solid rgba(16, 185, 129, 0.25);
  font-size: 0.78rem;
  line-height: 1.4;
}

.sales-adv-deduct:empty {
  display: none;
}

.sales-adv-deduct .adv-deduct-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
}

.sales-adv-deduct .adv-deduct-row strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  direction: ltr;
}

.sales-adv-deduct .adv-deduct-main {
  color: var(--accent);
  font-weight: 600;
}

.sales-adv-deduct .adv-deduct-main strong {
  color: var(--accent);
  font-size: 0.9rem;
}

.sales-adv-deduct .adv-deduct-empty {
  color: var(--text-muted);
}

.sales-direct-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 16px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.sales-direct-field {
  flex: 0 0 11rem;
  width: 11rem;
  max-width: 11rem;
}

.sales-direct-field label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.sales-direct-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 10px;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 0.78rem;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.sales-direct-check input {
  width: auto;
  margin: 0;
  flex-shrink: 0;
}

.sales-cell-direct {
  flex: 0 0 11rem;
  width: 11rem;
  max-width: 11rem;
}

@media (max-width: 640px) {
  .sales-direct-field,
  .sales-cell-direct {
    flex: 1 1 100%;
    width: 100%;
    max-width: none;
  }
}

.form-row {
  margin-bottom: 14px;
}

.form-row label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-row input:not(.inp-num) {
  width: 100%;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 16px 0;
  font-size: 0.85rem;
}

.checkbox-row input {
  accent-color: var(--primary);
  width: auto;
}

.pool-summary {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
}

.summary-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 12px;
  font-size: 0.78rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  flex: 1 1 0;
  min-width: 110px;
}

.summary-item span {
  color: var(--text-muted);
}

.summary-item strong {
  direction: ltr;
  font-variant-numeric: tabular-nums;
  font-size: 0.92rem;
  cursor: copy;
}

.summary-item.highlight {
  margin-top: 0;
  padding-top: 8px;
  border-bottom: none;
  border-color: rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.08);
  grid-column: unset;
  flex: 1.4 1 0;
}

.summary-item.highlight strong {
  color: var(--highlight);
  font-size: 1rem;
}

.percent-table {
  width: 100%;
}

.summary-item.highlight span,
.summary-item.highlight strong {
  color: var(--highlight);
  font-size: 0.95rem;
}

footer {
  text-align: center;
  margin-top: 32px;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.empty-msg {
  padding: 32px !important;
  color: var(--text-muted);
  text-align: center;
}

.field-hint {
  display: block;
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Modal */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}

.modal h3 {
  margin-bottom: 20px;
  font-size: 1.1rem;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
}

.toolbar-toggle {
  font-size: 0.85rem;
  color: var(--text);
  white-space: nowrap;
  flex-shrink: 0;
  padding: 8px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  gap: 8px;
}

.toolbar-toggle:hover {
  border-color: var(--primary);
}

.options-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  overflow: visible;
}

.codes-table .emp-name-text {
  font-size: 0.95rem;
  font-weight: 600;
  min-width: 160px;
}

.hesabfa-alias {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 2px;
}

.codes-table .code-input {
  text-align: center;
  font-weight: 600;
  letter-spacing: 0.05em;
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.08);
}

.codes-table .emp-salary.inp-num,
.codes-table .emp-daily.inp-num {
  font-size: 0.95rem;
  font-weight: 600;
}

.codes-table td.col-base-salary,
.codes-table td.col-emp-daily {
  white-space: nowrap;
}

.codes-table td[data-col-id="child-allowance"],
.codes-table th[data-col-id="child-allowance"] {
  min-width: 190px;
}

.codes-table td[data-col-id="active"],
.codes-table th[data-col-id="active"],
.codes-table td[data-col-id="focus"],
.codes-table th[data-col-id="focus"] {
  text-align: center;
  padding-inline: 2px;
}

.codes-table td[data-col-id="focus"] .btn-icon {
  margin-inline: auto;
}

.codes-table .code-input:focus {
  background: rgba(59, 130, 246, 0.15);
}

.codes-table .code-input::placeholder {
  font-weight: 400;
  opacity: 0.6;
}

.row-hidden {
  opacity: 0.45;
}

.row-hidden .name-col::after {
  content: ' (مخفی)';
  font-size: 0.75rem;
  color: var(--text-muted);
}

.row-dimmed {
  opacity: 0.22;
  filter: grayscale(0.55);
  transition: opacity 0.15s ease, filter 0.15s ease;
}

.row-dimmed input,
.row-dimmed button:not(.focus-emp) {
  pointer-events: none;
}

.row-focused {
  outline: 1px solid rgba(56, 189, 248, 0.45);
  outline-offset: -1px;
  background: rgba(56, 189, 248, 0.08);
}

.focus-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
  padding: 10px 14px;
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 8px;
  background: rgba(56, 189, 248, 0.1);
  color: var(--text);
  font-size: 0.92rem;
}

.col-hidden {
  display: none !important;
}

.col-visibility-menu {
  position: fixed;
  z-index: 100000;
  direction: rtl;
  min-width: 240px;
  width: max-content;
  max-width: min(320px, calc(100vw - 16px));
  max-height: min(420px, calc(100vh - 16px));
  display: flex;
  flex-direction: column;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface2);
  color: var(--text);
  box-shadow: var(--shadow), 0 0 0 1px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  isolation: isolate;
}

.col-menu-title {
  flex-shrink: 0;
  padding: 10px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.col-menu-list {
  flex: 1 1 auto;
  min-height: 0;
  max-height: 360px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  -webkit-overflow-scrolling: touch;
}

.col-menu-list::-webkit-scrollbar {
  width: 6px;
}

.col-menu-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.col-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1.4;
  user-select: none;
  white-space: nowrap;
}

.col-menu-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.col-menu-item input {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.col-menu-item span {
  flex: 1;
  min-width: 0;
}

table[data-col-resize] thead th[data-col-id] {
  cursor: context-menu;
}

.name-col .focus-emp {
  margin-left: 6px;
  vertical-align: middle;
}

.btn-icon.focus-emp {
  color: var(--text-muted);
  font-size: 1.05rem;
  opacity: 0.75;
}

.btn-icon.focus-emp:hover,
.btn-icon.focus-emp.is-on {
  color: #38bdf8;
  opacity: 1;
}

.btn-icon.focus-emp.is-on {
  filter: drop-shadow(0 0 4px rgba(56, 189, 248, 0.55));
}

.row-inactive {
  opacity: 0.35;
}

.row-no-percent {
  opacity: 0.72;
}

.row-no-percent .no-percent-badge {
  display: block;
  margin-top: 2px;
  font-size: 0.7rem;
  color: var(--highlight);
}

.toggle.toggle-sm {
  font-size: 0.72rem;
}

.toggle.toggle-sm span {
  padding: 4px 6px;
}

.allowance-bar--percent {
  margin-top: 12px;
  margin-bottom: 12px;
}

.child-missing {
  color: var(--warn, #c77800);
  font-weight: 600;
  cursor: help;
}

.emp-child-amt.inp-num {
  padding-inline: 10px;
  font-size: 0.95rem;
  margin-top: 6px;
}

#child-allowance-amount.inp-num,
.emp-child-amt.inp-num {
  width: 18ch;
  min-width: 18ch;
}

#child-allowance-amount.inp-num {
  padding-inline: 12px;
  font-size: 1rem;
}

.allowance-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 20px;
  margin-bottom: 16px;
  padding: 14px 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.allowance-amount-row {
  margin: 0;
  min-width: 260px;
}

.allowance-amount-row label {
  font-size: 0.85rem;
  margin-bottom: 6px;
  display: block;
}

.allowance-bar .field-hint {
  margin: 0;
  flex: 1 1 200px;
}

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

.save-status {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.save-status--ok {
  color: var(--accent);
}

.save-status--warn {
  color: var(--highlight);
}

.save-status--err {
  color: var(--danger);
}

.masked {
  letter-spacing: 2px;
  color: var(--text-muted);
}

body.hide-base-salary .col-base-salary {
  display: none;
}

.payslip-preview-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 560px;
}

.payslip-preview-host {
  margin-top: 8px;
}

.payslip-live-wrap {
  /* isolate payslip sheet styles from app chrome */
  border-radius: 18px;
  overflow: hidden;
}

.payslip-live-wrap body,
.payslip-live-wrap {
  background: transparent !important;
}

.payslip-live-wrap .sheet {
  margin: 0 auto;
}

.payslip-toolbar {
  flex-wrap: wrap;
  gap: 12px;
}

.payslip-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  width: 100%;
}

.payslip-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.payslip-actions .btn {
  flex: 1 1 auto;
  min-width: 110px;
}

@media (max-width: 720px) {
  .payslip-filters .filter-group {
    flex: 1 1 100%;
  }

  .payslip-filters .filter-group .inp,
  .payslip-filters .filter-group select {
    width: 100%;
  }

  .payslip-actions {
    width: 100%;
  }

  .payslip-actions .btn {
    min-width: calc(50% - 4px);
  }

  .payslip-live-wrap .sheet {
    max-width: 100%;
  }
}

.payslip-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.payslip-preview-header h3 {
  font-size: 1rem;
}

.payslip-preview-header span {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.payslip-preview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.payslip-preview-grid div {
  background: var(--surface);
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.payslip-preview-grid label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.payslip-preview-grid strong {
  font-size: 0.95rem;
  direction: ltr;
  display: block;
  text-align: left;
}

.payslip-preview-grid .full {
  grid-column: 1 / -1;
}

.payslip-preview-grid .total {
  background: rgba(251, 191, 36, 0.1);
  border-color: var(--highlight);
}

.payslip-preview-grid .total strong {
  color: var(--highlight);
  font-size: 1.1rem;
}

.payslip-note {
  margin-top: 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

/* Auth / Login */
body:not(.authed) .app {
  display: none !important;
}

.login-gate {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(ellipse at top, rgba(225, 29, 46, 0.25), transparent 55%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 24px;
  text-align: center;
  box-shadow: var(--shadow);
}

.login-logo {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  object-fit: contain;
  margin-bottom: 12px;
}

.login-card h1 {
  font-size: 1.25rem;
  margin-bottom: 4px;
  color: #f87171;
}

.login-card > p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 20px;
}

.login-card .form-row {
  text-align: right;
}

.login-card .inp {
  width: 100%;
}

.login-btn {
  width: 100%;
  justify-content: center;
  margin-top: 8px;
  padding: 12px;
}

.login-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin: 8px 0;
}

.login-hint {
  margin-top: 16px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.login-hint code {
  background: var(--surface2);
  padding: 2px 6px;
  border-radius: 4px;
}

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

.auth-user {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: center;
  text-align: right;
}

.brand-logo {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: contain;
}

.workflow-hint {
  color: var(--accent) !important;
  font-size: 0.85rem !important;
}

.quick-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  position: sticky;
  top: 0;
  z-index: 50;
}

.calendar-suggest {
  margin-bottom: 16px;
  padding: 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.calendar-suggest h3 {
  font-size: 0.95rem;
  margin-bottom: 8px;
}

.calendar-suggest .next-title {
  margin-top: 16px;
}

.suggest-formula {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.suggest-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.suggest-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  background: var(--surface);
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.85rem;
}

.suggest-row small {
  grid-column: 1 / -1;
  color: var(--text-muted);
}

.suggest-row.highlight-row,
.highlight-stat {
  border-color: var(--highlight) !important;
}

.suggest-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.cal-day.event {
  border-color: rgba(59, 130, 246, 0.4);
}

.cal-day .dbadge {
  position: absolute;
  top: 4px;
  left: 4px;
  font-size: 0.65rem;
  background: var(--danger);
  color: #fff;
  padding: 1px 4px;
  border-radius: 4px;
}

.badge-holiday,
.badge-event {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

.badge-holiday {
  background: rgba(234, 179, 8, 0.25);
  color: #facc15;
}

.badge-event {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
}

.bale-settings {
  margin-top: 20px;
  padding: 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.bale-settings h3 {
  font-size: 0.95rem;
  margin-bottom: 12px;
}

.bale-settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}

@media (max-width: 800px) {
  .bale-settings-grid {
    grid-template-columns: 1fr;
  }
}

.bale-settings .inp {
  width: 100%;
}

.bale-log {
  margin-top: 12px;
  max-height: 160px;
  overflow: auto;
  font-size: 0.8rem;
}

.bale-log-ok {
  color: var(--accent);
  padding: 2px 0;
}

.bale-log-err {
  color: var(--danger);
  padding: 2px 0;
}

@media (max-width: 700px) {
  .suggest-row {
    grid-template-columns: 1fr;
  }
  .brand-row {
    flex-direction: column;
    text-align: center;
  }
  .quick-bar {
    top: auto;
  }
}

/* Calendar */
.calendar-layout {
  display: block;
  max-width: 900px;
}

.calendar-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.calendar-summary .stat {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  min-width: 110px;
}

.calendar-summary .stat label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.calendar-summary .stat strong {
  font-size: 1.05rem;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 16px;
}

.calendar-month-block {
  margin-bottom: 8px;
}

.cal-month-title {
  font-size: 0.95rem;
  margin: 12px 0 8px;
  color: var(--text);
}

.calendar-next-month {
  padding: 12px 14px;
  background: rgba(56, 189, 248, 0.06);
  border: 1px solid rgba(56, 189, 248, 0.22);
  border-radius: 12px;
  margin-bottom: 12px;
}

.calendar-next-month .cal-month-title {
  color: #7dd3fc;
}

.suggest-next-hint,
.cal-next-hint {
  margin: 0 0 10px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.cal-head {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 8px 4px;
  font-weight: 600;
}

.cal-day {
  min-height: 64px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  text-align: right;
  position: relative;
}

.cal-day.empty {
  background: transparent;
  border-color: transparent;
}

.cal-day .dnum {
  font-weight: 700;
  font-size: 0.95rem;
}

.cal-day .dnote {
  display: block;
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.3;
  max-height: 2.6em;
  overflow: hidden;
}

.cal-day.clickable {
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.cal-day.clickable:hover {
  box-shadow: 0 0 0 2px rgba(148, 163, 184, 0.45);
}

.cal-day.friday {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.35);
}

.cal-day.store-closed {
  background: rgba(100, 116, 139, 0.28);
  border-color: #64748b;
  opacity: 0.72;
}

.cal-day.store-closed .dnum {
  color: #94a3b8;
  text-decoration: line-through;
}

.cal-day .closed-badge {
  background: rgba(100, 116, 139, 0.35);
  color: #cbd5e1;
}

.badge-closed {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  background: rgba(100, 116, 139, 0.3);
  color: #cbd5e1;
}

.calendar-legend .dot.store-closed { background: #64748b; }

.cal-hint {
  margin: 0 0 10px;
}

.cal-day.holiday {
  background: rgba(234, 179, 8, 0.22);
  border-color: #eab308;
}

.cal-day.holiday .dnum {
  color: #ca8a04;
}

.cal-day.friday .dnum {
  color: var(--danger);
}

.cal-day.holiday.friday .dnum {
  color: #ca8a04;
}

.cal-day.today {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.cal-day.work:not(.holiday):not(.friday):not(.store-closed) {
  border-color: rgba(16, 185, 129, 0.35);
}

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.calendar-legend .dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-left: 6px;
  vertical-align: middle;
}

.calendar-legend .dot.holiday { background: #eab308; }
.calendar-legend .dot.friday { background: #f87171; }
.calendar-legend .dot.today { background: var(--accent); }
.calendar-legend .dot.work { background: #34d399; }

.holiday-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.holiday-list li {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
  display: flex;
  gap: 10px;
}

.holiday-list li:last-child {
  border-bottom: none;
}

.holiday-list .hday {
  color: #ca8a04;
  font-weight: 700;
  min-width: 28px;
}

.calendar-embed-wrap h3 {
  font-size: 0.95rem;
  margin-bottom: 10px;
  color: var(--text-muted);
}

.calendar-embed {
  width: 100%;
  min-height: 640px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

@media (max-width: 700px) {
  .calendar-grid {
    gap: 4px;
  }
  .cal-day {
    min-height: 48px;
    padding: 4px;
  }
  .cal-day .dnote {
    display: none;
  }
  .calendar-embed {
    min-height: 420px;
  }
  .tabs {
    overflow-x: auto;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
  }
  .tab-btn {
    white-space: nowrap;
    padding: 8px 12px;
    font-size: 0.8rem;
  }
  .app {
    padding: 12px 10px 80px;
  }
  .actions {
    width: 100%;
    flex-wrap: wrap;
  }
  .actions .btn {
    flex: 1;
    justify-content: center;
  }
}

