/* ============================================= */
/* Perfect Panel Clone - Dark Theme              */
/* Exact match to Perfect Panel admin UI         */
/* ============================================= */

:root {
  /* Exact Perfect Panel palette (sampled from morethanpanel.com) */
  --bg: #1B1C20;
  --bg-card: #1B1C20;
  --bg-header: #141418;
  --bg-row-hover: #23252b;
  --bg-input: #141418;
  --border: rgba(103, 107, 118, 0.4);
  --border-strong: rgba(103, 107, 118, 0.65);
  --text: #DFE0E1;
  --text-muted: #898d96;
  --text-white: #ffffff;
  --link: #1E73D0;
  --link-hover: #4189d8;
  --topbar: #141418;
  --topbar-active: #ffffff;
  --topbar-inactive: #898d96;
  --filter-text: #898d96;
}

/* ==== LIGHT THEME ==== */
body.light {
  --bg: #f5f6f8;
  --bg-card: #ffffff;
  --bg-header: #f0f2f5;
  --bg-row-hover: #f7f8fa;
  --bg-input: #ffffff;
  --border: #e1e4e8;
  --border-strong: #c7ccd2;
  --text: #1f2328;
  --text-muted: #6b7280;
  --text-white: #0d1117;
  --link: #1E73D0;
  --link-hover: #155bb0;
  --topbar: #ffffff;
  --topbar-active: #0d1117;
  --topbar-inactive: #6b7280;
  --filter-text: #6b7280;
}
body.light .topbar { box-shadow: 0 1px 0 #e1e4e8; }
body.light .pp-table-wrap { box-shadow: 0 1px 2px rgba(0,0,0,.04); }
body.light .badge-api { background: rgba(30,115,208,.12); }
body.light tbody tr:hover { background: var(--bg-row-hover); }

/* ===== Ticket detail light-mode overrides ===== */
body.light .td-panel {
  background: var(--bg-card);
  border-color: var(--border);
}
body.light .td-panel-head {
  background: #f0f2f5;
  border-bottom-color: var(--border);
}
body.light .td-subject { color: var(--text-white); }
body.light .td-id { color: var(--text-muted); }
body.light .td-meta-row { color: var(--text-muted); }
body.light .td-meta-row span b { color: var(--text-white); }
body.light .td-compose-card {
  background: var(--bg-card);
  border-color: var(--border);
}
body.light .td-compose-toolbar {
  background: #f7f8fa;
  border-bottom-color: var(--border);
}
body.light .td-textarea {
  background: #ffffff;
  color: var(--text);
}
body.light .td-actions {
  background: #f7f8fa;
}
body.light .td-saved-btn {
  background: var(--bg-card);
  border-color: var(--border);
  color: var(--text);
}
body.light .td-saved-btn:hover { background: #f0f2f5; }
body.light .td-saved-menu {
  background: var(--bg-card);
  border-color: var(--border);
}
body.light .td-saved-menu button {
  color: var(--text);
  border-bottom-color: #e8eaef;
}
body.light .td-saved-menu input {
  background: #f7f8fa;
  color: var(--text);
}
body.light .td-sidebar .td-user-name { color: var(--text-white); }
body.light .td-msg-author { color: var(--text-muted); }

/* Notebook + Sheet light mode */
body.light .nb-text:empty::before { color: rgba(0,0,0,.3); }
body.light .nb-check {
  border-color: rgba(0,0,0,.25);
}
body.light .nb-line {
  border-bottom-color: rgba(0,0,0,.06);
}
body.light .nb-line:hover { background: rgba(0,0,0,.02); }
body.light .nb-line.done .nb-text {
  color: rgba(0,0,0,.35);
}
body.light .nb-num { color: rgba(0,0,0,.25); }
body.light .nb-tab.active {
  background: var(--bg-card);
  border-color: var(--border);
  border-bottom-color: var(--bg-card);
}
body.light .tasks-sidebar { background: var(--bg-card); }
body.light .tasks-list-btn.active {
  background: rgba(30,115,208,.1);
}

body.light .sheet-table thead th,
body.light .sheet-table tbody td,
body.light .sheet-table tbody th {
  border-color: rgba(0,0,0,.08);
  background: var(--bg-card);
}
body.light .sheet-table thead th.sheet-colhead,
body.light .sheet-table thead th.sheet-corner,
body.light .sheet-table tbody th.sheet-rownum {
  background: #f0f2f5;
  color: var(--text-muted);
}

/* Service Reports light overrides */
body.light .sr-tab-count { background: rgba(0,0,0,.06); color: var(--text-muted); }
body.light .sr-tab.active .sr-tab-count { background: rgba(30,115,208,.14); color: var(--link); }
body.light .sr-reason-card {
  background: #f7f8fa;
  border-color: var(--border);
}
body.light .sr-reason-card.selected {
  background: rgba(30,115,208,.08);
  border-color: var(--link);
}
body.light .sr-reason-title { color: var(--text-white); }

/* Services page category row */
body.light .sv-cat-row td { background: rgba(0,0,0,.03) !important; }
body.light .sv-cat-row:hover td { background: rgba(0,0,0,.06) !important; }
body.light .td-msg-body { color: var(--text); }
body.light .td-msg--user .td-msg-body {
  background: #f0f2f5;
  color: var(--text);
  border-color: var(--border);
}
body.light .td-msg--user .td-msg-body::before {
  border-bottom-color: #f0f2f5;
}
body.light .td-lock-notice {
  background: #fff7ed;
  color: #92400e;
  border-color: #fdba74;
}

/* Auth page light mode */
body.light .auth-overlay { background: #f5f6f8; }
body.light .auth-form-wrap { background: #ffffff; }
body.light .auth-card h2 { color: #0d1117; }
body.light .auth-field input {
  background: #f7f8fa;
  border-color: #e1e4e8;
  color: #0d1117;
}

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

body {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); }

/* ===== TOP NAVIGATION BAR (Perfect Panel style) ===== */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 42px;
  background: var(--topbar);
  display: flex;
  align-items: center;
  padding: 0 16px;
  z-index: 1000;
  border-bottom: 1px solid var(--border);
  gap: 0;
}

.topbar__tabs {
  display: flex;
  align-items: center;
  height: 100%;
  gap: 0;
  flex: 1;
}

/* Hamburger nav toggle (hidden on desktop) */
.nav-toggle {
  display: none;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  cursor: pointer;
  font-size: 16px;
  font-family: inherit;
  margin-right: 8px;
}
.nav-toggle:hover { color: var(--text-white); border-color: var(--text-muted); }

.topbar__tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 100%;
  padding: 0 18px;
  color: var(--topbar-inactive);
  font-size: 15px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color .15s;
  white-space: nowrap;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: inherit;
  text-decoration: none;    /* <a> default altı çizgiyi kaldır */
}

.topbar__tab:hover { color: var(--topbar-active); text-decoration: none; }

.topbar__tab.active {
  color: var(--topbar-active);
  border-bottom-color: var(--link);
}

.topbar__tab-badge {
  background: rgba(255,255,255,.12);
  color: var(--text);
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 10px;
  font-weight: 600;
  min-width: 18px;
  text-align: center;
  display: inline-block;
}
/* Hide topbar badges when empty (no count to show) */
.topbar__tab-badge:empty { display: none; }

.topbar__tab-badge--warning {
  background: rgba(255,255,255,.12);
  color: var(--text);
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* Top right icon buttons (Account, Dark mode, Logout) */
.topbar__icons {
  display: flex;
  align-items: center;
  gap: 2px;
  padding-right: 8px;
  border-right: 1px solid var(--border);
  margin-right: 4px;
  height: 30px;
}

.icon-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  color: var(--topbar-inactive);
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  transition: all .15s;
}

.icon-btn:hover {
  color: var(--text-white);
  background: var(--bg-input);
  border-color: var(--border);
}

.topbar__balance {
  background: #3a4550;
  color: #fff;
  padding: 4px 12px;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 600;
}

.topbar__icon {
  color: var(--topbar-inactive);
  cursor: pointer;
  font-size: 16px;
}

.topbar__icon:hover { color: #fff; }

/* Panel selector in topbar */
.topbar__panels {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}

.topbar__panel-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 10px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  transition: opacity .2s;
  border: none;
}

.topbar__panel-chip.off { opacity: .3; }
.topbar__panel-chip:hover { opacity: .8; }

/* ===== MAIN CONTENT ===== */
.main {
  margin-top: 42px;
  padding: 16px 20px;
  min-height: calc(100vh - 42px);
}

/* ===== ACTION BAR (below topbar) ===== */
.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
}

.action-bar__left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.action-bar__right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== STATUS FILTER TABS (colored text links) ===== */
.status-tabs {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.status-tab {
  font-size: 13px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  transition: opacity .15s;
}

.status-tab--all { color: var(--text-white); }
.status-tab--awaiting { color: #a78bfa; }
.status-tab--pending { color: #f59e0b; }
.status-tab--inprogress { color: #3b82f6; }
.status-tab--completed { color: #10b981; }
.status-tab--partial { color: #f97316; }
.status-tab--canceled { color: #6b7280; }
.status-tab--processing { color: #8b5cf6; }
.status-tab--fail { color: #ef4444; }
.status-tab--error { color: #ef4444; }

.status-tab.active { font-weight: 700; }
.status-tab:not(.active) { opacity: .7; }
.status-tab:hover { opacity: 1; }

/* Red numeric badge next to Fail/Error tabs (PP style) */
.status-tab__badge {
  display: inline-block;
  margin-left: 6px;
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  line-height: 1.4;
  vertical-align: middle;
}

.status-tab__count {
  background: rgba(255,255,255,.12);
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 10px;
  margin-left: 3px;
  font-weight: 600;
}

/* ===== FILTER CHIPS (Created, Provider, Service, etc.) ===== */
.filter-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--bg-card);
  color: var(--filter-text);
  font-size: 12px;
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
  white-space: nowrap;
}

.filter-chip:hover { border-color: var(--link); color: var(--text-white); }
.filter-chip.active { border-color: var(--link); color: var(--link); }

.filter-chip__icon {
  font-size: 10px;
  opacity: .6;
}

.clear-filters {
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
}

.clear-filters:hover { color: var(--text-white); }

/* ===== SEARCH (right side) ===== */
.search-group {
  display: flex;
  align-items: stretch;
  gap: 0;
  height: 30px;
}

.search-group > * {
  height: 30px;
  box-sizing: border-box;
  font-size: 12px;
  font-family: inherit;
  margin: 0;
  vertical-align: middle;
}

.search-group input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0 10px;
  border-radius: 0;
  outline: none;
  width: 180px;
  line-height: 28px;
}

.search-group input::placeholder { color: var(--text-muted); }
.search-group input:focus { border-color: var(--link); position: relative; z-index: 1; }

.search-group select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-left: none;
  color: var(--text-muted);
  padding: 0 22px 0 8px;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='8' height='6' viewBox='0 0 8 6'><path fill='%237a8490' d='M0 0h8L4 6z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

.search-group__btn {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-left: none;
  color: var(--text-muted);
  padding: 0 12px;
  cursor: pointer;
  border-radius: 0 3px 3px 0;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.search-group__btn:hover { color: var(--text-white); }

/* ===== TABLE (Perfect Panel dark style) ===== */
.pp-table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 16px;
  /* No overflow:hidden — would clip per-row Actions dropdowns */
  position: relative;
}

.table-scroll {
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
}
/* Scroll shadow indicator: fade on right edge hints at more content */
.pp-table-wrap::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 24px;
  pointer-events: none;
  background: linear-gradient(to left, var(--bg-card), transparent);
  opacity: 0;
  transition: opacity .15s;
}
@media (max-width: 900px) {
  .pp-table-wrap::after { opacity: 1; }
}

table { width: 100%; border-collapse: collapse; }

thead th {
  background: var(--bg-header);
  padding: 10px 8px;
  text-align: left;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
  cursor: default;
}

thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--text-white); }
.sort-arrow { font-size: 11px; opacity: .4; margin-left: 3px; display: inline-block; }
.sort-arrow:not(:empty) { opacity: 1; color: var(--link); font-weight: 700; font-size: 13px; }
thead th.sortable::after {
  content: '\25BE';
  font-size: 9px;
  opacity: .55;
  margin-left: 4px;
}
thead th.sortable.sort-asc::after { content: '\25B4'; opacity: 1; color: var(--link); }
thead th.sortable.sort-desc::after { content: '\25BE'; opacity: 1; color: var(--link); }

/* ===== MASS SELECTION TOOLBAR (above the table, PP-style) ===== */
.mass-toolbar {
  display: none;
  align-items: center;
  gap: 14px;
  padding: 11px 16px;
  background: #27282D;
  border: 1px solid #3F4149;
  border-radius: 4px;
  margin-bottom: 10px;
  font-size: 13px;
  color: #DFE0E1;
}
.mass-toolbar.active { display: flex; }

.mass-toolbar .mass-count-text {
  font-weight: 500;
}
.mass-toolbar .mass-clear {
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  background: none;
  border: none;
  margin-left: auto;
  font-family: inherit;
}
.mass-toolbar .mass-clear:hover { color: var(--text-white); }

/* ===== EMPTY STATE (richer) ===== */
.empty-box {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
  font-size: 13px;
}
.empty-box::before {
  content: '';
  display: block;
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: var(--bg-input);
  border: 2px solid var(--border);
  opacity: .8;
}

tbody td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  vertical-align: top;
  color: var(--text);
  line-height: 1.5;
}

tbody tr:hover { background: var(--bg-row-hover); }

/* Order row - sub info line (external id under order id, etc) */
.sub-info {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
  letter-spacing: .1px;
  font-weight: 400;
}
.cell-id .sub-info { font-weight: 400; }

/* ===== PANEL BADGE ===== */
.p-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  letter-spacing: .3px;
  white-space: nowrap;
  vertical-align: middle;
}

/* ===== STATUS TEXT (flat — white in dark mode, black in light mode) ===== */
.st { font-size: 13.5px; font-weight: 500; color: var(--text-white); }

/* All order / ticket / user statuses share the same flat text color.
   The text itself (Pending / Completed / Fail / etc.) carries the meaning. */
.st-awaiting, .st-pending, .st-inprogress, .st-in-progress,
.st-processing, .st-completed, .st-partial,
.st-canceled, .st-cancelled, .st-fail, .st-error,
.st-open, .st-answered, .st-closed, .st-locked,
.st-customer-reply, .st-welcome,
.st-active, .st-suspended, .st-banned, .st-inactive {
  color: var(--text-white);
}

/* ===== BADGES (small inline) ===== */
.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 10.5px;
  font-weight: 500;
  white-space: nowrap;
  letter-spacing: .2px;
}

.badge-api    { background: rgba(59,130,246,.14); color: #6ba8df; }
.badge-drip   { background: rgba(139,92,246,.14); color: #9d85e6; }
.badge-auto   { color: var(--text-muted); }
.badge-manual { color: var(--text-muted); }
.badge-new    { background: rgba(16,185,129,.12); color: #3fbf8f; }
.badge-regular{ color: var(--text-muted); }

/* ===== CELL STYLES ===== */
.cell-id {
  font-weight: 500;
  color: var(--text-white);
  white-space: nowrap;
  min-width: 0;
  font-size: 15px;
  letter-spacing: .2px;
}
.cell-id-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.cell-id-col {
  display: flex;
  flex-direction: column;
}
.cell-id-row .cell-id {
  min-width: 0;
  line-height: 1.2;
}
.cell-id-row .sub-info {
  margin-top: 2px;
  line-height: 1.2;
}
.cell-user { color: var(--text-white); font-weight: 500; }
.cell-charge { color: var(--text-white); }
.cell-link {
  color: var(--text);
  max-width: 340px;
  word-break: break-all;
  overflow-wrap: anywhere;
  white-space: normal;
  line-height: 1.4;
}
.sv-cat-row td { background: rgba(255,255,255,.02) !important; }
.sv-cat-row:hover td { background: rgba(255,255,255,.05) !important; }

/* ===== Service Report modal ===== */
.sr-targets {
  max-height: 180px;
  overflow-y: auto;
  margin-bottom: 16px;
  background: var(--bg-input, rgba(255,255,255,.04));
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text-muted);
}
.sr-section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .5px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 10px;
}
.sr-reasons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sr-reason-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
  user-select: none;
}
.sr-reason-card:hover {
  background: rgba(255,255,255,.06);
  border-color: rgba(30,115,208,.4);
}
.sr-reason-card.selected {
  background: rgba(30,115,208,.1);
  border-color: var(--accent, #1E73D0);
}
.sr-reason-card.selected .sr-reason-title { color: var(--text-white, #fff); }
.sr-reason-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.sr-reason-text { flex: 1; min-width: 0; }
.sr-reason-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.sr-reason-sub {
  font-size: 12px;
  color: var(--text-muted);
}
.sr-textarea {
  width: 100%;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  min-height: 90px;
  outline: none;
}
.sr-textarea:focus { border-color: var(--accent, #1E73D0); }

/* ============================================================ */
/* TASKS PAGE — simple excel-like rows                          */
/* ============================================================ */
.tasks-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}
.tasks-sidebar {
  flex: 0 0 200px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tasks-list-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 11px 14px;
  font-size: 13px;
  font-family: inherit;
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s, color .15s;
  text-align: left;
}
.tasks-list-btn:hover { background: rgba(255,255,255,.04); }
.tasks-list-btn.active {
  background: rgba(30,115,208,.14);
  color: #fff;
}
.tasks-list-btn .label { flex: 1; font-weight: 500; }
.tasks-list-btn .count {
  background: rgba(255,255,255,.08);
  color: var(--text-muted);
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  min-width: 22px;
  text-align: center;
}
.tasks-list-btn.active .count {
  background: rgba(30,115,208,.3);
  color: #fff;
}
.tasks-list-btn i { font-size: 13px; color: var(--text-muted); width: 16px; }
.tasks-list-btn.active i { color: var(--accent, #1E73D0); }

.tasks-main {
  flex: 1;
  min-width: 0;
}
.tasks-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.tasks-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-white);
  margin: 0;
}
.tasks-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.tasks-panel-filter {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  padding: 4px;
  background: rgba(255,255,255,.03);
  border-radius: 6px;
  width: fit-content;
}
.tasks-panel-filter button {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 5px 12px;
  font-size: 12px;
  font-family: inherit;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
}
.tasks-panel-filter button:hover { color: var(--text-white); }
.tasks-panel-filter button.active {
  background: var(--chip, var(--accent, #1E73D0));
  color: #fff;
}

/* ===== Notebook page tabs ===== */
.nb-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  padding: 0 0 0 4px;
}
.nb-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  color: var(--text-muted);
  padding: 9px 16px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px 6px 0 0;
  white-space: nowrap;
  position: relative;
  top: 1px;
}
.nb-tab:hover { color: var(--text-white, #fff); background: rgba(255,255,255,.03); }
.nb-tab.active {
  color: var(--text-white, #fff);
  background: var(--bg-card);
  border-color: var(--border);
  border-bottom-color: var(--bg-card);
}
.nb-tab-name { user-select: none; }
.nb-tab-name[contenteditable="true"] {
  outline: none;
  min-width: 40px;
  border-bottom: 1px dashed var(--accent, #1E73D0);
}
.nb-tab-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 16px;
  height: 16px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 10px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.nb-tab.active .nb-tab-close,
.nb-tab:hover .nb-tab-close { display: inline-flex; }
.nb-tab-close:hover { color: #ef4444; background: rgba(239,68,68,.1); }
.nb-tab-add {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 6px 12px;
  font-size: 14px;
  cursor: pointer;
  border-radius: 6px;
  margin-left: 4px;
  flex-shrink: 0;
}
.nb-tab-add:hover { color: var(--text-white, #fff); background: rgba(255,255,255,.05); }

.notebook {
  border-top-left-radius: 0;
}

/* ===== Notebook (simple line list) ===== */
.notebook {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 0;
  min-height: 300px;
}
.nb-line {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  border-bottom: 1px solid rgba(255,255,255,.04);
  min-height: 42px;
  transition: background .1s;
}
.nb-line:last-child { border-bottom: none; }
.nb-line:hover { background: rgba(255,255,255,.02); }
.nb-line.done .nb-text {
  color: rgba(255,255,255,.3);
  text-decoration: line-through;
}
.nb-line.done .nb-check {
  background: #10b981;
  border-color: #10b981;
}
.nb-line.done .nb-check i { opacity: 1; }

.nb-num {
  flex-shrink: 0;
  color: rgba(255,255,255,.2);
  font-size: 11px;
  width: 26px;
  text-align: right;
  user-select: none;
  font-variant-numeric: tabular-nums;
}

.nb-text {
  flex: 1;
  color: var(--text-white, #fff);
  font-size: 14px;
  outline: none;
  padding: 4px 0;
  min-height: 22px;
  word-break: break-word;
  white-space: pre-wrap;
}
.nb-text:empty::before {
  content: attr(data-placeholder);
  color: rgba(255,255,255,.18);
  pointer-events: none;
}

.nb-check {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1.5px solid rgba(255,255,255,.22);
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all .15s;
}
.nb-check:hover { border-color: var(--accent, #1E73D0); }
.nb-check i { font-size: 10px; color: #fff; opacity: 0; }

.nb-delete {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 22px;
  height: 22px;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0;
  font-size: 11px;
  flex-shrink: 0;
  transition: opacity .15s, color .15s, background .15s;
}
.nb-line:hover .nb-delete { opacity: .6; }
.nb-delete:hover { opacity: 1 !important; color: #ef4444; background: rgba(239,68,68,.1); }

.nb-empty-msg {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ===== Excel-like sheet ===== */
.sheet-save-status {
  font-size: 11px;
  color: var(--text-muted);
  margin-right: 8px;
  font-style: italic;
}
.sheet-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.sheet-scroll {
  overflow: auto;
  max-height: calc(100vh - 220px);
}
.sheet-table {
  border-collapse: collapse;
  font-size: 13px;
  color: var(--text-white);
  width: auto;
  table-layout: fixed;
}
.sheet-table thead th,
.sheet-table tbody td,
.sheet-table tbody th {
  border: 1px solid rgba(255,255,255,.08);
  padding: 0;
  vertical-align: middle;
  position: relative;
  background: var(--bg-card);
}
/* column header (A B C...) */
.sheet-table thead th.sheet-colhead {
  background: #1a1d23;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  height: 26px;
  user-select: none;
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 0 10px;
}
.sheet-col-resize {
  position: absolute;
  top: 0;
  right: -3px;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 5;
}
.sheet-col-resize:hover { background: var(--accent, #1E73D0); }
.sheet-check-head { width: 38px; min-width: 38px; max-width: 38px; }
.sheet-table thead th.sheet-corner {
  background: #1a1d23;
  width: 44px;
  position: sticky;
  left: 0;
  top: 0;
  z-index: 3;
}
/* row number column */
.sheet-table tbody th.sheet-rownum {
  background: #1a1d23;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  width: 44px;
  user-select: none;
  position: sticky;
  left: 0;
  z-index: 1;
  height: 30px;
}

/* data cells */
.sheet-cell {
  min-width: 140px;
  max-width: 280px;
  height: 30px;
  cursor: cell;
  padding: 0;
  overflow: hidden;
}
.sheet-cell-inner {
  padding: 6px 10px;
  min-height: 30px;
  outline: none;
  color: var(--text-white);
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  cursor: text;
}
.sheet-cell.selected {
  box-shadow: inset 0 0 0 2px var(--accent, #1E73D0);
  background: rgba(30,115,208,.04);
}
.sheet-cell:hover { background: rgba(255,255,255,.02); }
.sheet-cell.selected:hover { background: rgba(30,115,208,.04); }

/* Checkbox cell (now rendered at the right edge) */
.sheet-check-cell {
  width: 38px;
  min-width: 38px;
  max-width: 38px;
  text-align: center;
}
.sheet-check {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  border: 1.5px solid rgba(255,255,255,.25);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all .15s;
  margin: 0 auto;
}
.sheet-check:hover { border-color: var(--accent, #1E73D0); }
.sheet-check i { font-size: 9px; color: #fff; opacity: 0; }
.sheet-row.done .sheet-check {
  background: #10b981;
  border-color: #10b981;
}
.sheet-row.done .sheet-check i { opacity: 1; }
.sheet-row.done .sheet-cell-inner {
  color: rgba(255,255,255,.35);
  text-decoration: line-through;
}

/* Row actions on hover */
.sheet-row-delete {
  position: absolute;
  right: -22px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  background: rgba(239,68,68,.12);
  border: 1px solid rgba(239,68,68,.3);
  border-radius: 4px;
  color: #ef4444;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 10px;
}
.sheet-table tbody tr:hover .sheet-row-delete { display: flex; }

@media (max-width: 800px) {
  .tasks-layout { flex-direction: column; }
  .tasks-sidebar {
    flex: 0 0 auto;
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
  }
}

/* ===== Service Reports page toolbar & tabs ===== */
.sr-toolbar {
  padding: 14px 16px;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.sr-tabs {
  display: flex;
  gap: 18px;
  align-items: center;
}
.sr-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px 0;
  font-size: 14px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.sr-tab:hover { color: var(--text-white, #fff); }
.sr-tab.active {
  color: var(--text-white, #fff);
  border-bottom-color: var(--link);
}
.sr-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  border-radius: 9px;
  background: rgba(255,255,255,.08);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}
.sr-tab.active .sr-tab-count {
  background: rgba(30,115,208,.22);
  color: var(--link);
}
.sr-search {
  flex: 1;
  max-width: 320px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.sr-search:focus { border-color: var(--accent, #1E73D0); }

#sec-service-reports .pp-table-wrap,
#sec-service-reports .table-scroll {
  height: auto !important;
  max-height: none !important;
  overflow: visible !important;
}
#sec-service-reports .pp-table-wrap { padding-bottom: 200px; }

.cell-link a.order-link {
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.cell-link a.order-link:hover { text-decoration: underline; color: var(--text-white); }
.cell-link .order-link-icon {
  color: var(--link);
  font-size: 12px;
  flex-shrink: 0;
  opacity: .7;
}
.cell-service {
  max-width: 300px;
  white-space: normal;
  word-break: break-word;
  font-size: 12px;
  line-height: 1.4;
}
.cell-method {
  max-width: 260px;
  white-space: normal;
  word-break: break-word;
  line-height: 1.4;
}
.cell-memo {
  max-width: 220px;
  white-space: normal;
  word-break: break-all;
  line-height: 1.4;
}
.cell-service__id {
  display: inline-block;
  background: rgba(255,255,255,.08);
  padding: 1px 5px;
  border-radius: 2px;
  font-size: 10px;
  margin-right: 4px;
  color: var(--text-muted);
  font-weight: 600;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
  white-space: nowrap;
  line-height: 1.4;
}

.btn:hover { border-color: var(--link); color: var(--text-white); }
.btn-sm { padding: 5px 11px; font-size: 12px; }

.btn-primary {
  background: var(--link);
  color: #fff;
  border-color: var(--link);
  font-weight: 600;
}
.btn-primary:hover { background: var(--link-hover); border-color: var(--link-hover); color: #fff; }

.btn-outline { background: transparent; }

/* Section topbar (action buttons left, search right) */
.section-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  gap: 12px;
}
.section-topbar__left { display: flex; align-items: center; gap: 8px; }
.section-topbar__right { display: flex; align-items: center; gap: 8px; }

/* Status tabs row (tabs left, search right) */
.status-tabs-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.status-tabs-row .search-group {
  flex-shrink: 0;
}

/* Status tabs (PP-style) */
.status-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.status-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-family: inherit;
  padding: 8px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.status-tab:hover { color: var(--text-white); }
.status-tab.active {
  color: var(--text-white);
  border-bottom-color: var(--link);
}
.status-tab .tab-count {
  background: rgba(239,68,68,.2);
  color: #ef4444;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 4px;
}

/* Filter chips (PP-style) */
.filter-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  align-items: center;
}
.filter-chip {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  font-family: inherit;
  padding: 6px 14px;
  border-radius: 18px;
  cursor: pointer;
  transition: border-color .15s, color .15s;
  position: relative;
}
.filter-chip:hover { border-color: var(--link); color: var(--text-white); }
.filter-chip.active { border-color: var(--link); color: var(--link); }
.filter-chip--clear {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
}
.filter-chip--clear:hover { color: var(--text-white); }

/* Filter dropdown panel */
.filter-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 100;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 16px 60px;
  min-width: 200px;
  margin-top: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  display: none;
}
.filter-dropdown.open { display: block; }
.filter-dropdown h4 {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-white);
}
.filter-dropdown label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.filter-dropdown label:hover { color: var(--text-white); }
.filter-dropdown input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--link);
}
.filter-dropdown input[type="text"],
.filter-dropdown input[type="number"],
.filter-dropdown input[type="date"] {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  padding: 6px 10px;
  margin-top: 4px;
  outline: none;
}
.filter-dropdown input:focus { border-color: var(--link); }
.filter-dropdown .filter-apply {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 10px 16px;
  background: var(--link);
  color: #fff;
  border: none;
  border-radius: 0 0 6px 6px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}
.filter-dropdown .filter-apply:hover { opacity: .9; }
.filter-dropdown .filter-dates {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.filter-dropdown .filter-dates input { width: 50%; }

/* Reports page */
.report-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.report-tabs { flex-wrap: wrap; }
.report-filters {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}
.report-select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 6px 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
}
.report-toolbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.report-toolbar__left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-self: start;
}
/* Chart/Table toggle centered per PP layout */
.report-toolbar .report-toggle {
  justify-self: center;
}
@media (max-width: 900px) {
  .report-toolbar { grid-template-columns: 1fr; justify-items: center; }
  .report-toolbar__left { justify-self: center; }
}
/* PP date picker / year picker dropdown */
.rp-date-picker, .rp-year-picker { position: relative; }
.rp-date-btn {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 14px;
  border-radius: 3px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 130px;
  justify-content: space-between;
}
.rp-date-btn:hover { border-color: var(--link); }
.rp-date-btn i { opacity: 0.7; font-size: 11px; }
.rp-date-menu {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 3px;
  min-width: 260px;
  z-index: 500;
  display: none;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
}
.rp-date-menu.open { display: block; }
.rp-date-menu > a {
  display: block;
  padding: 8px 14px;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
}
.rp-date-menu > a:hover { background: var(--bg-input); color: var(--text-white); }
.rp-date-menu > a.active { background: var(--bg-input); color: var(--link); }
.rp-date-custom {
  border-top: 1px solid var(--border);
  padding: 10px 14px;
}
.rp-date-custom__label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.rp-date-custom__inputs {
  display: flex;
  align-items: center;
  gap: 6px;
}
.rp-date-custom__inputs span { color: var(--text-muted); }
.rp-date-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 6px;
  font-size: 12px;
  border-radius: 3px;
  color-scheme: dark;
  font-family: inherit;
}
.rp-date-custom__actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  margin-top: 8px;
}
.btn-sm { padding: 4px 12px; font-size: 12px; }
/* Year menu */
.rp-year-menu { min-width: 120px; }
/* Segmented control (Total orders / charges / quantity) */
.rp-seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.rp-seg__btn {
  background: var(--bg-input);
  border: none;
  color: var(--text-muted);
  padding: 6px 14px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  border-right: 1px solid var(--border);
}
.rp-seg__btn:last-child { border-right: none; }
.rp-seg__btn.active { background: var(--link); color: #fff; }
.rp-seg__btn:hover:not(.active) { color: var(--text); }
.report-toggle {
  display: flex;
  gap: 0;
  margin-bottom: 0;
  flex-shrink: 0;
}
.report-toggle__btn {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 18px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}
.report-toggle__btn:first-child { border-radius: 4px 0 0 4px; }
.report-toggle__btn:last-child { border-radius: 0 4px 4px 0; border-left: none; }
.report-toggle__btn.active { background: var(--bg-header); color: var(--text-white); border-color: var(--border); }
.report-chart-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 16px;
  margin-bottom: 12px;
}
#rTfoot tr {
  background: var(--bg-header);
  font-weight: 600;
}
#rTfoot td { padding: 10px 8px; border-top: 2px solid var(--border); }

/* Colored left border on rows (PP payments / providers) */
.rp-row-color { position: relative; }
.rp-row-color td:first-child { position: relative; }
.rp-row-color td:first-child::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--rp-color, var(--link));
}
.rp-check-col { width: 36px; text-align: center; padding-left: 12px !important; }

/* Calendar day×month grid (Orders, Profits) */
.rp-calendar-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 12px;
  overflow: hidden;
}
.rp-calendar { width: 100%; font-size: 12px; border-collapse: collapse; }
.rp-calendar th, .rp-calendar td {
  padding: 6px 8px;
  text-align: center;
  border: 1px solid var(--border);
  min-width: 70px;
}
.rp-calendar thead th {
  background: var(--bg-header);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.rp-calendar td.rp-day {
  color: var(--text-muted);
  background: var(--bg-header);
  font-weight: 500;
  width: 50px;
  min-width: 50px;
}
.rp-calendar td.rp-cell { color: var(--text); }
.rp-calendar td.rp-cell--empty { color: var(--text-muted); opacity: .3; }
.rp-calendar tfoot td {
  background: var(--bg-header);
  font-weight: 600;
  border-top: 2px solid var(--border);
}

/* Pagination (Users) — PP style: pages left, "X to Y of Z" right */
.rp-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 14px 0;
  flex-wrap: wrap;
}
.rp-pagination__pages {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.rp-pagination__info {
  color: var(--text-muted);
  font-size: 13px;
}
.rp-no-prev { color: var(--text-muted); font-style: italic; font-size: 12px; }
/* PP-style search group: [icon] [input] [field selector] inside one rounded pill */
.rp-search-group {
  display: inline-flex;
  align-items: stretch;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  height: 32px;
}
.rp-search-group:focus-within { border-color: var(--link); }
.rp-search-group__icon {
  display: flex;
  align-items: center;
  padding: 0 10px 0 12px;
  color: var(--text-muted);
  font-size: 12px;
}
.rp-search {
  background: transparent;
  border: none;
  color: var(--text);
  padding: 0 8px 0 0;
  font-family: inherit;
  font-size: 13px;
  min-width: 180px;
  outline: none;
}
.rp-search::placeholder { color: var(--text-muted); }
.rp-search-field {
  background: var(--bg-header);
  border: none;
  border-left: 1px solid var(--border);
  color: var(--text);
  padding: 0 28px 0 12px;
  font-size: 12.5px;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath fill='%23878ea0' d='M0 0l4 5 4-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  outline: none;
}
.rp-search-field:hover { background-color: var(--bg-input); }

/* User Churn days input */
.rp-days-filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
}
.rp-days-filter input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 8px;
  border-radius: 3px;
  font-family: inherit;
  font-size: 13px;
}
.rp-days-filter input:focus { outline: none; border-color: var(--link); }

/* Status multi-select dropdown (Profits etc.) */
.rp-dd { position: relative; }
.rp-status-menu {
  padding: 4px 0;
  min-width: 180px;
}
.rp-status-menu label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  cursor: pointer;
  color: var(--text);
  font-size: 13px;
}
.rp-status-menu label:hover { background: var(--bg-input); }
.rp-status-menu input[type="checkbox"] { accent-color: var(--link); }

/* Payment methods toggle switch */
.pm-switch { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.pm-switch input { margin: 0; }
.pm-switch span { font-size: 12px; color: var(--text-muted); }
.pm-switch input:checked + span { color: #22c55e; }

/* Reorder arrow buttons — compact, paired */
.pm-reorder { display: inline-flex; flex-direction: column; gap: 2px; }
.pm-reorder .btn { padding: 1px 6px; font-size: 11px; line-height: 1; min-width: 24px; }
.pm-reorder .btn[disabled] { opacity: 0.3; cursor: not-allowed; }

/* Reports data freshness banner — shows when numbers were last reconciled.
   Critical for accounting: a boss looking at totals needs to know max drift. */
.rp-freshness {
  margin: 0 0 14px 0;
  padding: 10px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-left: 3px solid var(--link);
  border-radius: 6px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  align-items: center;
}
.rp-freshness__title {
  color: var(--text);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-size: 11px;
  padding-right: 12px;
  border-right: 1px solid var(--border);
  margin-right: 4px;
}
.rp-freshness__item {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  white-space: nowrap;
}
.rp-freshness__panel {
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0.01em;
}
.rp-freshness__meta strong {
  color: var(--text);
  font-weight: 600;
}
.rp-freshness__sep {
  color: var(--border);
  user-select: none;
  padding: 0 2px;
}
.rp-freshness__dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #22c55e;  /* green = fresh */
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.15);
  flex-shrink: 0;
}
.rp-freshness__dot--stale {
  background: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.18);
}
.rp-freshness__dot--old {
  background: #ef4444;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}
.rp-freshness:empty { display: none; }

/* Modern panel select — colored dot + clean rounded pill */
.rp-panel-select {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 12px 4px 10px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color .12s;
  position: relative;
}
.rp-panel-select:hover { border-color: var(--link); }
.rp-panel-select select {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  padding: 4px 18px 4px 0;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
}
/* Native <option> elements — browsers render these with OS defaults and ignore
   transparent/inherited colors. Force explicit dark-theme colors so the opened
   dropdown list stays readable. */
.rp-panel-select select option,
.search-group .search-panel option {
  background-color: var(--bg-input);
  color: var(--text);
}
.rp-panel-select select option:checked,
.search-group .search-panel option:checked {
  background-color: var(--link);
  color: #fff;
}
.rp-panel-select__dot {
  width: 10px; height: 10px; border-radius: 50%; display: inline-block;
  flex-shrink: 0;
}
.rp-panel-select__caret {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--text-muted);
  font-size: 11px;
}

/* Sortable column header — click to toggle asc/desc */
th.rp-sort {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
th.rp-sort:hover { color: var(--link); }
th.rp-sort::after {
  content: '';
  display: inline-block;
  margin-left: 4px;
  opacity: 0.4;
  font-size: 10px;
  vertical-align: middle;
  transition: opacity .15s;
}
th.rp-sort:not(.rp-sort--active)::after { content: '⇅'; }
th.rp-sort--active { color: var(--link); }
th.rp-sort--asc::after  { content: '▲'; opacity: 1; }
th.rp-sort--desc::after { content: '▼'; opacity: 1; }
.rp-pagination a, .rp-pagination span {
  padding: 6px 11px;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text);
  text-decoration: none;
  background: var(--bg-input);
  font-size: 13px;
  cursor: pointer;
}
.rp-pagination a:hover { border-color: var(--link); color: var(--link); }
.rp-pagination .active { background: var(--link); color: #fff; border-color: var(--link); cursor: default; }
.rp-pagination .disabled { opacity: .4; cursor: default; }

/* Empty / coming-soon state */
.rp-empty {
  text-align: center;
  padding: 60px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
}
.rp-empty__icon { font-size: 48px; color: var(--text-muted); opacity: .4; margin-bottom: 16px; }
.rp-empty__title { font-size: 16px; color: var(--text); font-weight: 500; margin-bottom: 6px; }
.rp-empty__desc { color: var(--text-muted); font-size: 13px; }

/* Cost is red, profit is green in PP */
.rp-money-cost { color: #ef4444; }
.rp-money-profit { color: #10b981; }
.rp-change-up { color: #10b981; }
.rp-change-down { color: #ef4444; }
.rp-change-zero { color: var(--text-muted); }

/* Actions dropdown */
.actions-btn {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 3px 9px;
  border-radius: 3px;
  font-size: 11.5px;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  line-height: 1.3;
  font-weight: 400;
}

.actions-btn:hover { border-color: var(--link); color: var(--text-white); }

.dropdown { position: relative; display: inline-block; }

.dropdown-menu {
  display: none;
  position: absolute;
  right: 0; top: 100%;
  margin-top: 2px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 3px;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
  z-index: 1500;
  min-width: 160px;
  padding: 4px 0;
  white-space: nowrap;
}

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

.dropdown-menu button {
  display: block;
  width: 100%;
  padding: 6px 14px;
  border: none;
  background: none;
  text-align: left;
  font-size: 12px;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
}

.dropdown-menu button:hover { background: var(--bg-row-hover); color: var(--text-white); }
.dropdown-menu .dd-sep { height: 1px; background: var(--border); margin: 4px 0; }

/* ===== PAGINATION ===== */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}

.pagination-info {
  color: var(--text-muted);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Per-page limit selector (Records per page) */
.per-page {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 12px;
  color: var(--text-muted);
  font-size: 12px;
}

.per-page select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 3px 22px 3px 8px;
  font-size: 12px;
  border-radius: 3px;
  cursor: pointer;
  outline: none;
  font-family: inherit;
}

.per-page select:focus { border-color: var(--link); }

/* ===== COLUMN HEADER FILTER BUTTON (Tickets Status/Level/Assignee) ===== */
.th-filter {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  margin-left: 6px;
  font-family: inherit;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}

.th-filter:hover { border-color: var(--text-muted); color: var(--text-white); }
.th-filter.active { color: var(--link); border-color: var(--link); }

.th-filter::after {
  content: '\25BE';
  font-size: 9px;
  opacity: .7;
  margin-left: 2px;
}

/* Reuse dropdown menu inside header */
thead th .dropdown-menu {
  text-transform: none;
  font-weight: normal;
}

thead th .dropdown {
  vertical-align: middle;
}

.pagination { display: flex; gap: 3px; }

.pg-btn {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--bg-card);
  font-size: 12px;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
}

.pg-btn:hover { border-color: var(--link); color: var(--text-white); }
.pg-btn.active { background: var(--link); color: #fff; border-color: var(--link); }
.pg-btn:disabled { opacity: .3; cursor: not-allowed; }

/* ===== CHECKBOX ===== */
.chk { width: 14px; height: 14px; cursor: pointer; accent-color: var(--link); }

/* ===== LOADING / EMPTY ===== */
.loading-box {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 50px 20px;
  color: var(--text-muted);
  gap: 10px;
}

.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--link);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.empty-box { text-align: center; padding: 50px 20px; color: var(--text-muted); }

/* ===== SECTIONS ===== */
.section { display: none; }
.section.active { display: block; }

/* ===== DASHBOARD STATS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 16px;
}

.stat-card__label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: .4px;
  margin-bottom: 6px;
}

.stat-card__value { font-size: 22px; font-weight: 700; color: var(--text-white); }

.stat-card__breakdown {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* ===== MODAL ===== */
.modal-bg {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}

.modal-bg.open { display: flex; }

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  width: 620px;
  max-width: 92vw;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 30px rgba(0,0,0,.4);
}

.modal-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-head h3 { font-size: 14px; font-weight: 600; color: var(--text-white); }

.modal-close {
  border: none;
  background: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
}

.modal-body { padding: 18px; }

.modal-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.ticket-msg {
  padding: 10px 14px;
  border-radius: 4px;
  margin-bottom: 8px;
  font-size: 13px;
}

.ticket-msg--admin { background: rgba(91,155,213,.1); }
.ticket-msg--user { background: rgba(255,255,255,.04); }

.ticket-msg__meta { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }

.reply-box {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 10px;
  font-size: 13px;
  color: var(--text);
  resize: vertical;
  min-height: 80px;
  font-family: inherit;
}

.reply-box:focus { border-color: var(--link); outline: none; }

/* ===== TOAST ===== */
.toast-box {
  position: fixed;
  bottom: 20px; right: 20px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.toast-item {
  padding: 10px 18px;
  border-radius: 4px;
  font-size: 13px;
  color: #fff;
  box-shadow: 0 3px 10px rgba(0,0,0,.3);
  animation: toastIn .25s ease;
}

.toast-item--success { background: #10b981; }
.toast-item--error { background: #ef4444; }
.toast-item--info { background: #3b82f6; }

@keyframes toastIn {
  from { transform: translateX(80px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ===== EXPORT LINK ===== */
.export-link {
  color: var(--link);
  font-size: 12px;
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
}

.export-link:hover { color: var(--link-hover); }

/* ===== SHOW TOTALS ===== */
.show-totals {
  text-align: center;
  padding: 6px;
  color: var(--link);
  font-size: 12px;
  cursor: pointer;
}

.show-totals:hover { color: var(--link-hover); }

/* ===== ADD BUTTON (PP-style dark with border) ===== */
.btn-add {
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 7px 16px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}

.btn-add:hover { border-color: var(--text-muted); color: var(--text-white); }

/* ===== SEARCH PANEL SCOPE SELECTOR ===== */
.search-group .search-panel {
  border-radius: 3px 0 0 3px !important;
  border-right: none;
  max-width: 110px;
  color: var(--text-muted);
}

.search-group .search-panel:focus { border-color: var(--link); }

/* ===== TICKET DETAIL PAGE (PP layout — centered, main column + right sidebar) ===== */
#sec-ticket-detail {
  max-width: 1100px;
  margin: 0 auto;
}

.td-back-row { margin-bottom: 12px; }
.td-back-link {
  color: #1E73D0;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.td-back-link:hover { color: #4189d8; }

.td-layout {
  display: grid;
  grid-template-columns: minmax(0, 800px) 220px;
  gap: 32px;
  align-items: start;
  justify-content: center;
}

@media (max-width: 900px) {
  .td-layout { grid-template-columns: 1fr; }
  #sec-ticket-detail { max-width: 100%; }
}

.td-main { min-width: 0; }

/* ----- Outer panel — wraps subject + body + thread (PP panel-default) ----- */
.td-panel {
  background: #222327;
  border: 1px solid #3F4149;
  border-radius: 4px;
  overflow: hidden;
}

.td-panel-head {
  background: #27282D;
  padding: 15px 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid #3F4149;
}

.td-panel-body {
  padding: 18px 20px 20px;
}

.td-subject {
  font-size: 20px;
  font-weight: 500;
  color: #DFE0E1;
  line-height: 1.3;
}
.td-id {
  font-size: 16px;
  font-weight: 500;
  color: #878EA0;
}

/* ----- Subject sub-line: Created + Status ----- */
.td-meta-row {
  display: flex;
  gap: 18px;
  font-size: 12px;
  color: #878EA0;
  padding: 0 2px 14px;
}
.td-meta-row span b { color: #DFE0E1; font-weight: 600; }

/* ----- Compose section (no extra border — outer panel already provides it) ----- */
.td-compose-card {
  background: #222327;
  border-radius: 3px;
  padding: 0;
  margin-bottom: 18px;
  border: 1px solid #3F4149;
  overflow: hidden;
}

.td-compose-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid #3F4149;
  background: #1B1C20;
  flex-wrap: wrap;
}

.td-toolbar-icons { display: inline-flex; gap: 2px; }
.td-toolbar-icons button {
  background: transparent;
  border: none;
  color: var(--text);
  width: 28px; height: 28px;
  font-size: 12px;
  cursor: pointer;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.td-toolbar-icons button:hover { background: var(--bg-row-hover); color: var(--text-white); }

.td-saved-btn {
  background: transparent;
  border: none;
  color: #1E73D0;
  padding: 5px 8px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
}
.td-saved-btn:hover { color: #4189d8; }

.td-saved-menu {
  display: none;
  position: fixed;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 300px;
  max-height: 60vh;
  z-index: 9999;
  box-shadow: 0 8px 28px rgba(0,0,0,.5);
  flex-direction: column;
  overflow: hidden;
}
.td-saved-wrap.open .td-saved-menu { display: flex; }
#tdSavedList, #tdAiList {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
  overscroll-behavior: contain;
}
.td-saved-wrap { position: relative; }
.td-saved-search-row {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-input);
}
.td-saved-search-row input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 10px 14px;
  font-size: 13px;
  outline: none;
  font-family: inherit;
}
.td-saved-gear {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  color: var(--text-muted);
  text-decoration: none;
  cursor: pointer;
  font-size: 14px;
}
.td-saved-gear:hover { color: var(--text-white); }
.td-saved-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-bottom: 1px solid rgba(255,255,255,.04);
  color: var(--text);
  padding: 10px 14px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.td-saved-menu button:last-child { border-bottom: none; }
.td-saved-menu button:hover { background: var(--bg-row-hover); color: var(--text-white); }
.td-saved-menu .td-saved-add {
  color: var(--link);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  display: block;
  padding: 10px 14px;
  font-size: 12px;
  text-decoration: none;
}
.td-saved-menu .td-saved-add:hover { background: var(--bg-row-hover); }

/* Group the AI + saved-reply dropdowns on the right side of the toolbar so
   the flex parent doesn't stretch them apart. */
.td-toolbar-right { display: flex; gap: 10px; align-items: center; }

/* Split button — main action on the left, small caret on the right, visually
   welded together so they read as one control. */
.td-split-btn { display: inline-flex; }
.td-split-btn .td-saved-btn { border-radius: 0; }
.td-split-btn .td-split-main { border-top-left-radius: 3px; border-bottom-left-radius: 3px; padding-right: 10px; }
.td-split-btn .td-split-caret {
  border-top-right-radius: 3px;
  border-bottom-right-radius: 3px;
  border-left: 1px solid rgba(255,255,255,.12);
  padding: 0 10px;
}

/* Contenteditable reply box (PP-style rich text via execCommand) */
.td-textarea {
  width: 100%;
  background: #222327;
  border: none;
  padding: 16px 18px;
  font-size: 14px;
  color: #DFE0E1;
  min-height: 170px;
  height: 200px;
  max-height: 80vh;
  overflow-y: auto;
  font-family: inherit;
  line-height: 1.55;
  display: block;
  outline: none;
}
.td-resize-handle {
  height: 8px;
  cursor: ns-resize;
  background: transparent;
  position: relative;
  user-select: none;
}
.td-resize-handle::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
}
.td-resize-handle:hover::before { background: var(--accent); }
.td-textarea[contenteditable=true]:empty::before {
  content: attr(data-placeholder);
  color: #6b7280;
  pointer-events: none;
}
.td-textarea p { margin: 0 0 6px; }
.td-textarea ul, .td-textarea ol { margin: 0 0 6px 22px; padding: 0; }
.td-textarea b, .td-textarea strong { color: #ffffff; }

.td-attach-link {
  color: #DFE0E1;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.td-attach-link:hover { color: #1E73D0; }

.td-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  background: #222327;
  flex-wrap: wrap;
}

.td-assignee-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 12px;
  border-radius: 3px;
  font-size: 12px;
  cursor: pointer;
}
.td-assignee-pill:hover { border-color: var(--link); }

.td-lock-notice {
  text-align: center;
  background: rgba(0,0,0,.25);
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: 16px;
  font-size: 12px;
  margin: 0 auto 14px;
  width: fit-content;
}

/* ----- Messages thread ----- */
.td-thread {
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.td-msg {
  background: transparent;
  padding: 0;
  border: none;
  border-radius: 0;
  width: 100%;
  position: relative;
}
.td-msg-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  margin-top: 4px;
  opacity: 0.55;
  transition: opacity .15s;
}
.td-msg:hover .td-msg-actions,
.td-msg-actions:hover { opacity: 1; }
.td-msg-ai-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s, color .15s, border-color .15s;
}
.td-msg-ai-btn:hover {
  background: var(--bg-row-hover);
  color: var(--text-white);
  border-color: var(--accent);
}
.td-msg-ai-btn i { margin-right: 3px; font-size: 10px; }
.td-msg-ai-result {
  margin-top: 6px;
  padding: 10px 12px;
  background: rgba(255,255,255,.04);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  font-size: 13px;
  line-height: 1.5;
}
.td-msg-ai-label {
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.td-msg-ai-text { color: var(--text); }

.td-msg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: #878EA0;
  margin-bottom: 8px;
  padding: 0 4px;
  width: 100%;
  gap: 16px;
}

.td-msg-author {
  font-weight: 500;
  color: #DFE0E1;
  font-size: 14px;
  flex-shrink: 0;
}

.td-msg-body {
  font-size: 14px;
  line-height: 1.6;
  padding: 12px 16px;
  border-radius: 3px;
  word-break: break-word;
  position: relative;
}

/* Chat bubble tail — small triangle in the upper-left, PP-style */
.td-msg-body::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 14px;
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
}

/* Admin message — solid blue card */
.td-msg--admin .td-msg-body {
  background: #1E73D0;
  color: #ffffff;
}
.td-msg--admin .td-msg-body::before { border-bottom: 7px solid #1E73D0; }
.td-msg--admin .td-msg-body p,
.td-msg--admin .td-msg-body strong,
.td-msg--admin .td-msg-body b { color: #ffffff; }

/* User message — distinct dark card with stronger contrast against the page bg */
.td-msg--user .td-msg-body {
  background: #2A2B30;
  border: 1px solid #3F4149;
  color: #DFE0E1;
}
.td-msg--user .td-msg-body::before {
  border-bottom: 7px solid #2A2B30;
  top: -7px;
}

.td-msg-body p,
.td-msg-body div { margin: 0 0 6px; }
.td-msg-body p:last-child,
.td-msg-body div:last-child { margin-bottom: 0; }
.td-msg-body ul,
.td-msg-body ol {
  margin: 4px 0 6px;
  padding-left: 26px;
}
.td-msg-body li { margin: 2px 0; }
.td-msg-body hr { border: 0; border-top: 1px solid rgba(255,255,255,.15); margin: 10px 0; }
.td-msg-body b, .td-msg-body strong { color: var(--text-white); }

/* Attachments inside a message body — plain file name links (PP-style) */
.td-attach-list {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.td-attach-link-msg {
  font-size: 13px;
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(255,255,255,.4);
  word-break: break-all;
}
.td-attach-link-msg:hover { text-decoration-color: currentColor; }

.td-msg-actions {
  margin-top: 6px;
  padding: 0 4px;
  font-size: 11px;
  display: flex;
  gap: 12px;
  color: var(--link);
}
.td-msg-actions a { color: var(--link); cursor: pointer; }
.td-msg-actions a:hover { color: var(--link-hover); }

.td-msg-unread {
  text-align: right;
  font-size: 11px;
  color: #878EA0;
  margin-top: 6px;
  padding: 0 4px;
  font-style: italic;
  opacity: .75;
}

/* ----- Sidebar (right column) ----- */
.td-sidebar {
  background: transparent;
  padding: 0;
}
.td-sidebar .td-user-name {
  display: block;
  color: #DFE0E1;
  font-size: 16px;
  font-weight: 500;
  text-decoration: underline;
  margin-bottom: 14px;
}
.td-sidebar .td-user-links {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.td-sidebar .td-user-links a {
  display: block;
  color: #1E73D0;
  font-size: 14px;
  padding: 7px 0;
  border: none;
}
.td-sidebar .td-user-links a:hover { color: #4189d8; }

/* ============================================================ */
/* AUTH OVERLAY (Login + Setup)                                   */
/* ============================================================ */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: #0a0c10;
  z-index: 5000;
  display: none;
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
  overflow: hidden;
}
.auth-overlay.open { display: flex; }

.auth-split {
  display: flex;
  width: 100%;
  height: 100%;
  min-height: 100vh;
}

/* ---------- LEFT: animated visual ---------- */
.auth-visual {
  flex: 0 0 55%;
  position: relative;
  overflow: hidden;
  background: radial-gradient(ellipse at 30% 40%, #151a24 0%, #0a0c10 70%);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* animated gradient mesh blobs */
.auth-gradient-mesh {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.mesh-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: .45;
  mix-blend-mode: screen;
  animation: meshFloat 18s ease-in-out infinite;
}
.mesh-blob--1 {
  width: 520px; height: 520px;
  top: -80px; left: -100px;
  background: radial-gradient(circle, #1E73D0 0%, transparent 70%);
  animation-delay: 0s;
}
.mesh-blob--2 {
  width: 460px; height: 460px;
  bottom: -60px; left: 40%;
  background: radial-gradient(circle, #7c3aed 0%, transparent 70%);
  animation-delay: -6s;
}
.mesh-blob--3 {
  width: 380px; height: 380px;
  top: 30%; right: -80px;
  background: radial-gradient(circle, #06b6d4 0%, transparent 70%);
  animation-delay: -12s;
}
@keyframes meshFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(40px, -30px) scale(1.08); }
  66%      { transform: translate(-30px, 40px) scale(.95); }
}

.auth-visual-inner {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 56px 64px;
  width: 100%;
  max-width: 640px;
}

/* Logo */
.auth-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 40px;
}
.auth-logo-mark {
  width: 44px; height: 44px;
  border-radius: 10px;
  background: linear-gradient(135deg, #1E73D0, #7c3aed);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  box-shadow: 0 8px 24px rgba(30,115,208,.4);
}
.auth-logo-text {
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: .3px;
}

/* ===== Team stage — characters ===== */
.team-stage {
  position: relative;
  width: 100%;
  height: 360px;
  margin-bottom: 24px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0;
  padding-bottom: 20px;
}

/* Ground shadow */
.team-ground {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 500px;
  max-width: 90%;
  height: 14px;
  background: radial-gradient(ellipse at center, rgba(0,0,0,.5) 0%, transparent 70%);
  filter: blur(2px);
}

.team-char {
  position: relative;
  display: flex;
  align-items: flex-end;
}
.team-char svg {
  display: block;
  height: 100%;
  filter: drop-shadow(0 10px 24px rgba(0,0,0,.5));
  overflow: visible;
}

/* ---- dramatic per-character choreography ---- */
.team-char--1 {
  width: 140px; height: 200px;
  z-index: 2;
  animation: bounceLead 2.4s ease-in-out infinite;
}
.team-char--2 {
  width: 100px; height: 140px;
  margin-left: -10px;
  z-index: 3;
  animation: excitedHop 1.1s ease-in-out infinite;
}
.team-char--3 {
  width: 190px; height: 110px;
  margin-left: -45px;
  z-index: 1;
  animation: rollSway 2.8s ease-in-out infinite;
}
.team-char--4 {
  width: 80px; height: 120px;
  margin-left: -20px;
  z-index: 2;
  animation: jumpJoy 1.8s ease-in-out infinite;
  transform-origin: bottom center;
}

@keyframes bounceLead {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  25%      { transform: translateY(-8px) rotate(0deg); }
  50%      { transform: translateY(0) rotate(2deg); }
  75%      { transform: translateY(-4px) rotate(0deg); }
}
@keyframes excitedHop {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  45%      { transform: translateY(-24px) scale(0.95, 1.05); }
  55%      { transform: translateY(-24px) scale(0.95, 1.05); }
  70%      { transform: translateY(0) scale(1.1, 0.9); }
  85%      { transform: translateY(0) scale(1, 1); }
}
@keyframes rollSway {
  0%, 100% { transform: translateX(0) rotate(-3deg); }
  50%      { transform: translateX(10px) rotate(4deg); }
}
@keyframes jumpJoy {
  0%, 100% { transform: translateY(0) scaleY(1); }
  30%      { transform: translateY(0) scaleY(0.85); }
  55%      { transform: translateY(-40px) scaleY(1.05) rotate(-5deg); }
  80%      { transform: translateY(-10px) scaleY(1) rotate(5deg); }
}

/* lead's waving arm */
.arm--lead {
  animation: waveArm 1.6s ease-in-out infinite;
}
@keyframes waveArm {
  0%, 100% { transform: rotate(-20deg); }
  50%      { transform: rotate(25deg); }
}

/* yellow char's arms flailing */
.arm--yellow-l { animation: flailL .9s ease-in-out infinite; transform-origin: right center; }
.arm--yellow-r { animation: flailR .9s ease-in-out infinite; transform-origin: left center; }
@keyframes flailL {
  0%, 100% { transform: rotate(10deg); }
  50%      { transform: rotate(-40deg); }
}
@keyframes flailR {
  0%, 100% { transform: rotate(-10deg); }
  50%      { transform: rotate(40deg); }
}

/* blinking eyes */
.team-char .eye {
  transform-origin: center;
  animation: blink 4s infinite;
}
.team-char--2 .pupil { animation: lookAround 2s ease-in-out infinite; }

@keyframes blink {
  0%, 40%, 42%, 100% { transform: scaleY(1); }
  41%                { transform: scaleY(0.1); }
}
@keyframes lookAround {
  0%, 100% { transform: translate(0, 0); }
  25%      { transform: translate(-3px, -2px); }
  50%      { transform: translate(0, -3px); }
  75%      { transform: translate(3px, -2px); }
}

/* ---- Flying props: tickets & coins ---- */
.prop {
  position: absolute;
  pointer-events: none;
}
.prop--ticket {
  width: 60px;
  height: 36px;
}
.prop--ticket svg { width: 100%; height: 100%; filter: drop-shadow(0 6px 12px rgba(0,0,0,.5)); }

.prop--t1 {
  top: 20px; left: 10%;
  animation: ticketFly1 4s ease-in-out infinite;
}
.prop--t2 {
  top: 60px; right: 15%;
  animation: ticketFly2 3.5s ease-in-out infinite;
  animation-delay: -1s;
}
.prop--t3 {
  top: 30px; left: 50%;
  animation: ticketFly3 4.5s ease-in-out infinite;
  animation-delay: -2s;
}

@keyframes ticketFly1 {
  0%, 100% { transform: translate(0, 0) rotate(-8deg); }
  25%      { transform: translate(30px, -12px) rotate(6deg); }
  50%      { transform: translate(60px, 6px) rotate(-4deg); }
  75%      { transform: translate(30px, 18px) rotate(8deg); }
}
@keyframes ticketFly2 {
  0%, 100% { transform: translate(0, 0) rotate(6deg) scale(1); }
  50%      { transform: translate(-40px, 20px) rotate(-10deg) scale(1.1); }
}
@keyframes ticketFly3 {
  0%, 100% { transform: translate(0, 0) rotate(-12deg); }
  50%      { transform: translate(20px, 30px) rotate(15deg); }
}

.prop--coin {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fde68a, #f59e0b 60%, #b45309);
  border: 2px solid #92400e;
  color: #7c2d12;
  font-weight: 900;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 12px rgba(0,0,0,.5), inset 0 -2px 4px rgba(0,0,0,.2);
}
.prop--c1 { top: 90px; left: 25%; animation: coinSpin 2.2s linear infinite; }
.prop--c2 { top: 50px; right: 28%; animation: coinBounce 1.6s ease-in-out infinite; }
.prop--c3 { top: 120px; left: 60%; animation: coinSpin 2.8s linear infinite reverse; animation-delay: -.5s; }

@keyframes coinSpin {
  0%   { transform: rotateY(0) translateY(0); }
  50%  { transform: rotateY(180deg) translateY(-14px); }
  100% { transform: rotateY(360deg) translateY(0); }
}
@keyframes coinBounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-20px) scale(1.1); }
}

/* Speech bubble floating above the team */
.team-bubble {
  position: absolute;
  top: -10px;
  left: 50%;
  background: #fff;
  color: #0a0c10;
  padding: 10px 16px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
  opacity: 0;
  transform: translate(-50%, -4px);
  transition: opacity .3s, transform .3s;
  z-index: 10;
}
.team-bubble.show {
  opacity: 1;
  animation: bubblePop .3s cubic-bezier(.17,.89,.32,1.28);
}
.team-bubble-tail {
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 7px solid #fff;
}
@keyframes bubblePop {
  0%   { transform: translate(-50%, 4px) scale(.6); }
  60%  { transform: translate(-50%, -6px) scale(1.08); }
  100% { transform: translate(-50%, -4px) scale(1); }
}

.auth-tagline { margin-top: auto; }
.auth-tagline-title {
  color: #fff;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 8px;
}
.auth-tagline-sub {
  color: #6b7280;
  font-size: 13px;
  letter-spacing: .3px;
}

/* ---------- RIGHT: form ---------- */
.auth-form-wrap {
  flex: 1;
  background: #0f1116;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.auth-card {
  background: transparent;
  border: none;
  padding: 0;
  width: 100%;
  max-width: 380px;
  box-shadow: none;
}

.auth-card h2 {
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 8px;
  letter-spacing: -.3px;
}

.auth-card p {
  color: #6b7280;
  font-size: 13px;
  margin-bottom: 32px;
}

.auth-field { margin-bottom: 16px; }
.auth-field label {
  display: block;
  font-size: 11px;
  color: #6b7280;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .6px;
  font-weight: 600;
}
.auth-field input {
  width: 100%;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 14px;
  color: #fff;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, background .15s;
}
.auth-field input:focus {
  border-color: #1E73D0;
  background: rgba(255,255,255,.05);
}

.auth-error {
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.3);
  color: #ef4444;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12px;
  margin-bottom: 14px;
  display: none;
}
.auth-error.show { display: block; }

.auth-card .btn-primary {
  width: 100%;
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  margin-top: 10px;
  background: linear-gradient(135deg, #1E73D0, #2b8eff);
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  transition: transform .1s, box-shadow .15s;
  box-shadow: 0 8px 20px rgba(30,115,208,.3);
}
.auth-card .btn-primary:hover {
  box-shadow: 0 10px 28px rgba(30,115,208,.45);
  transform: translateY(-1px);
}
.auth-card .btn-primary:active { transform: translateY(0); }

/* Responsive */
@media (max-width: 900px) {
  .auth-visual { display: none; }
  .auth-form-wrap { flex: 1; }
}

/* ============================================================ */
/* SETTINGS SECTION (sub-nav + sub-pages)                          */
/* ============================================================ */
.settings-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 16px;
  align-items: start;
}

.settings-nav {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px;
}

.settings-nav button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-radius: 3px;
  color: var(--text-muted);
  padding: 9px 12px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  margin-bottom: 1px;
}

.settings-nav button:hover { color: var(--text-white); background: var(--bg-row-hover); }
.settings-nav button.active {
  background: var(--link);
  color: #fff;
  font-weight: 600;
}

.settings-pane {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 20px;
  display: none;
}
.settings-pane.active { display: block; }

.settings-pane h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-white);
  margin-bottom: 4px;
}
.settings-pane .pane-desc {
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 18px;
}

.settings-pane table {
  margin-bottom: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
}
.settings-pane thead th {
  background: var(--bg-header);
  padding: 9px 12px;
}
.settings-pane tbody td { padding: 9px 12px; }

.row-actions { display: inline-flex; gap: 6px; }
.row-actions button {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 3px 9px;
  font-size: 11px;
  border-radius: 3px;
  cursor: pointer;
  font-family: inherit;
}
.row-actions button:hover { color: var(--text-white); border-color: var(--link); }
.row-actions .danger:hover { color: #ef4444; border-color: #ef4444; }

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}
.field-grid .full { grid-column: 1 / -1; }

.field-grid label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: .4px;
}

/* Checkbox-style row inside a field-grid: override the default label rules
   (block / uppercase / margin) and the full-width input rule so the box and
   its text sit inline like a normal checkbox. */
.field-grid label.field-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  color: var(--text);
  margin: 0;
}
.field-grid label.field-checkbox input[type="checkbox"] {
  width: auto;
  margin: 0;
  padding: 0;
  flex: none;
}
.field-grid input, .field-grid select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text);
  font-family: inherit;
  outline: none;
}
.field-grid input:focus, .field-grid select:focus { border-color: var(--link); }

.color-swatch {
  display: inline-block;
  width: 14px; height: 14px;
  border-radius: 3px;
  vertical-align: middle;
  margin-right: 6px;
}

.section-divider {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 18px 0;
}

.staff-keys {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
.staff-keys .skey {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 8px 10px;
  min-width: 0; /* let flex children shrink (Safari fix) */
}
/* Checkbox rows: fix checkbox size, let the label text fill the rest */
.staff-keys .skey input[type="checkbox"] {
  width: auto;
  flex: none;
  margin: 0;
  padding: 0;
}
.staff-keys .skey > span {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}
.staff-keys .skey-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.staff-keys .skey input[type="text"],
.staff-keys .skey input[type="password"] {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 6px 8px;
  font-size: 11px;
  color: var(--text);
  font-family: monospace;
  outline: none;
}

.note-box {
  background: rgba(91,155,213,.07);
  border: 1px solid rgba(91,155,213,.25);
  border-radius: 3px;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text);
  margin-bottom: 14px;
}
.note-box strong { color: var(--link); }

/* Toggle row inside form (label + checkbox + helper text) */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  text-transform: none !important;
  letter-spacing: 0 !important;
  font-size: 13px !important;
  color: var(--text) !important;
}
.toggle-row input[type=checkbox] { width: 16px; height: 16px; margin: 0; accent-color: var(--link); }
.toggle-row small { color: var(--text-muted); font-size: 11px; margin-left: 6px; }

/* Status pill — clickable in panels table */
.status-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .3px;
  cursor: pointer;
  border: 1px solid transparent;
  user-select: none;
}
.status-pill--on  { background: rgba(16,185,129,.15); color: #10b981; border-color: rgba(16,185,129,.35); }
.status-pill--off { background: rgba(239,68,68,.13);  color: #ef4444; border-color: rgba(239,68,68,.35); }
.status-pill:hover { filter: brightness(1.15); }

/* ============================================================ */
/* PANEL/STAFF FORM MODAL                                          */
/* ============================================================ */
.cfg-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 2500;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 50px 20px;
  overflow-y: auto;
}
.cfg-modal.open { display: flex; }

.cfg-modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 560px;
  max-width: 100%;
  box-shadow: 0 10px 40px rgba(0,0,0,.5);
}
.cfg-modal-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.cfg-modal-head h3 { font-size: 15px; font-weight: 600; color: var(--text-white); margin: 0; }
.cfg-modal-body { padding: 18px; }
.cfg-modal-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.pane-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 10px;
}

/* ============================================================ */
/* MOBILE / RESPONSIVE                                             */
/* ============================================================ */
@media (max-width: 1024px) {
  /* Status tabs and filter chips wrap (PP-style) instead of scroll */
  .filter-chips { flex-wrap: wrap; }
  .status-tabs { flex-wrap: wrap; gap: 12px 16px; }
}

@media (max-width: 900px) {
  /* Hamburger menu — hide tabs by default, toggle to dropdown */
  .nav-toggle { display: inline-flex; }
  .topbar { padding: 0 12px; }
  .topbar__tabs {
    display: none;
    position: absolute;
    top: 42px; left: 0; right: 0;
    background: var(--topbar);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    height: auto;
    padding: 6px 0;
    z-index: 999;
    align-items: stretch;
  }
  .topbar__tabs.open { display: flex; }
  .topbar__tab {
    height: 40px;
    padding: 0 16px;
    border-bottom: none;
    border-left: 2px solid transparent;
    justify-content: flex-start;
  }
  .topbar__tab.active {
    border-bottom: none;
    border-left-color: var(--link);
    background: rgba(30,115,208,.06);
  }
  .topbar__panels {
    border-left: none;
    padding-left: 0;
    margin-left: 0;
    border-top: 1px solid var(--border);
    padding: 8px 12px;
    flex-wrap: wrap;
  }
}

@media (max-width: 768px) {
  body { font-size: 13px; }

  .topbar { gap: 8px; }
  .topbar__right { gap: 6px; }
  .topbar__icons { padding-right: 6px; margin-right: 2px; gap: 0; }
  .search-group { min-width: 0; }
  .search-group input { width: 110px; min-width: 0; }
  /* "All panels" text needs ~88px to render without truncation. 70px cut it
     to "All pa" on mobile. Keep globalSearchField hidden (space-saver). */
  .search-group .search-panel { max-width: 100px; min-width: 70px; }
  .search-group select#globalSearchField { display: none; }  /* hide field selector on tight screens */

  /* Status tabs — horizontal scroll instead of 5-row wrap on Orders */
  .status-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    scrollbar-width: thin;
  }
  .status-tabs::-webkit-scrollbar { height: 3px; }
  .status-tabs::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
  .status-tab { flex-shrink: 0; white-space: nowrap; }

  /* Action bar wrap */
  .action-bar { flex-wrap: wrap; gap: 8px; }
  .action-bar__right { width: auto; }

  /* Stack settings layout */
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav {
    display: flex;
    gap: 4px;
    padding: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    mask-image: linear-gradient(to right, black 0, black calc(100% - 20px), transparent 100%);
    -webkit-mask-image: linear-gradient(to right, black 0, black calc(100% - 20px), transparent 100%);
  }
  .settings-nav button { white-space: nowrap; padding: 8px 14px; flex-shrink: 0; }
  .pane-toolbar { flex-wrap: wrap; }

  /* Field grid stacks */
  .field-grid { grid-template-columns: 1fr; }
  .staff-keys { grid-template-columns: 1fr; }

  /* Modal full width */
  .cfg-modal { padding: 12px; align-items: stretch; }
  .cfg-modal-card { width: 100%; }

  /* Ticket detail */
  .td-header { padding: 12px; gap: 8px; }
  .td-meta { margin-left: 0; flex-basis: 100%; }
  .td-subject-bar { padding: 12px; flex-wrap: wrap; }
  .td-thread { padding: 12px; }
  .td-compose { padding: 12px; }

  /* Tables: scroll horizontally; padding tightened */
  thead th { padding: 9px 10px; font-size: 12px; }
  tbody td { padding: 9px 10px; font-size: 12.5px; }
}

@media (max-width: 480px) {
  .topbar__tab { padding: 0 12px; font-size: 13px; }
  .topbar__panel-chip { padding: 2px 7px; font-size: 10px; }
  .icon-btn { width: 28px; height: 28px; }
  .search-group__btn { padding: 0 9px; }
  .search-group input { width: 100px; }
  .auth-card { padding: 24px 18px; }

  /* On very small screens, keep all columns visible via horizontal scroll.
     Tighter padding keeps rows compact. */

  /* Settings → Panels: hide URL on tiny screens, keep Status badge visible */
  #panelsTbody tr td:nth-child(3) { display: none; }
  #pane-panels table thead th:nth-child(3) { display: none; }

  /* Tighter ticket detail */
  .td-textarea { min-height: 90px; }
  .td-saved-menu { width: 100%; left: 0; }
  .td-msg { padding: 9px 10px; }
  .td-msg-body { font-size: 12.5px; }

  /* Modal padding tighter */
  .cfg-modal { padding: 8px; }
  .cfg-modal-body { padding: 14px; }
  .cfg-modal-foot { padding: 10px 14px; }

  /* Topbar tickets badge slightly bigger so it's tappable */
  .topbar__tab-badge { padding: 2px 7px; font-size: 11px; }

  /* AI provider cards stack on mobile */
  #aiProviderCards { grid-template-columns: 1fr !important; }
}

/* ============================================================ */
/* MOBILE IMPROVEMENTS — touch targets, iOS zoom fix, scrolling  */
/* ============================================================ */
@media (max-width: 768px) {
  /* Prevent iOS from zooming in on focus — inputs must be 16px+ */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="url"],
  input[type="search"],
  input[type="tel"],
  input[type="date"],
  textarea,
  select,
  .td-textarea {
    font-size: 16px !important;
  }
  /* But compose editors / small inputs that don't trigger zoom can stay smaller */
  .sheet-cell-inner, .task-inline-input { font-size: 15px !important; }

  /* Tap targets — at least 40px for comfortable tapping */
  .btn, .actions-btn {
    min-height: 38px;
    padding: 8px 14px;
    font-size: 13px;
  }
  .btn-sm { min-height: 32px; }
  .nb-check, .sheet-check, .task-check { min-width: 24px; min-height: 24px; }
  .nb-delete, .task-delete { min-width: 32px; min-height: 32px; }

  /* Horizontally-scrollable tables wrap inside pp-table-wrap */
  .pp-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-scroll { -webkit-overflow-scrolling: touch; }
  /* Prevent wide tables from collapsing — keep their natural width and
     let the user scroll horizontally instead of producing 400px-tall rows. */
  .table-scroll > table { min-width: max-content; }

  /* Ticket detail layout stacks on mobile */
  .td-layout { flex-direction: column; }
  .td-main { width: 100%; min-width: 0; }
  .td-sidebar {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border);
    padding-top: 14px;
    margin-top: 14px;
  }

  /* Tasks notebook — sidebar becomes a horizontal pill row on mobile */
  .tasks-sidebar {
    flex: 0 0 auto;
    flex-direction: row;
    overflow-x: visible;
    padding: 4px;
    gap: 4px;
    width: 100%;
    margin-bottom: 10px;
    justify-content: space-between;
  }
  .tasks-list-btn {
    padding: 10px 12px;
    flex: 1;
    justify-content: center;
    min-width: 0;
  }
  .tasks-list-btn .count { display: none; }

  /* Service Reports tabs wrap nicely */
  .sr-toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .sr-tabs { gap: 14px; overflow-x: auto; padding-bottom: 4px; }
  .sr-search { max-width: none; width: 100%; }

  /* Services page filters wrap */
  #sec-services .tasks-panel-filter { flex-wrap: wrap; }

  /* Notebook page tabs scroll horizontally */
  .nb-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Reply toolbar buttons — larger tap targets */
  .td-toolbar button { min-width: 36px; min-height: 36px; }
  .td-saved-btn { min-height: 36px; }

  /* Pagination wraps on mobile */
  .pagination-bar { flex-wrap: wrap; gap: 8px; }
  .pagination { flex-wrap: wrap; }

  /* Modal footer buttons full-width on very tight screens */
  .cfg-modal-foot { flex-wrap: wrap; }
  .cfg-modal-foot .btn { flex: 1 1 auto; justify-content: center; }

  /* Body padding tighter on mobile */
  .main { padding: 12px 10px; }
}

@media (max-width: 480px) {
  /* Tighter status tabs on phone */
  .status-tabs { gap: 8px 12px; font-size: 12px; }

  /* Panel chips in topbar: smaller */
  .topbar__panels { gap: 4px; }
  .topbar__panel-chip { min-width: 28px; height: 20px; line-height: 20px; }

  /* Tasks tabs: hide icon on very small, keep label only */
  .tasks-list-btn i { display: none; }
  .tasks-list-btn { padding: 8px 12px; }

  /* Ticket thread body text */
  .td-msg { padding: 10px 12px; }
  .td-msg-body { font-size: 13px; line-height: 1.5; }
  .td-msg-ai-result { font-size: 12.5px; padding: 8px 10px; }

  /* Reply composer minimum height lower */
  .td-textarea { min-height: 100px; height: 120px; }

  /* Sheet cells wider scroll on tiny screens */
  .sheet-cell { min-width: 120px; max-width: 220px; }

  /* Per-message AI buttons always visible on mobile (no hover) */
  .td-msg-actions { opacity: 1 !important; }
}

/* ===== AI SETTINGS — provider cards ===== */
.ai-field { margin-top: 16px; }
.ai-field-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 6px;
}
.ai-field input {
  width: 100%;
  box-sizing: border-box;
}
.ai-current {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-muted);
  user-select: none;
}
.ai-current-empty { cursor: default; }
.ai-current-key {
  font-family: 'Courier New', Courier, monospace;
  word-break: break-all;
  color: var(--text);
}
.ai-eye-toggle {
  display: inline-block;
  margin-left: 8px;
  cursor: pointer;
  font-size: 12px;
  opacity: .5;
  transition: opacity .15s;
}
.ai-eye-toggle:hover { opacity: 1; }

/* ===== AI Analiz button ===== */
.td-ai-analyze-btn {
  color: #e8a020 !important;
  border-color: transparent !important;
  background: transparent !important;
  font-weight: 600;
}
.td-ai-analyze-btn:hover {
  color: #f0b840 !important;
  background: rgba(232,160,32,.1) !important;
}

/* ===== AI Analysis result panel ===== */
.td-ai-analysis {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card-bg);
  margin-top: 8px;
  overflow: hidden;
}
.td-ai-analysis-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,.15);
}
.td-ai-analysis-header button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 0;
}
.td-ai-analysis-header button:hover { color: var(--text); }
.td-ai-analysis-body {
  padding: 14px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
}

/* ===== Microphone button ===== */
.td-mic-btn {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 15px;
  padding: 4px 6px;
  border-radius: 4px;
  transition: color .15s, background .15s;
  z-index: 2;
}
.td-mic-btn:hover { color: var(--text); background: rgba(255,255,255,.06); }
.td-mic-btn.recording {
  color: #e53935;
  animation: mic-pulse 1s infinite;
}
@keyframes mic-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}
