/* ==========================================================================
   Gesthes — viste: matrici (forecast e consuntivo), schede di dettaglio,
   ricerca rapida (Ctrl K), account, dashboard.
   ========================================================================== */

/* ---- Matrici numeriche ---------------------------------------------------------- */
table.matrix {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table.matrix th {
  text-align: right;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text2);
  padding: 10px 12px;
  background: var(--surface2);
  background: color-mix(in srgb, var(--surface2) 55%, var(--surface));
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.matrix td {
  padding: 10px 12px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  border-bottom: 1px solid var(--border);
}
table.matrix tbody tr {
  transition: background var(--t-fast) var(--ease);
}
table.matrix tbody tr:hover {
  background: var(--row-hover);
}
table.matrix th:first-child,
table.matrix td:first-child {
  padding-left: 20px;
}
table.matrix th:last-child,
table.matrix td:last-child {
  padding-right: 20px;
}
table.matrix td.rowhead,
table.matrix th.rowhead {
  text-align: left;
  font-weight: 550;
  white-space: nowrap;
}
table.matrix td.tot,
table.matrix th.tot {
  font-weight: 650;
  border-left: 1px solid var(--border);
}
table.matrix tr.totrow td {
  font-weight: 650;
  background: var(--surface2);
  background: color-mix(in srgb, var(--surface2) 70%, var(--surface));
  border-top: 1px solid var(--border-strong);
  border-bottom: none;
}
table.matrix tr.totrow:hover td {
  background: var(--surface2);
  background: color-mix(in srgb, var(--surface2) 70%, var(--surface));
}
table.matrix .prov {
  color: var(--warn);
}

/* ---- Schede di dettaglio ----------------------------------------------------------- */
.detail-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 18px;
  align-items: start;
}
.detail-grid > * {
  min-width: 0;
}
@media (max-width: 1100px) {
  .detail-grid {
    grid-template-columns: 1fr;
  }
}
.kv {
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 10px 16px;
  font-size: 14px;
}
.kv dt {
  font-size: 13px;
  font-weight: 500;
  color: var(--text3);
  align-self: center;
}
.kv dd {
  font-weight: 550;
  min-width: 0;
  overflow-wrap: anywhere;
}
@media (max-width: 520px) {
  .kv {
    grid-template-columns: 1fr;
    gap: 2px 0;
  }
  .kv dd {
    margin-bottom: 10px;
  }
}

/* ---- Ricerca rapida e comandi (Ctrl K) ------------------------------------------- */
.search-modal {
  width: 640px;
}
.search-modal .modal-body {
  padding: 0;
  max-height: none;
}
.palette-field {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
}
.palette-ico {
  display: inline-flex;
  flex: none;
  color: var(--text3);
}
.palette-ico svg {
  width: 20px;
  height: 20px;
}
.search-input {
  flex: 1;
  width: 100%;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 16.5px;
  padding: 18px 0;
  outline: none;
}
.search-input:focus-visible {
  outline: none;
}
.search-input::placeholder {
  color: var(--text3);
}
.search-results {
  max-height: min(56vh, 460px);
  overflow-y: auto;
  padding: 8px;
}
.search-results .empty {
  padding: 28px 16px 30px;
}
.search-group-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text3);
  padding: 12px 12px 6px;
}
.search-hit {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 42px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  transition: background var(--t-fast) var(--ease);
}
.search-hit:hover {
  background: var(--surface2);
}
.search-hit.sel {
  background: var(--accent-soft);
  color: var(--accent);
}
.hit-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-xs);
  background: var(--surface2);
  color: var(--text2);
}
.hit-ico svg {
  width: 16px;
  height: 16px;
}
.search-hit.sel .hit-ico {
  background: var(--surface);
  color: var(--accent);
}
.hit-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hit-hint {
  font-size: 12.5px;
  color: var(--text3);
  white-space: nowrap;
}
.search-hit .mono {
  color: var(--text3);
  font-size: 13px;
}
.search-hit.sel .mono,
.search-hit.sel .hit-hint {
  color: var(--accent);
}
.palette-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  background: color-mix(in srgb, var(--surface2) 45%, var(--surface));
  font-size: 12.5px;
  color: var(--text3);
}
.palette-foot span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.palette-foot kbd {
  padding: 2px 5px;
  font-size: 10.5px;
}
@media (max-width: 640px) {
  .palette-foot {
    display: none;
  }
}

/* ---- Account e password --------------------------------------------------------------- */
.account-grid {
  align-items: start;
}
.pw-form {
  max-width: 440px;
}
.pw-wrap {
  position: relative;
}
.field .pw-wrap input {
  padding-right: 42px;
}
.pw-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 30px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
}
.pw-toggle:hover {
  color: var(--text);
  background: var(--surface2);
}
.pw-toggle svg,
.pw-rules svg {
  width: 16px;
  height: 16px;
}
.pw-rules {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: grid;
  gap: 4px;
  font-size: 13px;
  color: var(--text3);
}
.pw-rules li {
  display: flex;
  align-items: center;
  gap: 7px;
}
.pw-rules li.ok {
  color: var(--pos);
}
.pw-forced {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background:
    radial-gradient(1200px 600px at 0% 0%, color-mix(in srgb, var(--brand-navy) 10%, transparent), transparent 60%),
    var(--bg);
}
.pw-forced .card {
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
}
.pw-forced-brand {
  padding: 24px 24px 4px;
}
.pw-forced-brand img {
  height: 36px;
  width: auto;
}
.pw-forced .card-head {
  border-bottom: none;
  padding: 10px 24px 0;
  min-height: 0;
}
.pw-forced .card-head h2 {
  font-size: 22px;
  font-weight: 760;
  font-stretch: var(--wide);
}
.pw-forced .card-pad {
  padding: 12px 24px 24px;
}
.pw-forced .pw-form {
  max-width: none;
}
.pw-reveal {
  font-family: var(--font-mono);
  background: var(--surface2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 17px;
  letter-spacing: .04em;
  text-align: center;
  user-select: all;
}

/* ---- Consuntivo: griglia giornate, mesi consolidati, testata commessa ----------------- */
table.matrix.cons-grid td {
  padding-top: 6px;
  padding-bottom: 6px;
}
table.matrix input.gg-input {
  width: 64px;
  height: 32px;
  padding: 0 8px;
  text-align: right;
  font: inherit;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
table.matrix input.gg-input:hover {
  border-color: var(--text3);
}
table.matrix input.gg-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}
table.matrix input.gg-input.changed {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  font-weight: 650;
}
table.matrix input.gg-input.invalid {
  border-color: var(--neg);
  background: var(--neg-soft);
  color: var(--neg);
}
table.matrix .neg {
  color: var(--neg);
  font-weight: 650;
}
.cons-lock svg {
  width: 12px;
  height: 12px;
  margin-left: 3px;
  vertical-align: -1px;
  color: var(--pos);
}
.cons-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 26px;
  font-size: 13.5px;
  color: var(--text2);
}
.cons-meta strong {
  color: var(--text);
  font-weight: 650;
}

/* ---- Dashboard: saluto e azioni rapide ------------------------------------------- */
.hello h1 {
  font-size: 30px;
}
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
@media (max-width: 720px) {
  .hello h1 {
    font-size: 24px;
  }
  .quick-actions .btn {
    flex: 1 1 auto;
  }
}
