/* =====================================================================
 * Ziffone Web — stylesheet entry point
 * ===================================================================== */

@import "./base.css";
@import "./dialer.css";
@import "./views.css";
@import "./landing.css";

/* =====================================================================
 * App layer — the signed-in app, re-skinned to match the landing page.
 *
 * Rules here load after every imported sheet, so they are the final word
 * for the shared building blocks (shell, buttons, forms, cards, badges,
 * banners, tables, modals, settings tabs). Everything uses the --md-*
 * tokens from base.css, so light and dark both follow automatically.
 * Nothing here targets landing page specific classes.
 * ===================================================================== */

/* ---------- Base type ---------- */

html,
body {
  font-family: var(--md-font);
  background: var(--app-bg);
  color: var(--md-on-surface);
}

/* The signed-in app reads at 15px; rem sizes (and the landing page) are unchanged. */
.layout {
  font-size: 15px;
  line-height: 1.55;
}

:where(.layout) h1 {
  font-size: 1.625rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

:where(.layout) h2 {
  font-size: 1.25rem;
  font-weight: 650;
  letter-spacing: -0.015em;
}

:where(.layout) h3 {
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

:where(.layout) :focus-visible {
  outline: 2px solid var(--md-primary);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

::selection {
  background: var(--md-primary-container);
  color: var(--md-on-surface);
}

/* ---------- Buttons ---------- */

:where(.layout) button {
  font-weight: 600;
  letter-spacing: 0;
}

:where(.layout) button:active {
  transform: none;
}

.btn-primary,
button.btn-primary {
  background: var(--md-primary);
  color: var(--md-on-primary);
  border: 1px solid transparent;
  border-radius: var(--md-radius-button);
  font-weight: 600;
  box-shadow: none;
}

.btn-primary:hover:not(:disabled),
button.btn-primary:hover:not(:disabled) {
  background: var(--md-primary-hover);
}

.btn-secondary,
button.btn-secondary {
  background: var(--md-surface);
  color: var(--md-on-surface);
  border: 1px solid var(--md-outline-strong);
  border-radius: var(--md-radius-button);
  font-weight: 600;
  box-shadow: none;
}

.btn-secondary:hover:not(:disabled),
button.btn-secondary:hover:not(:disabled) {
  background: var(--md-surface-container-high);
  border-color: var(--md-on-surface-muted);
}

.btn-danger,
button.btn-danger {
  background: var(--md-error);
  color: var(--md-on-error);
  border: 1px solid transparent;
  border-radius: var(--md-radius-button);
  font-weight: 600;
}

.btn-danger:hover:not(:disabled),
button.btn-danger:hover:not(:disabled) {
  background: color-mix(in srgb, var(--md-error) 88%, black);
}

.btn-text-danger,
button.btn-text-danger {
  color: var(--md-error);
}

.btn-sm,
button.btn-sm {
  min-height: 34px;
  padding: 6px 14px;
  font-size: 0.8125rem;
  gap: 6px;
}

@media (max-width: 640px), (pointer: coarse) {
  .btn-sm,
  button.btn-sm {
    min-height: 40px;
  }
}

.btn-primary:disabled,
.btn-secondary:disabled,
.btn-danger:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-secondary:disabled {
  background: var(--md-surface);
  color: var(--md-on-surface-variant);
}

.btn-close,
button.btn-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--md-on-surface-variant);
  border: none;
  flex-shrink: 0;
}

.btn-close:hover {
  background: var(--md-surface-container-high);
  color: var(--md-on-surface);
}

/* ---------- Forms ---------- */

:where(.layout) input,
:where(.layout) select,
:where(.layout) textarea,
.form-input {
  border: 1px solid var(--md-outline-strong);
  border-radius: var(--md-radius-sm);
  background: var(--md-surface);
  color: var(--md-on-surface);
  font-size: 0.9375rem;
  padding: 10px 14px;
}

:where(.layout) input:where([type="checkbox"]),
:where(.layout) input:where([type="radio"]),
:where(.layout) input:where([type="range"]) {
  width: auto;
  min-height: 0;
  padding: 0;
  border: none;
  background: none;
  accent-color: var(--md-primary);
}

:where(.layout) input:where([type="range"]) {
  width: 100%;
}

:where(.layout) input:where([type="checkbox"]),
:where(.layout) input:where([type="radio"]) {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

:where(.layout) input::placeholder,
:where(.layout) textarea::placeholder {
  color: var(--md-on-surface-muted);
}

:where(.layout) input:focus,
:where(.layout) select:focus,
:where(.layout) textarea:focus,
.form-input:focus {
  outline: none;
  border-color: var(--md-primary);
  box-shadow: var(--md-focus-ring);
}

:where(.layout) input:where([type="checkbox"]):focus,
:where(.layout) input:where([type="range"]):focus {
  box-shadow: none;
}

:where(.layout) input:where([type="checkbox"]):focus-visible,
:where(.layout) input:where([type="range"]):focus-visible {
  outline: 2px solid var(--md-primary);
  outline-offset: 2px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--md-space-md);
}

.form-group label,
.form-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--md-on-surface);
  text-transform: none;
  letter-spacing: 0;
}

