/* Komponentët e ripërdorshëm: tabela, pilula, kuti mesazhi, zgjidhësi,
   kartat e eksportit, toast, dialog. */

/* --- Tabela --- */

.table-wrap {
  overflow-x: auto;
  scrollbar-color: var(--n-300) transparent;
  scrollbar-width: thin;
}

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

thead th {
  position: sticky; top: 0; z-index: 2;
  text-align: left; font-size: var(--fs-xs); font-weight: 600;
  text-transform: uppercase; letter-spacing: .075em;
  color: var(--text-muted);
  padding: 10px var(--s-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
thead th.num { text-align: right; }

tbody td {
  padding: 7px var(--s-3);
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 82%, var(--brand-050)); }
tbody td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

tfoot td {
  padding: var(--s-3) var(--s-4);
  border-top: 1px solid var(--line);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: var(--surface-2);
  white-space: nowrap;
}
tfoot td.num { text-align: right; }
tfoot tr.sub td { border-top: none; font-weight: 400; color: var(--text-muted); }
tfoot tr.sub td.num { color: var(--text); }

table.dense tbody td { padding: 5px var(--s-2); }
table.dense thead th { padding: 9px var(--s-2); }

/* Emri + meta në një qelizë */
.cell-name { font-weight: 600; }
.cell-meta { font-size: var(--fs-xs); color: var(--text-muted); }

/* Gjerësitë e fushave brenda tabelës */
td input, td select { width: 100%; padding: 4px 7px; }
td input.w-xs { width: 48px; }
td input.w-sm { width: 58px; }
td input.w-md { width: 92px; }
td input.w-id { width: 118px; }
td input.w-acc { width: 172px; }
td input.w-lg { width: 100%; min-width: 130px; }

/* --- Pilula --- */

.pill {
  display: inline-block; font-size: 10px; font-weight: 700;
  letter-spacing: .065em; text-transform: uppercase;
  padding: 3px 7px; border-radius: var(--r-pill);
  vertical-align: 1px;
}
.pill.info { background: var(--info-bg); color: var(--info-fg); }
.pill.ok { background: var(--ok-bg); color: var(--ok-fg); }
.pill.warn { background: var(--warn-bg); color: var(--warn-fg); }
.pill.bad { background: var(--bad-bg); color: var(--bad-fg); }
.pill.off { background: var(--surface-3); color: var(--text-muted); }

/* --- Kutitë e mesazheve --- */

.note-box {
  display: flex; gap: var(--s-2);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  padding: 11px 13px;
  font-size: var(--fs-md);
  margin-bottom: var(--s-3);
}
.note-box:last-child { margin-bottom: 0; }
.note-box.warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn-fg) 16%, transparent); color: var(--warn-fg); }
.note-box.info { background: var(--info-bg); border-color: color-mix(in srgb, var(--info-fg) 14%, transparent); color: var(--info-fg); }
.note-box.bad { background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad-fg) 14%, transparent); color: var(--bad-fg); }
.note-box b { font-weight: 700; }

/* --- Zgjidhësi i sasive --- */

