/* ============ Ottobix CRM — brand design system ============
   Tema chiaro (default, brand Ottobix) + tema scuro via [data-theme="dark"] */
:root {
  /* Neutri — light */
  --bg: #f5f6f8;
  --bg2: #ffffff;
  --bg3: #eef1f4;
  --bg-hover: #e8edf2;
  --border: rgba(37, 54, 73, 0.10);
  --border-strong: rgba(37, 54, 73, 0.18);
  --text: #253649;
  --text2: #54677a;
  --text3: #8494a3;
  --glass: rgba(255, 255, 255, 0.86);
  --scroll: #c9d3dc;
  --shadow: 0 10px 34px rgba(37, 54, 73, 0.10);

  /* Brand */
  --accent: #69a0bf;
  --accent-tint: rgba(105, 160, 191, 0.15);
  --accent-ink: #3f7595;
  --insight-ink: #2f5d78;

  /* Semantic (base = riempimenti/grafici, ink = testi, tint = sfondi) */
  --green: #61a980;  --green-ink: #417a5a;  --green-tint: rgba(97, 169, 128, 0.15);
  --gold: #d29857;   --gold-ink: #a06c2e;   --gold-tint: rgba(210, 152, 87, 0.16);
  --orange: #c97f52; --orange-ink: #a05a30; --orange-tint: rgba(201, 127, 82, 0.16);
  --red: #bf635f;    --red-ink: #a04440;    --red-tint: rgba(191, 99, 95, 0.14);
  --purple: #7a6fac; --purple-ink: #5c5290; --purple-tint: rgba(122, 111, 172, 0.15);
  --gray: #8494a5;   --gray-ink: #5f7183;   --gray-tint: rgba(132, 148, 165, 0.16);

  --radius: 14px;
  --radius-sm: 10px;
  --font: "Poppins", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
    Roboto, "Helvetica Neue", Arial, sans-serif;
}

[data-theme="dark"] {
  --bg: #111a24;
  --bg2: #1b2836;
  --bg3: #243444;
  --bg-hover: #2a3c4f;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);
  --text: #f2f6f9;
  --text2: #a8b8c6;
  --text3: #75879a;
  --glass: rgba(17, 26, 36, 0.84);
  --scroll: #2e4154;
  --shadow: 0 10px 34px rgba(0, 0, 0, 0.45);

  --accent-tint: rgba(105, 160, 191, 0.18);
  --accent-ink: #8fc0da;
  --insight-ink: #cfe4f2;

  --green-ink: #7fc39c;  --green-tint: rgba(97, 169, 128, 0.16);
  --gold-ink: #e2ae72;   --gold-tint: rgba(210, 152, 87, 0.15);
  --orange-ink: #db9a6e; --orange-tint: rgba(201, 127, 82, 0.15);
  --red-ink: #dd8b86;    --red-tint: rgba(191, 99, 95, 0.16);
  --purple-ink: #a89ddb; --purple-tint: rgba(122, 111, 172, 0.18);
  --gray-ink: #a5b3c0;   --gray-tint: rgba(132, 148, 165, 0.15);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-ink); text-decoration: none; }
button { font-family: var(--font); }
::selection { background: rgba(105, 160, 191, 0.30); }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 5px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 22px 12px 14px;
}
.logo { display: flex; align-items: center; gap: 9px; padding: 2px 10px 20px; }
.logo-img { height: 26px; max-width: 150px; object-fit: contain; display: block; }
[data-theme="dark"] .logo-img { filter: brightness(0) invert(1) opacity(0.92); }
.logo-mark {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  background: linear-gradient(135deg, #69a0bf, #253649);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 16px; color: #fff;
}
.logo-crm {
  font-size: 10px; font-weight: 700; letter-spacing: 0.8px;
  color: var(--accent-ink); background: var(--accent-tint);
  padding: 2px 7px; border-radius: 6px;
}
.logo-name { font-weight: 700; font-size: 15px; letter-spacing: -0.2px; }
.logo-name span { color: var(--text3); font-weight: 500; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text2); font-size: 13px; font-weight: 500;
  cursor: pointer; border: none; background: none; text-align: left;
  transition: background 0.15s, color 0.15s;
}
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--accent-tint); color: var(--accent-ink); font-weight: 600; }
.nav-badge {
  margin-left: auto; background: var(--red); color: #fff;
  font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 99px;
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-top: 1px solid var(--border); margin-top: 10px;
}
.sidebar-user .avatar { width: 30px; height: 30px; font-size: 12px; }
.sidebar-user-name { font-size: 13px; font-weight: 600; flex: 1; }
.sidebar-user-role { font-size: 11px; color: var(--text3); }
.icon-btn {
  background: none; border: none; color: var(--text3); cursor: pointer;
  padding: 6px; border-radius: 8px; display: flex;
}
.icon-btn:hover { color: var(--text); background: var(--bg3); }
.icon-btn svg { width: 17px; height: 17px; }

