/* ==========================================================================
   PC1 Connect — "Signal Grid"
   A black rail, a white grid, and two signal colors (red = alert,
   amber = attention). Everything else stays monochrome so the signals read
   instantly across a dense operations table.
   ========================================================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* ---- Ink / paper ---- */
  --ink: #0A0A0C;
  --ink-raised: #18191C;
  --ink-line: #2C2E32;
  --paper: #FFFFFF;
  --bg: #EEEAE0;
  --surface-2: #E4DED0;

  /* ---- Structure ---- */
  --line: #DDD5C3;
  --line-strong: #C7BCA4;

  /* ---- Text ---- */
  --text: #1A1B1D;
  --text-muted: #6B6E70;
  --text-faint: #9FA19A;
  --text-on-ink: #F4F3EF;
  --text-on-ink-muted: #93979E;

  /* ---- Signals ---- */
  --red: #E31E24;
  --red-soft: #FBEAEA;
  --amber-dot: #C97A1A;
  --amber-text: #875200;
  --amber-soft: #FBF1DE;
  --green: #1E8E5A;
  --green-soft: #E6F4ED;
  --green-text: #146C3E;

  /* ---- Avatar palette (muted, deterministic per name) ---- */
  --av-1: #2F5D62;
  --av-2: #5B4B8A;
  --av-3: #8A5A2B;
  --av-4: #3B5BA5;
  --av-5: #4B6B3A;
  --av-6: #7A3B4A;

  /* ---- Type ---- */
  --font-display: 'Archivo', -apple-system, 'Segoe UI', sans-serif;
  --font-body: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(20, 20, 15, 0.06), 0 2px 6px rgba(20, 20, 15, 0.08);
  --shadow-md: 0 4px 16px rgba(20, 20, 15, 0.08);
  --shadow-lg: 0 16px 44px rgba(20, 20, 15, 0.16);

  --sidebar-w: 236px;
  --topbar-h: 56px;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.45;
}

a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 2px;
}

a:hover {
  text-decoration-color: currentColor;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text);
}

h2.page-title,
.container > h2 {
  font-size: 22px;
  margin-bottom: 18px;
}

h3.section-title,
.container > h3 {
  font-size: 15px;
  margin-top: 28px;
  margin-bottom: 12px;
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
  }
}

/* ==========================================================================
   App shell — sidebar (desktop) / topbar + drawer (mobile)
   ========================================================================== */

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--paper);
  display: flex;
  flex-direction: column;
  z-index: 50;
  border-right: 1px solid var(--line);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}

.sidebar-brand img {
  height: 30px;
  width: auto;
  display: block;
  border-radius: var(--radius-sm);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--text-muted) !important;
  text-decoration: none !important;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13.5px;
  transition: background 0.12s, color 0.12s;
}

.sidebar-link svg {
  flex-shrink: 0;
  opacity: 0.85;
}

.sidebar-link-label {
  flex: 1;
}

.sidebar-link:hover {
  background: var(--bg);
  color: var(--text) !important;
}

.sidebar-link.active {
  background: var(--surface-2);
  color: var(--text) !important;
  font-weight: 700;
}

.sidebar-link.active svg {
  opacity: 1;
}

.sidebar-link-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--red);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  font-family: var(--font-body);
  text-transform: none;
  letter-spacing: 0;
  margin-left: auto;
}

.sidebar-link.active .sidebar-link-badge {
  background: var(--red);
  color: #fff;
}

.sidebar-foot {
  border-top: 1px solid var(--line);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-bell {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-md);
  color: var(--text-muted) !important;
  text-decoration: none !important;
  font-size: 13px;
  font-weight: 500;
  position: relative;
  transition: background 0.12s, color 0.12s;
}

.sidebar-bell:hover {
  background: var(--bg);
  color: var(--text) !important;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  color: var(--text-muted) !important;
  text-decoration: none !important;
  border-radius: var(--radius-md);
  transition: background 0.12s, color 0.12s;
}