.form-hint {
  font-size: 0.8125rem;
  color: var(--md-on-surface-muted);
  line-height: 1.5;
}

.checkbox-field,
.form-group label.checkbox-field {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  cursor: pointer;
}

/* ---------- Cards ---------- */

.card,
.settings-card {
  background: var(--md-surface);
  border: 1px solid var(--md-outline);
  border-radius: var(--md-radius-lg);
  box-shadow: var(--md-elevation-1);
  padding: var(--md-space-lg);
}

.card:hover,
.settings-card:hover {
  box-shadow: var(--md-elevation-1);
  transform: none;
  border-color: var(--md-outline);
}

.card-title,
.settings-card-title {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--md-on-surface);
}

.card-subtitle,
.settings-card-subtitle {
  font-size: 0.875rem;
  color: var(--md-on-surface-muted);
  margin-top: 2px;
}

.card-header-icon {
  background: var(--md-surface-container-high);
  color: var(--md-on-surface-variant);
  border: none;
  box-shadow: none;
}

.empty-state {
  padding: var(--md-space-2xl) var(--md-space-lg);
  text-align: center;
  color: var(--md-on-surface-variant);
  border: 1px dashed var(--md-outline-strong);
  border-radius: var(--md-radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--md-space-md);
}

.loading-text {
  color: var(--md-on-surface-muted);
  padding: var(--md-space-lg) 0;
}

/* ---------- Badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: var(--md-radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.5;
  text-transform: none;
  letter-spacing: 0;
  background: var(--md-surface-container-high);
  color: var(--md-on-surface-variant);
  border: none;
  white-space: nowrap;
}

.badge-accent {
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
}

.badge-success,
.badge-ok {
  background: var(--md-success-container);
  color: var(--md-on-success-container);
}

.badge-error,
.badge-not-connected {
  background: var(--md-error-container);
  color: var(--md-on-error-container);
}

.badge-muted,
.badge-disabled {
  background: var(--md-surface-container-high);
  color: var(--md-on-surface-muted);
}

/* ---------- Banners ---------- */

.banner,
.settings-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--md-space-sm) var(--md-space-md);
  padding: 12px 16px;
  margin-bottom: var(--md-space-md);
  border-radius: var(--md-radius-md);
  border: 1px solid var(--md-outline);
  background: var(--md-surface-container);
  color: var(--md-on-surface);
  font-size: 0.875rem;
  line-height: 1.5;
}

.settings-banner {
  justify-content: flex-start;
}

.banner-info {
  background: var(--md-primary-container);
  border-color: transparent;
  color: var(--md-on-surface);
}

.banner-error {
  background: var(--md-error-container);
  border-color: color-mix(in srgb, var(--md-error) 25%, transparent);
  color: var(--md-on-error-container);
}

.banner-success {
  background: var(--md-success-container);
  border-color: color-mix(in srgb, var(--md-success) 25%, transparent);
  color: var(--md-on-success-container);
}

.banner-warning {
  background: var(--md-warning-container);
  border-color: color-mix(in srgb, var(--md-warning) 25%, transparent);
  color: var(--md-on-warning-container);
}

