/* ─── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }

/* ─── Tokens ─────────────────────────────────────────────────────────────── */
:root {
  --bg:        #0c0c0c;
  --surface:   #131313;
  --surface-2: #1a1a1a;
  --surface-3: #222;
  --border:    #282828;
  --border-2:  #333;
  --text:      #ebebeb;
  --text-2:    #888;
  --text-3:    #4a4a4a;
  --accent:    #c9a96e;
  --accent-h:  #dfc08a;
  --danger:    #ef4444;
  --radius:    10px;
  --radius-sm: 6px;
  --shadow:    0 2px 12px rgba(0,0,0,.45);

  /* status */
  --s-da-fare:            #3f3f3f;
  --s-da-fare-t:          #aaa;
  --s-girato:             #1d4ed8;
  --s-girato-t:           #93c5fd;
  --s-montaggio:          #92400e;
  --s-montaggio-t:        #fcd34d;
  --s-revisione:          #9a3412;
  --s-revisione-t:        #fdba74;
  --s-consegnato:         #14532d;
  --s-consegnato-t:       #86efac;

  /* job status */
  --js-confermato:        #1e3a5f;
  --js-confermato-t:      #93c5fd;
  --js-in-lavorazione:    #78350f;
  --js-in-lavorazione-t:  #fde68a;
  --js-completato:        #3b0764;
  --js-completato-t:      #d8b4fe;
  --js-consegnato:        #14532d;
  --js-consegnato-t:      #86efac;

  /* type */
  --t-matrimonio:  #831843;
  --t-matrimonio-t:#fbcfe8;
  --t-social:      #1e3a5f;
  --t-social-t:    #bae6fd;
  --t-corporate:   #064e3b;
  --t-corporate-t: #6ee7b7;
}

/* ─── Base ───────────────────────────────────────────────────────────────── */
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  line-height: 1.55;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  outline: none;
}