.solutions { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.sol {
  cursor: pointer; text-align: left; font: inherit;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 9px 12px;
  background: var(--surface);
  color: var(--text);
  transition: border-color .16s, background .16s;
}
.sol:hover { border-color: var(--accent); background: var(--brand-050); }
.sol[aria-pressed="true"] { border-color: var(--accent); background: var(--brand-100); box-shadow: inset 0 0 0 1px var(--accent); }
.sol b { display: block; font-variant-numeric: tabular-nums; font-weight: 650; }
.sol small { display: block; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* --- Rezultati i madh (p.sh. "Për faturë") --- */

.big-figure {
  font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -.035em;
  font-variant-numeric: tabular-nums; color: var(--text-strong);
}

/* --- Kartat e eksportit --- */

.exports { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: var(--s-3); }
.exp {
  display: flex; flex-direction: column; gap: var(--s-2);
  border: 1px solid var(--line); border-radius: var(--r-md);
  padding: var(--s-4);
  background: var(--surface-2);
}
.exp h4 { margin: 0; font-size: var(--fs-md); font-weight: 650; }
.exp p { font-size: var(--fs-sm); color: var(--text-muted); flex: 1; }

pre.preview {
  margin: var(--s-2) 0 0;
  padding: var(--s-4);
  background: var(--brand-950);
  color: #dce5ff;
  border-radius: var(--r-md);
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.6;
  tab-size: 2;
}

/* --- Toast --- */

.toast {
  position: fixed; bottom: var(--s-5); left: 50%;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: var(--s-2);
  background: var(--brand-950); color: #f8faff;
  padding: 10px var(--s-4);
  border-radius: var(--r-md);
  font-size: var(--fs-md);
  box-shadow: var(--shadow-3);
  z-index: 60;
  max-width: min(560px, calc(100vw - 40px));
}
.toast[data-kind="err"] { background: var(--bad-fg); }
.toast[data-kind="ok"] { background: var(--ok-fg); }

/* --- Dialog --- */

.dialog {
  border: 1px solid var(--line); padding: 0;
  border-radius: var(--r-lg);
  max-width: 460px; width: calc(100vw - 40px);
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-3);
}
.dialog::backdrop { background: rgba(4, 10, 24, .58); backdrop-filter: blur(3px); }
.dialog form { padding: var(--s-6); display: flex; flex-direction: column; gap: var(--s-4); }
.dialog h2 { font-size: var(--fs-xl); }
.dialog menu { display: flex; justify-content: flex-end; gap: var(--s-2); margin: 0; padding: 0; }

/* --- Porta e kyçjes --- */

body.locked { overflow: hidden; }
body.locked .app-shell { visibility: hidden; }

.auth-gate {
  position: fixed; inset: 0; z-index: 80;
  display: grid; place-items: center;
  padding: var(--s-4);
  background: var(--bg);
}
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  padding: var(--s-7) var(--s-6);
  text-align: left;
}
.auth-brand {
  font-size: var(--fs-lg); font-weight: 600; letter-spacing: -.01em;
  color: var(--text-strong); margin-bottom: var(--s-5);
}
.auth-card h1 { font-size: var(--fs-2xl); margin-bottom: var(--s-2); }
.auth-card > .hint { margin-bottom: var(--s-4); text-align: left; }
.auth-card form { display: flex; flex-direction: column; gap: var(--s-3); text-align: left; }
.auth-card input[type="password"] { font-size: var(--fs-lg); letter-spacing: .08em; padding: 8px 10px; }
.auth-card .btn { justify-content: center; padding: 9px 14px; }
.auth-card .note-box { margin: 0; display: block; }
.auth-switch {
  margin-top: var(--s-4); font-size: var(--fs-sm); color: var(--text-muted);
  display: flex; align-items: center; justify-content: center; gap: var(--s-1); flex-wrap: wrap;
}
.auth-switch .btn { padding: 2px 6px; }
.auth-card .hint.auth-foot { margin-top: var(--s-3); text-align: center; font-size: var(--fs-xs); }
.auth-card select { width: 100%; }
.auth-foot { margin-top: var(--s-4); text-align: left; }

/* --- Zgjedhësi i punëtorit brenda dialogut --- */

.picker { max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--r-md); }
.picker button {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3);
  width: 100%; font: inherit; text-align: left; cursor: pointer;
  padding: var(--s-2) var(--s-3);
  background: transparent; border: none; border-bottom: 1px solid var(--line-soft);
  color: var(--text);
}
.picker button:last-child { border-bottom: none; }
.picker button:hover { background: var(--surface-2); }
.picker button .meta { font-size: var(--fs-sm); color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* --- Logoja e kompanisë --- */

.company-logo-upload {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-3);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.company-logo-preview {
  display: grid;
  place-items: center;
  width: 118px;
  height: 76px;
  overflow: hidden;
  padding: var(--s-2);
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
}
.company-logo-preview img { display: block; width: 100%; height: 100%; object-fit: cover; }
.company-logo-preview.is-default { padding: 0; background: var(--accent); }
.company-logo-preview.is-default img { width: 100%; height: 100%; object-fit: cover; }
.company-logo-copy { display: flex; flex-direction: column; gap: var(--s-3); min-width: 0; }
.company-logo-copy .field-title { font-size: var(--fs-sm); font-weight: 700; color: var(--text); }
.company-logo-copy .hint { margin-top: 3px; }
.company-logo-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.company-logo-actions .btn:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }

@media (max-width: 520px) {
  .company-logo-upload { grid-template-columns: 1fr; }
  .company-logo-preview { width: 100%; height: 92px; }
}

/* --- Dashboard / Përmbledhje --- */

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(300px, .85fr);
  gap: var(--s-4);
  align-items: stretch;
}

.dashboard-panel {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
}
.dashboard-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-5) var(--s-5) 0;
}
.dashboard-panel-header h2 { font-size: var(--fs-lg); }
.dashboard-panel-header p { margin-top: 3px; color: var(--text-muted); font-size: var(--fs-sm); }

.finance-panel { grid-column: 1; }
.finance-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: var(--s-6) var(--s-5) var(--s-5);
}
.finance-metric { min-width: 0; padding: 0 var(--s-5); border-left: 1px solid var(--line); }
.finance-metric:first-child { padding-left: 0; border-left: 0; }
.finance-metric:last-child { padding-right: 0; }
.finance-label { color: var(--text-muted); font-size: var(--fs-sm); }
.finance-value {
  margin-top: 7px;
  color: var(--text);
  font-size: clamp(23px, 2.15vw, 33px);
  font-weight: 680;
  letter-spacing: -.045em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.finance-metric.margin .finance-value,
.finance-metric.margin .finance-sub { color: var(--positive); }
.finance-metric.margin.negative .finance-value,
.finance-metric.margin.negative .finance-sub { color: var(--bad-fg); }
.finance-sub { margin-top: 4px; color: var(--text-muted); font-size: var(--fs-sm); font-weight: 600; }
.balance-wrap { padding: 0 var(--s-5) var(--s-5); }
.balance-bar {
  display: flex;
  height: 11px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--surface-3);
}
.balance-expenses { min-width: 0; background: var(--accent); }
.balance-margin { min-width: 0; background: var(--positive); }
.balance-legend {
  display: flex;
  justify-content: space-between;
  gap: var(--s-3);
  margin-top: 9px;
  color: var(--text-muted);
  font-size: var(--fs-xs);
}
.balance-legend span:last-child { color: var(--positive); }

.payroll-panel { grid-column: 1; }
.payroll-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: var(--s-4) var(--s-5);
}
.payroll-stat {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  column-gap: var(--s-3);
  align-items: center;
  min-width: 0;
  padding: var(--s-2) var(--s-5);
  border-left: 1px solid var(--line);
}
.payroll-stat:first-child { padding-left: 0; border-left: 0; }
.payroll-stat:last-child { padding-right: 0; }
.stat-icon {
  display: grid;
  grid-row: 1 / 3;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--brand-050);
  color: var(--text-strong);
}
.payroll-stat strong {
  overflow: hidden;
  font-size: var(--fs-xl);
  letter-spacing: -.035em;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.payroll-stat span:last-child { color: var(--text-muted); font-size: var(--fs-sm); }

.workflow-panel {
  grid-column: 2;
  grid-row: 1 / span 2;
  padding-bottom: var(--s-5);
}
.workflow-list { padding: var(--s-4) var(--s-5) 0; }
.workflow-step {
  position: relative;
  display: grid;
  grid-template-columns: 29px minmax(0, 1fr);
  column-gap: var(--s-3);
  padding-bottom: var(--s-4);
}
.workflow-step:not(:last-child)::before {
  content: "";
  position: absolute;
  top: 25px;
  bottom: 0;
  left: 13px;
  width: 1px;
  background: var(--line);
}
.step-dot {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--text-muted);
  background: var(--surface);
  font-size: 11px;
  font-weight: 700;
}
.workflow-step.done .step-dot { border-color: var(--ok-fg); background: var(--ok-bg); color: var(--ok-fg); }
.workflow-step.warn .step-dot { border-color: var(--warn-fg); background: var(--warn-bg); color: var(--warn-fg); }
.step-main { min-width: 0; padding-top: 2px; }
.step-title { display: flex; justify-content: space-between; gap: var(--s-2); font-weight: 650; }
.step-title small { color: var(--text-muted); font-size: 10px; font-weight: 500; white-space: nowrap; }
.step-state { margin-top: 2px; color: var(--text-muted); font-size: var(--fs-xs); }
.workflow-step.done .step-state { color: var(--ok-fg); }
.workflow-step.warn .step-state { color: var(--warn-fg); }
.step-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  margin-top: var(--s-3);
  padding: 9px 10px;
  border: 1px solid color-mix(in srgb, var(--warn-fg) 34%, var(--line));
  border-radius: var(--r-sm);
  color: var(--warn-fg);
  background: var(--warn-bg);
  font-size: var(--fs-xs);
  font-weight: 650;
  text-decoration: none;
}

