:root {
  --ink: #20242b;
  --muted: #6d7480;
  --line: #d7dde5;
  --soft-line: #e9edf2;
  --canvas: #f4f6f9;
  --panel: #ffffff;
  --sidebar: #171a21;
  --sidebar-deep: #101217;
  --sidebar-hover: #242936;
  --sidebar-active: #2c3344;
  --primary: #246bfe;
  --primary-strong: #1554d1;
  --primary-soft: #eaf1ff;
  --green: #12805c;
  --green-soft: #e7f6ef;
  --blue: #246bfe;
  --blue-soft: #eaf1ff;
  --amber: #a85b00;
  --amber-soft: #fff2dc;
  --red: #bd3038;
  --red-soft: #ffe8ea;
  --cyan: #0f8b99;
  --cyan-soft: #e5f7f9;
  --shadow: 0 10px 26px rgba(24, 31, 44, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(180deg, #f9fafc 0, var(--canvas) 230px),
    var(--canvas);
  font-family: "Fira Sans", Arial, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 100vh;
  overflow-y: auto;
  color: #f5f6f8;
  background:
    linear-gradient(180deg, rgba(36, 107, 254, 0.11), rgba(18, 128, 92, 0.06) 42%, transparent),
    var(--sidebar);
  box-shadow: inset -1px 0 rgba(255, 255, 255, 0.05);
}

.sidebar::-webkit-scrollbar,
.table-wrap::-webkit-scrollbar,
.settings-card pre::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.sidebar::-webkit-scrollbar-thumb,
.table-wrap::-webkit-scrollbar-thumb,
.settings-card pre::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: rgba(126, 139, 158, 0.45);
  background-clip: padding-box;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 15px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
}

.brand-mark {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 6px;
  color: #ffffff;
  background: linear-gradient(135deg, #246bfe, #12a36f);
  font-size: 15px;
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(36, 107, 254, 0.22);
}

.brand strong {
  display: block;
  font-size: 14px;
  line-height: 1.1;
}

.brand span {
  color: #aeb5c1;
  font-size: 11px;
}

.balance-strip {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 7px;
  align-items: center;
  padding: 11px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  color: #d0d5de;
  font-size: 12px;
}

.balance-strip strong {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  color: #ffffff;
  background: rgba(18, 128, 92, 0.18);
}

.balance-strip span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 8px;
  background: rgba(255, 255, 255, 0.06);
}

.balance-strip b {
  color: #8fdab8;
}

.side-search {
  display: grid;
  gap: 5px;
  padding: 12px 15px 8px;
}

.side-search span {
  color: #989fab;
  font-size: 11px;
}

.side-search input {
  min-height: 32px;
  border-color: #343a49;
  color: #f4f6f8;
  background: var(--sidebar-deep);
}

.side-search input::placeholder {
  color: #747c8a;
}

.nav-list {
  display: grid;
  gap: 2px;
  padding: 7px 8px 12px;
}

.nav-item {
  position: relative;
  display: block;
  width: 100%;
  min-height: 34px;
  border: 0;
  border-radius: 5px;
  padding: 0 11px 0 13px;
  color: #c9ced7;
  background: transparent;
  text-align: left;
  white-space: nowrap;
}

.nav-item:nth-child(3),
.nav-item:nth-child(7),
.nav-item:nth-child(12) {
  margin-top: 8px;
}

.nav-item::before {
  content: "";
  position: absolute;
  top: 7px;
  bottom: 7px;
  left: 5px;
  width: 3px;
  border-radius: 999px;
  background: transparent;
}

.nav-item:hover,
.nav-item.active {
  color: #ffffff;
  background: var(--sidebar-active);
}

.nav-item.active::before {
  background: #38bdf8;
}

.nav-item:hover::before {
  background: rgba(56, 189, 248, 0.45);
}

.side-panel {
  margin: auto 10px 12px;
  padding: 11px;
  border: 1px solid rgba(143, 218, 184, 0.18);
  border-radius: 6px;
  background: rgba(18, 128, 92, 0.08);
}

.side-panel .label {
  color: #9be7c1;
}

.side-panel strong {
  display: block;
  margin-bottom: 4px;
  color: #ffffff;
  font-size: 16px;
}

.side-panel small {
  display: block;
  color: #a7adb8;
  line-height: 1.35;
}

.workspace {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 62px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 1px 0 rgba(24, 31, 44, 0.03), 0 8px 22px rgba(24, 31, 44, 0.05);
  backdrop-filter: blur(12px);
}

.page-heading {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.page-heading::before {
  content: "";
  width: 8px;
  height: 30px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--primary), var(--green));
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 21px;
  font-weight: 700;
  line-height: 1.1;
}

