/* =============================================
   RILIEVO SERRAMENTI & ACCESSORI - CSS PREMIUM
   ============================================= */
:root {
  --bg: #070b12;
  --card: #0c1424;
  --card2: #0a1120;
  --text: #e8eefc;
  --muted: #9fb0d0;
  --line: rgba(255,255,255,.08);
  --acc: #31c3ff;
  --acc2: #3bf0d2;
  --warn: #ffcc66;
  --bad: #ff6b6b;
  --ok: #66ffa8;
  --shadow: 0 18px 60px rgba(0,0,0,.55);
  --r: 18px;
  --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: radial-gradient(1200px 900px at 20% 0%, rgba(49,195,255,.18), transparent 55%),
              radial-gradient(1000px 700px at 90% 15%, rgba(59,240,210,.13), transparent 55%),
              linear-gradient(180deg, #05070c 0%, #070b12 100%);
  color: var(--text); font-family: var(--font);
  min-height: 100vh;
}
a { color: inherit; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 18px 14px 96px; }
.hidden { display: none !important; }

/* TOP BAR */
.top {
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(10px);
  background: linear-gradient(180deg, rgba(7,11,18,.92), rgba(7,11,18,.6));
  border-bottom: 1px solid var(--line);
}
.top .bar { max-width: 1080px; margin: 0 auto; padding: 12px 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.logo {
  width: 40px; height: 40px; border-radius: 14px; flex-shrink: 0;
  background: linear-gradient(135deg, rgba(49,195,255,.95), rgba(59,240,210,.85));
  box-shadow: 0 14px 40px rgba(49,195,255,.14); display: grid; place-items: center;
  color: #00131e; font-weight: 900; font-size: 14px;
}
.title { display: flex; flex-direction: column; gap: 2px; }
.title h1 { font-size: 15px; margin: 0; }
.title p { margin: 0; color: var(--muted); font-size: 12px; }
.spacer { flex: 1; }
.pill {
  display: inline-flex; gap: 8px; align-items: center;
  padding: 7px 10px; border-radius: 999px;
  background: rgba(255,255,255,.06); border: 1px solid var(--line);
  color: var(--muted); font-size: 12px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 4px rgba(102,255,168,.14); }
.dot.bad { background: var(--bad); box-shadow: 0 0 0 4px rgba(255,107,107,.14); }
.user-pill {
  display: inline-flex; gap: 8px; align-items: center;
  padding: 6px 12px; border-radius: 999px;
  background: rgba(49,195,255,.08); border: 1px solid rgba(49,195,255,.2);
  color: var(--acc); font-size: 12px; cursor: pointer;
}
.user-pill:hover { background: rgba(49,195,255,.15); }

/* GRID & CARDS */
.grid { display: grid; gap: 12px; }
@media(min-width: 860px) {
  .grid.cols2 { grid-template-columns: 1.1fr .9fr; }
  .grid.cols3 { grid-template-columns: repeat(3, 1fr); }
}
.card {
  background: linear-gradient(180deg, rgba(12,20,36,.95), rgba(10,17,32,.95));
  border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow); overflow: hidden;
}
.card .head {
  padding: 14px 14px 10px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}
.card .head h2 { margin: 0; font-size: 15px; }
.card .head .sub { color: var(--muted); font-size: 12px; }
.card .body { padding: 14px; }

/* ROWS & FORM */
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
input, select, textarea {
  width: 100%; padding: 12px 12px; border-radius: 14px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.10);
  color: var(--text); outline: none; font-family: var(--font);
  font-size: 14px;
  transition: border-color .2s;
}
input:focus, select:focus, textarea:focus {
  border-color: rgba(49,195,255,.4);
  background: rgba(49,195,255,.04);
}
input[type="number"] { appearance: textfield; }
textarea { min-height: 90px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .7; }

