/* ===== Font Inter (self-hosted, offline) ===== */
@font-face { font-family: Inter; font-style: normal; font-weight: 400; font-display: swap; src: url('../vendor/fonts/inter-400.woff2') format('woff2'); }
@font-face { font-family: Inter; font-style: normal; font-weight: 500; font-display: swap; src: url('../vendor/fonts/inter-500.woff2') format('woff2'); }
@font-face { font-family: Inter; font-style: normal; font-weight: 600; font-display: swap; src: url('../vendor/fonts/inter-600.woff2') format('woff2'); }
@font-face { font-family: Inter; font-style: normal; font-weight: 700; font-display: swap; src: url('../vendor/fonts/inter-700.woff2') format('woff2'); }

/* ===== Brand tokens (da vcarder.app) ===== */
:root {
  --bg: #ffffff;
  --bg-soft: #f5f8fc;
  --card: #ffffff;
  --ink: #1b2433;
  --navy: #0d2a5c;
  --navy-deep: #08203f;
  --muted: #5b6675;
  --line: #e3e8f0;
  --blue: #1f6fd6;
  --blue-light: #3d8bf0;
  --blue-tint: #eaf1fc;
  --accent: #2bb673;
  --accent-tint: #e6f6ee;
  --danger: #e5484d;
  --danger-tint: #fdecec;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 18px 50px rgba(13,42,92,.12);
  --shadow-sm: 0 4px 16px rgba(13,42,92,.08);
  --grad: linear-gradient(135deg, var(--blue), var(--blue-light));
  --grad-navy: linear-gradient(160deg, var(--navy) 0%, var(--navy-deep) 100%);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* icone SVG */
.ico { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ===== Topbar ===== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--safe-top) + 14px) 18px 14px;
  background: rgba(255,255,255,.85); backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { width: 34px; height: 34px; border-radius: 10px; box-shadow: var(--shadow-sm); }
.brand-name { display: flex; flex-direction: column; line-height: 1; }
.brand-name b { font-size: 19px; font-weight: 800; color: var(--navy); letter-spacing: -.2px; }
.brand-name b span { color: var(--blue); }
.brand-name small { font-size: 9px; font-weight: 700; letter-spacing: 1.5px; color: var(--muted); margin-top: 3px; }
.icon-btn { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: #fff; color: var(--navy); cursor: pointer; }
.icon-btn:active { background: var(--bg-soft); }

/* ===== Layout ===== */
#app { padding: 16px 16px calc(28px + var(--safe-bot)); max-width: 760px; margin: 0 auto; }
.view { display: none; }
.view.is-active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.hero-strip {
  background: var(--grad-navy); color: #fff; border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.hero-strip .eyebrow { font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: #aebfda; font-weight: 700; }
.hero-strip h2 { margin: 6px 0 0; font-size: 20px; font-weight: 800; letter-spacing: -.3px; }
.hero-strip h2 span { color: var(--blue-light); }

/* ===== Actions grid ===== */
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 26px; }
.action {
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
  padding: 16px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); box-shadow: var(--shadow-sm); cursor: pointer;
  transition: transform .1s, box-shadow .2s, border-color .2s;
}
.action:active { transform: translateY(1px) scale(.99); }
.action:hover { border-color: #cfdcf2; box-shadow: var(--shadow); }
.action-ico { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 13px; background: var(--blue-tint); color: var(--blue); }
.action-ico .ico { width: 24px; height: 24px; }
.action[data-action="nfc"] .action-ico { background: var(--accent-tint); color: var(--accent); }
.action-label { font-weight: 700; font-size: 15px; color: var(--navy); }
.action-sub { color: var(--muted); font-size: 12.5px; margin-top: -6px; }

/* ===== List ===== */
.list-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.list-head h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 700; margin: 0; flex: 0 0 auto; }
.search-wrap { position: relative; flex: 1; }
.search-wrap .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); }
#search {
  width: 100%; padding: 10px 12px 10px 36px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--bg-soft); color: var(--ink); font: inherit; font-size: 14px;
}
#search:focus { outline: 2px solid var(--blue); border-color: transparent; background: #fff; }

.list-tools { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; min-height: 20px; }
.select-toggle { background: none; border: 0; color: var(--blue); font-weight: 600; font-size: 13.5px; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; padding: 4px 0; }
.sel-count { color: var(--muted); font-size: 13px; }