h2 {
  margin-bottom: 0;
  font-size: 17px;
  font-weight: 600;
}

h3 {
  margin-bottom: 7px;
  font-size: 14px;
}

#pageSubtitle {
  margin-bottom: 0;
  color: #7b8492;
}

.topbar-actions {
  display: flex;
  align-items: end;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.tenant-select,
.date-range {
  display: grid;
  gap: 3px;
}

.tenant-select {
  min-width: 160px;
}

.date-range {
  width: 205px;
}

.label,
.eyebrow,
.tenant-select span,
.date-range span,
label span {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

select,
input {
  width: 100%;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 5px 9px;
  color: var(--ink);
  background: #fbfcfe;
  outline: 0;
}

select:focus,
input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(36, 107, 254, 0.14);
}

input::placeholder {
  color: #9aa3b0;
}

.button,
.icon-button,
.table-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 31px;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 0 10px;
  font-weight: 600;
  white-space: nowrap;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.button.primary {
  color: #ffffff;
  border-color: var(--primary-strong);
  background: linear-gradient(180deg, #3d7dff, var(--primary));
  box-shadow: 0 6px 14px rgba(36, 107, 254, 0.18);
}

.button.primary:hover {
  background: linear-gradient(180deg, #2d70fa, var(--primary-strong));
  box-shadow: 0 7px 16px rgba(36, 107, 254, 0.24);
}

.button:active,
.table-action:active {
  transform: translateY(1px);
}

.button.secondary,
.table-action {
  color: #28313d;
  border-color: #cbd3de;
  background: #ffffff;
}

.button.secondary:hover,
.table-action:hover {
  border-color: #aebbd0;
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.icon-button {
  width: 32px;
  padding: 0;
  color: var(--muted);
  border-color: var(--line);
  background: #ffffff;
}

.icon-button:hover {
  color: var(--red);
  border-color: #f3b6bc;
  background: var(--red-soft);
}

.content {
  display: grid;
  gap: 14px;
  padding: 15px;
}

.report-filter,
.page-toolbar,
.table-card,
.chart-panel,
.settings-card,
.mini-metric {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(24, 31, 44, 0.04);
}

.report-filter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  border-left: 4px solid var(--primary);
}

.dense-report-header {
  padding-top: 9px;
  padding-bottom: 9px;
}

.report-titleline {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.report-filter strong {
  display: block;
  margin-bottom: 2px;
}

.report-filter strong::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 7px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(18, 128, 92, 0.12);
}

.report-filter span {
  color: var(--muted);
}

.active-filter {
  color: var(--primary-strong) !important;
  border-color: #b8caff !important;
  background: var(--primary-soft) !important;
}

.filter-actions,
.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.metric-strip.narrow {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mini-metric {
  min-height: 72px;
  position: relative;
  overflow: hidden;
  padding: 12px 13px;
}

.mini-metric::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--primary);
}

.mini-metric:nth-child(2)::before {
  background: var(--cyan);
}

.mini-metric:nth-child(3)::before,
.mini-metric:nth-child(5)::before {
  background: var(--green);
}

.mini-metric:nth-child(4)::before {
  background: var(--amber);
}

.mini-metric span,
.section-caption,
.subcell,
.settings-card p,
.panel-head p {
  color: var(--muted);
}

.mini-metric strong {
  display: block;
  margin: 5px 0 2px;
  font-size: 25px;
  color: #18202b;
  line-height: 1;
}

.mini-metric small {
  color: var(--muted);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 13px;
  border-bottom: 1px solid var(--soft-line);
  background: linear-gradient(180deg, #ffffff, #fbfcff);
}

.panel-head.compact p {
  margin-bottom: 0;
}

.hour-chart {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  align-items: end;
  gap: 6px;
  min-height: 205px;
  padding: 20px 15px 22px;
  border-top: 1px solid var(--soft-line);
  background:
    repeating-linear-gradient(0deg, transparent 0, transparent 39px, rgba(215, 221, 229, 0.55) 40px),
    #ffffff;
}

.hour-chart span {
  position: relative;
  min-height: 6px;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(180deg, #62a3ff, #246bfe);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.35);
}

.hour-chart b {
  position: absolute;
  bottom: -18px;
  left: 50%;
  color: #9aa2ad;
  font-size: 10px;
  font-weight: 400;
  transform: translateX(-50%);
}

.report-chart-card {
  border-left: 0;
}

.report-chart-head {
  align-items: flex-start;
}

.report-totals {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.report-totals span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 26px;
  border: 1px solid var(--soft-line);
  border-radius: 4px;
  padding: 0 8px;
  color: var(--muted);
  background: #ffffff;
  font-size: 12px;
}

.report-totals b {
  color: #1d2733;
}

.report-chart {
  position: relative;
  overflow: hidden;
  border-top: 1px solid var(--soft-line);
  background:
    linear-gradient(90deg, rgba(36, 107, 254, 0.03), rgba(18, 128, 92, 0.03)),
    #ffffff;
}

.report-svg {
  display: block;
  width: 100%;
  height: 284px;
  min-width: 760px;
}

.chart-grid {
  stroke: #e4e8ef;
  stroke-width: 1;
  stroke-dasharray: 3 4;
}

.chart-axis {
  stroke: #cbd3de;
  stroke-width: 1;
}

.axis-label,
.x-label {
  fill: #7c8795;
  font-size: 11px;
  dominant-baseline: middle;
}

.axis-label.right {
  text-anchor: start;
}

.x-label {
  text-anchor: middle;
}

.chart-area {
  fill: url(#callArea);
}

.chart-line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
}

.chart-line.calls {
  stroke: var(--primary);
}

.chart-line.revenue {
  stroke: var(--green);
  stroke-width: 2;
  stroke-dasharray: 6 5;
}

.chart-dot {
  fill: #ffffff;
  stroke: var(--primary);
  stroke-width: 2;
}

.chart-legend {
  position: absolute;
  right: 14px;
  bottom: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chart-legend i {
  width: 18px;
  height: 3px;
  border-radius: 999px;
}

.legend-call {
  background: var(--primary);
}

.legend-revenue {
  background: var(--green);
}

.split-panels {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(360px, 0.6fr);
  gap: 14px;
}

.section-caption {
  margin: 0 0 6px;
  color: #384252;
  font-weight: 700;
}

.page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  border-left: 4px solid var(--primary);
}

.page-title-block p {
  margin: 3px 0 0;
  color: var(--muted);
}

.search {
  min-width: 180px;
}

.rows-select {
  width: 70px;
}

.table-card {
  overflow: hidden;
}

.table-card + .table-card {
  margin-top: 10px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

.wide-table table {
  min-width: 1180px;
}

th,
td {
  border-bottom: 1px solid var(--soft-line);
  padding: 8px 11px;
  text-align: left;
  vertical-align: middle;
  font-size: 12px;
  line-height: 1.35;
}

th {
  color: #596374;
  background: linear-gradient(180deg, #fbfcff, #f3f6fb);
  font-size: 11px;
  font-weight: 700;
}

tbody tr:hover td {
  background: #f8fbff;
}

tbody tr:nth-child(even) td {
  background: #fcfdff;
}

tbody tr:nth-child(even):hover td {
  background: #f5f9ff;
}

td strong {
  display: block;
  color: #1d2733;
}

tr:last-child td {
  border-bottom: 0;
}

.empty-row {
  padding: 30px 12px;
  color: var(--muted);
  text-align: center;
}

.subcell {
  display: block;
  margin-top: 2px;
  font-size: 11px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  border-radius: 999px;
  padding: 0 7px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  text-transform: capitalize;
}

.badge.active,
.badge.answered,
.badge.reporting {
  color: var(--green);
  background: var(--green-soft);
  border: 1px solid rgba(18, 128, 92, 0.15);
}

.badge.paused,
.badge.missed,
.badge.review {
  color: var(--amber);
  background: var(--amber-soft);
  border: 1px solid rgba(168, 91, 0, 0.14);
}

.badge.voicemail,
.badge.trial {
  color: var(--blue);
  background: var(--blue-soft);
  border: 1px solid rgba(36, 107, 254, 0.14);
}

.badge.danger,
.badge.blocked {
  color: var(--red);
  background: var(--red-soft);
  border: 1px solid rgba(189, 48, 56, 0.14);
}

.badge.review {
  color: #725000;
}

.table-action {
  min-height: 26px;
  padding: 0 8px;
  font-size: 11px;
}

.progress {
  width: min(100%, 116px);
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7edf5;
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--cyan));
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 13px;
}

.workspace-settings-page {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr) 330px;
  gap: 14px;
  align-items: start;
}

.settings-tabs,
.settings-form-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(24, 31, 44, 0.04);
}

.settings-tabs {
  position: sticky;
  top: 76px;
  display: grid;
  gap: 1px;
  overflow: hidden;
  padding: 6px;
}

.settings-tab {
  min-height: 34px;
  border: 0;
  border-radius: 5px;
  padding: 0 10px;
  color: #455161;
  background: transparent;
  text-align: left;
  font-weight: 600;
}

.settings-tab:hover,
.settings-tab.active {
  color: var(--primary-strong);
  background: var(--primary-soft);
}

.settings-column {
  display: grid;
  gap: 14px;
}

.settings-column.side {
  gap: 12px;
}

.settings-form-card {
  overflow: hidden;
}

.settings-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 13px;
  border-bottom: 1px solid var(--soft-line);
  background: linear-gradient(180deg, #ffffff, #fbfcff);
}

.settings-status,
.settings-help {
  color: var(--muted);
  font-size: 12px;
}

.settings-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
  padding: 13px;
}

.toggle-list {
  display: grid;
  gap: 1px;
  padding: 8px 13px 13px;
}

.setting-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  border-bottom: 1px solid var(--soft-line);
  color: #303947;
}