/* ─── Nav ────────────────────────────────────────────────────────────────── */
.nav {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px;
  height: 54px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand {
  font-weight: 700;
  font-size: .9rem;
  letter-spacing: .06em;
  color: var(--accent);
  margin-right: 12px;
}
.nav-links { display: flex; gap: 2px; flex: 1; }
.nav-link {
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  color: var(--text-2);
  transition: color .15s, background .15s;
}
.nav-link:hover { color: var(--text); background: var(--surface-2); }
.nav-link.active { color: var(--text); background: var(--surface-3); }
.nav-logout { margin-left: auto; }

/* ─── Container ──────────────────────────────────────────────────────────── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

/* ─── Page header ────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.page-header h1 { font-size: 1.5rem; font-weight: 700; }
.header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.back-link {
  font-size: .8rem;
  color: var(--text-2);
  display: inline-block;
  margin-bottom: 4px;
  transition: color .15s;
}
.back-link:hover { color: var(--text); }

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border-2);
  background: var(--surface-2);
  color: var(--text);
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-3); border-color: #444; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
}
.btn-primary:hover { background: var(--accent-h); border-color: var(--accent-h); }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: rgba(239,68,68,.1); }
.btn-sm { padding: 4px 10px; font-size: .8rem; }
.btn-icon {
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .85rem;
  transition: background .15s;
}
.btn-icon:hover { background: var(--surface-3); }
.btn-icon-danger:hover { background: rgba(239,68,68,.15); color: var(--danger); }

/* ─── Stats ──────────────────────────────────────────────────────────────── */
.stats-row {
  display: flex;
  gap: 12px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}
.stat-card {
  flex: 1;
  min-width: 120px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-num { font-size: 2rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: .8rem; color: var(--text-2); }

/* ─── Grid ───────────────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.job-grid { display: grid; grid-template-columns: 1fr 320px; gap: 24px; align-items: start; }
@media (max-width: 768px) {
  .grid-2, .job-grid { grid-template-columns: 1fr; }
}

/* ─── Sections ───────────────────────────────────────────────────────────── */
section h2, h2 { font-size: 1rem; font-weight: 600; margin-bottom: 12px; color: var(--text-2); text-transform: uppercase; letter-spacing: .05em; font-size: .75rem; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-header h2 { margin-bottom: 0; }

/* ─── Card list ──────────────────────────────────────────────────────────── */
.card-list { display: flex; flex-direction: column; gap: 2px; }
.card-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: border-color .15s, background .15s;
  cursor: pointer;
}
.card-item:hover { border-color: var(--border-2); background: var(--surface-2); }
.card-item-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.card-item-main strong { font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-item-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }

/* ─── Jobs grid ──────────────────────────────────────────────────────────── */
.jobs-grid { display: flex; flex-direction: column; gap: 6px; }
.job-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: border-color .15s, background .15s;
  cursor: pointer;
}
.job-card:hover { border-color: var(--border-2); background: var(--surface-2); }
.job-card-top { display: flex; gap: 6px; align-items: center; }
.job-card-meta { min-width: 0; }
.job-card-title { display: block; font-size: .9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job-card-bottom { display: flex; align-items: center; gap: 10px; justify-content: flex-end; }
.job-card-progress { display: flex; align-items: center; gap: 6px; }
@media (max-width: 600px) {
  .job-card { grid-template-columns: auto 1fr; }
  .job-card-bottom { grid-column: 1 / -1; justify-content: flex-start; flex-wrap: wrap; }
}

/* ─── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px;
  background: var(--surface-3);
  font-size: .75rem;
  font-weight: 600;
}
.type-badge {
  display: inline-flex; align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .03em;
  width: fit-content;
}
.type-matrimonio { background: var(--t-matrimonio); color: var(--t-matrimonio-t); }
.type-social     { background: var(--t-social);     color: var(--t-social-t); }
.type-corporate  { background: var(--t-corporate);  color: var(--t-corporate-t); }

.status-badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 600;
  width: fit-content;
}
.status-da_fare            { background: var(--s-da-fare);      color: var(--s-da-fare-t); }
.status-girato_disponibile { background: var(--s-girato);       color: var(--s-girato-t); }
.status-in_montaggio       { background: var(--s-montaggio);    color: var(--s-montaggio-t); }
.status-in_revisione       { background: var(--s-revisione);    color: var(--s-revisione-t); }
.status-consegnato         { background: var(--s-consegnato);   color: var(--s-consegnato-t); }
.status-confermato         { background: var(--js-confermato);     color: var(--js-confermato-t); }
.status-in_lavorazione     { background: var(--js-in-lavorazione); color: var(--js-in-lavorazione-t); }
.status-completato         { background: var(--js-completato);     color: var(--js-completato-t); }

.date-badge {
  font-size: .75rem;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}

/* ─── Progress ───────────────────────────────────────────────────────────── */
.progress-wrap {
  width: 80px; height: 4px;
  background: var(--surface-3);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width .3s ease;
}

/* ─── Text utils ─────────────────────────────────────────────────────────── */
.text-2 { font-size: .8rem; color: var(--text-2); }
.text-xs { font-size: .72rem; }
.link-strong { color: var(--text); font-weight: 500; }
.link-strong:hover { color: var(--accent); }
.link-muted { color: var(--text-2); }
.link-muted:hover { color: var(--text); }
.empty { color: var(--text-3); font-size: .875rem; padding: 16px 0; }

/* ─── Filters ────────────────────────────────────────────────────────────── */
.filters {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 20px;
}
.filter-btn {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: .8rem;
  color: var(--text-2);
  border: 1px solid transparent;
  transition: all .15s;
  cursor: pointer;
}
.filter-btn:hover { color: var(--text); background: var(--surface-2); }
.filter-btn.active { color: var(--text); background: var(--surface-2); border-color: var(--border-2); }
.filter-sep { color: var(--text-3); padding: 0 4px; }

/* ─── Table ──────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  padding: 10px 14px;
  text-align: left;
  font-size: .875rem;
  border-bottom: 1px solid var(--border);
}
.table th { color: var(--text-2); font-weight: 500; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; background: var(--surface); }
.table td { background: var(--surface); }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--surface-2); }

/* ─── Info row ───────────────────────────────────────────────────────────── */
.job-info-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.info-chip {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .85rem;
}
.info-label { font-size: .68rem; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
.job-title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.client-meta { display: flex; gap: 12px; margin-top: 4px; font-size: .82rem; color: var(--text-2); flex-wrap: wrap; }
.note-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: .85rem;
  color: var(--text-2);
  margin-bottom: 20px;
  white-space: pre-wrap;
}

/* ─── Video items ────────────────────────────────────────────────────────── */
.video-group { margin-bottom: 16px; }
.video-group-label {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-3);
  margin-bottom: 6px;
  padding: 0 2px;
}
.video-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 4px;
}
.video-item-left { flex: 1; min-width: 0; }
.video-title { font-size: .875rem; font-weight: 500; }
.video-notes { font-size: .75rem; color: var(--text-2); margin-top: 2px; }
.video-item-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.price-tag {
  font-size: .75rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}