/* ---------- Tables ---------- */

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

.data-table th {
  padding: 10px 16px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--md-on-surface-muted);
  text-transform: none;
  letter-spacing: 0;
  border-bottom: 1px solid var(--md-outline);
  background: var(--md-surface-container);
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--md-outline-variant);
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: none;
}

/* ---------- Modals ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--md-scrim);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--md-space-md);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.modal-content {
  background: var(--md-surface);
  color: var(--md-on-surface);
  border: 1px solid var(--md-outline);
  border-radius: var(--md-radius-xl);
  box-shadow: var(--md-elevation-4);
  padding: var(--md-space-lg);
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--md-space-md);
  margin-bottom: var(--md-space-lg);
}

.modal-header h3,
.modal-content h3 {
  margin: 0;
  font-size: 1.1875rem;
  font-weight: 650;
}

.modal-actions,
.modal-footer {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--md-space-sm);
  margin-top: var(--md-space-lg);
}

@media (max-width: 480px) {
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .modal-content {
    border-radius: var(--md-radius-xl) var(--md-radius-xl) 0 0;
    max-height: 92vh;
    padding: var(--md-space-lg) var(--md-space-md) calc(var(--md-space-lg) + env(safe-area-inset-bottom, 0px));
  }
  .modal-actions > button,
  .modal-footer > button {
    flex: 1;
  }
}

/* =====================================================================
 * App shell: left sidebar (desktop) / bottom tab bar (phones) + top bar
 * ===================================================================== */

.layout {
  background: var(--app-bg);
}

.main-content {
  background: var(--app-bg);
}

/* ---- Brand ---- */

.nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--md-on-surface);
  text-decoration: none;
  border-radius: var(--md-radius-sm);
}

.nav-brand-logo-glow {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--md-primary);
  color: var(--md-on-primary);
  border: none;
  box-shadow: none;
}

.nav-brand-text {
  font-family: var(--md-font);
  font-size: 1.1875rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}

/* ---- Sidebar (desktop) ---- */

.nav {
  background: var(--app-nav-bg);
  border-color: var(--md-outline);
}

.nav-quick-dial-btn {
  height: 42px;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  background: var(--md-primary);
  color: var(--md-on-primary);
  border: none;
  box-shadow: none;
  font-size: 0.875rem;
  font-weight: 600;
}

.nav-quick-dial-btn:hover {
  background: var(--md-primary-hover);
  box-shadow: none;
  transform: none;
}

.nav-quick-dial-icon {
  color: inherit;
}

.nav-quick-dial-text {
  flex: 0 0 auto;
  margin: 0;
}

.nav-category-list {
  gap: 2px;
}

.nav-link-btn {
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--md-radius-sm);
  color: var(--md-on-surface-variant);
  font-size: 0.9375rem;
  font-weight: 500;
}

.nav-link-btn:hover {
  background: color-mix(in srgb, var(--md-on-surface) 5%, transparent);
  color: var(--md-on-surface);
}

.nav-link-btn.active,
:root[data-theme="dark"] .nav-link-btn.active {
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
  font-weight: 600;
  box-shadow: none;
}

.nav-icon {
  position: relative;
}

.nav-icon-dot {
  display: none;
  position: absolute;
  top: -2px;
  right: -4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--md-primary);
  box-shadow: 0 0 0 2px var(--app-nav-bg);
}

.nav-unread-dot {
  background: var(--md-primary);
}

.nav-unread-pill-count {
  background: var(--md-primary);
  color: var(--md-on-primary);
}

.nav-workspace-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  margin-top: auto;
  background: transparent;
  border: none;
  border-radius: var(--md-radius-md);
  box-shadow: none;
  text-decoration: none;
  color: inherit;
}

.nav-workspace-card:hover {
  background: color-mix(in srgb, var(--md-on-surface) 5%, transparent);
}

.nav-workspace-avatar,
:root[data-theme="dark"] .nav-workspace-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
  font-family: var(--md-font);
  font-size: 0.875rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-workspace-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--md-on-surface);
}