.main { padding: 26px 30px 60px; max-width: 1440px; width: 100%; margin: 0 auto; min-width: 0; }
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.page-title { font-size: 23px; font-weight: 700; letter-spacing: -0.4px; }
.page-sub { color: var(--text3); font-size: 13px; margin-top: 2px; }
.page-head .spacer { flex: 1; }

.topbar, .tabbar { display: none; }

/* ---------- Cards & KPI ---------- */
.card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
}
.card-title { font-size: 12.5px; font-weight: 600; color: var(--text2); margin-bottom: 14px; }
.grid-kpi {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px; margin-bottom: 18px;
}
.kpi { padding: 15px 16px; cursor: default; }
.kpi-label { font-size: 11px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: 0.5px; }
.kpi-value { font-size: 25px; font-weight: 700; letter-spacing: -0.5px; margin-top: 4px; }
.kpi-value small { font-size: 14px; color: var(--text3); font-weight: 600; }
.kpi-sub { font-size: 11.5px; color: var(--text3); margin-top: 2px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.grid-3 { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; }

/* ---------- Badges / pills ---------- */
.score-pill {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; height: 22px; padding: 0 8px; border-radius: 7px;
  font-weight: 700; font-size: 12.5px;
}
.sc-green { background: var(--green-tint); color: var(--green-ink); }
.sc-gold { background: var(--gold-tint); color: var(--gold-ink); }
.sc-orange { background: var(--orange-tint); color: var(--orange-ink); }
.sc-red { background: var(--red-tint); color: var(--red-ink); }
.sc-none { background: var(--bg3); color: var(--text3); }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 99px; font-size: 11.5px; font-weight: 600;
  background: var(--bg3); color: var(--text2); white-space: nowrap;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st-blue { background: var(--accent-tint); color: var(--accent-ink); }
.st-teal { background: rgba(74, 122, 150, 0.16); color: var(--accent-ink); }
.st-purple { background: var(--purple-tint); color: var(--purple-ink); }
.st-gold { background: var(--gold-tint); color: var(--gold-ink); }
.st-green { background: var(--green-tint); color: var(--green-ink); }
.st-red { background: var(--red-tint); color: var(--red-ink); }
.st-gray { background: var(--gray-tint); color: var(--gray-ink); }
.tag {
  display: inline-block; padding: 3px 9px; border-radius: 7px;
  background: var(--bg3); border: 1px solid var(--border);
  font-size: 12px; color: var(--text2); margin: 0 6px 6px 0;
}
.dir-badge { font-size: 10px; font-weight: 800; padding: 2px 7px; border-radius: 6px; }
.dir-in { background: var(--green-tint); color: var(--green-ink); }
.dir-out { background: var(--accent-tint); color: var(--accent-ink); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  background: var(--bg2); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 8px 15px; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background 0.15s, transform 0.05s;
  white-space: nowrap;
}
.btn:hover { background: var(--bg3); }
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn.primary:hover { background: #5b91b1; }
.btn.danger { background: var(--red-tint); border-color: transparent; color: var(--red-ink); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text2); }
.btn.ghost:hover { background: var(--bg3); color: var(--text); }
.btn.sm { padding: 5px 11px; font-size: 12px; border-radius: 8px; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn svg { width: 15px; height: 15px; }

/* ---------- Chips (filtri rapidi) ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 6px 13px; border-radius: 99px; font-size: 12.5px; font-weight: 600;
  background: var(--bg2); border: 1px solid var(--border); color: var(--text2);
  cursor: pointer; transition: all 0.15s;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.active { background: var(--accent-tint); border-color: rgba(105, 160, 191, 0.5); color: var(--accent-ink); }
.chip .n { opacity: 0.75; font-weight: 700; margin-left: 4px; }

/* ---------- Toolbar / forms ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.input, select.input, textarea.input {
  background: var(--bg2); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); color: var(--text);
  padding: 8px 12px; font-size: 13px; font-family: var(--font);
  outline: none; transition: border 0.15s, box-shadow 0.15s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(105, 160, 191, 0.22); }
.input::placeholder { color: var(--text3); }
select.input { appearance: none; -webkit-appearance: none; padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238494a3' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; }
textarea.input { resize: vertical; min-height: 74px; width: 100%; }
.search-wrap { position: relative; flex: 1; min-width: 180px; max-width: 340px; }
.search-wrap svg {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--text3); pointer-events: none;
}
.search-wrap .input { width: 100%; padding-left: 34px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 13px; }
.field > label { font-size: 11px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: 0.5px; }
.field .input { width: 100%; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.switch { position: relative; width: 42px; height: 25px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; background: var(--bg3);
  border: 1px solid var(--border-strong); border-radius: 99px;
  cursor: pointer; transition: background 0.2s;
}
.switch .track::after {
  content: ""; position: absolute; width: 19px; height: 19px; border-radius: 50%;
  background: #fff; top: 2px; left: 2px; transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(37, 54, 73, 0.35);
}
.switch input:checked + .track { background: var(--green); border-color: transparent; }
.switch input:checked + .track::after { transform: translateX(17px); }
.switch-row { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; }
.switch-row span { font-size: 13px; }

/* ---------- Tabella ---------- */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg2); }
table.tbl { width: 100%; border-collapse: collapse; min-width: 760px; }
.tbl th {
  text-align: left; font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.6px; color: var(--text3); padding: 11px 14px;
  border-bottom: 1px solid var(--border); cursor: pointer; user-select: none;
  white-space: nowrap; position: sticky; top: 0; background: var(--bg2); z-index: 1;
}
.tbl th:hover { color: var(--text2); }
.tbl th .arrow { font-size: 9px; margin-left: 4px; }
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
.tbl tbody tr { cursor: pointer; transition: background 0.12s; }
.tbl tbody tr:hover { background: var(--bg-hover); }
.tbl tbody tr:last-child td { border-bottom: none; }
.td-domain { font-weight: 600; }
.td-muted { color: var(--text3); font-size: 12.5px; }
.empty { text-align: center; padding: 46px 20px; color: var(--text3); }
.empty .big { font-size: 30px; margin-bottom: 8px; }

