/* Speakly — postazione agente. Nessuna dipendenza esterna; colori come token (chiaro/scuro). */
:root {
  --bg: #f3f5f9; --surface: #ffffff; --surface-2: #f7f8fb; --line: #e3e7ef; --fg: #182033; --muted: #69748a;
  --accent: #3b6cf6; --accent-soft: #e8eefe; --ok: #1f9d55; --ok-soft: #e3f6ea; --warn: #e08a00; --warn-soft: #fdf1dc;
  --err: #d93a3a; --err-soft: #fde7e7; --idle: #9aa3b5; --violet: #7b5cf0; --violet-soft: #efeafe;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
  --radius: 14px; --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f131b; --surface: #171c27; --surface-2: #1d2331; --line: #2a3142; --fg: #e7ebf3; --muted: #9aa4b8;
    --accent: #6d90ff; --accent-soft: #1f2a48; --ok: #35c27a; --ok-soft: #173326; --warn: #f0a63a; --warn-soft: #3a2c14;
    --err: #ff6b6b; --err-soft: #3e1d1f; --idle: #6c7488; --violet: #a28bff; --violet-soft: #2a2347;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  }
}
:root[data-theme="dark"] {
  --bg: #0f131b; --surface: #171c27; --surface-2: #1d2331; --line: #2a3142; --fg: #e7ebf3; --muted: #9aa4b8;
  --accent: #6d90ff; --accent-soft: #1f2a48; --ok: #35c27a; --ok-soft: #173326; --warn: #f0a63a; --warn-soft: #3a2c14;
  --err: #ff6b6b; --err-soft: #3e1d1f; --idle: #6c7488; --violet: #a28bff; --violet-soft: #2a2347;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.45 var(--font); background: var(--bg); color: var(--fg); -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
.sprite { display: none; }
svg { width: 20px; height: 20px; fill: currentColor; flex: none; }
h2 { font-size: 12px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
h3 { margin: 0 0 12px; font-size: 18px; }
h4 { margin: 8px 0; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.muted { color: var(--muted); } .error { color: var(--err); min-height: 1.4em; } .mono { font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; } .row.end { justify-content: flex-end; }
.spacer { flex: 1; }

/* controlli */
input, select, textarea { font: inherit; color: var(--fg); background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; width: 100%; outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; }
label { display: block; color: var(--muted); font-size: 13px; }
label input, label select { margin-top: 4px; }
.field { margin: 10px 0; }
.check { display: flex; gap: 8px; align-items: center; } .check input { width: auto; }
.btn { font: inherit; font-weight: 600; border: 0; border-radius: 10px; padding: 9px 16px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; justify-content: center; color: var(--fg); background: var(--surface-2); transition: filter .15s, transform .05s; text-decoration: none; }
.btn:hover { filter: brightness(.97); } .btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.call { background: var(--ok); color: #fff; } .btn.danger { background: var(--err); color: #fff; }
.btn.round { width: 46px; height: 46px; border-radius: 50%; padding: 0; }
.btn.wide { width: 100%; margin-top: 12px; padding: 11px; }
.icon-btn { border: 0; background: transparent; color: var(--muted); width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--fg); }

/* accesso */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(1200px 600px at 10% -10%, var(--accent-soft), transparent), var(--bg); }
.login { width: min(380px, 100%); padding: 28px; }
.login label { margin: 12px 0; }

/* struttura */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 750; font-size: 17px; letter-spacing: -.01em; }
.brand.big { font-size: 24px; }
.logo { width: 26px; height: 26px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), var(--violet)); display: inline-block; }
.layout { display: grid; grid-template-columns: minmax(250px, 1fr) minmax(380px, 1.6fr) minmax(250px, 1fr); gap: 16px; padding: 16px 20px; max-width: 1600px; margin: 0 auto; }
.col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
@media (max-width: 1180px) { .layout { grid-template-columns: minmax(240px, 1fr) minmax(340px, 1.6fr); } .layout > aside:last-child { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); } }
@media (max-width: 760px) { .layout { grid-template-columns: 1fr; padding: 12px 16px; } .layout > .center { order: -1; } .topbar { padding: 10px 16px; } .me span:last-child { display: none; } }