.sidebar-user > span {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.sidebar-user:hover {
  background: var(--bg);
  color: var(--text) !important;
}

.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.sidebar-user-8x8 {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.sidebar-logout {
  margin-top: 4px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-body);
  text-align: left;
  transition: all 0.12s;
}

.sidebar-logout:hover {
  border-color: var(--text-muted);
  color: var(--text);
  background: var(--bg);
}

.notification-badge {
  position: absolute;
  top: 4px;
  left: 22px;
  background: var(--red);
  color: #fff;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.app-main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
}

/* Unauthenticated pages (login, 2FA) render with no sidebar — don't reserve
   its width or the content shifts right, stranding a gap on the left. */
.app-main--full {
  margin-left: 0;
}

.topbar {
  display: none;
}

.nav-drawer {
  display: none;
}

@media (max-width: 1024px) {
  .sidebar {
    display: none;
  }

  .app-main {
    margin-left: 0;
    padding-top: var(--topbar-h);
  }

  .topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-h);
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    padding: 0 16px;
    z-index: 60;
  }

  .topbar-brand {
    display: flex;
    align-items: center;
    text-decoration: none;
  }

  .topbar-brand img {
    height: 26px;
    width: auto;
    border-radius: var(--radius-sm);
  }

  .topbar-right {
    display: flex;
    align-items: center;
    gap: 4px;
  }

  .topbar-bell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    color: var(--text) !important;
    text-decoration: none !important;
    font-size: 17px;
  }

  .topbar-bell:hover {
    background: var(--bg);
  }

  .topbar-bell .notification-badge {
    top: 4px;
    left: auto;
    right: 2px;
  }

  .nav-hamburger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 6px;
    transition: background 0.15s;
  }

  .nav-hamburger:hover {
    background: var(--bg);
  }

  .nav-hamburger span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: transform 0.2s ease, opacity 0.2s ease;
    transform-origin: center;
  }

  .nav-hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .nav-hamburger.open span:nth-child(2) { opacity: 0; }
  .nav-hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  .nav-drawer {
    display: none;
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    right: 0;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
    z-index: 55;
    padding: 8px 10px 14px;
    max-height: calc(100vh - var(--topbar-h));
    overflow-y: auto;
  }

  .nav-drawer.open {
    display: block;
  }

  .nav-drawer-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px 12px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 6px;
    color: var(--text-muted) !important;
    text-decoration: none !important;
  }

  .nav-drawer-user .user-name {
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
  }

  .nav-drawer-user > span {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
  }

  .nav-drawer-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 12px;
    border-radius: var(--radius-md);
    color: var(--text-muted) !important;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 14px;
    text-decoration: none !important;
    transition: background 0.12s, color 0.12s;
  }

  .nav-drawer-link svg {
    flex-shrink: 0;
    opacity: 0.85;
  }

  .nav-drawer-link-label {
    flex: 1;
  }

  .nav-drawer-link:hover svg,
  .nav-drawer-link.active svg {
    opacity: 1;
  }

  .nav-drawer-link.active {
    background: var(--surface-2);
    color: var(--text) !important;
    font-weight: 700;
  }

  .nav-drawer-link:hover {
    background: var(--bg);
    color: var(--text) !important;
  }

  .nav-drawer-logout {
    display: block;
    width: calc(100% - 24px);
    margin: 10px 12px 0;
    padding: 9px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--line-strong);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    text-align: left;
    font-family: var(--font-body);
    transition: all 0.15s;
  }

  .nav-drawer-logout:hover {
    border-color: var(--text-muted);
    color: var(--text);
    background: var(--bg);
  }
}

/* ==========================================================================
   Container / page furniture
   ========================================================================== */

.container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 32px 36px;
}

@media (max-width: 768px) {
  .container {
    padding: 20px 16px;
  }
}

.flash-error,
.flash-success {
  margin: 0 36px;
  padding: 11px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
}

@media (max-width: 768px) {
  .flash-error, .flash-success { margin: 0 16px; }
}

.flash-error {
  background: var(--red-soft);
  color: #A31217;
  border-color: #F3C7C8;
}

.flash-success {
  background: #E9F5EE;
  color: #146C3E;
  border-color: #BEE3CC;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.toolbar-btn,
.inline-btn,
.add-user-submit,
.nc-submit,
.qa-save,
.btn-continue,
.add-contact-form button,
.edit-contact-form button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none !important;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s, transform 0.08s;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}

.toolbar-btn:active,
.inline-btn:active,
.add-user-submit:active,
.nc-submit:active,
.qa-save:active,
.btn-continue:active {
  transform: translateY(1px);
}

.toolbar-btn:hover,
.inline-btn:hover,
.add-user-submit:hover,
.nc-submit:hover,
.qa-save:hover,
.btn-continue:hover,
.add-contact-form button:hover,
.edit-contact-form button:hover {
  background: var(--ink-raised);
  border-color: var(--ink-raised);
}

.inline-btn-secondary,
.nc-cancel,
.page-btn,
.contact-history-link,
.contact-action-link,
.btn-edit-user,
.notif-mark-read,
.notif-clear-btn,
#import-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none !important;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
}

.inline-btn-secondary:hover,
.nc-cancel:hover,
.page-btn:hover,
.contact-history-link:hover,
.contact-action-link:hover,
.btn-edit-user:hover,
.notif-mark-read:hover,
#import-toggle:hover {
  border-color: var(--ink);
  color: var(--ink);
}

.notif-clear-btn:hover {
  border-color: var(--red);
  color: var(--red);
}

.page-btn.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.btn-edit-active {
  background: var(--text);
  border-color: var(--text);
  color: var(--paper);
}

.contact-action-link {
  padding: 4px 10px;
  font-size: 12px;
  border-color: transparent;
  background: transparent;
}

.contact-action-link:hover {
  border-color: var(--line-strong);
  background: var(--bg);
}

.contact-history-link {
  padding: 4px 10px;
  font-size: 11px;
}

.btn-delete,
.delete-btn,
.pc1-dialog-ok.danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--red);
  background: var(--paper);
  color: var(--red);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
}

.btn-delete:hover,
.delete-btn:hover,
.pc1-dialog-ok.danger:hover {
  background: var(--red);
  color: #fff;
}

.pc1-dialog-ok {
  border-radius: var(--radius-pill);
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
}

.pc1-dialog-ok:hover {
  background: var(--ink-raised);
}

/* Small variants inherit sizing from context via inline styles in views;
   keep a compact class for consistency where used. */
.inline-btn-lg {
  padding: 11px 22px;
  font-size: 14px;
}

.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }
.text-danger { color: var(--red); }