/* ---------- Kanban ---------- */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 16px; align-items: flex-start; }
.kcol {
  min-width: 264px; width: 264px; flex: none;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px;
}
[data-theme="dark"] .kcol { background: var(--bg2); }
.kcol.drag-over { border-color: var(--accent); background: var(--accent-tint); }
.kcol-head { display: flex; align-items: center; gap: 8px; padding: 4px 6px 10px; }
.kcol-head .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.kcol-head .name { font-size: 12px; font-weight: 700; }
.kcol-head .count { color: var(--text3); font-size: 12px; font-weight: 600; }
.kcol-head .sum { margin-left: auto; font-size: 11px; color: var(--text3); font-weight: 600; }
.kcards { display: flex; flex-direction: column; gap: 8px; min-height: 30px; }
.kcard {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 11px 12px; cursor: grab;
  box-shadow: 0 1px 3px rgba(37, 54, 73, 0.06);
  transition: border 0.15s, transform 0.1s;
}
[data-theme="dark"] .kcard { background: var(--bg3); box-shadow: none; }
.kcard:hover { border-color: var(--border-strong); }
.kcard.dragging { opacity: 0.45; transform: rotate(1.5deg); }
.kcard-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.kcard-domain { font-weight: 600; font-size: 13px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kcard-meta { display: flex; align-items: center; gap: 8px; color: var(--text3); font-size: 11.5px; flex-wrap: wrap; }

/* ---------- Timeline ---------- */
.timeline { display: flex; flex-direction: column; }
.tl-item { display: flex; gap: 12px; position: relative; padding-bottom: 18px; }
.tl-item::before {
  content: ""; position: absolute; left: 14px; top: 30px; bottom: 0;
  width: 1.5px; background: var(--border);
}
.tl-item:last-child::before { display: none; }
.tl-icon {
  width: 29px; height: 29px; border-radius: 50%; flex: none; z-index: 1;
  background: var(--bg3); border: 1px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center; font-size: 13px;
}
.tl-body { flex: 1; min-width: 0; }
.tl-head { font-size: 12px; color: var(--text3); margin-bottom: 2px; }
.tl-head b { color: var(--text2); font-weight: 600; }
.tl-content { font-size: 13px; white-space: pre-wrap; word-break: break-word; }

/* ---------- Feed attività ---------- */
.feed-item { display: flex; gap: 11px; padding: 11px 0; border-bottom: 1px solid var(--border); align-items: flex-start; }
.feed-item:last-child { border-bottom: none; }
.feed-body { flex: 1; min-width: 0; font-size: 13px; }
.feed-body .who { font-weight: 600; }
.feed-body .what { color: var(--text2); }
.feed-time { color: var(--text3); font-size: 11.5px; white-space: nowrap; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 700; color: #fff;
}

/* ---------- Email archive ---------- */
.email-item { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 9px; overflow: hidden; background: var(--bg2); }
.email-head { display: flex; align-items: center; gap: 10px; padding: 11px 13px; cursor: pointer; }
.email-head:hover { background: var(--bg-hover); }
.email-subject { font-weight: 600; font-size: 13px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.email-date { color: var(--text3); font-size: 11.5px; white-space: nowrap; }
.email-body { padding: 4px 14px 14px; border-top: 1px solid var(--border); }
.email-meta { font-size: 12px; color: var(--text3); margin: 8px 0; line-height: 1.6; }
.email-text { font-size: 13px; white-space: pre-wrap; word-break: break-word; color: var(--text2); max-height: 420px; overflow-y: auto; }

/* ---------- Lead detail ---------- */
.detail-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 4fr); gap: 14px; align-items: start; }
.detail-head { display: flex; align-items: center; gap: 13px; flex-wrap: wrap; margin-bottom: 18px; }
.detail-title { font-size: 21px; font-weight: 700; letter-spacing: -0.4px; }
.back-btn { color: var(--text3); display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 600; cursor: pointer; background: none; border: none; padding: 6px 0; }
.back-btn:hover { color: var(--text); }
.info-rows { display: flex; flex-direction: column; }
.info-row { display: flex; justify-content: space-between; gap: 14px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.info-row:last-child { border-bottom: none; }
.info-row .k { color: var(--text3); flex: none; }
.info-row .v { text-align: right; word-break: break-word; }
.ai-problem { display: flex; gap: 9px; margin-bottom: 9px; font-size: 13px; color: var(--text2); }
.ai-problem .n {
  width: 19px; height: 19px; border-radius: 6px; flex: none; margin-top: 1px;
  background: var(--gold-tint); color: var(--gold-ink);
  font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.insight-box {
  background: var(--accent-tint); border: 1px solid rgba(105, 160, 191, 0.35);
  border-radius: var(--radius-sm); padding: 12px 14px; font-size: 13px;
  margin-bottom: 14px; color: var(--insight-ink);
}
.composer { display: flex; gap: 9px; margin-top: 6px; }
.composer .input { flex: 1; }
.section-label { font-size: 11px; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: 0.6px; margin: 16px 0 10px; }

/* ---------- Charts ---------- */
.chart { width: 100%; }
.chart svg { display: block; width: 100%; }
.chart text { font-family: var(--font); }
.hbar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.hbar-label { width: 108px; flex: none; font-size: 12px; color: var(--text2); text-align: right; }
.hbar-track { flex: 1; height: 20px; background: var(--bg3); border-radius: 6px; overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 6px; transition: width 0.5s ease; min-width: 2px; }
.hbar-val { width: 74px; font-size: 12px; color: var(--text3); font-weight: 600; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20, 32, 45, 0.45);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  animation: fadeIn 0.15s ease;
}
[data-theme="dark"] .modal-overlay { background: rgba(0, 0, 0, 0.6); }
.modal {
  background: var(--bg2); border: 1px solid var(--border-strong);
  border-radius: 18px; padding: 22px; width: 440px; max-width: calc(100vw - 32px);
  max-height: 86vh; overflow-y: auto; box-shadow: var(--shadow);
  animation: popIn 0.18s ease;
}
.modal-title { font-size: 16.5px; font-weight: 700; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: scale(0.96) translateY(8px); } }