/* chip e badge */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.chips.selectable .chip { cursor: pointer; border: 1px solid var(--line); background: var(--surface-2); color: var(--fg); padding: 6px 12px; font-size: 13px; }
.chips.selectable .chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: var(--violet-soft); color: var(--violet); font-weight: 650; }
.count { background: var(--surface-2); color: var(--muted); border-radius: 999px; padding: 0 8px; font-size: 11px; }

/* stato agente */
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--idle); display: inline-block; flex: none; }
.reg { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.reg.on .dot { background: var(--ok); } .reg.off .dot { background: var(--err); } .reg.wait .dot { background: var(--warn); }
.status-menu { position: relative; }
.state-btn { font: inherit; font-weight: 650; display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--surface-2); color: var(--fg); padding: 7px 12px; border-radius: 999px; cursor: pointer; }
.state-btn.ready { background: var(--ok-soft); border-color: transparent; } .state-btn.ready .dot { background: var(--ok); }
.state-btn.pause { background: var(--warn-soft); border-color: transparent; } .state-btn.pause .dot { background: var(--warn); }
.state-btn.busy { background: var(--err-soft); border-color: transparent; } .state-btn.busy .dot { background: var(--err); }
.state-btn .timer { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 230px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; z-index: 20; }
.menu button { width: 100%; text-align: left; border: 0; background: transparent; color: var(--fg); font: inherit; padding: 8px 10px; border-radius: 8px; display: flex; gap: 10px; align-items: center; cursor: pointer; }
.menu button:hover { background: var(--surface-2); }
.menu .sep { height: 1px; background: var(--line); margin: 4px 0; }
.me { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13px; flex: none; }
.avatar.xl { width: 64px; height: 64px; } .avatar.xl svg { width: 34px; height: 34px; }

/* code */
.queues, .team, .recent, .log, .timeline, .pick { list-style: none; margin: 0; padding: 0; }
.queue { padding: 10px 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; }
.queue:last-child, .member:last-child, .recent li:last-child { border-bottom: 0; }
.queue .name { font-weight: 600; }
.queue .sub { font-size: 12px; color: var(--muted); }
.queue .waiting { grid-row: 1 / 3; grid-column: 2; align-self: center; text-align: right; }
.waiting .n { font-size: 22px; font-weight: 700; line-height: 1; display: block; }
.waiting .n.hot { color: var(--err); } .waiting .l { font-size: 11px; color: var(--muted); }
.member { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.member .who { flex: 1; min-width: 0; } .member .who div:first-child { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member .st { font-size: 12px; color: var(--muted); }
.member .dot.free { background: var(--ok); } .member .dot.incall { background: var(--err); } .member .dot.wrapup { background: var(--violet); } .member .dot.pause { background: var(--warn); }

/* dialer */
.dial-row { display: flex; gap: 10px; align-items: center; }
.dial-row input { font-size: 20px; padding: 10px 14px; letter-spacing: .02em; }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; max-width: 320px; }
.pad button { font: inherit; font-size: 20px; font-weight: 600; padding: 12px 0; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--fg); cursor: pointer; }
.pad button:hover { background: var(--accent-soft); }
.pad.small { margin: 12px auto 0; } .pad.small button { font-size: 17px; padding: 8px 0; }
.dialer .btn.ghost { margin-top: 4px; }

