:root {
  --ink: #17213a;
  --muted: #69738a;
  --line: #e4e8f0;
  --surface: #ffffff;
  --canvas: #f4f6fa;
  --brand: #3157e3;
  --brand-dark: #2445be;
  --success: #16794d;
  --success-bg: #e8f6ef;
  --done: #8338c9;
  --done-bg: #f6edfd;
  --warning: #9b6412;
  --warning-bg: #fff4dc;
  --danger: #b42318;
  --shadow: 0 18px 45px rgba(24, 34, 58, .12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--canvas); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 .4rem; color: var(--brand); font-size: .72rem; font-weight: 800; letter-spacing: .12em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 2rem; background: radial-gradient(circle at 15% 10%, #dfe7ff, transparent 35%), linear-gradient(145deg, #f7f9ff, #eef1f8); }
.login-card { width: min(430px, 100%); padding: 2.6rem; border: 1px solid rgba(255,255,255,.7); border-radius: 24px; background: rgba(255,255,255,.9); box-shadow: var(--shadow); backdrop-filter: blur(14px); }
.login-card h1 { margin: .25rem 0 .4rem; font-size: 2rem; }
.login-card form { display: grid; gap: 1rem; margin-top: 1.8rem; }
.brand-mark { display: grid; width: 54px; height: 54px; place-items: center; border-radius: 16px; color: white; background: linear-gradient(135deg, #335be8, #713de0); font-size: 1.2rem; font-weight: 850; box-shadow: 0 10px 24px rgba(49,87,227,.25); }
.brand-mark.small { width: 38px; height: 38px; border-radius: 12px; font-size: .9rem; }

.app-shell { min-height: 100vh; }
.mobile-appbar, .mobile-nav-backdrop { display: none; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 5; display: flex; width: 245px; flex-direction: column; padding: 1.5rem 1rem; color: white; background: #151e35; }
.brand { display: flex; align-items: center; gap: .75rem; padding: 0 .5rem 1.8rem; font-weight: 850; letter-spacing: .06em; }
.sidebar nav { display: grid; gap: .35rem; }
.nav-item { display: flex; width: 100%; justify-content: space-between; padding: .85rem 1rem; border: 0; border-radius: 11px; color: #cad2e5; background: transparent; text-align: left; text-decoration: none; font-weight: 650; }
.nav-item.active { color: white; background: rgba(255,255,255,.1); }
.nav-item.disabled { opacity: .62; cursor: default; }
.nav-item small { font-size: .62rem; font-weight: 500; }
.plan-summary { display: grid; gap: .3rem; margin: 1rem .4rem 0; padding: .9rem 1rem; border: 1px solid rgba(255,255,255,.13); border-radius: 12px; background: rgba(255,255,255,.07); }
.plan-kicker { color: #91adff; font-size: .62rem; font-weight: 850; letter-spacing: .1em; }
.plan-summary > strong { color: white; font-size: .9rem; }
.plan-balance { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; color: #cad2e5; }
.plan-balance > span { color: white; font-size: 1.25rem; font-weight: 850; font-variant-numeric: tabular-nums; }
.plan-balance small { font-size: .67rem; }
.sidebar-footer { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding: 1rem .6rem 0; border-top: 1px solid rgba(255,255,255,.12); color: #cad2e5; font-size: .85rem; }
.text-button { border: 0; color: #fff; background: transparent; }
main { min-height: 100vh; margin-left: 245px; padding: 2.1rem clamp(1.5rem, 4vw, 4rem); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.topbar h1 { margin: 0; font-size: clamp(1.7rem, 3vw, 2.35rem); }
.topbar-actions { display: flex; gap: .7rem; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin: 2rem 0; }
.metrics article { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 1.4rem; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.metrics span { color: var(--muted); font-size: .88rem; font-weight: 650; }
.metrics strong { font-size: 1.7rem; }
.content-section { padding: 1.5rem; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.section-heading h2 { margin: 0 0 .3rem; }
.section-heading p { margin: 0; }
.search input { width: min(300px, 38vw); }
.structure-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1rem; }
.structure-card { display: flex; min-height: 230px; flex-direction: column; padding: 1.25rem; border: 1px solid var(--line); border-radius: 16px; background: #fff; transition: transform .18s, box-shadow .18s; }
.structure-card:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(24,34,58,.08); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.card-head h3 { margin: 0; font-size: 1.08rem; }
.card-head p { margin: .25rem 0 0; color: var(--muted); font-size: .85rem; }
.badge { display: inline-flex; padding: .32rem .55rem; border-radius: 999px; font-size: .7rem; font-weight: 800; }
.badge.active { color: var(--success); background: var(--success-bg); }
.badge.suspended { color: var(--warning); background: var(--warning-bg); }
.greeting-preview { margin: 1.2rem 0; color: #46516a; font-size: .87rem; line-height: 1.5; }
.phone-list, .extension-list { display: flex; flex-wrap: wrap; gap: .45rem; }
.phone-list { margin-top: .8rem; }
.extension-list { margin-top: .45rem; }
.phone-chip { padding: .36rem .55rem; border: 1px solid var(--line); border-radius: 8px; color: #45516a; background: #f8f9fc; font-size: .76rem; }
.extension-chip { padding: .36rem .55rem; border: 1px solid var(--line); border-radius: 8px; color: #45516a; background: #f8f9fc; font-size: .76rem; }
.telephony-chip.online { color: var(--success); border-color: #b7dfcc; background: var(--success-bg); }
.telephony-chip.offline { color: var(--warning); border-color: #ead39f; background: var(--warning-bg); }
.ai-status-row { margin-top: .8rem; }
.ai-status { display: inline-flex; padding: .3rem .55rem; border-radius: 999px; font-size: .7rem; font-weight: 850; }
.ai-status.enabled { color: var(--success); background: var(--success-bg); }
.ai-status.disabled { color: var(--warning); background: var(--warning-bg); }
.card-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: .5rem; margin-top: auto; padding-top: 1rem; }
.user-grid { display: grid; gap: .75rem; }
.user-card { display: grid; grid-template-columns: minmax(170px, 1.15fr) minmax(170px, 1fr) minmax(145px, .8fr) auto minmax(210px, auto); align-items: center; gap: 1rem; padding: 1rem 1.15rem; border: 1px solid var(--line); border-radius: 13px; }
.user-card h3, .user-card p { margin: 0; }
.user-card h3 { font-size: .98rem; }
.user-card p, .user-card small { color: var(--muted); }
.user-role { font-size: .78rem; font-weight: 750; }
.account-plan { display: grid; gap: .2rem; }
.account-plan strong { font-size: .86rem; }
.account-actions { display: flex; align-items: center; justify-content: flex-end; gap: .45rem; flex-wrap: wrap; }
.billing-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 1rem; }
.billing-card { display: grid; gap: 1rem; padding: 1.2rem; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
.billing-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.billing-card-head h3, .billing-card-head p { margin: 0; }
.billing-card-head p { margin-top: .25rem; color: var(--muted); font-size: .8rem; }
.billing-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; }
.billing-stats div { display: grid; gap: .2rem; padding: .75rem; border-radius: 10px; background: #f7f8fb; }
.billing-stats span { color: var(--muted); font-size: .72rem; font-weight: 700; }
.billing-stats strong { font-size: .95rem; font-variant-numeric: tabular-nums; }
.usage-track { height: 8px; overflow: hidden; border-radius: 999px; background: #e9edf5; }
.usage-track span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--brand), #7047dd); }
.billing-customer-summary { display: grid; gap: .2rem; margin-bottom: 1rem; padding: 1rem; border-radius: 12px; background: #f6f7fb; }
.billing-customer-summary span, .billing-customer-summary small { color: var(--muted); font-size: .76rem; }
.billing-customer-summary strong { font-size: 1.05rem; }
.notification-layout { display: grid; grid-template-columns: minmax(360px,.9fr) minmax(420px,1.2fr); gap: 1rem; }
.smtp-settings-panel { margin-bottom: 1rem; padding: 1.2rem; border: 1px solid var(--line); border-radius: 17px; background: white; box-shadow: 0 8px 22px rgba(24,34,58,.045); }
.smtp-settings-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: .7rem; }
.smtp-settings-grid label { min-width: 0; }
.smtp-actions { justify-content: flex-end; gap: .55rem; }
.notification-settings-panel, .notification-history-panel { min-width: 0; padding: 1.2rem; border: 1px solid var(--line); border-radius: 17px; background: white; box-shadow: 0 8px 22px rgba(24,34,58,.045); }
.notification-recipient-panel { max-width: 980px; padding: 1.35rem; border: 1px solid var(--line); border-radius: 17px; background: white; box-shadow: 0 8px 22px rgba(24,34,58,.045); }
.notification-recipient-channels { display: grid; gap: 1rem; }
.notification-recipient-channel { min-width: 0; margin: 0; padding: 1rem; border: 1px solid var(--line); border-radius: 13px; background: #fbfcff; transition: opacity .16s ease, background .16s ease; }
.notification-recipient-channel.is-disabled { background: #f5f6f9; }
.notification-recipient-channel.is-disabled .notification-email-list,
.notification-recipient-channel.is-disabled .notification-whatsapp-field { opacity: .55; }
.notification-recipient-channel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: .9rem; }
.notification-recipient-channel-heading h4 { margin: 0; padding: 0; font-size: 1rem; font-weight: 850; }
.notification-recipient-channel-heading p { margin: .25rem 0 0; color: var(--muted); font-size: .75rem; line-height: 1.45; }
.notification-recipient-toggle { display: inline-flex; flex: 0 0 auto; align-items: center; gap: .5rem; min-height: 40px; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 10px; background: white; font-size: .75rem; font-weight: 800; cursor: pointer; }
.notification-recipient-toggle:has(input:checked) { border-color: #afbeff; color: #2449dd; background: #eef2ff; }
.notification-recipient-toggle input { width: auto; margin: 0; }
.notification-email-list { display: grid; gap: .8rem; }
.notification-whatsapp-field { max-width: 560px; }
.notification-email-list label, .notification-whatsapp-field label { min-width: 0; }
.notification-email-list small, .notification-whatsapp-field small { display: block; margin-top: .35rem; color: var(--muted); font-size: .7rem; line-height: 1.4; }
.optional-label { margin-left: .25rem; color: var(--muted); font-size: .67rem; font-weight: 650; }
.notification-recipient-help { margin: 1rem 0 0; padding: .85rem 1rem; border-radius: 11px; color: #35415a; background: #f4f7ff; font-size: .78rem; line-height: 1.5; }
.notification-contact-summary { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .6rem; margin-bottom: .8rem; }
.notification-contact-summary div { display: grid; gap: .25rem; min-width: 0; padding: .75rem; border-radius: 11px; background: #f6f8fc; }
.notification-contact-summary span { color: var(--muted); font-size: .68rem; font-weight: 750; }
.notification-contact-summary strong { overflow-wrap: anywhere; font-size: .8rem; }
.notification-provider-warning { padding: .75rem; border: 1px solid #f1d49b; border-radius: 11px; color: #85540b; background: #fff8e9; font-size: .74rem; line-height: 1.45; }
.notification-provider-warning.ready { border-color: #b8dfcb; color: #08743f; background: #effaf4; }
.notification-options { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .55rem; margin: 1rem 0 0; padding: .85rem; border: 1px solid var(--line); border-radius: 12px; }
.notification-options legend { padding: 0 .35rem; font-size: .75rem; font-weight: 850; }
.notification-options .checkbox-field { min-height: 42px; margin: 0; padding: .6rem; border-radius: 9px; background: #f7f8fb; }
.notification-options.is-disabled { opacity: .58; }
.notification-rule-note { grid-column: 1 / -1; margin: 0; padding: .65rem .75rem; border-radius: 9px; color: var(--muted); background: #f6f8fc; font-size: .72rem; line-height: 1.45; }
.notification-channel-card { display: grid; gap: .45rem; min-width: 0; padding: .8rem; border: 1px solid var(--line); border-radius: 11px; background: #f8f9fc; cursor: pointer; }
.notification-channel-card:has(input:checked) { border-color: #aebeff; background: #f2f5ff; box-shadow: inset 0 0 0 1px #dce3ff; }
.notification-channel-card > span { display: flex; align-items: center; gap: .55rem; }
.notification-channel-card input { width: auto; }
.notification-channel-card small { color: var(--muted); line-height: 1.35; overflow-wrap: anywhere; }
.notification-channel-card b { color: var(--ink); }
.notification-threshold { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-top: .2rem; padding: .65rem .75rem; border-radius: 9px; background: #f8f9fc; }
.notification-threshold span { display: flex; align-items: center; gap: .4rem; }
.notification-threshold input { width: 100px; }
.appointment-summary-options { grid-template-columns: repeat(3,minmax(0,1fr)); }
.appointment-summary-options > label:not(.checkbox-field) { min-width: 0; }
.appointment-summary-options .manual-summary-row { grid-column: 1 / -1; }
.notification-master-toggle { grid-column: 1 / -1; font-weight: 800; }
.whatsapp-options { grid-template-columns: repeat(2,minmax(0,1fr)); }
.whatsapp-options > label { min-width: 0; }
.whatsapp-reminder-leads { grid-column: 1 / -1; display: grid; gap: .35rem; }
.whatsapp-reminder-leads > small { color: var(--muted); }
.whatsapp-reminder-leads > div { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: .45rem; }
.whatsapp-reminder-leads .checkbox-field { font-size: .73rem; }
.whatsapp-test-message { grid-column: 1 / -1; }
.whatsapp-status-card { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: .25rem .6rem; padding: .65rem; border: 1px solid var(--line); border-radius: 10px; background: #fbfcff; }
.whatsapp-status-card span { grid-column: 1 / -1; color: var(--muted); font-size: .68rem; font-weight: 750; }
.whatsapp-status-card strong { font-size: .8rem; }
.whatsapp-status-card strong.online { color: var(--success); }
.whatsapp-status-card strong.offline { color: var(--warning); }
.whatsapp-status-card button { justify-self: end; }
.whatsapp-qr-panel { grid-column: 1 / -1; display: grid; justify-items: center; gap: .65rem; padding: 1rem; border: 1px solid var(--line); border-radius: 12px; background: #fff; text-align: center; }
.whatsapp-qr-panel[hidden] { display: none; }
.whatsapp-qr-panel p, .whatsapp-qr-panel small { margin: 0; color: var(--muted); }
.whatsapp-qr-panel img { width: min(100%, 320px); height: auto; padding: .5rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; image-rendering: pixelated; }
.whatsapp-history-heading { margin-top: 1.2rem; padding-top: 1.1rem; border-top: 1px solid var(--line); }
.whatsapp-retry { margin-top: .45rem; }
.manual-summary-row { display: flex; align-items: end; justify-content: space-between; gap: .65rem; margin-top: 1rem; padding: .8rem; border-radius: 11px; background: #f6f8fc; }
.notification-advanced { margin: 1rem 0; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.notification-advanced > summary { padding: .85rem 1rem; color: var(--ink); font-size: .78rem; font-weight: 850; cursor: pointer; }
.notification-advanced[open] > summary { border-bottom: 1px solid var(--line); }
.smtp-settings-details .smtp-settings-panel { margin: 0; border: 0; border-radius: 0 0 12px 12px; box-shadow: none; }
.whatsapp-technical-settings { grid-column: 1 / -1; }
.whatsapp-technical-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .65rem; padding: .85rem; }
.whatsapp-technical-grid > label { min-width: 0; }
.whatsapp-technical-grid > button { justify-self: start; }
.manual-summary-row label { flex: 1; }
.notification-event-list { display: grid; gap: .6rem; }
.notification-event { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: .65rem; padding: .85rem; border: 1px solid #edf0f5; border-radius: 11px; background: #fbfcff; }
.notification-event h4, .notification-event p { margin: 0; }
.notification-event h4 { font-size: .86rem; }
.notification-event p { margin-top: .25rem; color: var(--muted); font-size: .73rem; line-height: 1.45; }
.notification-event-meta { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .45rem; }
.notification-channel { padding: .24rem .42rem; border-radius: 999px; color: #405078; background: #edf2ff; font-size: .65rem; font-weight: 800; }
.notification-event-side { min-width: 105px; text-align: right; }
.notification-event-side time { display: block; color: var(--muted); font-size: .67rem; }
.notification-delivery-status { display: inline-flex; margin-top: .4rem; padding: .25rem .42rem; border-radius: 999px; color: #85540b; background: var(--warning-bg); font-size: .63rem; font-weight: 850; }
.operations-heading > label { min-width: min(320px, 100%); }
.operations-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.management-panel { padding: 1.2rem; border: 1px solid var(--line); border-radius: 16px; background: #fbfcff; }
.management-panel h3 { margin: 0; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.management-list { display: grid; gap: .65rem; }
.management-item { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 1rem; padding: .9rem; border: 1px solid var(--line); border-radius: 11px; background: white; }
.management-item h4, .management-item p { margin: 0; }
.management-item h4 { font-size: .95rem; }
.management-item p { margin-top: .25rem; color: var(--muted); font-size: .8rem; line-height: 1.4; }
.management-meta { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .5rem; }
.meta-chip { padding: .25rem .45rem; border-radius: 6px; color: #46516a; background: #eef1f7; font-size: .7rem; font-weight: 700; }
.empty-state.compact { padding: 1.5rem .5rem; }
.hours-panel { margin-top: 1rem; }
.weekly-hours { display: grid; gap: .55rem; }
.hours-row { display: grid; grid-template-columns: minmax(110px, 1fr) repeat(2, minmax(105px, .7fr)) minmax(75px, .48fr) repeat(2, minmax(105px, .7fr)); align-items: center; gap: .7rem; padding: .7rem .8rem; border: 1px solid var(--line); border-radius: 10px; background: white; }
.day-toggle { display: flex; align-items: center; gap: .65rem; font-size: .86rem; }
.day-toggle input { width: auto; }
.pause-toggle { display: flex; align-items: center; gap: .45rem; padding-top: 1.35rem; }
.pause-toggle input { width: auto; }
.panel-footer { display: flex; justify-content: flex-end; margin-top: 1rem; }

.button { min-height: 42px; padding: .68rem 1rem; border: 0; border-radius: 10px; font-weight: 750; }
.button.primary { color: white; background: var(--brand); box-shadow: 0 8px 18px rgba(49,87,227,.2); }
.button.primary:hover { background: var(--brand-dark); }
.button.secondary { color: var(--ink); background: #eef1f7; }
.button.full { width: 100%; }
.button:disabled { opacity: .55; cursor: wait; }
.icon-button { width: 38px; height: 38px; border: 0; border-radius: 50%; color: var(--muted); background: #f0f2f7; font-size: 1.45rem; }
label { display: grid; gap: .42rem; color: #3b465d; font-size: .82rem; font-weight: 700; }
input, select, textarea { width: 100%; padding: .74rem .8rem; border: 1px solid #ccd3e0; border-radius: 9px; color: var(--ink); background: white; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(49,87,227,.12); }
textarea { resize: vertical; line-height: 1.45; }
.form-error { min-height: 1.2rem; margin: .3rem 0; color: var(--danger); font-size: .82rem; }
.extension-email-status { min-height: 1.2rem; margin: .35rem 0 0; color: var(--success); font-size: .84rem; font-weight: 700; }
.extension-email-status.error { color: var(--danger); }
.notice { margin-bottom: 1rem; padding: .8rem 1rem; border-radius: 10px; color: var(--success); background: var(--success-bg); }
.notice.error { color: var(--danger); background: #fff0ef; }
.empty-state { padding: 4rem 1rem; text-align: center; color: var(--muted); }
.empty-state h3 { color: var(--ink); }

dialog { width: min(760px, calc(100% - 2rem)); max-height: calc(100vh - 2rem); padding: 0; border: 0; border-radius: 20px; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(16,24,42,.58); backdrop-filter: blur(3px); }
#structure-form { padding: 1.5rem; }
#user-form, #password-form, #billing-form, #service-form, #operator-form, #workstation-form, #customer-form, #appointment-form, #location-form, #sales-user-form { max-height: calc(100vh - 2rem); overflow-y: auto; padding: 1.5rem; }
.dialog-header, .dialog-footer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.dialog-header { margin-bottom: 1.4rem; }
.dialog-header h2 { margin: 0; }
.dialog-footer { justify-content: flex-end; padding-top: 1rem; border-top: 1px solid var(--line); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 1rem; }
.form-grid .wide { grid-column: 1 / -1; }
.checkbox-field { display: flex; align-items: center; gap: .6rem; padding: .75rem .85rem; border: 1px solid var(--line); border-radius: 9px; background: #f8f9fc; }
.checkbox-field input { width: auto; }
.phone-editor, .extension-editor { margin: 1.3rem 0; padding: 1rem; border: 1px solid var(--line); border-radius: 12px; background: #f9fafc; }
.phone-editor h3, .phone-editor p, .extension-editor h3, .extension-editor p { margin: 0 0 .25rem; }
.phone-add-row, .extension-add-row { display: grid; grid-template-columns: minmax(280px,1.35fr) 1fr minmax(220px,1fr); align-items: end; gap: .7rem; margin-top: .8rem; }
.extension-add-row { grid-template-columns: minmax(320px,1.4fr) minmax(220px,1fr); }
.phone-inventory-field, .extension-inventory-field { min-width: 0; }
.phone-inventory-field > label, .extension-inventory-field > label { display: block; margin-bottom: .35rem; color: var(--ink); font-size: .78rem; font-weight: 700; }
.phone-inventory-control, .extension-inventory-control { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: .45rem; }
.phone-inventory-control .button, .extension-inventory-control .button { white-space: nowrap; }
.phone-inventory-help, .extension-inventory-help { min-height: 1rem; margin-top: .35rem !important; font-size: .74rem; }
.phone-inventory-help.error, .extension-inventory-help.error { color: var(--danger); }
.phone-inventory-state, .extension-pbx-status { color: var(--success); }
.phone-inventory-state.offline, .extension-pbx-status.offline { color: var(--warning); }
.phone-edit-row, .extension-edit-row { display: grid; grid-template-columns: 1fr minmax(220px, .9fr) auto; align-items: center; gap: .7rem; margin-top: .6rem; padding: .65rem; border-radius: 9px; background: white; }
.extension-edit-row { grid-template-columns: minmax(0,1fr) auto; }
.phone-edit-row p, .extension-edit-row p { margin: 0; color: var(--ink); font-weight: 650; }
.phone-edit-row small, .extension-edit-row small { display: block; color: var(--muted); }
.phone-edit-row .phone-pbx-status { display: block; margin-top: .16rem; font-weight: 700; }
.extension-edit-row .extension-pbx-status { margin-top: .16rem; font-weight: 700; }
.phone-row-actions, .extension-row-actions { display: flex; align-items: center; justify-content: flex-end; gap: .45rem; }
.button.unlink-phone, .button.unlink-extension { display: inline-flex; align-items: center; gap: .35rem; color: var(--danger); border-color: #efc1bd; background: #fff7f6; }
.button.unlink-phone:hover, .button.unlink-extension:hover { border-color: var(--danger); background: #fff0ef; }
.button.unlink-phone svg, .button.unlink-extension svg { width: 1rem; height: 1rem; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.location-editor { margin: 1.3rem 0; padding: 1rem; border: 1px solid var(--line); border-radius: 12px; background: #f9fafc; }
.location-editor h3, .location-editor p { margin: 0 0 .25rem; }
.location-list { display: grid; gap: .6rem; margin-top: .8rem; }
.location-edit-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem; border-radius: 9px; background: white; }
.location-edit-row p, .location-edit-row small { margin: 0; }
.location-edit-row small { display: block; margin-top: .2rem; color: var(--muted); }
.location-address-search { display: grid; gap: .42rem; padding: .85rem; border: 1px solid #dbe3f4; border-radius: 11px; background: #f7f9ff; }
.location-address-search > label { color: #3b465d; font-size: .82rem; font-weight: 800; }
.location-address-search > small { color: var(--muted); font-size: .75rem; font-weight: 500; line-height: 1.35; }
.location-address-search-control { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: .55rem; }
.location-address-results { display: grid; gap: .45rem; margin-top: .2rem; }
.location-address-result { display: grid; gap: .16rem; width: 100%; padding: .72rem .8rem; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: white; text-align: left; cursor: pointer; }
.location-address-result:hover, .location-address-result:focus-visible { border-color: var(--brand); background: #f4f7ff; outline: none; }
.location-address-result span { color: #4f5b72; font-size: .76rem; line-height: 1.35; }
.location-address-result small { color: var(--brand); font-size: .72rem; font-weight: 750; }
.location-map-attribution { margin: -.2rem 0 0; color: var(--muted); font-size: .7rem; }
.location-map-attribution a { color: var(--brand); }
.location-summary { display: flex; flex-wrap: wrap; gap: .4rem; margin: .75rem 0; }
.location-chip { padding: .36rem .55rem; border: 1px solid #dbe3f4; border-radius: 8px; background: #f4f7ff; color: #35415a; font-size: .76rem; }
.password-note { margin: 1rem 0 0; font-size: .82rem; }
.password-fields { display: grid; gap: 1rem; margin: 1.25rem 0; }
.heading-controls { display: flex; align-items: end; gap: .7rem; flex-wrap: wrap; }
.heading-controls label { min-width: 145px; }
.heading-controls .search { min-width: 250px; }
.customer-list { display: grid; gap: .7rem; }
.customer-item { display: grid; grid-template-columns: minmax(180px, 1.2fr) minmax(170px, 1fr) minmax(150px, .8fr) auto; align-items: center; gap: 1rem; padding: 1rem 1.1rem; border: 1px solid var(--line); border-radius: 13px; background: white; }
.customer-item h3, .customer-item p { margin: 0; }
.customer-item p { margin-top: .25rem; color: var(--muted); font-size: .8rem; }
.appointment-status { justify-self: start; }
.badge.cancelled, .badge.archived { color: var(--muted); background: #eef1f7; }
.badge.confirmed { color: var(--success); background: var(--success-bg); }
.badge.completed { color: var(--done); background: var(--done-bg); }
.badge.scheduled { color: var(--brand); background: #eaf0ff; }
.badge.no_show { color: var(--warning); background: var(--warning-bg); }
.calendar-navigation { display: flex; gap: .4rem; }
.calendar-nav-button { min-width: 42px; padding-inline: .75rem; font-size: 1.25rem; }
.calendar-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: .85rem; }
.calendar-toolbar .eyebrow, .calendar-toolbar h3 { margin: 0; }
.calendar-toolbar h3 { margin-top: .18rem; text-transform: capitalize; font-size: 1.35rem; }
.calendar-legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .75rem; color: var(--muted); font-size: .75rem; font-weight: 700; }
.calendar-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.calendar-legend i { width: 9px; height: 9px; border-radius: 50%; background: var(--brand); }
.calendar-legend i.confirmed { background: var(--success); }
.calendar-legend i.completed { background: var(--done); }
.calendar-legend i.cancelled { background: #8992a3; }
.calendar-shell { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: white; box-shadow: 0 8px 24px rgba(25,36,61,.05); }
.calendar-weekdays, .appointment-calendar { display: grid; grid-template-columns: repeat(7, minmax(120px, 1fr)); min-width: 840px; }
.calendar-weekdays { color: var(--muted); background: #f7f8fb; border-radius: 14px 14px 0 0; }
.calendar-weekdays span { padding: .7rem; border-right: 1px solid var(--line); text-align: center; font-size: .72rem; font-weight: 800; text-transform: uppercase; }
.calendar-weekdays span:last-child { border-right: 0; }
.calendar-day { min-height: 132px; padding: .5rem; border-top: 1px solid var(--line); border-right: 1px solid var(--line); background: white; }
.calendar-day:nth-child(7n) { border-right: 0; }
.calendar-day.other-month { background: #fafbfc; }
.calendar-day > header { display: flex; align-items: center; justify-content: space-between; min-height: 26px; }
.calendar-day time { display: inline-grid; place-items: center; width: 27px; height: 27px; border-radius: 50%; color: var(--ink); font-size: .78rem; font-weight: 850; }
.calendar-weekday-mobile { display: none; }
.calendar-day.other-month time { color: #a5adbb; }
.calendar-day.today time { color: white; background: var(--brand); }
.calendar-day-add { width: 25px; height: 25px; padding: 0; border: 0; border-radius: 7px; color: var(--brand); background: transparent; font-size: 1rem; opacity: 0; }
.calendar-day:hover .calendar-day-add, .calendar-day-add:focus { opacity: 1; background: #eaf0ff; }
.calendar-day-events { display: grid; gap: .28rem; margin-top: .3rem; }
.calendar-event-wrap { position: relative; }
.calendar-event { display: grid; grid-template-columns: auto minmax(0,1fr); gap: .08rem .36rem; width: 100%; padding: .38rem 1.8rem .38rem .42rem; border: 0; border-left: 3px solid var(--brand); border-radius: 7px; color: #24409c; background: #edf2ff; text-align: left; cursor: pointer; }
.calendar-event:hover, .calendar-event:focus { z-index: 2; outline: 2px solid rgba(49,87,227,.2); transform: translateY(-1px); }
.calendar-event.confirmed { color: #19643f; border-left-color: var(--success); background: var(--success-bg); }
.calendar-event.completed { color: #5b2192; border-left-color: var(--done); background: var(--done-bg); }
.calendar-event.cancelled { color: #727b8c; border-left-color: #8992a3; background: #f0f2f6; text-decoration: line-through; }
.calendar-event.no_show { color: #8b5a0a; border-left-color: var(--warning); background: var(--warning-bg); }
.calendar-event-time { font-size: .7rem; font-weight: 900; }
.calendar-event-name { overflow: hidden; font-size: .72rem; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.calendar-event-service { grid-column: 2; overflow: hidden; opacity: .78; font-size: .64rem; text-overflow: ellipsis; white-space: nowrap; }
.calendar-event-cancel { position: absolute; top: .25rem; right: .25rem; z-index: 1; display: grid; width: 1.35rem; height: 1.35rem; place-items: center; padding: 0; border: 0; border-radius: 5px; color: var(--danger); background: rgba(255,255,255,.82); opacity: 0; transition: opacity .15s, background .15s; }
.calendar-event-wrap:hover .calendar-event-cancel, .calendar-event-cancel:focus { opacity: 1; }
.calendar-event-cancel:hover { background: #fff0ef; }
.calendar-event-cancel svg { width: .82rem; height: .82rem; }

/* Giorni già trascorsi: cella attenuata, appuntamenti sempre leggibili. */
.calendar-day.past { background: #e9edf4; }
.calendar-day.past > header time { color: #939cad; }
.calendar-day.past.today time { color: white; }
.calendar-day.past .calendar-day-add { color: #7f8798; }

/* Spostamento di un appuntamento in un altro giorno. */
.calendar-event.is-movable { cursor: grab; touch-action: pan-y; }
.calendar-event.is-dragging { opacity: .35; }
body.is-moving-appointment { cursor: grabbing; user-select: none; }
.calendar-event-ghost { position: fixed; z-index: 60; margin: 0; opacity: .96; box-shadow: 0 14px 30px rgba(24,34,58,.3); transform: rotate(-1.5deg); pointer-events: none; }
.calendar-day.drop-target, .calendar-day.past.drop-target { background: #e5eeff; box-shadow: inset 0 0 0 2px var(--brand); }

.availability-fieldset { min-width: 0; padding: 1rem; border: 1px solid var(--line); border-radius: 12px; }
.availability-fieldset legend { padding: 0 .35rem; font-weight: 800; }
.availability-fieldset p { margin: 0 0 .75rem; font-size: .8rem; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: .55rem; }
.choice-item { display: flex; align-items: center; gap: .5rem; padding: .55rem .65rem; border: 1px solid var(--line); border-radius: 9px; background: #f8f9fc; font-size: .82rem; font-weight: 700; }
.choice-item input { width: auto; }
.confirmation-dialog { width: min(560px, calc(100vw - 2rem)); }
.confirmation-dialog form { max-height: calc(100vh - 2rem); overflow-y: auto; padding: 1.5rem; }
.confirmation-dialog .muted { margin: 1rem 0; line-height: 1.55; }
.confirmation-dialog .dialog-footer { flex-wrap: wrap; }
.confirmation-summary { padding: 1rem; border-radius: 12px; background: #f6f7fb; font-weight: 750; line-height: 1.5; }
.confirmation-warning { margin: -.25rem 0 1rem; color: var(--warning); font-size: .82rem; font-weight: 700; line-height: 1.45; }
.button.danger { color: white; border-color: var(--danger); background: var(--danger); }
.calendar-empty { margin-top: .75rem; padding: .8rem 1rem; border-radius: 10px; color: var(--muted); background: #f7f8fb; font-size: .82rem; text-align: center; }
.appointment-hover-card { position: fixed; z-index: 1000; display: grid; gap: .32rem; width: min(320px, calc(100vw - 24px)); padding: .85rem .95rem; border: 1px solid rgba(255,255,255,.12); border-radius: 12px; color: white; background: #17223b; box-shadow: 0 14px 38px rgba(11,18,34,.3); pointer-events: none; }
.appointment-hover-card[hidden] { display: none; }
.appointment-hover-card strong { font-size: .92rem; }
.appointment-hover-card span { color: #d5dceb; font-size: .76rem; }
.appointment-hover-card .tooltip-notes { margin-top: .15rem; padding-top: .4rem; border-top: 1px solid rgba(255,255,255,.12); }
.appointment-hover-card .tooltip-status { color: #91adff; font-weight: 850; }
.form-field { display: grid; gap: .42rem; }
.field-label-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.field-label-row label { display: block; }
.text-button { padding: 0; border: 0; color: var(--brand); background: transparent; font-size: .75rem; font-weight: 800; }

.dashboard-section { padding: 0; border: 0; background: transparent; }
.dashboard-hero { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.2rem; padding: 1.5rem 1.65rem; border-radius: 20px; color: white; background: linear-gradient(125deg, #17264c, #3157e3 68%, #6c43dd); box-shadow: 0 18px 38px rgba(34,64,156,.2); }
.dashboard-hero .eyebrow { color: #c5d2ff; }
.dashboard-hero h2, .dashboard-hero p { margin: 0; }
.dashboard-hero h2 { margin-bottom: .35rem; font-size: clamp(1.35rem, 2.4vw, 1.9rem); }
.dashboard-hero .muted { color: #e0e7ff; }
.dashboard-hero .button { color: #1f315f; background: white; }
.dashboard-hero-actions { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: .55rem; }
.dashboard-forwarding-control { display: grid; gap: .2rem; min-width: 170px; }
.dashboard-forwarding-control span { color: #e0e7ff; font-size: .68rem; font-weight: 800; }
.dashboard-forwarding-control select { min-height: 42px; padding: .55rem 2rem .55rem .7rem; border: 1px solid rgba(255,255,255,.55); border-radius: 10px; color: #17264c; background: white; font: inherit; font-size: .78rem; font-weight: 750; }
#dashboard-ai-toggle[data-enabled="false"] { color: white; background: #16855a; }
.dashboard-metrics { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: .9rem; margin-bottom: 1rem; }
.dashboard-metrics article { display: grid; min-height: 132px; align-content: start; padding: 1.1rem 1.2rem; border: 1px solid var(--line); border-radius: 16px; background: white; box-shadow: 0 8px 20px rgba(24,34,58,.045); }
.dashboard-metrics article.attention { border-color: #f1d49b; background: linear-gradient(145deg, #fff, #fff8e9); }
.dashboard-metrics span { color: var(--muted); font-size: .78rem; font-weight: 750; }
.dashboard-metrics strong { margin: .35rem 0 .15rem; font-size: 2rem; line-height: 1; }
.dashboard-metrics small { color: #8a94a7; font-size: .7rem; }
.dashboard-layout { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 1rem; }
.dashboard-panel { min-width: 0; padding: 1.2rem; border: 1px solid var(--line); border-radius: 17px; background: white; box-shadow: 0 8px 22px rgba(24,34,58,.045); }
.dashboard-panel .panel-heading { margin-bottom: .8rem; }
.dashboard-panel .panel-heading h3, .dashboard-panel .panel-heading p { margin: 0; }
.dashboard-panel .panel-heading h3 { margin-top: .15rem; font-size: 1.05rem; }
.dashboard-panel-intro { margin: -.25rem 0 .85rem; color: var(--muted); font-size: .76rem; line-height: 1.45; }
.dashboard-agenda-panel, .dashboard-callback-panel { min-height: 285px; }
.dashboard-list { display: grid; gap: .55rem; }
.dashboard-row { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: .8rem; padding: .8rem; border: 1px solid #edf0f5; border-radius: 11px; background: #fbfcff; }
.dashboard-row time { min-width: 48px; color: var(--brand); font-size: .82rem; font-weight: 900; }
.dashboard-row strong, .dashboard-row span, .dashboard-row small { display: block; }
.dashboard-row strong { font-size: .86rem; }
.dashboard-row span, .dashboard-row small { margin-top: .18rem; color: var(--muted); font-size: .72rem; }
.dashboard-row-meta { text-align: right; }
.dashboard-row-meta span { color: var(--ink); font-weight: 750; }
.callback-row { grid-template-columns: minmax(0,1fr) auto; align-items: end; }
.callback-row.urgent { border-color: #f4c6c2; background: #fff8f7; }
.callback-main a { display: inline-block; margin-top: .2rem; color: var(--brand); font-size: .8rem; font-weight: 800; text-decoration: none; }
.callback-title { display: flex; align-items: center; gap: .45rem; }
.urgent-badge { display: inline-flex !important; margin: 0 !important; padding: .2rem .38rem; border-radius: 999px; color: var(--danger) !important; background: #ffe4e1; font-size: .58rem !important; font-weight: 900; }
.dashboard-count-badge { display: grid; min-width: 30px; height: 30px; place-items: center; padding: 0 .45rem; border-radius: 999px; color: #85540b; background: var(--warning-bg); font-size: .75rem; font-weight: 900; }
.button.compact { min-height: 34px; padding: .5rem .65rem; font-size: .7rem; }
.dashboard-empty { display: grid; min-height: 150px; place-content: center; gap: .25rem; padding: 1rem; border: 1px dashed #d9dfeb; border-radius: 12px; color: var(--muted); background: #fafbfd; text-align: center; }
.dashboard-empty strong { color: var(--ink); font-size: .88rem; }
.dashboard-empty span { font-size: .75rem; }
.dashboard-empty.positive { border-color: #c8ead9; background: #f5fcf8; }
.dashboard-stats-list { display: grid; grid-template-columns: repeat(3,1fr); gap: .55rem; }
.dashboard-stats-list div { display: grid; gap: .25rem; padding: .75rem; border-radius: 11px; background: #f6f8fc; }
.dashboard-stats-list span { color: var(--muted); font-size: .68rem; font-weight: 700; }
.dashboard-stats-list strong { font-size: 1rem; font-variant-numeric: tabular-nums; }
.dashboard-quick-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }

.call-log-privacy-note { display: flex; align-items: flex-start; gap: .65rem; margin-bottom: 1rem; padding: .8rem 1rem; border: 1px solid #cbd9ff; border-radius: 12px; color: #29447f; background: #f4f7ff; font-size: .76rem; line-height: 1.5; }
.call-log-privacy-note strong { flex: 0 0 auto; color: var(--brand); }
.call-log-list { display: grid; gap: .75rem; }
.call-log-card { overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: white; }
.call-log-card summary { display: flex; min-height: 76px; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem; cursor: pointer; list-style: none; }
.call-log-card summary::-webkit-details-marker { display: none; }
.call-log-card summary::after { content: "⌄"; color: var(--muted); font-size: 1.1rem; font-weight: 900; transition: transform .18s; }
.call-log-card[open] summary::after { transform: rotate(180deg); }
.call-log-main { display: grid; min-width: 0; gap: .25rem; margin-right: auto; }
.call-log-main strong { font-size: .92rem; }
.call-log-main small { color: var(--muted); font-size: .72rem; }
.call-log-number-line { display: flex; align-items: center; flex-wrap: wrap; gap: .45rem; }
.call-log-blocked { display: inline-flex; padding: .22rem .42rem; border-radius: 999px; color: #a3221a; background: #ffe8e5; font-size: .62rem; font-weight: 900; text-transform: uppercase; }
.call-log-status { display: inline-flex; align-items: center; padding: .28rem .48rem; border-radius: 999px; color: #176a46; background: #e4f6ed; font-size: .65rem; font-weight: 900; }
.call-log-status.failed { color: #9f2c22; background: #ffe8e5; }
.call-log-status.cancelled { color: #87540a; background: var(--warning-bg); }
.call-log-body { padding: 0 1rem 1rem; border-top: 1px solid #edf0f5; }
.call-log-meta { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; padding: .8rem 0; color: var(--muted); font-size: .7rem; }
.call-log-meta strong { margin-left: .2rem; color: var(--ink); }
.call-log-actions { display: flex; justify-content: flex-end; padding-top: .2rem; }

@media (max-width: 780px) {
  body.mobile-nav-open { overflow: hidden; }
  .mobile-appbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    min-height: 68px;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .7rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
    color: white;
    background: rgba(21,30,53,.97);
    box-shadow: 0 8px 24px rgba(12,20,39,.18);
    backdrop-filter: blur(14px);
  }
  .mobile-brand { display: flex; min-width: 0; align-items: center; gap: .7rem; }
  .mobile-page-context { display: grid; min-width: 0; gap: .08rem; }
  .mobile-page-context small { overflow: hidden; color: #91adff; font-size: .58rem; font-weight: 850; letter-spacing: .08em; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-page-context strong { overflow: hidden; color: white; font-size: .94rem; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-menu-button { display: grid; width: 44px; height: 44px; flex: 0 0 auto; place-content: center; gap: 4px; padding: 0; border: 1px solid rgba(255,255,255,.14); border-radius: 12px; color: white; background: rgba(255,255,255,.08); }
  .mobile-menu-button span { display: block; width: 20px; height: 2px; border-radius: 2px; background: currentColor; transition: transform .18s, opacity .18s; }
  body.mobile-nav-open .mobile-menu-button span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
  body.mobile-nav-open .mobile-menu-button span:nth-child(2) { opacity: 0; }
  body.mobile-nav-open .mobile-menu-button span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
  .mobile-nav-backdrop { position: fixed; inset: 0; z-index: 39; display: block; width: 100%; height: 100%; padding: 0; border: 0; background: rgba(10,17,32,.55); backdrop-filter: blur(2px); }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: min(84vw, 320px);
    min-height: 100dvh;
    padding: 1.25rem 1rem max(1rem, env(safe-area-inset-bottom));
    box-shadow: 20px 0 50px rgba(8,15,30,.28);
    transform: translateX(-105%);
    transition: transform .22s ease;
  }
  body.mobile-nav-open .sidebar { transform: translateX(0); }
  .sidebar .brand { padding-bottom: 1.25rem; }
  .sidebar nav { display: grid; gap: .35rem; overflow: visible; }
  .nav-item { min-height: 46px; width: 100%; flex: none; }
  .nav-item.disabled { display: none; }
  .plan-summary { margin: 1rem .4rem 0; }
  .sidebar-footer { margin-top: auto; padding-top: 1rem; }

  main { min-height: calc(100dvh - 68px); margin-left: 0; padding: 1rem; }
  .topbar { align-items: stretch; margin-bottom: .85rem; }
  .topbar > div:first-child { display: none; }
  .topbar-actions { width: 100%; }
  .topbar-actions .button { flex: 1; }
  .metrics { grid-template-columns: repeat(2, minmax(0,1fr)); gap: .65rem; margin: .25rem 0 1rem; }
  .metrics article { min-height: 80px; align-items: flex-start; flex-direction: column; justify-content: center; gap: .25rem; padding: .85rem 1rem; border-radius: 14px; }
  .metrics article[data-platform-only] { grid-column: 1 / -1; }
  .metrics strong { font-size: 1.45rem; }
  .content-section { padding: 1rem; border-radius: 16px; }
  .section-heading { align-items: stretch; flex-direction: column; margin-bottom: 1rem; }
  .section-heading h2 { font-size: 1.28rem; }
  .search, .search input { width: 100%; }
  .structure-grid { grid-template-columns: minmax(0,1fr); }
  .structure-card { min-height: 0; padding: 1rem; }
  .structure-card:hover { transform: none; box-shadow: none; }
  .card-actions { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); }
  .card-actions .button { width: 100%; min-width: 0; padding-inline: .55rem; }

  .button { min-height: 44px; }
  .form-grid, .phone-add-row, .extension-add-row { grid-template-columns: minmax(0,1fr); }
  .phone-edit-row, .extension-edit-row { grid-template-columns: minmax(0,1fr); }
  .phone-row-actions, .extension-row-actions { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); }
  .phone-row-actions .button, .extension-row-actions .button { width: 100%; }
  .location-edit-row { align-items: stretch; flex-direction: column; }
  .location-edit-row .button { width: 100%; }
  .location-address-search-control { grid-template-columns: minmax(0,1fr); }
  .location-address-search-control .button { width: 100%; }
  .user-card { grid-template-columns: minmax(0,1fr); }
  .account-actions { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); justify-content: stretch; }
  .account-actions .button { width: 100%; }
  .billing-grid { grid-template-columns: minmax(0,1fr); }
  .billing-card-head { align-items: stretch; flex-direction: column; }
  .notification-layout { grid-template-columns: minmax(0,1fr); }
  .notification-recipient-channel-heading { align-items: stretch; flex-direction: column; }
  .notification-recipient-toggle { justify-content: center; }
  .smtp-settings-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .operations-grid { grid-template-columns: minmax(0,1fr); }
  .management-panel { padding: 1rem; }
  .management-item { grid-template-columns: minmax(0,1fr); }
  .management-item .button { width: 100%; }
  .hours-row { grid-template-columns: repeat(2,minmax(0,1fr)); padding: .8rem; }
  .hours-row .day-toggle, .hours-row .pause-toggle { grid-column: 1 / -1; }
  .pause-toggle { padding-top: 0; }
  .panel-heading { align-items: stretch; flex-direction: column; }
  .panel-heading .button { width: 100%; }
  .heading-controls { align-items: stretch; flex-direction: column; }
  .heading-controls label, .heading-controls .search { min-width: 0; }
  .customer-item { grid-template-columns: minmax(0,1fr); }

  .calendar-toolbar { align-items: stretch; flex-direction: column; }
  .calendar-toolbar > div:first-child { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
  .calendar-navigation { flex: 0 0 auto; }
  .calendar-legend { justify-content: flex-start; gap: .55rem; }
  .calendar-shell { overflow: visible; border: 0; border-radius: 0; box-shadow: none; }
  .calendar-weekdays { display: none; }
  .appointment-calendar { display: grid; min-width: 0; grid-template-columns: minmax(0,1fr); gap: .55rem; }
  .calendar-day, .calendar-day:nth-child(7n) { min-height: 60px; padding: .65rem; border: 1px solid var(--line); border-radius: 11px; background: white; }
  .calendar-day.past, .calendar-day.past:nth-child(7n) { border-color: #d9dfea; background: #e9edf4; }
  .calendar-day.drop-target, .calendar-day.drop-target:nth-child(7n) { background: #e5eeff; }
  .calendar-day.other-month { display: none; }
  .calendar-day > header { min-height: 32px; }
  .calendar-day time { display: flex; width: auto; height: 32px; align-items: center; gap: .42rem; padding: 0 .55rem; border-radius: 999px; }
  .calendar-weekday-mobile { display: inline; font-size: .68rem; text-transform: uppercase; }
  .calendar-day-add { width: 36px; height: 36px; opacity: 1; background: #eaf0ff; }
  .calendar-day-events { gap: .4rem; }
  .calendar-event { min-height: 48px; padding: .5rem 2.25rem .5rem .55rem; }
  .calendar-event-name, .calendar-event-service { white-space: normal; }
  .calendar-event-cancel { top: .55rem; right: .55rem; width: 1.8rem; height: 1.8rem; opacity: 1; }
  .appointment-hover-card { display: none !important; }

  dialog, .confirmation-dialog { inset: 0; width: 100%; max-width: none; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
  #structure-form, #user-form, #password-form, #billing-form, #service-form, #operator-form, #workstation-form, #customer-form, #appointment-form, #location-form, #sales-user-form, .confirmation-dialog form { min-height: 100dvh; max-height: 100dvh; overflow-y: auto; padding: 1rem; }
  .dialog-header { position: sticky; top: -1rem; z-index: 2; margin: -1rem -1rem 1rem; padding: 1rem; border-bottom: 1px solid var(--line); background: white; }
  .dialog-footer { position: sticky; bottom: -1rem; z-index: 2; align-items: stretch; flex-direction: column-reverse; margin: 1rem -1rem -1rem; padding: .9rem 1rem max(.9rem,env(safe-area-inset-bottom)); background: white; }
  .dialog-footer .button { width: 100%; }
  .confirmation-dialog .muted { margin: .75rem 0; }

  .dashboard-hero { align-items: stretch; flex-direction: column; padding: 1.2rem; border-radius: 16px; }
  .dashboard-hero-actions { display: grid; grid-template-columns: minmax(0,1fr); }
  .dashboard-forwarding-control { width: 100%; }
  .dashboard-hero .button { width: 100%; }
  .dashboard-metrics { grid-template-columns: repeat(2,minmax(0,1fr)); gap: .65rem; }
  .dashboard-metrics article { min-height: 112px; padding: .9rem; }
  .dashboard-layout { grid-template-columns: minmax(0,1fr); }
  .dashboard-panel { padding: 1rem; }
  .dashboard-agenda-panel, .dashboard-callback-panel { min-height: 0; }
  .dashboard-row, .callback-row { grid-template-columns: minmax(0,1fr); align-items: start; }
  .dashboard-row-meta { text-align: left; }
  .callback-row .button { width: 100%; }
  .dashboard-stats-list { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .dashboard-quick-actions { display: grid; grid-template-columns: minmax(0,1fr); }
  .dashboard-quick-actions .button { width: 100%; }
  .call-log-card summary { align-items: flex-start; flex-wrap: wrap; }
  .call-log-status { order: 2; }
  .call-log-privacy-note { flex-direction: column; gap: .25rem; }
}

@media (max-width: 390px) {
  main { padding: .75rem; }
  .mobile-appbar { padding-inline: .75rem; }
  .dashboard-metrics { grid-template-columns: minmax(0,1fr); }
  .dashboard-metrics article { min-height: 96px; }
  .dashboard-stats-list { grid-template-columns: minmax(0,1fr); }
  .billing-stats { grid-template-columns: minmax(0,1fr); }
  .notification-contact-summary, .notification-options, .whatsapp-options, .whatsapp-reminder-leads > div, .whatsapp-technical-grid { grid-template-columns: minmax(0,1fr); }
  .whatsapp-test-message { grid-column: auto; }
  .smtp-settings-grid { grid-template-columns: minmax(0,1fr); }
  .manual-summary-row { align-items: stretch; flex-direction: column; }
  .notification-event { grid-template-columns: minmax(0,1fr); }
  .notification-event-side { text-align: left; }
  .card-actions, .account-actions { grid-template-columns: minmax(0,1fr); }
}

/* --- Integrazioni --- */
.integration-card { margin-top: 1rem; padding: 1.25rem; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
.integration-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.integration-head h3 { margin: 0 0 .25rem; font-size: 1.05rem; }
.integration-head p { margin: 0; font-size: .85rem; }
.integration-url { display: block; margin-top: 1rem; font-size: .78rem; font-weight: 700; color: var(--muted); }
.integration-url input { width: 100%; margin-top: .3rem; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .82rem; }
.integration-hint { margin: .6rem 0 0; color: var(--muted); font-size: .8rem; }
.integration-actions { display: flex; align-items: end; flex-wrap: wrap; gap: .6rem; margin-top: 1rem; }
.integration-actions label { display: grid; gap: .25rem; font-size: .78rem; font-weight: 700; color: var(--muted); }
.integration-reveal { display: grid; gap: .5rem; margin-top: 1rem; padding: .9rem; border: 1px solid #f0d9a8; border-radius: 12px; background: var(--warning-bg); }
.integration-reveal strong { color: var(--warning); font-size: .85rem; }
.integration-reveal input { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .82rem; }
.integration-list { display: grid; gap: .5rem; margin-top: 1rem; }
.integration-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem .9rem; border: 1px solid var(--line); border-radius: 11px; }
.integration-row > div { display: grid; gap: .12rem; }
.integration-row strong { font-size: .9rem; }
.integration-row span, .integration-row small { font-size: .74rem; }
.button.danger { color: var(--danger); background: #fdeceb; }
@media (max-width: 780px) {
  .integration-head { flex-direction: column; }
  .integration-actions { flex-direction: column; align-items: stretch; }
  .integration-row { flex-direction: column; align-items: stretch; }
}

/* --- Panoramica piattaforma --- */
.pf-alert.critical { border-left: 4px solid var(--danger); }
.pf-alert.warning { border-left: 4px solid var(--warning); }
.pf-alert span { color: var(--muted); }
.pf-consumption-row { display: grid; gap: .35rem; padding: .7rem .9rem; border: 1px solid var(--line); border-radius: 11px; }
.pf-consumption-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.pf-consumption-head strong { font-size: .9rem; }
.pf-consumption-head span { font-size: .74rem; }
.pf-bar { height: 8px; overflow: hidden; border-radius: 999px; background: #eef1f7; }
.pf-bar-fill { display: block; height: 100%; border-radius: 999px; background: var(--success); }
.pf-bar-fill.warning { background: var(--warning); }
.pf-bar-fill.critical { background: var(--danger); }
.pf-trend { display: flex; align-items: flex-end; gap: .3rem; height: 150px; margin-top: 1rem; padding-top: .5rem; }
.pf-trend-col { display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: .3rem; }
.pf-trend-bar { display: block; width: 100%; max-width: 34px; border-radius: 5px 5px 0 0; background: linear-gradient(180deg, #6c8bff, var(--brand)); }
.pf-trend-col small { color: var(--muted); font-size: .62rem; }

/* --- Caselle di spunta nei form: allineate al campo affiancato --- */
.form-grid .toggle-label {
  display: flex;
  align-items: center;
  align-self: end;
  gap: .65rem;
  min-height: 47px;
  padding: .7rem .85rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f8f9fc;
  color: var(--ink);
  font-size: .84rem;
  font-weight: 650;
  line-height: 1.3;
}
.form-grid .toggle-label input[type="checkbox"] {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
  accent-color: var(--brand);
}
/* I suggerimenti sotto i campi non devono sfalsare la riga successiva. */
.form-grid > label > small { color: var(--muted); font-size: .72rem; font-weight: 550; line-height: 1.35; }

/* --- Dashboard venditore --- */
.sd-stats { display: flex; flex-wrap: wrap; gap: .25rem .9rem; margin-top: .45rem; font-size: .76rem; color: var(--muted); }
.sd-stats strong { color: var(--ink); }

/* --- Selettore clienti ricercabile (scala a molte strutture) --- */
.client-picker { display: grid; gap: .5rem; }
.picker-title { color: #3b465d; font-size: .82rem; font-weight: 700; }
.picker-toolbar { display: flex; align-items: center; gap: .9rem; }
.picker-action { padding: 0; color: var(--brand); font-size: .76rem; font-weight: 750; }
.picker-toolbar .muted { margin-left: auto; font-size: .74rem; font-weight: 650; }
.picker-list { max-height: 240px; overflow-y: auto; border: 1px solid #ccd3e0; border-radius: 9px; background: white; }
.picker-item { display: flex; align-items: center; gap: .6rem; padding: .55rem .7rem; border-bottom: 1px solid #f0f2f7; color: var(--ink); font-size: .85rem; font-weight: 600; cursor: pointer; }
.picker-item:last-child { border-bottom: 0; }
.picker-item:hover { background: #f6f8fd; }
.picker-item input[type="checkbox"] { flex: 0 0 auto; width: 17px; height: 17px; margin: 0; accent-color: var(--brand); }
.picker-item small { margin-left: auto; color: var(--muted); font-size: .72rem; font-weight: 550; }
.picker-empty { margin: 0; padding: .8rem; color: var(--muted); font-size: .8rem; text-align: center; }

/* --- Scheda cliente del venditore --- */
#sales-client-form { max-height: calc(100vh - 2rem); overflow-y: auto; padding: 1.5rem; }
.sc-section { margin-bottom: 1.4rem; }
.sc-section .eyebrow { margin-bottom: .45rem; }
.sc-address { margin: 0 0 .7rem; color: var(--ink); font-size: .92rem; font-weight: 650; }
.sc-contacts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .6rem; }
.sc-contact { display: grid; gap: .12rem; padding: .75rem .85rem; border: 1px solid var(--line); border-radius: 11px; background: #f8f9fc; color: var(--ink); text-decoration: none; }
.sc-contact:hover { border-color: var(--brand); background: #eef3ff; }
.sc-contact strong { color: var(--muted); font-size: .68rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.sc-contact span { font-size: .88rem; font-weight: 700; overflow-wrap: anywhere; }
.sc-contact small { color: var(--brand); font-size: .72rem; font-weight: 700; }
#sc-note { min-height: 130px; resize: vertical; }
.pf-consumption-row.is-clickable { cursor: pointer; }
.pf-consumption-row.is-clickable:hover { border-color: var(--brand); background: #f7f9ff; }


/* --- Compensi venditore --- */
.sp-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .7rem; margin-top: 1rem; }
.sp-summary > div { display: grid; gap: .2rem; padding: .8rem .9rem; border: 1px solid var(--line); border-radius: 11px; background: #f8f9fc; }
.sp-summary span { color: var(--muted); font-size: .72rem; font-weight: 700; }
.sp-summary strong { font-size: 1.2rem; }
.sp-form-title { margin: 1.4rem 0 .6rem; }
#sales-payment-form .form-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
.sales-code { padding: .1rem .4rem; border-radius: 6px; color: var(--brand); background: #eaf0ff; font-size: .72rem; font-weight: 800; }
.sales-payout { display: grid; justify-items: end; gap: .15rem; text-align: right; }
.sales-payout strong { font-size: 1.05rem; }
.sales-payout small { font-size: .72rem; }


/* --- Wizard nuovo cliente --- */
#onboarding-form { max-height: calc(100vh - 2rem); overflow-y: auto; padding: 1.5rem; }
.wz-steps { display: flex; flex-wrap: wrap; gap: .35rem; margin: 0 0 1.3rem; padding: 0; list-style: none; counter-reset: wz; }
.wz-steps li { flex: 1 1 auto; padding: .4rem .5rem; border-bottom: 3px solid var(--line); color: var(--muted); font-size: .72rem; font-weight: 750; text-align: center; }
.wz-steps li.active { border-bottom-color: var(--brand); color: var(--brand); }
.wz-steps li.done { border-bottom-color: var(--success); color: var(--success); }
.wz-rows { display: grid; gap: .5rem; margin: .8rem 0; }
.wz-rows-spaced { margin-top: 1.4rem; }
.wz-row { display: grid; grid-template-columns: minmax(0,2fr) minmax(0,1fr) minmax(0,1fr) auto; align-items: center; gap: .5rem; padding: .6rem; border: 1px solid var(--line); border-radius: 10px; background: #f8f9fc; }
.wz-row.simple { grid-template-columns: minmax(0,1fr) minmax(0,1fr) auto; }
.wz-row input { padding: .5rem .6rem; }
.wz-remove { padding: .35rem .6rem; border: 0; border-radius: 8px; color: var(--danger); background: #fdeceb; font-size: .74rem; font-weight: 750; }
.wz-days { display: grid; gap: .5rem; }
.wz-day { display: grid; grid-template-columns: minmax(0,1.6fr) repeat(4, minmax(0,1fr)); align-items: center; gap: .5rem; }
.wz-days-head { display: grid; grid-template-columns: minmax(0,1.6fr) repeat(4, minmax(0,1fr)); gap: .5rem; margin-bottom: .35rem; padding: 0 .1rem; color: var(--muted); font-size: .68rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.wz-day .toggle-label { display: flex; align-items: center; gap: .6rem; align-self: stretch; min-height: 44px; padding: .6rem .8rem; border: 1px solid var(--line); border-radius: 9px; background: #f8f9fc; font-size: .84rem; font-weight: 650; color: var(--ink); }
.wz-day .toggle-label input { flex: 0 0 auto; width: 18px; height: 18px; margin: 0; accent-color: var(--brand); }
.wz-summary { display: grid; gap: .45rem; margin-bottom: 1rem; padding: .9rem; border: 1px solid var(--line); border-radius: 11px; background: #f8f9fc; font-size: .86rem; }
.wz-summary div { display: flex; justify-content: space-between; gap: 1rem; }
.wz-summary span { color: var(--muted); }
.wz-summary strong { text-align: right; }
@media (max-width: 780px) {
  .wz-row, .wz-row.simple, .wz-day { grid-template-columns: minmax(0,1fr); }
  .wz-days-head { display: none; }
  .wz-steps li { flex: 1 1 40%; }
}


/* --- Chiusure --- */
.closure-form { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)) auto; align-items: end; gap: .6rem; margin: 1rem 0; }
.closure-form label { display: grid; gap: .25rem; font-size: .78rem; font-weight: 700; color: var(--muted); }
@media (max-width: 780px) { .closure-form { grid-template-columns: minmax(0,1fr); } }


/* --- Storico pagamenti --- */
#payout-form { max-height: calc(100vh - 2rem); overflow-y: auto; padding: 1.5rem; }
#payout-form .dialog-footer { justify-content: flex-end; margin-top: 1rem; }
#payout-list { margin-top: .8rem; }