/* ---------- Toast ---------- */
#toast-root { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: #253649; border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff; padding: 10px 18px; border-radius: 99px;
  font-size: 13px; font-weight: 600; box-shadow: var(--shadow);
  animation: toastIn 0.25s ease; display: flex; gap: 8px; align-items: center;
}
.toast.err { background: #6e3a38; color: #ffd9d6; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  width: 380px; max-width: 100%; text-align: center;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 20px; padding: 34px 30px; box-shadow: var(--shadow);
}
.login-logo-img { height: 38px; max-width: 220px; object-fit: contain; margin: 4px auto 18px; display: block; }
[data-theme="dark"] .login-logo-img { filter: brightness(0) invert(1) opacity(0.92); }
.login-logo {
  width: 58px; height: 58px; border-radius: 15px; margin: 0 auto 16px;
  background: linear-gradient(135deg, #69a0bf, #253649);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 800; color: #fff;
}
.login-title { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; }
.login-sub { color: var(--text3); font-size: 12.5px; margin: 4px 0 24px; }
.login-card form { text-align: left; }
.login-err { color: var(--red-ink); font-size: 12.5px; margin-top: 10px; text-align: center; min-height: 18px; }
.shake { animation: shake 0.4s; }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }

.loading { display: flex; justify-content: center; padding: 60px; color: var(--text3); }
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2.5px solid var(--bg3); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.mono { font-variant-numeric: tabular-nums; }
.mt { margin-top: 14px; }
.muted { color: var(--text3); }
.link-ext { color: var(--accent-ink); font-size: 12.5px; font-weight: 600; }