/* BUTTONS */
.btn {
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
  color: var(--text); border-radius: 14px;
  padding: 12px 14px; font-weight: 700; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 14px; font-family: var(--font);
  transition: background .15s, transform .1s, box-shadow .15s;
  white-space: nowrap;
}
.btn:hover { background: rgba(255,255,255,.1); }
.btn.primary {
  background: linear-gradient(135deg, rgba(49,195,255,.95), rgba(59,240,210,.90));
  color: #00131e; border: none;
  box-shadow: 0 8px 30px rgba(49,195,255,.2);
}
.btn.primary:hover { box-shadow: 0 8px 40px rgba(49,195,255,.35); }
.btn.secondary {
  background: rgba(49,195,255,.08); border-color: rgba(49,195,255,.25); color: var(--acc);
}
.btn.secondary:hover { background: rgba(49,195,255,.15); }
.btn.warn { background: rgba(255,204,102,.15); border-color: rgba(255,204,102,.22); color: var(--warn); }
.btn.warn:hover { background: rgba(255,204,102,.25); }
.btn.danger { background: rgba(255,107,107,.15); border-color: rgba(255,107,107,.22); color: var(--bad); }
.btn.danger:hover { background: rgba(255,107,107,.25); }
.btn.small { padding: 8px 12px; border-radius: 12px; font-size: 12px; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

/* CHIPS */
.muted { color: var(--muted); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  font-size: 12px; padding: 7px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: rgba(255,255,255,.04); color: var(--muted);
  cursor: pointer; user-select: none; transition: all .15s;
}
.chip:hover { background: rgba(255,255,255,.08); }
.chip.active {
  color: #00131e;
  background: linear-gradient(135deg, rgba(49,195,255,.95), rgba(59,240,210,.88));
  border-color: transparent;
}

/* LIST & ITEMS */
.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  border: 1px solid var(--line); background: rgba(255,255,255,.025);
  border-radius: 16px; padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
  transition: border-color .2s, background .2s;
}
.item:hover { border-color: rgba(49,195,255,.2); background: rgba(49,195,255,.02); }
.item .toprow { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.item .code { font-weight: 900; letter-spacing: .3px; font-size: 14px; }
.badge {
  font-size: 11px; padding: 5px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: rgba(255,255,255,.04); color: var(--muted);
  display: inline-flex; gap: 6px; align-items: center; white-space: nowrap;
}
.badge .b { width: 7px; height: 7px; border-radius: 50%; }
.b.gray { background: #96a1bd; }
.b.blue { background: var(--acc); }
.b.green { background: var(--ok); }
.b.yellow { background: var(--warn); }
.b.red { background: var(--bad); }
.b.purple { background: #c084fc; }

/* KV GRID */
.kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media(min-width: 860px) { .kv { grid-template-columns: repeat(4, 1fr); } }
.kv .k {
  border: 1px dashed rgba(255,255,255,.08);
  background: rgba(255,255,255,.02);
  border-radius: 12px; padding: 10px;
}
.kv .k .t { font-size: 11px; color: var(--muted); }
.kv .k .v { font-size: 14px; margin-top: 4px; font-weight: 700; }
.kv .k .v.acc { color: var(--acc); }
.kv .k .v.ok { color: var(--ok); }

/* FOOTER NAV */
.footerbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: linear-gradient(180deg, rgba(7,11,18,0), rgba(7,11,18,.97) 30%);
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255,255,255,.06);
}
.footerbar .inner { max-width: 1080px; margin: 0 auto; display: flex; gap: 8px; }
.footerbar .inner > * { flex: 1; }
.nav-btn {
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.04);
  color: var(--muted); border-radius: 12px;
  padding: 10px 8px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  font-size: 11px; font-family: var(--font);
  flex-direction: column;
  transition: all .15s;
}
.nav-btn i { font-size: 16px; }
.nav-btn.active { color: var(--acc); border-color: rgba(49,195,255,.25); background: rgba(49,195,255,.06); }
.nav-btn:hover { background: rgba(255,255,255,.08); }

/* MISC */
.split { display: flex; gap: 10px; flex-wrap: wrap; }
.split > * { flex: 1; min-width: 160px; }
.hr { height: 1px; background: var(--line); margin: 14px 0; }
.hint { font-size: 12px; color: var(--muted); line-height: 1.45; }
.right { justify-content: flex-end; }
.tiny { font-size: 11px; color: var(--muted); }
.dangerText { color: var(--bad); font-weight: 700; }
.mt8 { margin-top: 8px; }
.mt12 { margin-top: 12px; }
.mb0 { margin-bottom: 0; }
.bold { font-weight: 700; }
.text-acc { color: var(--acc); }
.text-ok { color: var(--ok); }
.text-warn { color: var(--warn); }
.text-bad { color: var(--bad); }
.section-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .8px; color: var(--acc2); margin: 14px 0 10px;
  display: flex; align-items: center; gap: 6px;
}
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* PHOTOS */
.gallery { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media(min-width: 640px) { .gallery { grid-template-columns: repeat(3, 1fr); } }
figure { margin: 0; }
figure img {
  width: 100%; height: 150px; object-fit: cover; border-radius: 12px;
  border: 1px solid rgba(255,255,255,.10); cursor: zoom-in;
  transition: transform .2s;
}
figure img:hover { transform: scale(1.02); }
figcaption { margin-top: 5px; font-size: 11px; color: var(--muted); }

/* CANVAS */
canvas {
  width: 100%; border-radius: 16px; border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.03); touch-action: none; display: block;
}