.setting-toggle:last-child {
  border-bottom: 0;
}

.setting-toggle input {
  width: 16px;
  min-height: 16px;
}

.settings-form-card .table-card {
  border: 0;
  border-top: 1px solid var(--soft-line);
  border-radius: 0;
  box-shadow: none;
}

.settings-form-card table {
  min-width: 560px;
}

.compact-card {
  padding: 12px;
}

.compact-card h2 {
  margin-bottom: 10px;
}

.plan-box,
.balance-box {
  display: grid;
  gap: 7px;
  border: 1px solid var(--soft-line);
  border-radius: 6px;
  padding: 11px;
  background: #fbfcff;
}

.plan-box strong,
.balance-box strong {
  font-size: 20px;
}

.plan-box span,
.balance-box span {
  color: var(--muted);
}

.full-button {
  width: 100%;
  margin-top: 10px;
}

.settings-code {
  max-height: 260px;
  overflow: auto;
  border: 1px solid #243044;
  border-radius: 5px;
  padding: 10px;
  color: #d9e6ff;
  background: #111827;
  font-size: 11px;
  line-height: 1.45;
}

.settings-card {
  padding: 12px;
  overflow: hidden;
}

.settings-card pre {
  max-height: 520px;
  overflow: auto;
  border: 1px solid #2d3748;
  border-radius: 5px;
  padding: 12px;
  color: #d9e6ff;
  background: #111827;
  font-size: 11px;
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(17, 24, 39, 0.62);
  backdrop-filter: blur(2px);
}