/* ---------- Timeline delete ---------- */
.tl-del {
  margin-left: auto; align-self: flex-start; flex: none;
  background: none; border: none; color: var(--text3);
  font-size: 16px; line-height: 1; cursor: pointer;
  padding: 3px 8px; border-radius: 6px;
  opacity: 0; transition: opacity 0.15s, background 0.15s;
}
.tl-item:hover .tl-del { opacity: 1; }
.tl-del:hover { background: var(--red-tint); color: var(--red-ink); }
@media (max-width: 900px) { .tl-del { opacity: 1; } }

/* ---------- Bulk select ---------- */
input[type="checkbox"].sel-row, #sel-all {
  accent-color: var(--accent);
  width: 16px; height: 16px; cursor: pointer;
}
.sel-cell { cursor: default; }

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar {
    display: flex; align-items: center; gap: 10px;
    position: sticky; top: 0; z-index: 50;
    background: var(--glass);
    backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
    padding: 12px 16px; border-bottom: 1px solid var(--border);
  }
  .topbar .logo-img { height: 21px; }
  .topbar .logo-mark { width: 26px; height: 26px; font-size: 14px; border-radius: 7px; }
  .topbar-title { font-weight: 700; font-size: 15.5px; }
  .tabbar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    background: var(--glass);
    backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
    border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tab-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    background: none; border: none; color: var(--text3); font-size: 9.5px; font-weight: 600;
    padding: 5px 2px; cursor: pointer; border-radius: 10px;
  }
  .tab-item svg { width: 21px; height: 21px; }
  .tab-item.active { color: var(--accent-ink); }
  .main { padding: 16px 14px 90px; }
  .page-title { font-size: 19px; }
  .grid-2, .grid-3, .detail-grid, .field-row { grid-template-columns: 1fr; }
  .grid-kpi { grid-template-columns: repeat(2, 1fr); gap: 9px; }
  .kpi-value { font-size: 21px; }
  .search-wrap { max-width: none; }
  .login-card { padding: 28px 22px; }

  /* tabella → card */
  .tbl-wrap { border: none; background: none; overflow: visible; }
  table.tbl { min-width: 0; }
  .tbl thead { display: none; }
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; }
  .tbl tbody tr {
    background: var(--bg2); border: 1px solid var(--border);
    border-radius: var(--radius); margin-bottom: 10px; padding: 6px 2px;
  }
  .tbl td { border: none; padding: 6px 14px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
  .tbl td::before {
    content: attr(data-label); font-size: 10.5px; font-weight: 700;
    color: var(--text3); text-transform: uppercase; letter-spacing: 0.5px;
  }
  .tbl td:first-child { padding-top: 10px; }
  .tbl td:last-child { padding-bottom: 10px; }
  .kcol { min-width: 82vw; width: 82vw; }
  .kanban { scroll-snap-type: x mandatory; }
  .kcol { scroll-snap-align: center; }
  .modal { width: 100%; }
}