/* LIGHTBOX */
.lightbox {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0,0,0,.85); display: none; place-items: center; padding: 16px;
}
.lightbox.open { display: grid; }
.lightbox img {
  max-width: min(980px, 100%); max-height: 80vh;
  border-radius: 16px; border: 1px solid rgba(255,255,255,.14);
}
.lbbar { display: flex; gap: 10px; margin-top: 10px; width: min(980px, 100%); }
.lbbar .btn { flex: 1; }

/* MODAL */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,.75); display: none; place-items: center; padding: 16px;
}
.modal-overlay.open { display: grid; }
.modal {
  background: linear-gradient(180deg, #0d1629, #090f1e);
  border: 1px solid rgba(255,255,255,.12); border-radius: 22px;
  box-shadow: 0 30px 80px rgba(0,0,0,.7);
  width: 100%; max-width: 480px; padding: 28px;
  animation: modalIn .2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(10px) scale(.97); }
  to { opacity: 1; transform: none; }
}
.modal h2 { margin: 0 0 20px; font-size: 20px; }
.modal .close-btn {
  position: absolute; top: 16px; right: 16px;
  background: rgba(255,255,255,.08); border: none; color: var(--muted);
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
  font-size: 16px;
}
.modal-rel { position: relative; }

/* AUTH SCREEN */
#viewAuth {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.auth-card {
  width: 100%; max-width: 420px;
  background: linear-gradient(180deg, rgba(12,20,36,.98), rgba(10,17,32,.98));
  border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow);
  padding: 36px 28px;
}
.auth-logo {
  width: 60px; height: 60px; border-radius: 20px;
  background: linear-gradient(135deg, rgba(49,195,255,.95), rgba(59,240,210,.85));
  display: grid; place-items: center; color: #00131e; font-weight: 900; font-size: 20px;
  margin: 0 auto 20px;
}
.auth-card h2 { text-align: center; margin: 0 0 6px; font-size: 22px; }
.auth-card .sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 28px; }
.auth-tabs { display: flex; gap: 4px; background: rgba(255,255,255,.04); border-radius: 12px; padding: 4px; margin-bottom: 24px; }
.auth-tab {
  flex: 1; padding: 8px; border-radius: 9px; border: none; cursor: pointer;
  background: none; color: var(--muted); font-weight: 600; font-size: 13px; font-family: var(--font);
  transition: all .15s;
}
.auth-tab.active { background: rgba(49,195,255,.15); color: var(--acc); }
.auth-form .field { margin-bottom: 16px; }
.auth-form .field label { margin-bottom: 8px; font-size: 13px; }
.auth-form .field input { padding: 14px 16px; font-size: 15px; }
.auth-error { color: var(--bad); font-size: 13px; text-align: center; margin-top: 10px; }
.auth-success { color: var(--ok); font-size: 13px; text-align: center; margin-top: 10px; }
.role-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 700;
}
.role-badge.admin { background: rgba(192,132,252,.15); border: 1px solid rgba(192,132,252,.3); color: #c084fc; }
.role-badge.tecnico { background: rgba(49,195,255,.12); border: 1px solid rgba(49,195,255,.25); color: var(--acc); }

/* ACCESSORY SECTIONS */
.acc-section {
  border: 1px solid var(--line); border-radius: 14px; overflow: hidden; margin-bottom: 12px;
}
.acc-header {
  padding: 12px 14px; display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; user-select: none; gap: 10px;
  background: rgba(255,255,255,.02);
  transition: background .15s;
}
.acc-header:hover { background: rgba(255,255,255,.05); }
.acc-header .acc-title { font-weight: 700; font-size: 13px; display: flex; gap: 8px; align-items: center; }
.acc-header .acc-badge {
  font-size: 11px; padding: 3px 8px; border-radius: 999px;
  background: rgba(49,195,255,.12); border: 1px solid rgba(49,195,255,.2); color: var(--acc);
}
.acc-header .acc-badge.enabled {
  background: rgba(102,255,168,.12); border-color: rgba(102,255,168,.2); color: var(--ok);
}
.acc-header .chevron { color: var(--muted); transition: transform .2s; font-size: 12px; }
.acc-header.open .chevron { transform: rotate(180deg); }
.acc-body { padding: 14px; border-top: 1px solid var(--line); }
.acc-body.collapsed { display: none; }

/* SUMMARY TABLE */
.summary-table { overflow-x: auto; }
.summary-table table {
  width: 100%; border-collapse: separate; border-spacing: 0 8px;
  font-size: 13px; min-width: 700px;
}
.summary-table thead tr { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.summary-table thead th { padding: 6px 10px; text-align: left; white-space: nowrap; }
.summary-table tbody tr {
  background: rgba(255,255,255,.025); transition: background .15s;
}
.summary-table tbody tr:hover { background: rgba(49,195,255,.04); }
.summary-table tbody td { padding: 10px; }
.summary-table tbody td:first-child { border-top-left-radius: 12px; border-bottom-left-radius: 12px; }
.summary-table tbody td:last-child { border-top-right-radius: 12px; border-bottom-right-radius: 12px; }

/* TOAST */
.toast-container {
  position: fixed; bottom: 90px; right: 16px; z-index: 100;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  padding: 12px 18px; border-radius: 14px; font-size: 13px; font-weight: 600;
  box-shadow: 0 8px 30px rgba(0,0,0,.4); pointer-events: auto;
  animation: toastIn .2s ease; max-width: 280px;
}
.toast.success { background: rgba(102,255,168,.15); border: 1px solid rgba(102,255,168,.3); color: var(--ok); }
.toast.error { background: rgba(255,107,107,.15); border: 1px solid rgba(255,107,107,.3); color: var(--bad); }
.toast.info { background: rgba(49,195,255,.12); border: 1px solid rgba(49,195,255,.25); color: var(--acc); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: none; }
}

/* CHECKLIST */
.checklist-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: rgba(255,255,255,.02); margin-bottom: 8px;
}
.checklist-item .check-icon {
  width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 14px;
}
.checklist-item .check-icon.yes { background: rgba(102,255,168,.12); color: var(--ok); }
.checklist-item .check-icon.no { background: rgba(255,107,107,.08); color: var(--bad); }
.checklist-item .check-label { flex: 1; font-size: 13px; }