/* ==========================================================================
   Inputs / selects / textareas
   ========================================================================== */

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="datetime-local"],
input[type="number"],
input[type="file"],
select,
textarea,
.search-input,
.archive-filter-input,
.inline-input,
.edit-panel-input-sm,
.contact-picker-wrap input {
  font-family: var(--font-body);
  font-size: 13.5px;
  color: var(--text);
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  transition: border-color 0.12s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--ink);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-faint);
}

select {
  cursor: pointer;
}

textarea {
  font-family: inherit;
  resize: vertical;
}

.search-input {
  width: 100%;
  max-width: 400px;
  padding: 9px 14px;
}

/* ==========================================================================
   Toolbar / filters
   ========================================================================== */

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
  flex-wrap: wrap;
  align-items: center;
}

.toolbar form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar select,
.toolbar input {
  padding: 9px 12px;
  font-size: 13px;
}

.dashboard-search {
  max-width: 220px;
}

.archive-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.archive-count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
}

.archive-filters {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.archive-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.archive-filter-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
  min-width: 140px;
}

.archive-filter-label,
.add-user-field-label,
.edit-panel-label,
.qa-label {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: var(--font-body);
}

.archive-filter-input {
  width: 100%;
}

.archive-filter-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  padding-bottom: 1px;
}

/* Without this, the [hidden] attribute set by the live-filter JS has no
   effect: an author rule's display:flex above beats the UA stylesheet's
   [hidden]{display:none} at equal specificity regardless of source order. */
.archive-filter-actions[hidden] {
  display: none;
}

/* ---- Filters modal (small screens) ---- */

.filters-toggle-btn {
  display: none;
}

.filters-active-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
  display: inline-block;
}

.archive-filter-modal-head {
  display: none;
}

@media (max-width: 768px) {
  .filters-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 16px;
  }

  .archive-filters {
    display: none;
  }

  .archive-filters.open {
    display: flex;
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 12, 0.55);
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    margin: 0;
  }

  .archive-filters.open .archive-filter-row {
    background: var(--paper);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 20px;
    max-width: 420px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    flex-direction: column;
    align-items: stretch;
  }

  .archive-filter-modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
  }

  .archive-filter-modal-head .modal-title {
    font-size: 15px;
  }

  .archive-filters .archive-filter-field {
    min-width: 0;
  }

  .archive-filters .archive-filter-actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .archive-filters .archive-filter-actions .toolbar-btn,
  .archive-filters .archive-filter-actions .inline-btn-secondary {
    width: 100%;
    text-align: center;
  }
}

/* ==========================================================================
   Tables
   ========================================================================== */

.calls-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--paper);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.calls-table th,
.calls-table td {
  padding: 13px 16px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.calls-table th {
  background: var(--paper);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  border-bottom: 1px solid var(--line-strong);
}

.calls-table tbody tr:hover {
  background: var(--bg);
  cursor: pointer;
}

.calls-table tr.selected {
  background: var(--surface-2);
}

.calls-table tbody tr[data-urgency="critical"] {
  border-left: 3px solid var(--red);
}

.calls-table tbody tr[data-urgency="high"] {
  border-left: 3px solid var(--amber-dot);
}

.calls-table tbody tr.row-aging {
  background: var(--amber-soft);
  border-left: 3px solid var(--amber-dot);
}

.calls-table tbody tr.row-aging:hover {
  background: #F7E7C6;
}

.calls-table td {
  font-size: 13px;
  color: var(--text);
  vertical-align: top;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
}

/* ==========================================================================
   Signals — status / urgency (dot + label, not filled pills)
   ========================================================================== */

.status-badge,
.urgency-badge,
.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px 3px 8px;
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--surface-2);
  white-space: nowrap;
}

.status-badge::before,
.urgency-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
}

.status-new { color: var(--ink); background: var(--surface-2); }
.status-new::before { background: var(--ink); }