.nav-workspace-status {
  font-size: 0.75rem;
  color: var(--md-on-surface-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (min-width: 768px) {
  .nav {
    padding: 20px 14px 14px;
    gap: 6px;
  }
  .nav-header {
    padding: 0 6px;
    margin-bottom: 10px;
  }
  .nav-quick-action-wrap {
    margin: 0 0 14px;
  }
  .nav-scroll-area {
    gap: 4px;
  }
  .topbar-mobile-brand {
    display: none;
  }
}

/* ---- Bottom tab bar (phones and small tablets) ---- */

@media (max-width: 767.98px) {
  .nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    z-index: 800;
    padding: 0 4px env(safe-area-inset-bottom, 0px);
    border-top: 1px solid var(--md-outline);
    border-bottom: none;
    background: var(--md-surface);
  }

  .nav-header,
  .nav-quick-action-wrap,
  .nav-spacer,
  .nav-workspace-card,
  .nav-unread-dot,
  .nav-unread-pill-count {
    display: none;
  }

  .nav-scroll-area,
  .nav-scroll-area.open {
    display: block;
    position: static;
    padding: 0;
    background: none;
    border: none;
    box-shadow: none;
  }

  .nav-category-list {
    flex-direction: row;
    justify-content: space-around;
    gap: 0;
  }

  .nav-item-li {
    flex: 1;
    min-width: 0;
  }

  .nav-link-btn {
    flex-direction: column;
    gap: 3px;
    padding: 8px 2px 7px;
    min-height: 58px;
    justify-content: center;
    border-radius: 0;
    font-size: 0.6875rem;
    font-weight: 500;
    text-align: center;
  }

  .nav-link-btn:hover {
    background: transparent;
  }

  .nav-link-btn.active,
  :root[data-theme="dark"] .nav-link-btn.active {
    background: transparent;
    color: var(--md-primary);
  }

  .nav-label {
    flex: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }

  .nav-icon-dot {
    display: block;
    box-shadow: 0 0 0 2px var(--md-surface);
  }

  /* Leave room for the tab bar under the page and lift the Phone button. */
  .main-content {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  }

  .dialer-floating-fab {
    bottom: calc(76px + env(safe-area-inset-bottom, 0px));
    right: 16px;
  }

  .topbar-mobile-brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--md-on-surface);
  }

  .topbar-mobile-brand .nav-brand-logo-glow {
    width: 26px;
    height: 26px;
    border-radius: 8px;
  }

  .topbar-mobile-brand .nav-brand-text {
    font-size: 1.0625rem;
  }
}

/* ---- Top bar ---- */

.topbar {
  height: 60px;
  padding: 0 var(--md-space-lg);
  background: var(--app-bg);
  border-bottom: 1px solid var(--md-outline-variant);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

@media (max-width: 767.98px) {
  .topbar {
    height: 56px;
    padding: 0 var(--md-space-md);
  }
}

.topbar-search-form {
  background: var(--md-surface-container-high);
  border: 1px solid transparent;
  padding: 8px 14px;
}

.topbar-search-form:focus-within {
  background: var(--md-surface);
  border-color: var(--md-primary);
  box-shadow: var(--md-focus-ring);
}

.topbar-search-input,
.topbar-search-input:focus {
  font-size: 0.875rem;
  border: none;
  box-shadow: none;
  background: transparent;
}

.topbar-search-kbd {
  background: var(--md-surface);
  border-color: var(--md-outline);
  color: var(--md-on-surface-muted);
}

.topbar-icon-btn {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--md-on-surface-variant);
}

.topbar-icon-btn:hover {
  background: var(--md-surface-container-high);
  color: var(--md-on-surface);
}

.topbar-user-badge {
  padding: 0;
  min-height: 36px;
  min-width: 36px;
  background: transparent;
  border: none;
  border-radius: 50%;
}

.topbar-user-badge:hover {
  background: transparent;
}

.topbar-avatar {
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
  font-weight: 700;
  border: none;
}

.topbar-account-menu {
  background: var(--md-surface);
  border: 1px solid var(--md-outline);
  border-radius: var(--md-radius-lg);
  box-shadow: var(--md-elevation-3);
  padding: 6px;
  min-width: 240px;
}