.price-tag-sm {
  font-size: .72rem;
  font-weight: 600;
  color: var(--accent);
  margin-left: 4px;
}

/* ─── Status select ──────────────────────────────────────────────────────── */
.status-select {
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: .82rem;
  cursor: pointer;
  min-width: 150px;
}
.status-select-sm {
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: .75rem;
  cursor: pointer;
  font-weight: 500;
}
.status-select-sm.status-da_fare            { background: var(--s-da-fare);      color: var(--s-da-fare-t); }
.status-select-sm.status-girato_disponibile { background: var(--s-girato);       color: var(--s-girato-t); }
.status-select-sm.status-in_montaggio       { background: var(--s-montaggio);    color: var(--s-montaggio-t); }
.status-select-sm.status-in_revisione       { background: var(--s-revisione);    color: var(--s-revisione-t); }
.status-select-sm.status-consegnato         { background: var(--s-consegnato);   color: var(--s-consegnato-t); }
.status-select-sm option                    { background: var(--surface-2); color: var(--text); }

/* ─── Cost card ──────────────────────────────────────────────────────────── */
.cost-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.cost-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  font-size: .875rem;
  border-bottom: 1px solid var(--border);
}
.cost-row:last-child { border-bottom: none; }
.cost-total { font-weight: 700; font-size: 1rem; padding-top: 10px; margin-top: 2px; }
.cost-total span:last-child { color: var(--accent); }

/* ─── Forms ──────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: .78rem; color: var(--text-2); font-weight: 500; }
.field input, .field select, .field textarea {
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-2);
  background: var(--surface-2);
  font-size: .875rem;
  transition: border-color .15s;
  color: var(--text);
  width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.checkbox-field { flex-direction: row; align-items: center; }
.checkbox-label { display: flex; align-items: center; gap: 8px; font-size: .875rem; cursor: pointer; }
.checkbox-label input[type=checkbox] {
  width: 16px; height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  border: none;
  padding: 0;
}

/* ─── Modal ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal-lg { max-width: 600px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-close { font-size: 1.1rem; cursor: pointer; color: var(--text-2); padding: 4px; }
.modal-close:hover { color: var(--text); }
.modal form { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 4px;
}

/* ─── Login ──────────────────────────────────────────────────────────────── */
.login-page { display: flex; align-items: center; justify-content: center; }
.login-wrap {
  width: 100%;
  max-width: 340px;
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.login-logo {
  width: 56px; height: 56px;
  border-radius: 14px;
  background: var(--accent);
  color: #000;
  font-weight: 800;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}
.login-wrap h1 { font-size: 1.4rem; font-weight: 700; }
.login-sub { font-size: .85rem; color: var(--text-2); margin-bottom: 8px; }
.login-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.login-form input {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-2);
  background: var(--surface);
  font-size: .95rem;
  color: var(--text);
  width: 100%;
}
.login-form input:focus { border-color: var(--accent); }
.login-form button {
  padding: 11px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #000;
  font-weight: 600;
  cursor: pointer;
  font-size: .95rem;
  transition: background .15s;
}
.login-form button:hover { background: var(--accent-h); }
.login-error {
  font-size: .82rem;
  color: var(--danger);
  text-align: center;
}