.status-assigned { color: #1D4E89; background: #E7EEF7; }
.status-assigned::before { background: #1D4E89; }

.status-in-progress { color: var(--amber-text); background: var(--amber-soft); }
.status-in-progress::before { background: var(--amber-dot); }

.status-resolved { color: var(--green-text); background: var(--green-soft); }
.status-resolved::before { background: var(--green); }

.status-closed { color: var(--text-faint); background: var(--surface-2); opacity: 0.8; }
.status-closed::before { display: none; }

.urgency-critical { color: #A31217; background: var(--red-soft); font-weight: 700; }
.urgency-critical::before { background: var(--red); }

.urgency-high { color: var(--amber-text); background: var(--amber-soft); }
.urgency-high::before { background: var(--amber-dot); }

.urgency-normal { color: var(--text-faint); background: transparent; padding-left: 0; }
.urgency-normal::before { display: none; }

.urgency-low { color: var(--text-faint); background: transparent; opacity: 0.7; padding-left: 0; }
.urgency-low::before { display: none; }

.role-badge::before { display: none; }
.role-badge.role-admin { color: var(--ink); background: var(--surface-2); font-weight: 700; }
.role-badge.role-user { color: var(--text-muted); background: var(--surface-2); }

/* ==========================================================================
   Caller / user cells
   ========================================================================== */

.copy-caller {
  cursor: pointer;
  color: var(--text);
  font-family: var(--font-mono);
}

.copy-caller:hover {
  color: var(--ink);
}

.copy-icons {
  display: inline-flex;
  gap: 2px;
  margin-left: 5px;
  vertical-align: middle;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}

.copy-caller:hover .copy-icons {
  opacity: 1;
  pointer-events: auto;
}

.copy-icon-btn,
.call-icon-btn {
  display: inline-flex;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  cursor: pointer;
  background-repeat: no-repeat;
  background-size: 12px 12px;
  background-position: center;
  transition: background-color 0.12s;
  flex-shrink: 0;
}

.copy-icon-btn:hover { background-color: var(--surface-2); }
.call-icon-btn:hover { background-color: var(--surface-2); }

.copy-icon-btn {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2317181A' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='5' y='5' width='9' height='9' rx='1'/%3E%3Cpath d='M3 11V3a1 1 0 0 1 1-1h8'/%3E%3C/svg%3E");
}

.call-icon-btn {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23146C3E' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07A19.5 19.5 0 0 1 4.69 13 19.79 19.79 0 0 1 1.61 4.37 2 2 0 0 1 3.6 2.18h3a2 2 0 0 1 2 1.72c.127.96.361 1.903.7 2.81a2 2 0 0 1-.45 2.11L7.91 9.91a16 16 0 0 0 6.06 6.06l.91-.91a2 2 0 0 1 2.11-.45c.907.339 1.85.573 2.81.7A2 2 0 0 1 22 16.92z'/%3E%3C/svg%3E");
}

.copy-caller.copied .copy-icon-btn {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23146C3E' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='2.5,8.5 6,12 13.5,4.5'/%3E%3C/svg%3E");
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  flex-shrink: 0;
  color: #fff;
  font-family: var(--font-body);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.avatar-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.calls-table td[data-label="Handler"],
.calls-table td[data-label="Assigned To"] {
  text-align: center;
}

.avatar-sm {
  width: 20px;
  height: 20px;
  font-size: 9px;
}

.avatar-lg {
  width: 52px;
  height: 52px;
  font-size: 18px;
}

.caller-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}

.user-name {
  text-transform: capitalize;
}

.caller-number {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  display: block;
}

.caller-contact {
  font-size: 12px;
  color: var(--text-muted);
}

.call-note-preview {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 2px;
  max-width: 300px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   Call detail page
   ========================================================================== */

.call-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none !important;
  margin-bottom: 16px;
}

.call-back-link:hover {
  color: var(--ink);
}

.call-hero {
  display: flex;
  gap: 18px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 22px 24px;
  margin-bottom: 20px;
}

.call-hero .avatar-lg {
  flex-shrink: 0;
}

.call-hero-body {
  flex: 1;
  min-width: 0;
}

.call-hero-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.call-hero-name {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.01em;
}

.call-hero-name .copy-caller {
  font-family: var(--font-display);
}

.call-hero-number {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.call-hero-number .copy-caller {
  color: inherit;
}

.call-hero-number .copy-caller:hover {
  color: var(--text);
}

.call-hero-company {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 2px;
}

.call-hero-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.call-hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.call-meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.call-meta-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
}

.call-meta-mono {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  word-break: break-all;
}

.call-hero-transfers {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.call-transfer-row {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.call-actions-panel {
  margin-bottom: 20px;
}

.call-actions-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  align-items: stretch;
}

.call-actions-row .call-card {
  display: flex;
  flex-direction: column;
}

.call-actions-modal-head {
  display: none;
}

@media (max-width: 768px) {
  .call-actions-panel {
    display: none;
  }

  .call-actions-panel.open {
    display: flex;
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 12, 0.55);
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    margin: 0;
  }

  .call-actions-panel.open .call-actions-row {
    background: var(--paper);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 20px;
    max-width: 420px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    grid-template-columns: 1fr;
  }

  .call-actions-modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
  }
}

.call-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
}

.call-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.call-card-head h3 {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.call-card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.call-card .call-card-title h3,
.call-card .call-card-head h3 {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
  font-size: 15px;
  font-weight: 700;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
}

.call-card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.call-card-icon-red { background: var(--red-soft); color: var(--red); }
.call-card-icon-ink { background: var(--surface-2); color: var(--ink); }
.call-card-icon-blue { background: #E7EEF7; color: #1D4E89; }
.call-card-icon-amber { background: var(--amber-soft); color: var(--amber-text); }
.call-card-icon-green { background: var(--green-soft); color: var(--green-text); }

.call-card-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  margin-left: auto;
  cursor: help;
  flex-shrink: 0;
}

.call-card-info:hover {
  color: var(--text-muted);
}

.call-card-clickable {
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.call-card-clickable:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
}

.call-card-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13.5px;
  color: var(--text-muted);
}

.call-card-summary-count {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
}

.call-card-cta {
  color: var(--ink);
  font-weight: 700;
}

.call-card-chevron {
  display: inline-flex;
  color: var(--text-faint);
  flex-shrink: 0;
}

.call-card-clickable:hover .call-card-chevron {
  color: var(--text-muted);
}

.call-card-add-btn {
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--text);
  font-size: 16px;
  line-height: 1;
  font-weight: 400;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.call-card-add-btn:hover {
  border-color: var(--ink);
  color: var(--ink);
}

.call-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 500px) {
  .call-form-grid {
    grid-template-columns: 1fr;
  }
}

