.portal-body { min-height: 100vh; background: #f4f7fb; }
.portal-body [hidden] { display: none !important; }
.portal-login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.portal-shell { min-height: 100vh; display: grid; grid-template-columns: 280px minmax(0, 1fr); }
.portal-sidebar {
  position: sticky; top: 0; height: 100vh; max-height: 100vh; display: flex; flex-direction: column;
  background: #fff; border-right: 1px solid var(--border); padding: 18px 12px;
  overflow: hidden; min-height: 0;
}
.portal-brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 20px; text-decoration: none; font-weight: 800; color: var(--brand-blue); }
.portal-brand img { width: auto; max-width: 160px; height: 38px; object-fit: contain; }
.tenant-logo-preview {
  display: block; max-width: 240px; max-height: 80px; width: auto; height: auto;
  object-fit: contain; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 8px;
}
.portal-tenant { margin: 0 6px 22px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; display: grid; }
.portal-tenant span, .portal-tenant small { color: var(--muted); font-size: 12px; }
.portal-tenant strong { color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.portal-mode {
  display: grid; gap: 6px; margin: 0 6px 16px; color: var(--muted);
  font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
}
.portal-mode select {
  width: 100%; border: 1px solid var(--border); border-radius: 9px; background: #fff;
  color: var(--text); font: inherit; font-size: 14px; font-weight: 700; letter-spacing: 0;
  text-transform: none; padding: 9px 11px;
}
.portal-nav {
  overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column; align-items: stretch; gap: 8px; padding: 0 2px 8px;
}
.portal-nav-group {
  flex: 0 0 auto; min-width: 0; width: 100%;
  border: 1px solid var(--border); border-radius: 12px; background: #fff; overflow: visible;
}
.portal-nav-toggle {
  display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 8px;
  margin: 0; padding: 10px 12px; border: 0; background: #f8fafc; border-radius: 11px;
  color: #64748b; font: inherit; font-size: 11px; font-weight: 800; line-height: 1.35;
  letter-spacing: .06em; text-transform: uppercase; cursor: pointer; text-align: left;
  white-space: normal; overflow: visible; min-width: 0;
}
.portal-nav-group.is-open .portal-nav-toggle { border-radius: 11px 11px 0 0; }
.portal-nav-toggle:hover, .portal-nav-toggle:focus-visible { color: #0369a1; background: #f0f9ff; }
.portal-nav-chevron {
  width: 6px; height: 6px; flex: 0 0 auto;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg); transition: transform .18s ease;
}
.portal-nav-toggle[aria-expanded="true"] .portal-nav-chevron { transform: rotate(45deg); }
.portal-nav-items { padding: 4px 8px 8px; overflow: visible; min-width: 0; }
.portal-nav a {
  display: block; padding: 8px 10px; border-radius: 9px;
  color: #475569; text-decoration: none; font-size: 14px; font-weight: 600; line-height: 1.4;
  white-space: normal; overflow: visible; overflow-wrap: break-word; word-break: normal;
  min-width: 0;
}
.portal-nav a:hover, .portal-nav a.active { color: #0369a1; background: #e0f2fe; }
.portal-nav a span {
  display: inline-block; margin-left: 6px; vertical-align: middle;
  font-size: 9px; color: #a16207; background: #fef3c7; padding: 2px 5px; border-radius: 4px;
}
.portal-logout { margin-top: 12px; flex-shrink: 0; border: 1px solid var(--border); background: #fff; border-radius: 9px; padding: 9px; cursor: pointer; }
.portal-main { min-width: 0; }
.portal-topbar {
  min-height: 78px; display: flex; align-items: center; gap: 18px; justify-content: space-between;
  padding: 14px 28px; background: #fff; border-bottom: 1px solid var(--border);
}
.portal-topbar h1 { margin: 0; color: var(--brand-blue); font-size: 22px; }
.portal-topbar p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.portal-user { display: grid; justify-items: end; text-align: right; font-size: 13px; gap: 4px; }
.portal-body.simple-mode [data-advanced] { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.portal-user small { color: var(--muted); }
.portal-menu { display: none; }
.portal-content { width: 100%; max-width: 1440px; margin: 0 auto; padding: 28px; }
.portal-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.portal-card {
  min-width: 0; overflow: hidden; overflow-wrap: anywhere; word-break: break-word;
  background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 18px;
}
.portal-card h2, .portal-card h3 { margin: 0 0 12px; color: var(--brand-blue); }
.portal-metric strong { display: block; font-size: 28px; line-height: 1.2; }
.portal-metric span { color: var(--muted); font-size: 13px; }
.portal-section { margin-top: 18px; }
.portal-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; justify-content: space-between; margin-bottom: 14px; }
.cdr-filter { justify-content: flex-start; }
.cdr-export-actions { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.portal-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; min-width: 0; }
.portal-form-grid label { min-width: 0; }
.portal-modal-card label.hd-audio-field,
.portal-modal-card label.fw-upgrade-field { grid-column: 1 / -1; }
.portal-modal-card label.hd-audio-field input[type="checkbox"],
.portal-modal-card label.fw-upgrade-field input[type="checkbox"],
.device-detail-row label.hd-audio-field input[type="checkbox"],
.device-detail-row label.fw-upgrade-field input[type="checkbox"] {
  width: auto; justify-self: start; margin: 2px 0 0; padding: 0; border: 0; box-shadow: none;
}
.device-detail-row label.hd-audio-field,
.device-detail-row label.fw-upgrade-field {
  display: grid; gap: 4px; margin: 0 0 10px; max-width: 36rem;
}
.device-net-select {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 0 10px;
  max-width: 28rem;
  font-weight: 600;
  font-size: 13px;
  line-height: 1.35;
  color: #334155;
}
.device-net-select select { font-weight: 500; }
.portal-card .field-help,
.portal-modal-card .field-help, .device-detail-row .field-help { font-weight: 500; color: var(--muted); font-size: 12px; }
.portal-check-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(150px,1fr)); gap: 8px; }
.portal-modal-card fieldset { margin: 16px 0; border: 1px solid var(--border); border-radius: 10px; }
.portal-actions.compact { margin-top: 0; }
.portal-table audio { display: block; width: min(280px, 70vw); height: 40px; min-height: 40px; }
.audio-listen { min-width: 220px; }
.portal-card label, .portal-modal-card label { display: grid; gap: 4px; color: var(--muted); font-size: 13px; font-weight: 600; }
.portal-card input, .portal-card select, .portal-card textarea,
.portal-modal-card input, .portal-modal-card select, .portal-modal-card textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 9px; padding: 9px 10px;
  background: #fff; color: var(--text); font: inherit;
}
.portal-card textarea, .portal-modal-card textarea { min-height: 92px; resize: vertical; }
.portal-card input::placeholder, .portal-card textarea::placeholder,
.portal-modal-card input::placeholder, .portal-modal-card textarea::placeholder { color: #94a3b8; opacity: 1; }
.portal-card input:focus, .portal-card select:focus, .portal-card textarea:focus,
.portal-modal-card input:focus, .portal-modal-card select:focus, .portal-modal-card textarea:focus {
  outline: none; border-color: var(--brand-cyan); box-shadow: 0 0 0 3px rgba(0,174,239,.15);
}
.portal-table-wrap { overflow-x: auto; }
.portal-card > .portal-table { display: block; overflow-x: auto; }
.portal-table { width: 100%; min-width: max-content; border-collapse: collapse; }
.portal-table td, .portal-table th {
  white-space: nowrap;
  word-break: normal;
  overflow-wrap: normal;
  vertical-align: middle;
  padding: 12px 14px;
}
.portal-table .peer-name-input {
  width: 16rem;
  min-width: 12rem;
  max-width: 22rem;
}
.portal-table tr.device-row.is-expandable { cursor: pointer; }
.portal-table tr.device-row.is-expandable:hover,
.portal-table tr.device-row.is-open { background: #f8fafc; }
.portal-table tr.device-row:focus-visible {
  outline: 2px solid rgba(0,174,239,.45);
  outline-offset: -2px;
}
.device-row-chevron {
  display: inline-block;
  width: 6px; height: 6px;
  margin-right: 10px; vertical-align: 2px;
  border-right: 2px solid #94a3b8; border-bottom: 2px solid #94a3b8;
  transform: rotate(-45deg); transition: transform .18s ease;
}
.device-row.is-open .device-row-chevron { transform: rotate(45deg); border-color: #0369a1; }
.portal-table tr.device-detail-row > td {
  white-space: normal;
  padding: 0;
  background: #f8fafc;
  border-top: 0;
}
.device-actions-strip {
  padding: 10px 10px 14px 28px;
  overflow-x: auto;
}
.device-fw-hint {
  margin: 0 0 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f0f9ff;
  color: #0c4a6e;
  font-size: 13px;
}
.device-action-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(12.5rem, 1fr));
  gap: 8px;
  align-items: stretch;
  min-width: 64.5rem;
}
.device-action-slot { min-width: 0; min-height: 34px; }
.device-action-slot .btn {
  width: 100%;
  box-sizing: border-box;
  height: 34px; min-height: 34px;
  padding: 0 12px;
  font-size: 13px; line-height: 1;
  white-space: nowrap;
  box-shadow: none;
}
.device-action-slot .btn-primary:hover { transform: none; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: #94a3b8; }
.status-dot.on { background: #16a34a; }
.status-dot.warn { background: #d97706; }
.status-dot.off, .status-dot.err { background: #dc2626; }
.status-dot.lg { width: 12px; height: 12px; vertical-align: -1px; box-shadow: 0 0 0 2px #fff, 0 0 0 3px rgba(15, 23, 42, .12); }
.status-dot.blf-idle { background: #16a34a; }
.status-dot.blf-ringing { background: #f59e0b; animation: blf-pulse 1s ease-in-out infinite; }
.status-dot.blf-busy { background: #dc2626; }
.status-dot.blf-unregistered { background: #94a3b8; }
@keyframes blf-pulse { 50% { opacity: .4; } }
.blf-live { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 10px; }
.blf-lamp {
  display: flex; align-items: center; gap: 10px; min-width: 0;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: #f8fafc;
}
.blf-lamp .status-dot.lg { width: 14px; height: 14px; margin-right: 0; flex: 0 0 auto; }
.blf-lamp span { min-width: 0; display: grid; gap: 1px; }
.blf-lamp strong { color: var(--text); }
.blf-lamp small, .blf-lamp em { color: var(--muted); font-size: 12px; font-style: normal; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.blf-status { display: inline-flex; align-items: center; gap: 2px; white-space: nowrap; }
.trunk-live { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; white-space: nowrap; }
.trunk-name { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.trunk-name small { color: var(--muted); font-weight: 500; }
.trunk-server, .trunk-transport { min-width: 4.5rem; }
.portal-row-actions {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  margin: 0;
}
.portal-row-actions .btn {
  flex: 0 0 auto;
  height: 34px;
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
  line-height: 1;
  white-space: nowrap;
  box-shadow: none;
}
.portal-row-actions .btn-primary:hover { transform: none; }
.portal-table td.portal-row-actions-cell { white-space: nowrap; }
.portal-modal-card:has(.ext-advanced) { width: min(440px, 100%); }
.ext-advanced { display: grid; gap: 16px; }
.ext-advanced-group { margin: 0; }
.ext-advanced-group h3,
.ext-advanced-danger h3 {
  margin: 0 0 8px;
  color: var(--brand-blue);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.ext-advanced-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.ext-advanced-btns .btn {
  margin: 0;
  white-space: nowrap;
}
.ext-advanced-danger {
  margin: 0;
  padding: 14px 0 0;
  border-top: 1px solid var(--border);
}
.ext-advanced-danger h3 { color: #b91c1c; }
.ext-advanced-danger p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.status-pill { display: inline-block; padding: 3px 7px; border-radius: 6px; background: #f1f5f9; font-size: 11px; font-weight: 700; }
.portal-empty { color: var(--muted); text-align: center; padding: 30px; }
.portal-notice { padding: 12px; border-radius: 10px; background: #fef3c7; color: #854d0e; margin-bottom: 14px; font-size: 13px; }
.portal-modal { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 20px; background: rgba(15,23,42,.55); }
.portal-modal-card {
  position: relative; width: min(720px, 100%); max-height: calc(100vh - 40px); overflow: auto;
  overscroll-behavior: contain; background: #fff; border-radius: 14px; padding: 22px;
  box-shadow: 0 24px 70px rgba(15,23,42,.28);
  min-width: 0;
}
.portal-modal-card p, .portal-modal-card .muted, .portal-modal-card li {
  overflow-wrap: anywhere; word-break: break-word; min-width: 0;
}
.portal-modal-card h2 { margin: 0 42px 18px 0; color: var(--brand-blue); }
.portal-modal-close {
  position: sticky; z-index: 3; top: 0; float: right; width: 36px; height: 36px;
  margin: -8px -8px 0 8px; border: 1px solid var(--border); border-radius: 50%;
  background: #fff; color: #475569; font-size: 24px; line-height: 1; cursor: pointer;
}
.portal-modal-card form > .portal-actions:last-child {
  position: sticky; z-index: 2; bottom: -22px; margin: 18px -22px -22px;
  padding: 14px 22px; border-top: 1px solid var(--border); background: rgba(255,255,255,.97);
}
.portal-secret {
  word-break: break-all; overflow-wrap: anywhere; padding: 10px; background: #f1f5f9;
  border-radius: 8px; font-family: monospace; font-size: 12px; line-height: 1.45;
  max-width: 100%; min-width: 0;
}
.portal-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.portal-actions .btn { white-space: normal; max-width: 100%; }
.portal-error, .portal-ok {
  color: #b91c1c; font-size: 13px; min-height: 1.2em; overflow-wrap: anywhere; word-break: break-word;
}
.portal-ok { color: #166534; }
.btn-danger { background: #dc2626; color: #fff; border-color: #dc2626; }
.portal-qr { display: block; width: 280px; max-width: 100%; margin: 18px auto; border-radius: 12px; }
.portal-code-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 18px 0; }
.portal-code-list code { display: block; padding: 10px; text-align: center; background: #eef6ff; border-radius: 8px; font-size: 16px; }
.notification-rule { padding: 14px 0; border-bottom: 1px solid #e2e8f0; }
.notification-rule:last-of-type { border-bottom: 0; }
.connection-status { display: flex; flex-direction: column; gap: 5px; padding: 16px; border-radius: 10px; background: #f1f5f9; }
.connection-status.connected { background: #ecfdf5; color: #065f46; }
details > summary { cursor: pointer; color: #475569; font-weight: 700; }
details[open] > summary { margin-bottom: 10px; }
.portal-howto {
  margin: 14px 0 4px; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: 12px; background: #f8fafc;
  overflow-wrap: anywhere; word-break: break-word;
}
.portal-howto > summary { color: var(--brand-blue); font-size: 15px; }
.portal-howto ol { margin: 0; padding-left: 1.25rem; }
.portal-howto ul { margin: 8px 0 0; padding-left: 1.1rem; }
.portal-howto li { margin: 0 0 12px; color: #334155; font-size: 14px; line-height: 1.45; }
.portal-howto li ul li { margin: 4px 0; }
.portal-howto li:last-child { margin-bottom: 0; }
.portal-howto a { font-weight: 700; }
.portal-howto code { word-break: break-all; overflow-wrap: anywhere; }
.portal-howto .portal-secret { margin: 8px 0; }
.portal-howto .portal-actions { margin-top: 8px; }
.portal-howto .muted { margin: 10px 0 0; }
.audio-preview {
  margin-top: 14px; padding: 12px; border: 1px solid #bae6fd; border-radius: 10px; background: #f0f9ff;
}
.audio-preview p { margin: 0 0 8px; color: #0369a1; font-size: 13px; font-weight: 600; }
.audio-preview audio { width: 100%; }
.audio-catalog-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin: 10px 0 18px; }
.audio-catalog-card {
  display: grid; gap: 6px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: #f8fafc;
}
.audio-catalog-card small { color: var(--muted); }
.audio-catalog-card audio { width: 100%; height: 40px; min-height: 40px; }
.audio-catalog-card .btn { justify-self: start; }
.audio-moh-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin: 0 0 16px; }
.audio-moh-form label { flex: 1 1 280px; }
.audio-page { display: grid; gap: 14px; min-width: 0; }
.audio-page a { font-weight: 700; }
.tts-excerpt { display: block; max-width: 36rem; white-space: pre-wrap; font-weight: 500; color: var(--muted); }
.portal-card h3 { margin: 16px 0 8px; color: var(--brand-blue); font-size: 16px; }
.pattern-field { align-content: start; }
.pattern-label {
  position: relative;
  width: max-content;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: help;
  color: inherit;
}
.pattern-hint {
  display: inline-grid;
  place-items: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #e0f2fe;
  color: #0369a1;
  font-size: 10px;
  font-style: normal;
  font-weight: 800;
  line-height: 1;
}
.pattern-guide {
  display: none;
  position: absolute;
  z-index: 6;
  left: 0;
  top: calc(100% + 6px);
  width: min(280px, 68vw);
  padding: 10px 12px;
  border: 1px solid #1e293b;
  border-radius: 10px;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.45;
  box-shadow: 0 12px 30px rgba(15, 23, 42, .28);
  pointer-events: none;
}
.pattern-guide strong { display: block; margin-bottom: 6px; color: #fff; font-size: 12px; }
.pattern-guide ul { margin: 0; padding: 0; list-style: none; }
.pattern-guide li { margin: 0 0 4px; }
.pattern-guide li:last-child { margin-bottom: 0; }
.pattern-guide code {
  display: inline-block;
  margin-right: 4px;
  padding: 1px 5px;
  border-radius: 4px;
  background: #1e293b;
  color: #7dd3fc;
  font-size: 11px;
}
.pattern-label:hover .pattern-guide,
.pattern-label:focus .pattern-guide,
.pattern-label:focus-within .pattern-guide { display: block; }
.pattern-custom { margin-top: 2px; }
.portal-nav-tip {
  display: none;
  position: fixed;
  z-index: 180;
  left: 0;
  top: 0;
  width: min(260px, calc(100vw - 24px));
  padding: 10px 12px;
  border: 1px solid #1e293b;
  border-radius: 10px;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.45;
  box-shadow: 0 12px 30px rgba(15, 23, 42, .28);
  pointer-events: none;
}
.portal-nav-tip.is-on { display: block; }

@media (max-width: 980px) {
  .portal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .portal-shell { grid-template-columns: 1fr; }
  .portal-sidebar { position: fixed; z-index: 150; width: 280px; transform: translateX(-100%); transition: transform .2s; }
  .portal-sidebar.open { transform: translateX(0); }
  .portal-menu { display: inline-flex; border: 1px solid var(--border); background: #fff; padding: 8px; border-radius: 8px; }
}
.ai-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.ai-tabs button {
  border: 1px solid var(--border); background: #fff; border-radius: 999px;
  padding: 7px 12px; font: inherit; font-size: 13px; font-weight: 700; color: #475569; cursor: pointer;
}
.ai-tabs button.active { background: #e0f2fe; color: #0369a1; border-color: #7dd3fc; }
.ai-panel[hidden] { display: none !important; }
.lab-panel[hidden] { display: none !important; }
.lab-thread { display: grid; gap: 12px; margin: 14px 0; }
.lab-msg { padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: #f8fafc; }
.lab-msg-user { background: #e0f2fe; }
.lab-msg-ai { background: #fff; }
.lab-msg p { margin: 6px 0 0; }
.lab-meta { margin: 8px 0 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 8px 14px; color: var(--muted); font-size: 12px; }
.lab-err { color: #b91c1c; }
.lab-composer { margin-top: 16px; display: grid; gap: 10px; }
.lab-knowledge { display: grid; gap: 8px; margin: 0 0 12px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: #f8fafc; }
.lab-proposals { display: grid; gap: 14px; padding: 0; list-style: none; }
.lab-proposals li { padding: 12px; border: 1px solid var(--border); border-radius: 12px; }
.lab-proposals pre { overflow: auto; background: #f8fafc; padding: 10px; border-radius: 8px; font-size: 12px; }
.lab-run { margin: 12px 0; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: #f8fafc; }
@media (max-width: 640px) {
  .portal-content, .portal-topbar { padding: 16px; }
  .portal-grid, .portal-form-grid { grid-template-columns: 1fr; }
  .portal-user { display: none; }
  .portal-modal { align-items: end; padding: 0; }
  .portal-modal-card { width: 100%; max-height: 94vh; border-radius: 16px 16px 0 0; padding: 18px; }
  .portal-modal-card form > .portal-actions:last-child {
    bottom: -18px; margin: 18px -18px -18px; padding: 12px 18px;
  }
  .portal-modal-card form > .portal-actions:last-child .btn { flex: 1 1 150px; }
}
.portal-modal-card:has(.schedule-editor) { width: min(920px, 100%); }
.schedule-editor h3 { margin: 16px 0 8px; }
.schedule-day {
  display: grid; gap: 8px; margin: 0 0 10px; padding: 12px;
  border: 1px solid var(--border); border-radius: 10px; background: #f8fafc;
}
.schedule-day-head, .schedule-copy {
  display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center;
}
.schedule-day-head .chk, .schedule-copy .chk, .schedule-editor label.chk {
  display: inline-flex; align-items: center; gap: 6px; margin: 0; color: var(--text);
}
.schedule-day input[type="checkbox"], .schedule-copy input[type="checkbox"],
.schedule-editor label.chk input[type="checkbox"] { width: auto; margin: 0; flex: 0 0 auto; }
.schedule-times { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.schedule-copy {
  padding-top: 8px; border-top: 1px dashed var(--border); color: var(--muted); font-size: 13px;
}
.schedule-copy span { font-weight: 700; color: #475569; }
.peer-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 28px;
  letter-spacing: 0.14em;
  font-weight: 800;
  color: var(--brand-blue);
  margin: 8px 0 12px;
}
.peer-link h3 { margin: 18px 0 8px; font-size: 15px; color: var(--brand-blue); }
.peer-pick { margin: 0 0 14px; }
.peer-pick-all { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-weight: 700; }
.peer-pick-list {
  display: grid;
  gap: 6px;
  max-height: 220px;
  overflow: auto;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
}
.peer-pick-list label.chk, .peer-pick-all.chk {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}
.peer-pick-list input[type="checkbox"], .peer-pick-all input[type="checkbox"] {
  width: auto;
  margin: 0;
  flex: 0 0 auto;
}
.peer-redeem-card {
  overflow-wrap: break-word;
  word-break: normal;
}
.peer-redeem {
  display: grid;
  gap: 18px;
  min-width: 0;
}
.peer-redeem-group {
  margin: 0;
  max-width: 28rem;
}
.peer-code-field {
  display: grid;
  gap: 6px;
}
.peer-code-field input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.04em;
  font-weight: 700;
}
.peer-receive {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  min-width: 0;
  overflow-wrap: normal;
  word-break: normal;
}
.peer-link .peer-receive { margin: 4px 0 18px; }
.portal-card .peer-receive h3 {
  margin: 0;
  color: var(--brand-blue);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: none;
  line-height: 1.35;
  overflow-wrap: break-word;
  word-break: normal;
}
.peer-receive > p.muted {
  margin: 0;
  line-height: 1.5;
  overflow-wrap: break-word;
  word-break: normal;
}
.peer-receive-choices {
  display: grid;
  gap: 10px;
}
.portal-card label.peer-choice {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  margin: 0;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  overflow-wrap: break-word;
  word-break: normal;
}
.portal-card label.peer-choice:hover { border-color: #94a3b8; }
.portal-card label.peer-choice:has(input:checked) {
  border-color: var(--brand-cyan);
  background: #f0f9ff;
  box-shadow: 0 0 0 3px rgba(0,174,239,.12);
}
.portal-card label.peer-choice input[type="radio"] {
  width: auto;
  margin: 3px 0 0;
  padding: 0;
  flex: 0 0 auto;
  box-shadow: none;
}
.peer-choice-body {
  display: grid;
  gap: 6px;
  min-width: 0;
  overflow-wrap: break-word;
  word-break: normal;
}
.peer-choice-body strong {
  color: var(--brand-blue);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.3;
}
.peer-choice-body span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.55;
}
.feature-code-table td { white-space: normal; }
.feature-code-table code {
  font-size: 16px; font-weight: 800; color: var(--brand-blue); letter-spacing: .04em;
}
.directory-print-actions {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: end;
}
.directory-print-actions label { margin: 0; min-width: 8rem; }
.ext-directory {
  margin-top: 14px; padding: 22px 24px; border: 1px solid var(--border);
  border-radius: 12px; background: #fff; color: #0f172a;
}
.ext-directory-head {
  display: flex; align-items: center; gap: 16px;
  padding-bottom: 14px; margin-bottom: 14px;
  border-bottom: 2px solid #2E3192;
}
.ext-directory-head img { width: 52px; height: 52px; object-fit: contain; }
.ext-directory-brand {
  margin: 0; font-size: 11px; font-weight: 800; letter-spacing: .16em;
  text-transform: uppercase; color: #00AEEF;
}
.ext-directory-head h3 { margin: 2px 0 0; font-size: 22px; color: #2E3192; }
.ext-directory-head p { margin: 2px 0 0; color: #64748b; font-size: 13px; }
.ext-directory-table { width: 100%; border-collapse: collapse; }
.ext-directory-table th, .ext-directory-table td {
  text-align: left; padding: 9px 4px; border-bottom: 1px solid #e2e8f0;
}
.ext-directory-table th {
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #64748b;
}
.ext-directory-table td:last-child, .ext-directory-table th:last-child {
  text-align: right; font-variant-numeric: tabular-nums; font-weight: 800; color: #2E3192;
}
.ext-directory-foot {
  margin: 16px 0 0; padding-top: 10px; border-top: 1px solid #e2e8f0;
  color: #64748b; font-size: 11px;
}
.portal-toolbar-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.holiday-check-toolbar { display: flex; gap: 8px; margin: 10px 0 8px; }
.holiday-check-list {
  display: grid;
  gap: 6px;
  max-height: 360px;
  overflow: auto;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
}
.holiday-check-list label.chk {
  display: flex; align-items: flex-start; gap: 8px; margin: 0;
  color: var(--text); font-weight: 500;
}
.holiday-check-list label.chk input { width: auto; margin: 2px 0 0; flex: 0 0 auto; }
.holiday-check-list label.chk span { display: grid; gap: 2px; }
.holiday-check-list label.chk small { color: var(--muted); font-weight: 500; }
.holiday-check-list label.is-present { opacity: .78; }
.holiday-kind {
  display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .02em;
  text-transform: uppercase; padding: 2px 8px; border-radius: 999px;
  background: #e2e8f0; color: #334155;
}
.holiday-kind.nazionale { background: #dbeafe; color: #1e40af; }
.holiday-kind.ferie { background: #fef3c7; color: #92400e; }
.holiday-kind.patrono { background: #ede9fe; color: #5b21b6; }
.holiday-kind.altro { background: #e2e8f0; color: #334155; }

.call-flow { display: grid; gap: 16px; }
.flow-card {
  background: #fff; border: 1px solid var(--border); border-radius: 14px; overflow: hidden;
}
.flow-did-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  padding: 16px 18px; background: #0f2744; color: #fff;
}
.flow-did-bar strong { display: block; font-size: 20px; letter-spacing: .02em; }
.flow-did-bar small { display: block; margin-top: 2px; color: #93c5fd; font-weight: 500; }
.flow-kicker {
  display: block; font-size: 11px; font-weight: 800; letter-spacing: .06em;
  text-transform: uppercase; color: #64748b;
}
.flow-did-bar .flow-kicker { color: #93c5fd; }
.flow-now-pill {
  margin-left: auto; background: #fef3c7; color: #92400e;
  font-size: 12px; font-weight: 700; padding: 6px 10px; border-radius: 999px;
}
.flow-did-bar .btn-ghost { color: #fff; border-color: rgba(255,255,255,.35); }
.flow-tree { padding: 20px 18px 22px; display: grid; justify-items: center; gap: 14px; }
.flow-node {
  min-width: 220px; max-width: 340px; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: 12px; background: #f8fafc; text-align: left;
}
.flow-node strong { display: block; color: var(--text); font-size: 14px; }
.flow-node small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.flow-node.is-active { border-color: #eab308; box-shadow: 0 0 0 3px rgba(234,179,8,.25); background: #fffbeb; }
.flow-node.is-idle { opacity: .7; }
.flow-node.dest.queue, .flow-node.dest.extension { border-left: 4px solid #0369a1; }
.flow-node.dest.ivr { border-left: 4px solid #7c3aed; }
.flow-node.dest.ai_receptionist { border-left: 4px solid #0f766e; }
.flow-node.dest.voicemail { border-left: 4px solid #b45309; }
.flow-node.dest.hangup { border-left: 4px solid #94a3b8; }
.flow-split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; width: min(720px, 100%); }
.flow-arm { display: grid; gap: 8px; justify-items: center; }
.flow-arm-label { font-size: 12px; font-weight: 800; color: #0369a1; }
.flow-banner { margin: 0; padding: 10px 18px; background: #fff7ed; color: #9a3412; font-size: 13px; }
.flow-warn-inline { color: #9a3412; font-size: 12px; font-weight: 600; }
.flow-now.open, .flow-now.always { color: #166534; font-weight: 700; font-size: 12px; }
.flow-now.closed { color: #9a3412; font-weight: 700; font-size: 12px; }
.inbound-condition { margin: 14px 0; }
@media (max-width: 720px) {
  .flow-split { grid-template-columns: 1fr; }
  .flow-now-pill { margin-left: 0; }
}
.patron-suggest {
  margin: 6px 0 10px; border: 1px solid var(--border); border-radius: 10px;
  background: #fff; overflow: hidden;
}
.patron-suggest button {
  display: grid; width: 100%; text-align: left; gap: 2px; padding: 10px 12px;
  border: 0; border-bottom: 1px solid var(--border); background: #fff; cursor: pointer;
}
.patron-suggest button:last-child { border-bottom: 0; }
.patron-suggest button:hover { background: #f8fafc; }
.patron-suggest strong { color: var(--text); }
.patron-suggest span, .patron-suggest .muted { color: var(--muted); font-size: 13px; }
.patron-picked {
  margin: 0 0 12px; padding: 10px 12px; border-radius: 10px;
  background: #eff6ff; color: #1e3a8a;
}
.patron-picked small { display: block; margin-top: 2px; color: #1d4ed8; }
.portal-modal-card:has(#italian-holiday-form) { width: min(640px, 100%); }
.portal-modal-card label.chk {
  display: flex; align-items: center; gap: 8px; margin: 8px 0 0;
  color: var(--text); font-weight: 500;
}
.portal-modal-card label.chk input[type="checkbox"] { width: auto; margin: 0; flex: 0 0 auto; }

@media print {
  body.printing-directory * { visibility: hidden !important; }
  body.printing-directory .ext-directory,
  body.printing-directory .ext-directory * { visibility: visible !important; }
  body.printing-directory .ext-directory {
    position: absolute; left: 0; top: 0; width: 100%;
    margin: 0; padding: 0; border: 0; border-radius: 0;
    box-shadow: none; background: #fff;
  }
  body.printing-directory .portal-toolbar,
  body.printing-directory .directory-print-actions { display: none !important; }
  body.dir-print-a6 .ext-directory-head img { width: 36px; height: 36px; }
  body.dir-print-a6 .ext-directory-head h3 { font-size: 16px; }
  body.dir-print-a6 .ext-directory-table th, body.dir-print-a6 .ext-directory-table td {
    padding: 6px 2px; font-size: 12px;
  }
}