/* ─── Quote statuses ─────────────────────────────────────────────────────── */
.status-q-bozza     { background: var(--surface-3); color: var(--text-2); }
.status-q-inviato   { background: var(--js-confermato);     color: var(--js-confermato-t); }
.status-q-accettato { background: var(--s-consegnato);      color: var(--s-consegnato-t); }
.status-q-rifiutato { background: #450a0a; color: #fca5a5; }
.status-q-scaduto   { background: var(--s-montaggio);       color: var(--s-montaggio-t); }

/* ─── Quote items form ───────────────────────────────────────────────────── */
.quote-item-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}
.quote-item-row input {
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-2);
  background: var(--surface-2);
  color: var(--text);
  font-size: .875rem;
}
.quote-item-row input:focus { border-color: var(--accent); outline: none; }

/* ─── Quote items table (detail view) ───────────────────────────────────── */
.quote-items-table { margin-bottom: 8px; }
.qi-header {
  display: grid;
  grid-template-columns: 1fr 60px 90px 90px;
  gap: 8px;
  padding: 0 0 8px;
  border-bottom: 1px solid var(--border);
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-3);
  font-weight: 600;
}
.qi-row {
  display: grid;
  grid-template-columns: 1fr 60px 90px 90px;
  gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: .875rem;
}
.qi-row:last-child { border-bottom: none; }
.qi-header span:not(:first-child),
.qi-row span:not(:first-child) { text-align: right; }

/* ─── Share URL bar ──────────────────────────────────────────────────────── */
.share-url-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.share-url-bar code {
  flex: 1;
  font-size: .78rem;
  color: var(--accent);
  word-break: break-all;
  font-family: monospace;
}

/* ─── File rows ──────────────────────────────────────────────────────────── */
.file-rows { display: flex; flex-direction: column; gap: 6px; }
.file-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color .15s;
}
.file-row-filled { border-color: var(--border-2); }
.file-row-phase {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 170px;
  flex-shrink: 0;
}
.file-row-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  min-width: 0;
}
.file-row-storage { font-size: .875rem; font-weight: 500; white-space: nowrap; }
.file-row-path {
  font-size: .72rem;
  color: var(--text-2);
  font-family: monospace;
  background: var(--surface-2);
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 300px;
}

/* ─── Price col table ────────────────────────────────────────────────────── */
.price-col { font-weight: 600; color: var(--accent); }
.text-danger { color: var(--danger); }

/* ─── Files grid ─────────────────────────────────────────────────────────── */
.files-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.file-card {
  background: var(--surface);
  border: 1px dashed var(--border-2);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color .15s, background .15s;
  min-height: 90px;
}
.file-card-filled {
  border-style: solid;
  border-color: var(--border);
}
.file-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
}
.file-phase-icon { font-size: 1.1rem; flex-shrink: 0; }
.file-phase-label { font-size: .82rem; font-weight: 600; }
.file-card-body { display: flex; flex-direction: column; gap: 5px; }
.file-loc { display: flex; align-items: center; gap: 6px; font-size: .82rem; }
.file-loc-icon { font-size: .9rem; }
.file-path code {
  font-size: .72rem;
  color: var(--text-2);
  word-break: break-all;
  font-family: monospace;
  background: var(--surface-3);
  padding: 2px 6px;
  border-radius: 4px;
  display: block;
}
.file-link {
  font-size: .78rem;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}
.file-link:hover { color: var(--accent-h); }

/* ─── Light theme ───────────────────────────────────────────────────────── */
[data-theme="light"] {
  --bg:        #f7f6f3;
  --surface:   #ffffff;
  --surface-2: #f1f0ed;
  --surface-3: #e9e8e5;
  --border:    #e3e2de;
  --border-2:  #d6d5d2;
  --text:      #1a1a1a;
  --text-2:    #787774;
  --text-3:    #b0aeaa;
  --shadow:    0 2px 8px rgba(0,0,0,.07);
}