.call-form-grid > * {
  min-width: 0;
}

.call-notes-card .notes-list {
  max-height: 520px;
  overflow-y: auto;
  padding-right: 2px;
}

.note-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 4px;
}

.note-head .note-meta {
  margin-bottom: 0;
  flex: 1;
}

.panel-section {
  margin-bottom: 26px;
}

.panel-section h3 {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-body);
}

.call-detail {
  max-width: 640px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.detail-label {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12.5px;
  flex-shrink: 0;
}

.detail-value {
  font-size: 13.5px;
  color: var(--text);
  text-align: right;
}

.assign-row,
.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.assign-row select,
.status-row select {
  flex: 1 1 140px;
  min-width: 0;
}

.assign-row button[type="submit"],
.status-row button[type="submit"] {
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  font-family: var(--font-body);
}

.assign-row button[type="submit"]:hover,
.status-row button[type="submit"]:hover {
  background: var(--ink-raised);
}

.assign-row .inline-btn-secondary,
.status-row .inline-btn-secondary {
  flex-shrink: 0;
}

/* ==========================================================================
   Notes
   ========================================================================== */

.notes-list {
  list-style: none;
}

.note-item {
  padding: 12px 14px;
  margin-bottom: 8px;
  background: var(--bg);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--ink);
}

.note-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.note-content {
  font-size: 13.5px;
  color: var(--text);
  white-space: pre-line;
}

.note-edited-flag {
  font-size: 11px;
  color: var(--text-faint);
  margin-left: 4px;
  cursor: default;
  border-bottom: 1px dashed var(--line-strong);
}

.note-edit-btn {
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 0 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: color 0.15s;
  font-family: var(--font-body);
}

.note-edit-btn:hover {
  color: var(--ink);
}

.note-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.note-form textarea {
  min-height: 80px;
}

.note-form button {
  align-self: flex-end;
  padding: 8px 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 13px;
}

.note-form button:hover {
  background: var(--ink-raised);
}

/* ==========================================================================
   Modals
   ========================================================================== */

.modal-overlay,
.pc1-dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 12, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}

.pc1-dialog-overlay {
  z-index: 2000;
}

.modal-card {
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  width: 100%;
  max-width: 1230px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  background: var(--paper);
}

.modal-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
}

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: var(--text-faint);
  cursor: pointer;
  padding: 0 4px;
}

.modal-close:hover {
  color: var(--text);
}

.modal-body {
  overflow-y: auto;
  flex: 1;
  padding: 16px;
}

.modal-body .calls-table {
  margin: 0;
}

.modal-body .calls-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}

.modal-loading {
  padding: 32px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
}

.modal-subtitle {
  font-size: 12px;
  color: var(--text-faint);
  margin: 2px 0 0;
}

.pc1-dialog {
  background: var(--paper);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
  width: 100%;
  max-width: 400px;
  overflow: hidden;
}

.pc1-dialog-body {
  padding: 22px 22px 6px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  white-space: pre-line;
}

.pc1-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 22px 20px;
}

.pc1-dialog-btn {
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-family: var(--font-body);
  text-decoration: none !important;
  text-align: center;
}

.pc1-dialog-cancel {
  background: var(--paper);
  color: var(--text);
  border: 1px solid var(--line-strong);
}

.pc1-dialog-cancel:hover {
  background: var(--bg);
}

#new-call-modal .modal-body {
  padding: 4px 20px 20px;
}

.new-call-form .form-group,
.edit-contact-form .form-group {
  margin-bottom: 14px;
}

.new-call-form label,
.edit-contact-form label {
  display: block;
  font-weight: 600;
  font-size: 11.5px;
  color: var(--text-faint);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.new-call-form input,
.new-call-form select,
.new-call-form textarea,
.edit-contact-form input,
.edit-contact-form textarea {
  width: 100%;
}

.edit-contact-form input,
.edit-contact-form textarea {
  max-width: 400px;
}

.new-call-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

/* ==========================================================================
   Contact picker / mention dropdown
   ========================================================================== */

.contact-picker-wrap {
  position: relative;
  flex: 1;
}

.contact-picker-results,
.mention-dropdown {
  position: absolute;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.14);
  z-index: 200;
}

.contact-picker-results {
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  max-height: 220px;
  overflow-y: auto;
}

.mention-dropdown {
  z-index: 9999;
  list-style: none;
  padding: 4px 0;
  margin: 0;
  min-width: 160px;
  max-height: 200px;
  overflow-y: auto;
}

.contact-picker-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.contact-picker-item:last-child { border-bottom: none; }
.contact-picker-item:hover { background: var(--bg); }

.contact-picker-name {
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.contact-picker-number {
  color: var(--text-muted);
  font-size: 12px;
  font-family: var(--font-mono);
  white-space: nowrap;
  flex-shrink: 0;
}

.contact-picker-number .contact-picker-label {
  color: var(--text-faint);
  font-size: 11px;
  font-family: var(--font-body);
}

.mention-option {
  padding: 7px 14px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
}

.mention-option:hover,
.mention-option.active {
  background: var(--bg);
  color: var(--ink);
  font-weight: 600;
}

/* ==========================================================================
   Contacts page
   ========================================================================== */

.search-input-wrap {
  position: relative;
  flex: 1;
  display: flex;
}

.search-input-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  pointer-events: none;
  display: flex;
}