.topbar-account-item {
  background: transparent;
  color: var(--md-on-surface);
  border-radius: var(--md-radius-sm);
  font-weight: 500;
  justify-content: flex-start;
}

.topbar-account-item:hover:not(:disabled) {
  background: var(--md-surface-container-high);
}

.topbar-account-item.danger {
  color: var(--md-error);
}

.topbar-account-role {
  background: var(--md-surface-container-high);
  color: var(--md-on-surface-variant);
  text-transform: none;
  letter-spacing: 0;
}

/* =====================================================================
 * Settings
 * ===================================================================== */

.settings-container {
  max-width: 1040px;
  margin: 0 auto;
  padding: var(--md-space-xl) var(--md-space-lg) var(--md-space-2xl);
}

.settings-page-title {
  margin-bottom: var(--md-space-lg);
}

.settings-tabs {
  gap: 4px;
  border-bottom: 1px solid var(--md-outline);
  padding-bottom: 0;
  margin-bottom: var(--md-space-lg);
  background: none;
  border-radius: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.settings-tabs::-webkit-scrollbar {
  display: none;
}

.settings-tab,
button.settings-tab {
  background: transparent;
  color: var(--md-on-surface-variant);
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 10px 12px;
  margin-bottom: -1px;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: none;
}

.settings-tab:hover {
  background: transparent;
  color: var(--md-on-surface);
}

.settings-tab-active,
.settings-tab-active:hover,
button.settings-tab-active {
  background: transparent;
  color: var(--md-on-surface);
  border-bottom-color: var(--md-primary);
  font-weight: 600;
  box-shadow: none;
}

.settings-tab-icon {
  display: none;
}

.settings-tab-menu-trigger {
  background: var(--md-surface);
  color: var(--md-on-surface);
  border: 1px solid var(--md-outline-strong);
  border-radius: var(--md-radius-md);
}

.settings-tab-menu-trigger .settings-tab-icon,
.settings-tab-menu-item .settings-tab-icon {
  display: inline-flex;
  color: var(--md-on-surface-variant);
}

.settings-tab-menu-list {
  background: var(--md-surface);
  border: 1px solid var(--md-outline);
  border-radius: var(--md-radius-lg);
  box-shadow: var(--md-elevation-3);
}

.settings-tab-menu-item {
  background: transparent;
  color: var(--md-on-surface);
  font-weight: 500;
}

.settings-tab-menu-item-active,
.settings-tab-menu-item-active:hover {
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
}

.settings-tab-content {
  background: none;
  border: none;
  box-shadow: none;
  padding: 0;
}

.settings-section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--md-space-md);
  margin-bottom: var(--md-space-lg);
}

.settings-section-title {
  margin: 0 0 4px;
  font-size: 1.1875rem;
  font-weight: 650;
}

.settings-password-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--md-space-md);
  margin-top: var(--md-space-md);
}

.settings-password-row .form-hint {
  flex: 1 1 240px;
}

/* Profile header — quiet, no status decorations */
.profile-hero-card {
  background: var(--md-surface);
  border: 1px solid var(--md-outline);
  border-radius: var(--md-radius-lg);
  box-shadow: var(--md-elevation-1);
}

.profile-avatar {
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
  font-family: var(--md-font);
  font-weight: 700;
  box-shadow: none;
  border: none;
}

.profile-badge-role,
.readonly-role-pill {
  background: var(--md-surface-container-high);
  color: var(--md-on-surface-variant);
  border: none;
  text-transform: none;
  letter-spacing: 0;
}

.session-icon-box {
  background: var(--md-surface-container-high);
  color: var(--md-on-surface-variant);
  border: none;
}

.btn-signout,
button.btn-signout {
  background: var(--md-surface);
  color: var(--md-error);
  border: 1px solid var(--md-outline-strong);
}

.btn-signout:hover {
  background: var(--md-error-container);
}

/* Devices */
.devices-container {
  padding: 0;
  max-width: none;
}

.device-card {
  background: var(--md-surface);
  border: 1px solid var(--md-outline);
  border-radius: var(--md-radius-lg);
  box-shadow: none;
}

.device-current-badge {
  margin-left: 8px;
}