/* ─── Theme toggle ───────────────────────────────────────────────────────── */
.theme-toggle {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  transition: background .15s;
  margin-left: 4px;
}
.theme-toggle:hover { background: var(--surface-3); }

/* ─── Dashboard ──────────────────────────────────────────────────────────── */
.dash-greeting-row {
  margin-bottom: 24px;
}
.dash-greeting {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.2;
}
.dash-date {
  font-size: .85rem;
  color: var(--text-2);
  margin-top: 2px;
}
.dash-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}
.dash-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color .15s, box-shadow .15s;
}
.dash-stat-card:hover { border-color: var(--border-2); box-shadow: var(--shadow); }
.dash-stat-accent  { border-color: rgba(201,169,110,.3);  background: rgba(201,169,110,.05); }
.dash-stat-warning { border-color: rgba(249,115,22,.35);  background: rgba(249,115,22,.06); }
.dash-stat-danger  { border-color: rgba(239,68,68,.35);   background: rgba(239,68,68,.06); }
.dash-stat-num {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}
.dash-stat-accent .dash-stat-num  { color: var(--accent); }
.dash-stat-warning .dash-stat-num { color: #f97316; }
.dash-stat-danger .dash-stat-num  { color: var(--danger); }
.dash-stat-label { font-size: .78rem; color: var(--text-2); }

.dash-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  align-items: start;
}
@media (max-width: 900px) { .dash-layout { grid-template-columns: 1fr; } }
.dash-right { display: flex; flex-direction: column; gap: 0; }