.search-input-wrap .search-input {
  padding-left: 36px;
}

.company-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-muted);
  flex-shrink: 0;
}

.contact-company-count {
  font-size: 11px;
  color: var(--text-faint);
  font-weight: 500;
}

.row-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  text-decoration: none !important;
  font-family: inherit;
}

.row-icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.row-icon-btn.danger:hover {
  background: var(--red-soft);
  color: var(--red);
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.contacts-page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 10px;
}

.contacts-page-actions {
  display: flex;
  gap: 8px;
}

.contacts-collapsible {
  margin-bottom: 16px;
}

.contacts-panel {
  flex: 1;
  min-width: 280px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.panel-heading {
  margin-bottom: 8px;
  font-family: var(--font-display);
  font-weight: 800;
}

.phone-fields {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.phone-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.phone-row input { flex: 1; }

.phone-label-select { width: 100px; padding: 8px; }
.phone-country-select { width: 150px; flex-shrink: 0; padding: 8px; }

.nc-caller-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.nc-caller-row .phone-country-select { width: 150px; }
.nc-caller-row input { flex: 1; }

.phone-remove-btn {
  background: none;
  border: none;
  color: var(--red);
  cursor: pointer;
  font-size: 18px;
  padding: 0 4px;
  line-height: 1;
}

.phone-fields + .inline-btn-secondary { margin-top: 6px; }

.contact-form-actions {
  width: 100%;
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.contact-search { margin-bottom: 24px; }

.contact-search-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.contact-search-form .search-input { flex: 1; }

.page-size-select {
  padding: 7px 10px;
  font-size: 13px;
}

.contact-company-header { cursor: pointer; user-select: none; }

.contact-company-header td {
  background: var(--paper);
  padding: 9px 16px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  transition: background 0.12s;
}

.contact-company-header:hover td { background: var(--surface-2); }
.contact-company-header:first-child td { border-top: none; }

.contact-company-header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.contact-company-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.contact-company-chevron {
  display: inline-block;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2363666B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 4l4 4-4 4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: contain;
  transition: transform 0.15s;
}

.contact-company-header.open .contact-company-chevron { transform: rotate(90deg); }

.contact-company-name {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.01em;
  font-family: var(--font-body);
}

.contact-company-none { color: var(--text-faint); font-weight: 400; }

.contact-name-cell {
  padding-left: 42px !important;
  font-weight: 600;
  color: var(--text);
}

.contact-phone-row {
  display: flex;
  align-items: baseline;
  gap: 5px;
  line-height: 1.6;
}

.contact-phone-label {
  font-size: 11px;
  color: var(--text-faint);
}

.contact-row-actions {
  white-space: nowrap;
  text-align: right;
}

/* ==========================================================================
   Callbacks
   ========================================================================== */

.callback-list {
  margin-top: 12px;
  border-top: 1px solid var(--line);
}

.callback-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
  gap: 8px;
}

.callback-item-info { flex: 1; min-width: 0; }

.callback-item-note {
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.callback-overdue .callback-item-info time {
  color: var(--red);
  font-weight: 700;
}

.callback-done { opacity: 0.5; }

.callback-done-tag {
  display: inline-block;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: 4px;
  text-transform: uppercase;
}

/* ==========================================================================
   Notifications page
   ========================================================================== */

.notif-perm-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: none;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-body);
  cursor: default;
  transition: background 0.15s, border-color 0.15s;
}

.notif-perm-status.enabled {
  color: #146C3E;
  background: #E9F5EE;
  border-color: #BEE3CC;
}

.notif-perm-status.disabled {
  color: #A31217;
  background: var(--red-soft);
  border-color: #F3C7C8;
  cursor: pointer;
}

.notif-perm-status.disabled:hover { background: #F7D6D7; }

.notif-perm-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.notif-perm-status.enabled .notif-perm-dot { background: #1E8E5A; }
.notif-perm-status.disabled .notif-perm-dot { background: var(--red); }

.notifications-list .notif-item {
  display: block;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 8px;
  text-decoration: none !important;
  color: var(--text);
  transition: background 0.12s, border-color 0.12s;
  box-shadow: var(--shadow-sm);
}

.notifications-list .notif-item:hover {
  background: var(--bg);
  border-color: var(--line-strong);
}

.notifications-list .notif-item.unread {
  border-left: 3px solid var(--ink);
}

.notif-item { cursor: pointer; font-size: 13px; }
.notif-message { white-space: pre-line; }
.notif-time { font-size: 11px; color: var(--text-faint); margin-top: 4px; }
.notif-empty { padding: 20px; text-align: center; color: var(--text-faint); }

.notif-actions {
  margin-top: 6px;
  display: flex;
  gap: 12px;
  align-items: center;
}

.notif-mark-read {
  padding: 4px 10px;
  font-size: 12px;
}

.notif-archive-header,
.notif-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 24px 0 10px;
  gap: 12px;
}

.notif-archive-header h3,
.notif-section-head h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0;
  border: none;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.notif-section-head .archive-count {
  background: var(--surface-2);
  color: var(--text-muted);
  border-radius: var(--radius-pill);
  padding: 1px 8px;
  font-size: 11px;
}

.notif-clear-btn {
  padding: 5px 12px;
  font-size: 12px;
}

.notif-item-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.notif-item-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-muted);
  flex-shrink: 0;
}