.btn-remove-device,
.btn-confirm-remove,
.btn-cancel-remove {
  border-radius: var(--md-radius-button);
  font-weight: 600;
}

/* Team */
.team-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

.team-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-top: 1px solid var(--md-outline-variant);
}

.team-row:first-child {
  border-top: none;
}

.team-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
  font-weight: 700;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.team-row-main {
  flex: 1;
  min-width: 0;
}

.team-row-name {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-weight: 600;
}

.team-row-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 12px;
  font-size: 0.8125rem;
  color: var(--md-on-surface-muted);
  overflow-wrap: anywhere;
}

.team-row-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.card.team-list {
  padding: 0;
}

@media (max-width: 560px) {
  .team-row {
    flex-wrap: wrap;
    padding: 14px 16px;
  }
  .team-row-actions {
    width: 100%;
    padding-left: 48px;
  }
}

.team-role-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.team-role-choice,
button.team-role-choice {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-height: 0;
  padding: 12px 14px;
  text-align: left;
  white-space: normal;
  background: var(--md-surface);
  color: var(--md-on-surface);
  border: 1px solid var(--md-outline-strong);
  border-radius: var(--md-radius-md);
  font-weight: 500;
}

.team-role-choice:hover {
  background: var(--md-surface-container);
}

.team-role-choice.selected,
.team-role-choice.selected:hover {
  border-color: var(--md-primary);
  background: var(--md-primary-container);
  box-shadow: inset 0 0 0 1px var(--md-primary);
}

.team-role-choice-title {
  font-weight: 600;
  font-size: 0.9375rem;
}

.team-role-choice-hint {
  font-size: 0.8125rem;
  color: var(--md-on-surface-muted);
  line-height: 1.4;
}

/* Audio */
.audio-section-icon {
  background: var(--md-surface-container-high);
  color: var(--md-on-surface-variant);
  border: none;
}

.audio-section-title {
  text-transform: none;
  letter-spacing: 0;
}

@media (max-width: 640px) {
  .settings-container {
    padding: var(--md-space-lg) var(--md-space-md) var(--md-space-xl);
  }
}

/* =====================================================================
 * Calls section: tabs + Voicemail and Recordings lists
 * ===================================================================== */

.calls-section-header {
  margin-bottom: var(--md-space-lg);
}

.calls-section-header .call-history-header {
  margin-bottom: var(--md-space-md);
}

.calls-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--md-outline);
  overflow-x: auto;
  scrollbar-width: none;
}

.calls-tabs::-webkit-scrollbar {
  display: none;
}

.calls-tab {
  padding: 10px 12px;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--md-on-surface-variant);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
  white-space: nowrap;
}

.calls-tab:hover {
  color: var(--md-on-surface);
}

.calls-tab.active {
  color: var(--md-on-surface);
  font-weight: 600;
  border-bottom-color: var(--md-primary);
}

.calls-tab:focus-visible {
  border-radius: var(--md-radius-xs);
}

.calls-library-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--md-space-md);
  margin-bottom: var(--md-space-md);
}

.calls-library-summary {
  color: var(--md-on-surface-muted);
  font-size: 0.875rem;
}

.calls-library-notice {
  margin-bottom: var(--md-space-md);
}

.calls-vm-settings {
  margin-bottom: var(--md-space-lg);
}

.calls-vm-settings-grid {
  display: flex;
  flex-direction: column;
  gap: var(--md-space-sm);
}

.calls-vm-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--md-space-md);
  padding: 4px 0 var(--md-space-md);
  cursor: pointer;
}

.calls-vm-toggle > span {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.calls-vm-setting-title {
  font-weight: 600;
  font-size: 0.9375rem;
}

.calls-vm-settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--md-space-sm);
}

.calls-library-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--md-surface);
  border: 1px solid var(--md-outline);
  border-radius: var(--md-radius-lg);
  overflow: hidden;
}

.calls-library-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 18px;
  border-top: 1px solid var(--md-outline-variant);
}

.calls-library-item:first-child {
  border-top: none;
}

.calls-library-item.active {
  background: var(--md-surface-container);
}