.contact-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.contact-item {
  display: flex; align-items: center; gap: 13px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--card);
  box-shadow: var(--shadow-sm); cursor: pointer; transition: border-color .15s, background .15s;
}
.contact-item:active { background: var(--bg-soft); }
.contact-item.selected { border-color: var(--blue); background: var(--blue-tint); }
.avatar {
  width: 44px; height: 44px; border-radius: 13px; flex: 0 0 auto;
  display: grid; place-items: center; font-weight: 800; font-size: 15px; color: #fff;
  background: var(--grad);
}
.ci-main { flex: 1; min-width: 0; }
.ci-name { font-weight: 700; color: var(--navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-chev { width: 20px; height: 20px; color: #b9c4d6; }
.ci-check { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; color: transparent; flex: 0 0 auto; }
.contact-item.selected .ci-check { background: var(--blue); border-color: var(--blue); color: #fff; }
.empty { color: var(--muted); text-align: center; padding: 40px 16px; }
.empty .ico { width: 40px; height: 40px; color: #c4d0e4; margin-bottom: 10px; }

/* ===== Camera ===== */
.view-camera { position: fixed; inset: 0; background: #000; padding: 0; margin: 0; z-index: 40; }
.view-camera.is-active { display: flex; flex-direction: column; }
.cam-wrap { position: relative; flex: 1; overflow: hidden; }
#cam { width: 100%; height: 100%; object-fit: cover; }
.cam-frame { position: absolute; inset: 14% 8%; border: 2px solid rgba(255,255,255,.9); border-radius: 16px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.4); pointer-events: none; }
.cam-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 22px calc(20px + var(--safe-bot)); background: #000; color: #fff; }
.cam-hint { color: #cfd6ee; font-size: 13px; min-width: 70px; text-align: right; }
.shutter { width: 70px; height: 70px; border-radius: 50%; padding: 0; border: 4px solid #fff; background: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,.25); }
.cam-status { position: absolute; left: 0; right: 0; bottom: 120px; text-align: center; color: #fff; font-weight: 600; text-shadow: 0 1px 4px #000; }

/* ===== Forms ===== */
.form { display: flex; flex-direction: column; gap: 14px; padding-top: 6px; }
.view-title { font-size: 20px; font-weight: 800; color: var(--navy); margin: 4px 0 2px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.form input, .form textarea, select {
  padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font: inherit; font-size: 16px;
}
.form input:focus, .form textarea:focus, select:focus { outline: 2px solid var(--blue); border-color: transparent; }
.preview-row { display: flex; align-items: center; gap: 12px; }
.review-thumb { width: 96px; height: 62px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--blue-tint); color: var(--blue); }
.raw summary { color: var(--muted); font-size: 13px; cursor: pointer; }
.raw pre { white-space: pre-wrap; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 10px; padding: 10px; font-size: 12px; color: var(--muted); max-height: 160px; overflow: auto; }

/* voce → nota */
.voice-block { border: 1px dashed var(--line); border-radius: 12px; padding: 12px; background: var(--bg-soft); }
.voice-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.voice-title { font-weight: 700; color: var(--navy); font-size: 14px; display: flex; align-items: center; gap: 8px; }
.rec-btn { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 999px; border: 0; background: var(--grad); color: #fff; font-weight: 600; cursor: pointer; }
.rec-btn.recording { background: var(--danger); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100%{ box-shadow: 0 0 0 0 rgba(229,72,77,.5);} 50%{ box-shadow: 0 0 0 8px rgba(229,72,77,0);} }
.voice-audio { width: 100%; margin-top: 10px; }
.voice-status { font-size: 12.5px; color: var(--muted); margin-top: 6px; }

/* ===== Buttons ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 13px 16px; border-radius: 12px; border: 1px solid var(--line); background: #fff; color: var(--navy); font-weight: 600; font-size: 15px; font-family: inherit; cursor: pointer; }
.btn .ico { width: 19px; height: 19px; }
.btn.primary { background: var(--grad); border: 0; color: #fff; box-shadow: 0 8px 20px rgba(31,111,214,.28); }
.btn.accent { background: var(--accent); border: 0; color: #fff; }
.btn.ghost { background: #fff; }
.btn.danger { background: #fff; color: var(--danger); border-color: #f3c9cb; }
.btn:active { transform: translateY(1px); }
.form-bar, .sheet-bar { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.form-bar .btn { flex: 1; }

/* ===== Sheets (modali) ===== */
.sheet { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; background: rgba(8,32,63,.4); backdrop-filter: blur(3px); }
.sheet[hidden] { display: none; }
.sheet-card { width: 100%; max-width: 680px; max-height: 88vh; overflow: auto; background: #fff; border-radius: 22px 22px 0 0; padding: 22px 18px calc(22px + var(--safe-bot)); box-shadow: 0 -20px 60px rgba(8,32,63,.25); animation: slideup .22s ease; }
@keyframes slideup { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-card h2 { margin: 2px 0 16px; color: var(--navy); }
.detail-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.detail-head .avatar { width: 54px; height: 54px; font-size: 19px; border-radius: 16px; }
.detail-name { font-size: 20px; font-weight: 800; color: var(--navy); }
.detail-org { color: var(--muted); font-size: 14px; }
.detail-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.detail-row .ico { width: 20px; height: 20px; color: var(--blue); }
.detail-row .v { flex: 1; min-width: 0; }
.detail-row .v a { color: var(--blue); text-decoration: none; word-break: break-word; }
.detail-row .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }

/* link social/enrichment */
.enrich { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 4px; }
.chip-link { display: inline-flex; align-items: center; gap: 7px; padding: 8px 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg-soft); color: var(--navy); font-size: 13.5px; font-weight: 600; text-decoration: none; }
.chip-link .ico { width: 16px; height: 16px; color: var(--blue); }
.chip-link:active { background: var(--blue-tint); }

.switch { display: flex; align-items: center; gap: 12px; margin: 10px 0; font-size: 14.5px; color: var(--ink); }
.switch input { width: 20px; height: 20px; accent-color: var(--blue); }
.field { display: flex; flex-direction: column; gap: 7px; margin: 16px 0; color: var(--muted); font-size: 13px; font-weight: 600; }
.hint { color: var(--muted); font-size: 13px; line-height: 1.55; }
.powered { display: flex; align-items: center; gap: 8px; justify-content: center; margin-top: 18px; color: var(--muted); font-size: 12px; }
.powered img { height: 18px; opacity: .8; }

/* ===== Share bar fissa (multi-select) ===== */
.action-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 55; transform: translateY(120%); transition: transform .25s; padding: 12px 14px calc(12px + var(--safe-bot)); background: rgba(255,255,255,.96); backdrop-filter: blur(8px); border-top: 1px solid var(--line); box-shadow: 0 -10px 30px rgba(8,32,63,.12); }
.action-bar.show { transform: none; }
.action-bar-inner { display: flex; gap: 8px; max-width: 760px; margin: 0 auto; }
.action-bar .btn { flex: 1; padding: 12px 8px; font-size: 13.5px; }
.action-bar .btn .ico { width: 18px; height: 18px; }

/* ===== Crop / deskew ===== */
.crop-overlay { position: fixed; inset: 0; z-index: 70; background: var(--navy-deep); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.crop-stage { position: relative; touch-action: none; }
.crop-canvas { display: block; border-radius: 8px; }
.crop-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.crop-poly { fill: rgba(61,139,240,.16); stroke: var(--blue-light); stroke-width: 2; }
.crop-handle { position: absolute; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%; background: #fff; border: 3px solid var(--blue); box-shadow: 0 2px 8px rgba(0,0,0,.5); touch-action: none; }
.crop-bar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 8px; padding: 12px 14px calc(14px + var(--safe-bot)); background: #000; }
.crop-bar .btn { flex: 1; padding: 12px 8px; font-size: 14px; }

/* ===== Busy overlay ===== */
.busy { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; background: rgba(8,32,63,.5); backdrop-filter: blur(4px); }
.busy[hidden] { display: none; }
.busy-card { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 28px 32px; background: #fff; border-radius: 18px; min-width: 210px; text-align: center; box-shadow: var(--shadow); }
.busy-text { margin: 0; color: var(--navy); font-weight: 600; }
.spinner { width: 38px; height: 38px; border-radius: 50%; border: 4px solid var(--blue-tint); border-top-color: var(--blue); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Toast ===== */
.toast { position: fixed; left: 50%; bottom: calc(28px + var(--safe-bot)); transform: translateX(-50%); background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 90; box-shadow: var(--shadow); max-width: 90%; font-size: 14.5px; font-weight: 500; }
.toast[hidden] { display: none; }