.notif-item.unread .notif-item-icon {
  background: var(--red-soft);
  color: var(--red);
}

.notif-item-body {
  flex: 1;
  min-width: 0;
}

/* ==========================================================================
   Toasts
   ========================================================================== */

#in-app-toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.in-app-toast {
  background: var(--ink);
  color: var(--text-on-ink);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  max-width: 320px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
  pointer-events: all;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.22s ease, transform 0.22s ease;
  border-left: 3px solid var(--red);
}

.in-app-toast--visible { opacity: 1; transform: translateY(0); }
.in-app-toast-title { font-size: 13px; font-weight: 700; margin-bottom: 3px; }
.in-app-toast-body { font-size: 12px; color: var(--text-on-ink-muted); white-space: pre-line; line-height: 1.45; }

/* ==========================================================================
   Auth screens
   ========================================================================== */

.auth-screen {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: var(--bg);
  padding: 24px;
}

.auth-box {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 400px;
  max-width: 100%;
  box-shadow: var(--shadow-md);
}

.auth-box .auth-logo {
  display: block;
  margin: 0 auto 28px;
  height: 34px;
  width: auto;
}

.auth-box h2 {
  margin-bottom: 22px;
  text-align: center;
  color: var(--text);
  font-size: 19px;
}

.auth-box input {
  width: 100%;
  padding: 11px 14px;
  margin-bottom: 12px;
  font-size: 14px;
}

.auth-box button {
  width: 100%;
  padding: 11px;
  border-radius: var(--radius-md);
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 8px;
  transition: background 0.15s;
  font-family: var(--font-body);
}

.auth-box button:hover { background: var(--ink-raised); }

.auth-box .toggle {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

.auth-box .error {
  color: #A31217;
  background: var(--red-soft);
  border: 1px solid #F3C7C8;
  border-radius: var(--radius-md);
  padding: 9px 12px;
  font-size: 13px;
  margin-bottom: 12px;
}

.auth-box-wide { width: 460px; }

.auth-sub {
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
  line-height: 1.55;
  margin-bottom: 20px;
}

.auth-alt {
  text-align: center;
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1.5;
  margin-top: 16px;
}

.totp-qr {
  display: block;
  width: 200px;
  height: 200px;
  margin: 4px auto 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
}

.totp-secret-label {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.totp-secret {
  display: block;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 15px;
  letter-spacing: 0.12em;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px;
  margin-bottom: 20px;
  word-break: break-all;
}

.backup-code-list {
  list-style: none;
  padding: 16px;
  margin: 0 0 20px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
  font-family: var(--font-mono);
  font-size: 15px;
  letter-spacing: 0.06em;
  color: var(--text);
  text-align: center;
}

/* ==========================================================================
   Misc shared
   ========================================================================== */

.inline-form { display: flex; gap: 6px; align-items: center; }
.inline-input { width: 180px; padding: 6px 10px; font-size: 13px; }
.clear-push-btn { font-size: 12px; padding: 4px 10px; }

.users-table { min-width: 600px; }
.users-table td { vertical-align: middle; }
.users-table tr:hover { background: inherit; cursor: default; }

.self-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  margin-left: 6px;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.not-set { color: var(--text-faint); }

.date-cell {
  white-space: nowrap;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.user-row-actions {
  white-space: nowrap;
  display: flex;
  gap: 6px;
  align-items: center;
}

.user-edit-panel { display: none; }
.user-edit-panel.open { display: table-row; }
.user-edit-panel > td { padding: 0; border-top: none; }

.edit-panel-inner {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  background: var(--bg);
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--line);
  padding: 16px 20px;
  gap: 4px;
}

.edit-panel-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 20px 4px 0;
}

.edit-panel-divider {
  width: 1px;
  background: var(--line-strong);
  align-self: stretch;
  margin: 0 16px;
  min-height: 44px;
}

.edit-field-form { display: flex; gap: 6px; align-items: center; }
.edit-panel-input { width: 150px; }
.edit-panel-input-sm { width: 120px; }
.edit-panel-readonly {
  font-size: 14px;
  color: var(--text);
  padding: 6px 0;
  text-transform: capitalize;
}

.role-select { padding: 6px 8px; font-size: 13px; }

.add-user-card {
  margin-top: 32px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
}

.add-user-fields {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.add-user-field { display: flex; flex-direction: column; gap: 6px; }

.add-user-form input,
.add-user-form select {
  min-width: 160px;
  padding: 8px 12px;
  font-size: 14px;
}

.add-contact-form { display: flex; gap: 8px; flex-wrap: wrap; }
.add-contact-form input { padding: 8px 12px; font-size: 14px; }

.user-8x8 { font-size: 11px; color: var(--text-faint); }
.user-select { color: var(--text-faint); }

.user-list { list-style: none; max-height: 200px; overflow-y: auto; }
.user-list li { padding: 8px; border-bottom: 1px solid var(--line); color: var(--text); }

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  flex-wrap: wrap;
}

/* ==========================================================================
   Dashboard — quick action popover
   ========================================================================== */

.row-action-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 18px;
  color: var(--text-faint);
  opacity: 0;
  transition: opacity 0.15s, background 0.12s;
  font-family: inherit;
  line-height: 1;
}

