:root {
  /* Lexogenix brand theme (from lexogenix.com) */
  --fp-bg: #f4f6fa;
  --fp-panel: #ffffff;
  --fp-side: #0f1830;
  --fp-side-2: #1a2744;
  --fp-accent: #d4920a;
  --fp-accent-2: #e8a317;
  --fp-link: #1a2744;
  --fp-text: #1a2744;
  --fp-muted: #5a6a85;
  --fp-line: #e8edf6;
  --fp-ok: #047857;
  --fp-danger: #b91c1c;
  --radius: 8px;
  --font: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font-family: var(--font); background: var(--fp-bg); color: var(--fp-text); font-size: 14px; }
a { color: var(--fp-link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* LOGIN */
.login-body { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.login-hero {
  background: linear-gradient(160deg, #0f1830, #1a2744 55%, #243556);
  color: #ecf0f1; padding: 3rem; display: flex; flex-direction: column; justify-content: center;
}
.login-hero h1 { font-size: 2.1rem; margin: 0 0 .75rem; font-weight: 700; }
.login-hero p { color: #93a0b8; line-height: 1.6; max-width: 420px; }
.login-hero ul { list-style: none; padding: 0; margin: 1.5rem 0 0; }
.login-hero li { margin: .5rem 0; padding-left: 1.2rem; position: relative; color: #ecf0f1; }
.login-hero li::before { content: "✓"; position: absolute; left: 0; color: var(--fp-accent); font-weight: 700; }
.brand-logo { height: 36px; width: auto; display: block; }
.brand-logo.lg { height: 42px; }
.sidebar .brand-logo { height: 28px; filter: brightness(1.05); }
.tenant-banner {
  background: #fff8e8; border: 1px solid #f0d48a; color: #7a5a00;
  padding: .55rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .88rem;
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.topbar select.tenant-switch {
  min-width: 180px; padding: .4rem .55rem; font-size: .85rem;
}
.login-card-wrap { display: grid; place-items: center; padding: 2rem; background: #fff; }
.login-panel { width: min(400px, 100%); }
.login-panel h2 { margin: 0 0 .3rem; font-size: 1.45rem; }
.login-panel .sub { color: var(--fp-muted); margin: 0 0 1.25rem; }
.brand-row { display: flex; align-items: center; gap: .7rem; margin-bottom: 1.25rem; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 8px; display: grid; place-items: center;
  background: var(--fp-accent); color: #fff; font-weight: 800; font-size: 1rem;
}
.login-form label, .form-grid label { display: grid; gap: .35rem; margin-bottom: .9rem; font-size: .82rem; color: var(--fp-muted); font-weight: 600; }
input, select, textarea {
  width: 100%; padding: .65rem .75rem; border: 1px solid var(--fp-line); border-radius: var(--radius);
  font: inherit; background: #fff; color: var(--fp-text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--fp-accent); box-shadow: 0 0 0 3px rgba(212,146,10,.22); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  border: 1px solid transparent; border-radius: var(--radius); padding: .55rem .95rem;
  font: inherit; font-weight: 600; cursor: pointer; background: #fff; color: var(--fp-text);
}
.btn.primary { background: var(--fp-accent); color: #fff; }
.btn.primary:hover { background: var(--fp-accent-2); }
.btn.ghost { border-color: var(--fp-line); color: var(--fp-muted); }
.btn.danger { background: #fdecea; color: var(--fp-danger); border-color: #f5c6cb; }
.btn.sm { padding: .3rem .55rem; font-size: .78rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.alert { padding: .7rem .9rem; border-radius: var(--radius); margin-bottom: .9rem; font-size: .9rem; }
.alert.error { background: #fdecea; border: 1px solid #f5c6cb; color: #922b21; }
.alert.success { background: #eafaf1; border: 1px solid #abebc6; color: #1e8449; }
.alert.info { background: #ebf5fb; border: 1px solid #aed6f1; color: #1a5276; }
.toast-wrap { position: fixed; top: 16px; right: 16px; z-index: 9999; display: grid; gap: .5rem; }
.toast { min-width: 260px; max-width: 380px; padding: .75rem 1rem; border-radius: 8px; background: #2c3e50; color: #fff; box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.toast.ok { background: #1e8449; }
.toast.err { background: #922b21; }

/* APP */
.app-body { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--fp-side); color: #ecf0f1; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow: auto;
}
.brand { display: flex; gap: .65rem; align-items: center; padding: 1rem .9rem; background: var(--fp-side-2); }
.brand .brand-logo { height: 32px; width: auto; max-width: 160px; object-fit: contain; }
.brand strong { display: block; color: #fff; font-size: .95rem; }
.brand small { color: #95a5a6; font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; }
.nav-section {
  color: #7f8c8d; font-size: .65rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; padding: .85rem .9rem .25rem;
}
.sidebar nav a {
  display: block; color: #bdc3c7; padding: .45rem .9rem; font-weight: 500; font-size: .9rem;
  border-left: 3px solid transparent;
}
.sidebar nav a:hover, .sidebar nav a.active {
  background: rgba(212,146,10,.14); color: #fff; border-left-color: var(--fp-accent); text-decoration: none;
}
.sidebar-foot { margin-top: auto; border-top: 1px solid rgba(255,255,255,.08); padding: .9rem; }
.who strong { display: block; color: #fff; font-size: .88rem; }
.who small { color: #95a5a6; font-size: .75rem; }

.main-wrap { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: #fff; border-bottom: 1px solid var(--fp-line); padding: .65rem 1.25rem;
  display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 30;
  gap: 1rem;
}
.topbar .crumb { color: var(--fp-muted); }
.topbar .crumb strong { color: var(--fp-text); }
.topbar-right { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; justify-content: flex-end; }

/* Icon action buttons — label only on hover (title/tooltip) */
.btn-icon {
  width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid #e0e0e0; border-radius: 3px; background: #fff; color: #444;
  font-size: .85rem; cursor: pointer; line-height: 1; text-decoration: none; padding: 0;
}
.btn-icon i { pointer-events: none; }
.btn-icon:hover { background: #f4f6fa; border-color: var(--fp-accent); color: var(--fp-accent); text-decoration: none; }
.btn-icon.danger { color: var(--fp-danger); border-color: #f5c6cb; background: #fdecea; }
.btn-icon.danger:hover { background: #fadbd8; }
.btn-icon.primary { background: var(--fp-accent); border-color: var(--fp-accent); color: #fff; }
.btn-icon.primary:hover { background: var(--fp-accent-2); color: #fff; }
.actions { display: inline-flex; gap: .35rem; align-items: center; justify-content: flex-end; white-space: nowrap; }
table.data-table th.actions-col, table.data-table td.actions-col { text-align: right; width: 1%; }

/* Avatar / account menu */
.user-menu { position: relative; }
.user-menu-btn {
  display: inline-flex; align-items: center; gap: .5rem; border: 1px solid var(--fp-line);
  background: #fff; border-radius: 999px; padding: .25rem .65rem .25rem .25rem; cursor: pointer; font: inherit;
}
.user-menu-btn:hover { border-color: var(--fp-accent); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--fp-side); color: #fff;
  display: grid; place-items: center; font-size: .72rem; font-weight: 700;
}
.user-menu-name { font-weight: 600; font-size: .88rem; color: var(--fp-text); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu .chev { color: var(--fp-muted); font-size: .7rem; }
.user-menu-drop {
  display: none; position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px;
  background: #fff; border: 1px solid var(--fp-line); border-radius: 10px;
  box-shadow: 0 12px 30px rgba(15,24,48,.12); padding: .35rem; z-index: 50;
}
.user-menu.open .user-menu-drop { display: block; }
.user-menu-head { padding: .65rem .75rem; border-bottom: 1px solid var(--fp-line); margin-bottom: .25rem; }
.user-menu-head strong { display: block; font-size: .9rem; }
.user-menu-head small { color: var(--fp-muted); font-size: .75rem; }
.user-menu-drop a {
  display: block; padding: .55rem .75rem; border-radius: 8px; color: var(--fp-text); font-weight: 500; text-decoration: none;
}
.user-menu-drop a:hover { background: #f4f6fa; }
.user-menu-drop a.danger { color: var(--fp-danger); }
.user-menu-drop .menu-action {
  display: block; width: 100%; text-align: left; padding: .55rem .75rem; border-radius: 8px;
  border: 0; background: transparent; color: var(--fp-text); font: inherit; font-weight: 500; cursor: pointer;
}
.user-menu-drop .menu-action:hover { background: #f4f6fa; }
.pill {
  display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .55rem; border-radius: 999px;
  background: #fef5e7; color: #9a7b0a; font-size: .72rem; font-weight: 700;
}
.main { padding: 1.1rem 1.25rem 2rem; }

.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .85rem; }
.page-head h1 { margin: 0; font-size: 1.25rem; font-weight: 600; letter-spacing: -.01em; }
.page-head p { margin: .2rem 0 0; color: var(--fp-muted); font-size: .88rem; }
.page-head .btn.primary { border-radius: 3px; height: 34px; padding: 0 1rem; font-weight: 500; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .85rem; margin-bottom: 1rem; }
.card {
  background: var(--fp-panel); border: 1px solid var(--fp-line); border-radius: var(--radius); padding: .9rem 1rem;
}
.card .label { color: var(--fp-muted); font-size: .72rem; font-weight: 700; text-transform: uppercase; }
.card .value { font-size: 1.55rem; font-weight: 700; margin-top: .15rem; }

/* —— Zoho-style list views —— */
.panel {
  background: #fff; border: 1px solid #e0e0e0; border-radius: 4px;
  padding: 1rem; margin-bottom: 1rem;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
/* List panels (toolbar + table) — Zoho flush layout */
.panel:has(> .toolbar),
.panel:has(> .table-scroll),
.panel:has(> table.data-table) {
  padding: 0; overflow: hidden;
}
.panel > h2 { margin: 0 0 .85rem; font-size: .98rem; }
.panel:has(> .toolbar) > h2 {
  margin: 0; padding: .85rem 1rem; border-bottom: 1px solid #eee;
}

.toolbar {
  display: flex; flex-wrap: wrap; gap: .5rem; align-items: center;
  padding: .55rem .75rem; border-bottom: 1px solid #eee; background: #fff;
  min-height: 48px;
}
.toolbar .spacer { flex: 1; min-width: .5rem; }
.toolbar input[type="search"] {
  max-width: 280px; height: 32px; padding: 0 .7rem 0 2rem; margin: 0;
  border: 1px solid #d0d0d0; border-radius: 3px; font-size: .84rem;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='%23888' viewBox='0 0 16 16'%3E%3Cpath d='M11.7 10.3h-.8l-.3-.3a6 6 0 1 0-.7.7l.3.3v.8l4.6 4.6 1.4-1.4-4.5-4.7zm-5.2 0a4.2 4.2 0 1 1 0-8.4 4.2 4.2 0 0 1 0 8.4z'/%3E%3C/svg%3E") .55rem 50% no-repeat;
}
.toolbar input[type="search"]:focus { border-color: #2d8ceb; box-shadow: 0 0 0 2px rgba(45,140,235,.15); }
.toolbar .btn { height: 32px; padding: 0 .75rem; border-radius: 3px; font-size: .82rem; font-weight: 500; }
.toolbar .btn.ghost { border-color: #d0d0d0; color: #333; background: #fff; }
.toolbar .btn.ghost:hover { background: #f5f5f5; }
.toolbar .btn.danger { height: 32px; }
.toolbar .pager-size-wrap,
.toolbar .dt-length {
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: .84rem; color: #333; white-space: nowrap; margin: 0; font-weight: 400;
}
.toolbar .pager-size-wrap select.pager-size {
  width: auto; min-width: 3.5rem; height: 32px; padding: 0 .4rem; margin: 0 .15rem;
  font-size: .84rem; border: 1px solid #d0d0d0; border-radius: 3px; background: #fff;
}
.toolbar .dt-search-wrap {
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: .84rem; color: #333; margin: 0; font-weight: 400; white-space: nowrap;
}
.toolbar .dt-search-wrap input[type="search"] {
  max-width: 220px;
}

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

table.data-table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-size: .875rem;
}
table.data-table thead th {
  text-align: left; padding: .65rem .85rem; vertical-align: middle;
  background: #f6f6f6; color: #222; font-size: .78rem; font-weight: 600;
  text-transform: none; letter-spacing: 0;
  border-bottom: 1px solid #e0e0e0; border-top: 1px solid #e0e0e0;
  white-space: nowrap; position: sticky; top: 0; z-index: 1;
}
table.data-table tbody td {
  text-align: left; padding: .7rem .85rem; vertical-align: middle;
  border-bottom: 1px solid #f0f0f0; color: #333; background: #fff;
}
table.data-table tbody tr:last-child td { border-bottom: none; }
table.data-table tbody tr:hover td { background: #f7fbff; }
table.data-table tbody tr.selected td { background: #eef6ff; }
table.data-table th:first-child,
table.data-table td:first-child { padding-left: 1rem; }
table.data-table input[type="checkbox"] {
  width: 15px; height: 15px; margin: 0; accent-color: #2d8ceb; cursor: pointer;
}
table.data-table .empty {
  text-align: center; color: #888; padding: 2.5rem 1rem; font-size: .9rem;
  background: #fff !important;
}
table.data-table a { color: #2d8ceb; font-weight: 500; }
table.data-table a:hover { text-decoration: underline; }

.mono { font-family: var(--mono); font-size: .8rem; color: #444; }
.badge {
  display: inline-block; padding: .15rem .5rem; border-radius: 3px; font-size: .72rem; font-weight: 600;
  background: #e8f1fb; color: #1a5f9e; border: 1px solid #d0e3f5;
}
.badge.ok { background: #e5f7ed; color: #1b7a45; border-color: #c6ebd4; }
.badge.off { background: #f2f2f2; color: #666; border-color: #e0e0e0; }
.badge.warn { background: #fff6e5; color: #9a6b00; border-color: #f0e0b8; }

/* DataTables footer: Showing X to Y of Z · Previous 1 2 Next */
.pager,
.pager.dt-footer {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .65rem .85rem; border-top: 1px solid #eee; background: #fff;
  color: #333; font-size: .84rem; flex-wrap: wrap; margin: 0;
}
.pager #pagerInfo,
.pager .pager-info {
  color: #333; font-weight: 400; text-align: left; flex: 1; min-width: 180px;
}
.pager .pages {
  display: inline-flex; gap: 0; align-items: center; flex-wrap: wrap;
}
.pager .pages .zpage {
  min-width: 32px; height: 32px; padding: 0 .55rem; display: inline-flex;
  align-items: center; justify-content: center;
  border: 1px solid #ddd; margin-left: -1px; background: #fff; color: #333;
  font-size: .84rem; cursor: pointer; line-height: 1; border-radius: 0;
}
.pager .pages .zpage:first-child { border-radius: 3px 0 0 3px; margin-left: 0; }
.pager .pages .zpage:last-child { border-radius: 0 3px 3px 0; }
.pager .pages .zpage.zpage-nav { min-width: auto; padding: 0 .75rem; }
.pager .pages .zpage:hover:not(:disabled):not(.active) { background: #f5f5f5; z-index: 1; position: relative; }
.pager .pages .zpage:disabled { opacity: .45; cursor: default; color: #999; }
.pager .pages .zpage.active {
  background: #2d8ceb; border-color: #2d8ceb; color: #fff; font-weight: 600; z-index: 2; position: relative;
}
.pager .pages .pager-gap {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 32px; color: #888; border: 1px solid #ddd; margin-left: -1px;
  background: #fff; font-size: .84rem;
}

/* Sound quick-search picker */
.sound-picker { position: relative; }
.sound-picker > input { width: 100%; }
.sound-picker-panel {
  display: none; position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 40;
  background: #fff; border: 1px solid #d0d0d0; border-radius: 4px; box-shadow: 0 8px 24px rgba(0,0,0,.12);
  max-height: 260px; overflow: hidden;
}
.sound-picker-panel.open { display: block; }
.sound-picker-q {
  width: 100%; border: 0; border-bottom: 1px solid #eee; border-radius: 0; padding: .55rem .7rem; margin: 0;
}
.sound-picker-list { list-style: none; margin: 0; padding: 0; max-height: 210px; overflow: auto; }
.sound-picker-list li {
  padding: .5rem .7rem; cursor: pointer; border-bottom: 1px solid #f3f3f3;
}
.sound-picker-list li:hover { background: #f7fbff; }
.sound-picker-list li strong { display: block; font-size: .86rem; }
.sound-picker-list li small { color: #888; font-size: .75rem; }
.sound-picker-list li.empty { color: #888; cursor: default; }
.user-menu-drop a i { width: 1.1rem; margin-right: .35rem; opacity: .85; }

/* MODAL */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20,30,40,.45); z-index: 80;
  display: none; align-items: center; justify-content: center; padding: 1rem;
}
.modal-backdrop.show { display: flex; }
.modal {
  width: min(560px, 100%); background: #fff; border-radius: 10px; box-shadow: 0 20px 50px rgba(0,0,0,.25);
  max-height: 90vh; overflow: auto;
}
.modal.modal-lg { width: min(720px, 100%); }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: .9rem 1rem; border-bottom: 1px solid var(--fp-line); }
.modal header h3 { margin: 0; font-size: 1.05rem; }
.modal .body { padding: 1rem; }
.modal footer { display: flex; justify-content: flex-end; gap: .5rem; padding: .85rem 1rem; border-top: 1px solid var(--fp-line); background: #fafbfc; }
.check { display: flex !important; flex-direction: row !important; align-items: center; gap: .45rem; color: var(--fp-text); }
.form-grid { display: grid; gap: .15rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.help { color: var(--fp-muted); font-size: .78rem; margin: -.4rem 0 .6rem; line-height: 1.4; }
.empty { text-align: center; color: var(--fp-muted); padding: 1.5rem; }

/* Softphone keep dark */
.softphone { display: grid; grid-template-columns: 340px 1fr; gap: 1rem; }
.softphone-solo { grid-template-columns: min(380px, 100%); justify-content: start; }
.phone {
  background: linear-gradient(180deg, #1a252f, #2c3e50); color: #ecf0f1;
  border-radius: 18px; padding: 1.1rem;
}
.phone-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: .75rem; gap: .5rem; }
.phone-meta { color: #94a3b8; font-size: .78rem; margin-top: .15rem; }
.phone-display { background: #0f161c; border-radius: 12px; padding: .9rem; margin-bottom: .9rem; min-height: 80px; font-family: var(--mono); }
.phone-label { color: #64748b; font-size: .7rem; margin-bottom: .3rem; }
#dialDisplay { font-size: 1.35rem; color: #fff; }
#callStatus { color: #94a3b8; font-size: .78rem; margin-top: .35rem; }
.dialpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .45rem; }
.dialpad button {
  border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.05); color: #fff;
  border-radius: 12px; padding: .85rem 0; font: inherit; font-size: 1.1rem; cursor: pointer;
}
.phone-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: .75rem; }
.phone-actions.three { grid-template-columns: 1fr 1fr 1fr; }
.phone-btn { color: #e2e8f0 !important; border-color: rgba(255,255,255,.15) !important; background: transparent !important; }
.phone-btn.hidden, .hidden { display: none !important; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: #7f8c8d; }
.status-dot.on { background: #27ae60; box-shadow: 0 0 8px rgba(39,174,96,.6); }
.agent-state-bar { display: flex; gap: .4rem; align-items: center; margin-bottom: .65rem; }
.agent-toggle {
  flex: 1; border: 1px solid rgba(255,255,255,.15); background: transparent; color: #cbd5e1;
  border-radius: 8px; padding: .4rem; font: inherit; font-size: .82rem; cursor: pointer;
}
.agent-toggle.active { background: rgba(39,174,96,.2); border-color: #27ae60; color: #fff; }
.agent-state { font-size: .72rem; padding: .2rem .5rem; border-radius: 999px; }
.agent-state.ready { background: rgba(39,174,96,.25); color: #a7f3d0; }
.agent-state.paused { background: rgba(245,158,11,.25); color: #fde68a; }
.timers {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; margin-bottom: .75rem;
}
.timers div {
  background: rgba(0,0,0,.25); border-radius: 8px; padding: .4rem .5rem; text-align: center;
}
.timers span { display: block; font-size: .65rem; color: #94a3b8; text-transform: uppercase; letter-spacing: .04em; }
.timers strong { font-family: var(--mono); font-size: .95rem; color: #fff; }
.moh-pick { display: block; margin-top: .85rem; font-size: .78rem; color: #94a3b8; }
.moh-pick select {
  width: 100%; margin-top: .3rem; background: #0f161c; color: #e2e8f0; border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px; padding: .45rem .55rem; font: inherit;
}
.phone-hint { color: #64748b; font-size: .75rem; margin: .85rem 0 0; line-height: 1.45; }
.phone-hint .mono { color: #cbd5e1; }
.inline-pick select { min-width: 180px; }

@media (max-width: 960px) {
  .login-body, .app-body, .softphone, .grid-2 { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .sidebar { height: auto; position: relative; }
}