.dashboard-bottom {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
  gap: var(--s-4);
}
.quick-actions { padding: var(--s-4) var(--s-5) var(--s-5); }
.quick-action {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  padding: 11px 0;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text);
  background: transparent;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
}
.quick-action:first-child { padding-top: 0; }
.quick-action:last-child { padding-bottom: 0; border-bottom: 0; }
.quick-action .icon-box {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--text-strong);
  background: var(--surface-2);
}
.quick-action .action-copy { flex: 1; min-width: 0; }
.quick-action small { display: block; margin-top: 1px; color: var(--text-muted); font-weight: 400; }
.quick-action:hover { color: var(--text-strong); }

.invoice-summary { padding: var(--s-4) var(--s-5) var(--s-5); }
.invoice-row {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  gap: var(--s-3);
  align-items: center;
}
.invoice-doc {
  display: grid;
  place-items: center;
  width: 46px;
  height: 54px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--text-strong);
  background: var(--surface-2);
}
.invoice-copy strong { display: block; font-size: var(--fs-lg); }
.invoice-copy span { display: block; color: var(--text-muted); font-size: var(--fs-sm); }
.invoice-total { text-align: right; }
.invoice-total strong { display: block; color: var(--text-strong); font-size: var(--fs-xl); font-variant-numeric: tabular-nums; }
.invoice-total .pill { margin-top: 4px; }
.invoice-links {
  display: flex;
  justify-content: space-between;
  gap: var(--s-3);
  padding-top: var(--s-4);
  margin-top: var(--s-4);
  border-top: 1px solid var(--line-soft);
}
.text-link { color: var(--text-strong); font-size: var(--fs-sm); font-weight: 650; text-decoration: none; }
.text-link:hover { text-decoration: underline; text-underline-offset: 3px; }

@media (max-width: 1120px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .finance-panel, .payroll-panel, .workflow-panel, .dashboard-bottom {
    grid-column: 1;
    grid-row: auto;
  }
  .dashboard-bottom { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .dashboard-grid, .dashboard-bottom { grid-template-columns: 1fr; }
  .finance-metrics, .payroll-summary { grid-template-columns: 1fr; }
  .finance-metric {
    padding: var(--s-4) 0;
    border-top: 1px solid var(--line-soft);
    border-left: 0;
  }
  .finance-metric:first-child { padding-top: 0; border-top: 0; }
  .finance-value { font-size: 29px; }
  .payroll-stat {
    padding: var(--s-4) 0;
    border-top: 1px solid var(--line-soft);
    border-left: 0;
  }
  .payroll-stat:first-child { padding-top: 0; border-top: 0; }
  .invoice-row { grid-template-columns: 46px minmax(0, 1fr); }
  .invoice-total { grid-column: 2; text-align: left; }
  .dialog form { padding: var(--s-5); }
  .toast { bottom: var(--s-3); width: calc(100vw - 32px); justify-content: center; }
}