.calls-table tbody tr:hover .row-action-btn { opacity: 1; }
.row-action-btn:hover { background: var(--surface-2); color: var(--text); }

.quick-action-popover {
  position: absolute;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.16);
  padding: 12px;
  z-index: 500;
  min-width: 200px;
  flex-direction: column;
  gap: 10px;
}

.qa-field { display: flex; flex-direction: column; gap: 4px; }
.qa-select { padding: 6px 8px; font-size: 13px; }

/* ==========================================================================
   Incoming call chooser
   ========================================================================== */

.incoming-wrap { max-width: 720px; margin: 0 auto; }

.incoming-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.incoming-intro { font-size: 14px; color: var(--text-muted); line-height: 1.55; }
.incoming-intro strong { color: var(--text); }

.incoming-call-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.incoming-call-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.incoming-call-id { font-family: var(--font-mono); font-size: 14px; font-weight: 700; color: var(--text); }
.incoming-call-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.incoming-call-actions form { margin: 0; }
.incoming-call-sub { margin-top: 8px; font-size: 12.5px; color: var(--text-muted); }

.incoming-notes {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.incoming-note { font-size: 13px; }
.incoming-note-author { font-weight: 700; color: var(--text); }
.incoming-note-time { color: var(--text-faint); font-size: 11px; margin-left: 4px; }
.incoming-note-body { margin-top: 3px; color: var(--text-muted); white-space: pre-wrap; line-height: 1.5; }
.incoming-note-empty { margin-top: 10px; font-size: 12px; color: var(--text-faint); }

.incoming-new {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.incoming-new-text { font-size: 13.5px; color: var(--text-muted); }
.incoming-new form { margin: 0; }

/* ==========================================================================
   Legacy slide-out panel (kept minimal for compatibility)
   ========================================================================== */

.detail-panel {
  position: fixed;
  top: 0;
  right: -500px;
  width: 500px;
  height: 100%;
  background: var(--paper);
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.16);
  z-index: 101;
  transition: right 0.3s;
  overflow-y: auto;
}

.detail-panel.open { right: 0; }

.panel-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 12, 0.5);
  z-index: 100;
}

.panel-overlay.open { display: block; }

.panel-header {
  padding: 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-header h2 { font-size: 18px; color: var(--text); }
.panel-body { padding: 20px; }

.notifications-dropdown {
  display: none;
  position: absolute;
  top: 36px;
  right: 0;
  width: 340px;
  background: var(--paper);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.16);
  z-index: 200;
  max-height: 400px;
  overflow-y: auto;
}

.notifications-dropdown.open { display: block; }

/* ==========================================================================
   Responsive — card layout for tables at narrow widths
   Threshold is wider than the sidebar breakpoint (1024px): the sidebar stays
   visible up to 1024px, and its 232px eats into the table's available width,
   so the table needs to drop to cards well before the table itself would
   naturally wrap at a bare-viewport 1024px.
   ========================================================================== */

@media (max-width: 1400px) {
  .calls-table,
  .calls-table thead,
  .calls-table tbody,
  .calls-table tr,
  .calls-table th,
  .calls-table td {
    display: block;
  }

  .calls-table thead { display: none; }

  .calls-table {
    background: transparent;
    border-radius: 0;
    overflow: visible;
    border: none;
  }

  .calls-table tbody tr {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    margin-bottom: 10px;
    position: relative;
    border-top: 1px solid var(--line);
    border-left: 1px solid var(--line);
  }

  .calls-table tbody tr[data-urgency="critical"] { border-left: 3px solid var(--red); }
  .calls-table tbody tr[data-urgency="high"] { border-left: 3px solid var(--amber-dot); }
  .calls-table tbody tr.row-aging { background: var(--amber-soft); border-left: 3px solid var(--amber-dot); }

  .calls-table td {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 4px 0;
    border-bottom: none;
    font-size: 13px;
  }

  .calls-table td[data-label]::before {
    content: attr(data-label);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-faint);
    min-width: 82px;
    flex-shrink: 0;
    line-height: 1.9;
  }

  .calls-table td[data-label]:first-child {
    font-size: 14px;
    padding-bottom: 10px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--line);
    padding-right: 40px;
  }

  .calls-table td[data-label]:first-child::before { display: none; }

  .calls-table .td-card-action {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 0;
    display: flex;
    gap: 4px;
    align-items: center;
    border-bottom: none;
  }

  .calls-table .row-action-btn { opacity: 1; }

  .calls-table td[colspan] { text-align: center; justify-content: center; }

  .calls-table td[data-label="Handler"],
  .calls-table td[data-label="Assigned To"] {
    text-align: left;
  }

  .cb-form-grid { grid-template-columns: 1fr !important; }
  .cb-form-grid [style*="grid-column"] { grid-column: auto !important; }

  .calls-table td.contact-name-cell {
    padding-left: 0 !important;
    padding-right: 104px !important;
  }
}

@media (max-width: 768px) {
  .edit-panel-inner { flex-direction: column; gap: 16px; }
  .edit-panel-divider { display: none; }
  .edit-panel-section { padding: 0; }
  .edit-panel-input,
  .edit-panel-input-sm { width: 100%; min-width: 120px; }
}