.calls-library-play,
button.calls-library-play {
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  border-radius: 50%;
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
  border: none;
  flex-shrink: 0;
}

.calls-library-play:hover {
  background: color-mix(in srgb, var(--md-primary) 22%, transparent);
}

.calls-library-play.playing,
.calls-library-play.playing:hover {
  background: var(--md-primary);
  color: var(--md-on-primary);
}

.calls-library-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.calls-library-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.calls-library-expand,
button.calls-library-expand {
  width: 100%;
  min-height: 0;
  padding: 0;
  background: none;
  color: inherit;
  border: none;
  border-radius: var(--md-radius-xs);
  font-weight: inherit;
  text-align: left;
  white-space: normal;
}

.calls-library-expand:hover {
  background: none;
}

.calls-library-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--md-on-surface);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calls-library-item.unread .calls-library-title {
  font-weight: 700;
}

.calls-library-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--md-primary);
  flex-shrink: 0;
}

.calls-library-time {
  font-size: 0.8125rem;
  color: var(--md-on-surface-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.calls-library-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 14px;
  font-size: 0.8125rem;
  color: var(--md-on-surface-muted);
  font-variant-numeric: tabular-nums;
}

.calls-library-direction {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.calls-library-seek {
  margin-top: 6px;
  max-width: 420px;
}

.calls-library-transcript {
  margin-top: 6px;
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--md-on-surface-variant);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.calls-library-transcript.expanded {
  display: block;
  -webkit-line-clamp: unset;
  line-clamp: unset;
  background: var(--md-surface);
  border: 1px solid var(--md-outline);
  border-radius: var(--md-radius-md);
  padding: 10px 12px;
}

.calls-library-actions {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.calls-library-icon-actions,
.calls-library-confirm {
  display: flex;
  align-items: center;
  gap: 4px;
}

.calls-library-confirm > span {
  font-size: 0.8125rem;
  color: var(--md-on-surface-variant);
  margin-right: 4px;
}

.call-action-btn-danger:hover {
  color: var(--md-error);
  background: var(--md-error-container);
}

.calls-library-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  padding: var(--md-space-2xl) var(--md-space-lg);
  border: 1px dashed var(--md-outline-strong);
  border-radius: var(--md-radius-lg);
}

.calls-library-empty-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
}

.calls-library-empty-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--md-on-surface);
}

.calls-library-empty-text {
  color: var(--md-on-surface-muted);
  font-size: 0.875rem;
}

.calls-library-more {
  display: flex;
  justify-content: center;
  padding: var(--md-space-lg) 0;
}

.call-recording-btn.playing {
  background: var(--md-primary);
  color: var(--md-on-primary);
}

.call-entry-actions-mobile {
  display: flex;
  align-items: center;
}

@media (max-width: 560px) {
  .calls-library-item {
    flex-wrap: wrap;
    padding: 14px 16px;
    gap: 12px;
  }
  .calls-library-main {
    flex-basis: calc(100% - 52px);
  }
  .calls-library-actions {
    width: 100%;
    padding-left: 52px;
    margin-top: -4px;
  }
  .calls-library-title-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
  }
}

/* =====================================================================
 * Motion
 * ===================================================================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* =====================================================================
 * One way to start a call per screen size:
 *   desktop → "New call" in the sidebar (the floating Phone button is hidden)
 *   phones  → the floating Phone button (page-level "Make a call" is hidden)
 * ===================================================================== */

@media (min-width: 768px) {
  .dialer-floating-fab {
    display: none;
  }
}

@media (max-width: 767.98px) {
  .call-history-dial {
    display: none;
  }
}

/* ---- Inbox list header: stack title, search and filters ---- */

.conversations-container > .conversations-header {
  flex-direction: column;
  align-items: stretch;
  gap: var(--md-space-sm);
  margin-bottom: var(--md-space-md);
}

.conversations-filter {
  padding: 0;
  background: none;
  border: none;
  border-radius: 0;
}

/* Recording play button stays visible on phones (other row actions use the tap sheet). */
.call-history-entry .call-entry-actions.call-entry-actions-mobile {
  display: flex;
}

.calls-vm-settings-grid .form-group {
  margin-bottom: var(--md-space-sm);
}