.modal {
  width: min(760px, 100%);
  max-height: min(760px, 92vh);
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.modal-head,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px;
  border-bottom: 1px solid var(--soft-line);
  background: #fbfcff;
}

.modal-actions {
  justify-content: flex-end;
  border-top: 1px solid var(--soft-line);
  border-bottom: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 14px;
}

label {
  display: grid;
  gap: 5px;
}

.full {
  grid-column: 1 / -1;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 31px;
}

.checkline input {
  width: 15px;
  min-height: 15px;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 30;
  width: min(340px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-left: 4px solid var(--green);
  border-radius: 6px;
  padding: 11px 12px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .metric-strip,
  .metric-strip.narrow {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .split-panels,
  .settings-grid,
  .workspace-settings-page {
    grid-template-columns: 1fr;
  }

  .settings-tabs {
    position: static;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    min-height: auto;
  }

  .nav-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nav-item {
    white-space: normal;
  }

  .topbar,
  .page-toolbar,
  .report-filter {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .toolbar-controls,
  .filter-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .date-range,
  .tenant-select,
  .rows-select,
  .search {
    width: 100%;
    min-width: 0;
  }

  .metric-strip,
  .metric-strip.narrow,
  .form-grid,
  .settings-form-grid {
    grid-template-columns: 1fr;
  }

  .settings-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .report-totals {
    justify-content: flex-start;
  }
}