/* USERS TABLE */
.users-table { width: 100%; border-collapse: separate; border-spacing: 0 8px; }
.users-table thead { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.users-table th { padding: 6px 10px; text-align: left; }
.users-table td { padding: 10px; background: rgba(255,255,255,.025); }
.users-table td:first-child { border-top-left-radius: 12px; border-bottom-left-radius: 12px; }
.users-table td:last-child { border-top-right-radius: 12px; border-bottom-right-radius: 12px; }

/* PRINT STYLES */
@media print {
  .top, .footerbar, .btn, .no-print { display: none !important; }
  body { background: white; color: #111; }
  .card { box-shadow: none; border: 1px solid #ddd; background: white; }
  .badge { border: 1px solid #999; }
  canvas { display: none; }
}

/* SCROLLBAR */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: rgba(255,255,255,.02); }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 3px; }

/* ANIMATIONS */
.fade-in { animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.slide-up { animation: slideUp .25s ease; }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* PROGRESS INDICATOR */
.progress-bar {
  height: 3px; border-radius: 2px; background: rgba(255,255,255,.06);
  overflow: hidden; margin: 8px 0;
}
.progress-bar .fill {
  height: 100%; border-radius: 2px;
  background: linear-gradient(90deg, var(--acc), var(--acc2));
  transition: width .3s ease;
}

/* STATUS COLORS */
.status-da-verificare { color: var(--warn); }
.status-misurato { color: var(--ok); }
.status-in-preventivo { color: var(--acc); }
.status-ordinato { color: var(--acc2); }
.status-in-posa { color: var(--warn); }
.status-chiuso { color: var(--ok); }

/* EMPTY STATE */
.empty-state {
  text-align: center; padding: 40px 20px; color: var(--muted);
}
.empty-state i { font-size: 48px; opacity: .3; margin-bottom: 16px; }
.empty-state h3 { font-size: 16px; color: var(--text); margin: 0 0 8px; }
.empty-state p { font-size: 13px; margin: 0; }

/* RESPONSIVE */
@media(max-width: 600px) {
  .wrap { padding: 14px 10px 90px; }
  .card .body { padding: 12px; }
  .btn { padding: 11px 12px; font-size: 13px; }
  .kv { grid-template-columns: 1fr 1fr; }
  .nav-btn span.nav-label { display: none; }
  .nav-btn { padding: 8px; }
}