/* ─── Job work cards ─────────────────────────────────────────────────────── */
.job-work-list { display: flex; flex-direction: column; gap: 10px; }
.job-work-card {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow .15s, border-color .15s;
  cursor: pointer;
}
.job-work-card:hover { box-shadow: var(--shadow); border-color: var(--border-2); }
.job-work-strip { width: 4px; flex-shrink: 0; }
.job-work-matrimonio .job-work-strip { background: #f472b6; }
.job-work-matrimonio { background: rgba(244,114,182,.04); }
.job-work-social .job-work-strip { background: #60a5fa; }
.job-work-social { background: rgba(96,165,250,.04); }
.job-work-corporate .job-work-strip { background: #34d399; }
.job-work-corporate { background: rgba(52,211,153,.04); }
.job-work-body {
  flex: 1;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.job-work-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.job-work-pct {
  font-size: .78rem;
  font-weight: 700;
  color: var(--text-2);
}
.job-work-title {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.job-work-meta {
  font-size: .78rem;
  color: var(--text-2);
}
.job-work-bar-wrap {
  height: 5px;
  background: var(--surface-3);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 2px;
}
.job-work-bar {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width .4s;
}
.job-work-matrimonio .job-work-bar { background: #f472b6; }
.job-work-social .job-work-bar { background: #60a5fa; }
.job-work-corporate .job-work-bar { background: #34d399; }
.job-work-count {
  font-size: .72rem;
  color: var(--text-3);
}

/* ─── Agenda ─────────────────────────────────────────────────────────────── */
.agenda-list { display: flex; flex-direction: column; gap: 8px; }
.agenda-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  transition: box-shadow .15s, border-color .15s;
}
.agenda-item:hover { box-shadow: var(--shadow); border-color: var(--border-2); }
.agenda-date-box {
  flex-shrink: 0;
  width: 40px;
  text-align: center;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 4px 0;
}
.agenda-day { font-size: 1.1rem; font-weight: 700; line-height: 1; }
.agenda-mon { font-size: .62rem; font-weight: 600; color: var(--text-2); letter-spacing: .05em; }
.agenda-info { flex: 1; min-width: 0; }
.agenda-title { font-size: .875rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agenda-sub { font-size: .75rem; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ─── Urgent deadlines (dashboard) ──────────────────────────────────────── */
.urgent-dl-list { display: flex; flex-direction: column; gap: 2px; }
.urgent-section {
  background: rgba(239,68,68,.04);
  border: 1px solid rgba(239,68,68,.25);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 0;
}
.urgent-dl-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: 4px;
  transition: border-color .15s;
}
.urgent-dl-item.past { border-color: rgba(239,68,68,.3); background: rgba(239,68,68,.04); }
.urgent-dl-body { flex: 1; min-width: 0; }
.urgent-dl-title { font-size: .875rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.urgent-dl-job { font-size: .72rem; color: var(--text-2); }
.urgent-dl-when { font-size: .75rem; font-weight: 600; color: var(--text-2); white-space: nowrap; }
.urgent-dl-when.past { color: var(--danger); }

/* ─── Alert scadenze (dashboard) ────────────────────────────────────────── */
.alert-scadenze {
  background: rgba(239,68,68,.08);
  border: 1px solid rgba(239,68,68,.3);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 24px;
}
.alert-scadenze h3 {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--danger);
  margin-bottom: 10px;
}
.alert-dl-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px solid rgba(239,68,68,.12);
  font-size: .875rem;
}
.alert-dl-row:last-child { border-bottom: none; }
.alert-dl-title { flex: 1; }
.alert-dl-date { font-size: .78rem; color: var(--danger); font-weight: 600; white-space: nowrap; }

/* ─── Urgency tags (deadlines) ───────────────────────────────────────────── */
.urgency-tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
}
.urgency-tag.urgency-scaduta       { background: rgba(239,68,68,.15); color: var(--danger); }
.urgency-tag.urgency-urgente       { background: rgba(249,115,22,.15); color: #f97316; }
.urgency-tag.urgency-questa-settimana { background: rgba(234,179,8,.12); color: #ca8a04; }
.urgency-tag.urgency-ok            { background: var(--surface-3); color: var(--text-2); }

/* ─── Priority dot ───────────────────────────────────────────────────────── */
.priority-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.priority-dot.priority-normale   { background: var(--text-3); }
.priority-dot.priority-alta      { background: #f97316; }
.priority-dot.priority-urgente   { background: var(--danger); }

/* ─── Recur badge ────────────────────────────────────────────────────────── */
.recur-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 600;
  background: rgba(201,169,110,.12);
  color: var(--accent);
  white-space: nowrap;
}

/* ─── Deadline card highlight rows ──────────────────────────────────────── */
.dl-scaduta .card-item     { border-color: rgba(239,68,68,.35); }
.dl-urgente .card-item     { border-color: rgba(249,115,22,.3); }
.dl-questa-settimana .card-item { border-color: rgba(234,179,8,.25); }

/* ─── Client notes ───────────────────────────────────────────────────────── */
.client-notes-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.client-note {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.cn-body {
  font-size: .875rem;
  line-height: 1.6;
  margin-bottom: 8px;
  white-space: pre-wrap;
}
.cn-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* ─── Dropdown ───────────────────────────────────────────────────────────── */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 220px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  z-index: 200;
  overflow: hidden;
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 14px;
  font-size: .875rem;
  cursor: pointer;
  text-align: left;
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background: var(--surface-3); }

/* ─── Bar chart (report) ─────────────────────────────────────────────────── */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 180px;
  padding: 0 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.bc-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
}
.bc-bar-wrap {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  position: relative;
}
.bc-bar {
  width: 100%;
  background: var(--accent);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  transition: height .3s;
}
.bc-val {
  font-size: .58rem;
  color: var(--text-2);
  text-align: center;
  margin-bottom: 3px;
  white-space: nowrap;
}
.bc-label {
  font-size: .7rem;
  color: var(--text-2);
  text-align: center;
  padding-bottom: 4px;
}

/* ─── Utility ────────────────────────────────────────────────────────────── */
.line-through { text-decoration: line-through; opacity: .5; }
.text-xs { font-size: .75rem; }

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .nav { padding: 0 12px; }
  .container { padding: 20px 12px 40px; }
  .field-row { grid-template-columns: 1fr; }
  .table-wrap { font-size: .8rem; }
  .stats-row { gap: 8px; }
}