/* interazione */
.interaction { border-top: 4px solid var(--accent); }
.party { display: flex; gap: 16px; align-items: center; }
.party-number { font-size: 26px; font-weight: 700; letter-spacing: -.01em; overflow-wrap: anywhere; }
.party-campaign { color: var(--accent); font-weight: 600; }
.party-meta { display: flex; gap: 10px; align-items: center; margin-top: 4px; flex-wrap: wrap; color: var(--muted); }
.call-state { font-weight: 600; }
.rec { display: inline-flex; align-items: center; gap: 3px; color: var(--err); font-size: 12px; font-weight: 700; }
.rec svg { width: 12px; height: 12px; animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: .25; } }
.hold-bar { position: relative; height: 26px; margin-top: 14px; background: var(--surface-2); border-radius: 8px; overflow: hidden; }
.hold-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--ok); transition: width 1s linear, background .3s; }
.hold-bar span { position: relative; z-index: 1; font-size: 12px; font-weight: 650; padding: 0 10px; line-height: 26px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.tool { font: inherit; display: flex; flex-direction: column; align-items: center; gap: 4px; border: 0; background: transparent; color: var(--fg); cursor: pointer; padding: 0; width: 66px; }
.tool svg { width: 48px; height: 48px; padding: 13px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line); transition: background .15s; }
.tool:hover svg { background: var(--accent-soft); }
.tool span { font-size: 12px; color: var(--muted); }
.tool.on svg { background: var(--accent); color: #fff; border-color: var(--accent); }
.tool.answer svg { background: var(--ok); color: #fff; border-color: var(--ok); animation: pulse 1.2s infinite; }
.tool.hangup svg { background: var(--err); color: #fff; border-color: var(--err); }
.tool:disabled { opacity: .35; cursor: default; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(31, 157, 85, .5); } 70% { box-shadow: 0 0 0 12px rgba(31, 157, 85, 0); } 100% { box-shadow: 0 0 0 0 rgba(31, 157, 85, 0); } }
.consult { margin-top: 14px; padding: 12px; border-radius: 12px; background: var(--violet-soft); display: grid; gap: 10px; }
#screenpop { margin-top: 14px; }

/* schede */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -4px -4px 14px; padding: 0 4px; overflow-x: auto; }
.tab { font: inherit; font-weight: 600; border: 0; background: transparent; color: var(--muted); padding: 8px 12px; border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.tab.active { color: var(--accent); border-color: var(--accent); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
#t-wrap textarea { margin: 12px 0; }
.acw { display: flex; justify-content: space-between; padding: 8px 12px; border-radius: 10px; background: var(--violet-soft); color: var(--violet); font-weight: 650; margin-bottom: 12px; }
.timeline li { padding: 8px 0 8px 14px; border-left: 2px solid var(--line); margin-left: 4px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 13px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.timeline .meta { font-size: 12px; color: var(--muted); }

/* destra */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi { background: var(--surface-2); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; }
.kpi-v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi-l { font-size: 12px; color: var(--muted); }
.recent li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.recent .dir { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.recent .dir.missed { color: var(--err); background: var(--err-soft); }
.recent .dir svg { width: 16px; height: 16px; }
.recent .info { flex: 1; min-width: 0; } .recent .num { font-weight: 600; } .recent .sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent .icon-btn { color: var(--ok); }
.log-card summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.log li { font-size: 12px; color: var(--muted); padding: 3px 0; font-variant-numeric: tabular-nums; }

/* chiamata in arrivo */
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 50; display: flex; gap: 16px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 16px 18px; box-shadow: 0 10px 40px rgba(0, 0, 0, .25); width: min(440px, calc(100vw - 32px)); animation: slide .25s ease-out; }
@keyframes slide { from { transform: translateY(20px); opacity: 0; } }
.toast-info { flex: 1; min-width: 0; } .toast .party-number { font-size: 20px; }
.ring { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--ok-soft); color: var(--ok); animation: pulse 1.2s infinite; flex: none; }
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: 20px; z-index: 60; display: grid; gap: 8px; }
.note { background: var(--fg); color: var(--bg); padding: 9px 14px; border-radius: 10px; font-weight: 600; box-shadow: var(--shadow); animation: slide .2s; }
.note.err { background: var(--err); color: #fff; }

/* finestre */
.dialog { border: 0; border-radius: 18px; padding: 20px; width: min(560px, calc(100vw - 32px)); background: var(--surface); color: var(--fg); box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.dialog::backdrop { background: rgba(10, 14, 22, .45); }
.xfer-lists { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 8px 0 12px; max-height: 50vh; overflow: auto; }
@media (max-width: 560px) { .xfer-lists { grid-template-columns: 1fr; } }
.pick li button { width: 100%; text-align: left; font: inherit; color: var(--fg); background: transparent; border: 1px solid transparent; border-radius: 10px; padding: 8px 10px; display: flex; gap: 10px; align-items: center; cursor: pointer; }
.pick li button:hover { background: var(--surface-2); border-color: var(--line); }
.pick li button:disabled { opacity: .45; cursor: default; }
.pick .sub { font-size: 12px; color: var(--muted); }
