:root {
  --tf-sidebar: #172033;
  --tf-sidebar-active: #233453;
  --tf-accent: #0f766e;
  --tf-bg: #f4f7fb;
  --tf-border: #dbe3ef;
}

.login-page {
  min-height: 100vh;
  margin: 0;
  background: #081526;
}

.login-experience {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(420px, .8fr);
}

.login-showcase {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(36px, 6vw, 82px);
  color: #fff;
  background: radial-gradient(circle at 20% 20%, color-mix(in srgb, var(--tf-accent) 55%, transparent), transparent 38%), linear-gradient(145deg, #071426, #102b43 58%, #0c554f);
}

.login-showcase:after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .13;
  background-image: linear-gradient(rgba(255,255,255,.1) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.1) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, transparent, #000, transparent);
}

.login-brand, .login-copy { position: relative; z-index: 2; }
.login-brand { display: flex; align-items: center; gap: 12px; font-size: 18px; }
.login-copy { max-width: 660px; }
.login-copy h1 { font-size: clamp(38px, 5vw, 72px); line-height: 1.02; letter-spacing: -.045em; margin: 14px 0 22px; }
.login-copy p { font-size: 18px; line-height: 1.7; color: #c7d8e7; max-width: 560px; }
.login-eyebrow { color: #7ee7d6; font-size: 12px; font-weight: 800; letter-spacing: .2em; }
.login-trust { display: flex; flex-wrap: wrap; gap: 20px; margin-top: 32px; color: #d8e8f3; }
.login-trust span { display: flex; align-items: center; gap: 8px; }
.login-form-side { display: grid; place-items: center; padding: 32px; background: #f7fafc; }
.login-card { width: min(100%, 430px); padding: 38px; border-radius: 20px; background: #fff; box-shadow: 0 30px 80px rgba(8,21,38,.16); border: 1px solid #e6edf5; }
.login-card .input-group-text { background: #f8fafc; border-right: 0; }
.login-card .input-group .form-control { border-left: 0; padding-left: 2px; }
.login-card .form-control, .login-card .input-group-text { min-height: 48px; }
.login-foot { margin-top: 24px; text-align: center; color: #7b8797; font-size: 12px; }
.login-orb { position: absolute; border-radius: 50%; filter: blur(4px); opacity: .25; animation: login-float 10s ease-in-out infinite; }
.orb-one { width: 360px; height: 360px; right: -100px; top: 8%; background: #34d399; }
.orb-two { width: 240px; height: 240px; left: 18%; bottom: -100px; background: #60a5fa; animation-delay: -4s; }
@keyframes login-float { 50% { transform: translate3d(20px,-20px,0) scale(1.06); } }
@media (prefers-reduced-motion: reduce) { .login-orb { animation: none; } }
@media (max-width: 900px) { .login-experience { grid-template-columns: 1fr; } .login-showcase { min-height: 340px; padding: 36px; } .login-copy h1 { font-size: 40px; } .login-form-side { padding: 22px; } }

body {
  background: var(--tf-bg);
  color: #1f2937;
  font-size: 14px;
}

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

.sidebar {
  width: 264px;
  background: var(--tf-sidebar);
  color: #e5ecf6;
  position: fixed;
  inset: 0 auto 0 0;
  overflow-y: auto;
  z-index: 1020;
}

.brand {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  font-weight: 700;
  letter-spacing: 0;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #0f766e;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav-sidebar {
  padding: 14px 10px;
}

.nav-section {
  padding: 14px 12px 6px;
  color: #7f91ac;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.nav-section:first-child { padding-top: 4px; }

.nav-sidebar .nav-link {
  color: #cbd5e1;
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 2px;
}

.nav-sidebar .nav-link i { width: 18px; text-align: center; }
.sidebar-close, .menu-toggle, .sidebar-backdrop { display: none; }

.nav-sidebar .nav-link:hover,
.nav-sidebar .nav-link.active {
  color: #fff;
  background: var(--tf-sidebar-active);
}

.main {
  margin-left: 264px;
  width: calc(100% - 264px);
  min-height: 100vh;
}

.topbar {
  height: 64px;
  background: #fff;
  border-bottom: 1px solid var(--tf-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.content {
  padding: 24px;
}

.metric-card,
.panel {
  background: #fff;
  border: 1px solid var(--tf-border);
  border-radius: 8px;
}

.metric-card {
  padding: 16px;
  min-height: 118px;
  position: relative;
  overflow: hidden;
  transition: transform .2s ease, box-shadow .2s ease;
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(15, 23, 42, .08);
}

.metric-card > div > i {
  font-size: 20px;
  color: var(--tf-accent);
}

.metric-live {
  border-color: rgba(15, 118, 110, .4);
  background: linear-gradient(145deg, #fff, #ecfdf5);
}

.metric-danger > div > i { color: #dc2626; }
.metric-warning > div > i { color: #d97706; }
.metric-success > div > i { color: #059669; }

.live-command {
  background: linear-gradient(115deg, #10243d, #0f766e);
  color: #fff;
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 16px;
  box-shadow: 0 12px 30px rgba(15, 32, 51, .16);
}

.live-command.live-error {
  background: linear-gradient(115deg, #3f1d28, #991b1b);
}

.operation-flow {
  padding: 20px;
}

.flow-total {
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: #64748b;
}

.flow-total strong {
  color: #0f172a;
  font-size: 25px;
}

.flow-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
}

.flow-stage {
  min-width: 0;
  border: 1px solid #e2e8f0;
  background: #fbfdff;
  border-radius: 10px;
  padding: 13px;
}

.flow-stage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 5px;
}

.flow-stage-head i { font-size: 17px; }
.flow-stage-head strong {
  font-size: 24px;
  font-variant-numeric: tabular-nums;
}

.flow-stage > span {
  display: block;
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .045em;
  text-transform: uppercase;
}

.flow-track {
  height: 5px;
  margin-top: 11px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.flow-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: currentColor;
  transition: width .45s ease;
}

.flow-queue { color: #64748b; }
.flow-dialing { color: #2563eb; }
.flow-ringing { color: #d97706; }
.flow-talking { color: #16a34a; }
.flow-transferred { color: #7c3aed; }
.flow-finished { color: #0f766e; }

.live-toolbar,
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.live-pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #5eead4;
  box-shadow: 0 0 0 rgba(94, 234, 212, .5);
  animation: livePulse 1.8s infinite;
}

@keyframes livePulse {
  0% { box-shadow: 0 0 0 0 rgba(94, 234, 212, .55); }
  70% { box-shadow: 0 0 0 10px rgba(94, 234, 212, 0); }
  100% { box-shadow: 0 0 0 0 rgba(94, 234, 212, 0); }
}

.pbx-health {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
}

.health-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #94a3b8;
}

.health-dot.online { background: #5eead4; }
.health-dot.offline { background: #fca5a5; }
.health-dot.checking { animation: livePulse 1.8s infinite; }

.panel-heading {
  margin-bottom: 16px;
}

.live-count {
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #ecfdf5;
  color: #047857;
  font-weight: 800;
}

.live-panel {
  min-height: 360px;
}

.chart-live-panel {
  min-height: 360px;
}

.chart-live-panel canvas {
  max-height: 275px;
}

.live-call-list {
  display: grid;
  gap: 9px;
}

.live-call {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto 62px;
  gap: 12px;
  align-items: center;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 11px 12px;
  background: #fbfdff;
}

.call-avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: #ccfbf1;
  color: #0f766e;
}

.call-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.call-main span {
  color: #64748b;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.call-timer {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  color: #334155;
}

.status-live {
  display: inline-flex;
  width: max-content;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
  background: #f1f5f9;
  color: #475569;
}

.status-ringing { background: #fef3c7; color: #92400e; }
.status-answered { background: #e0f2fe; color: #0369a1; }
.status-transferred { background: #d1fae5; color: #047857; }
.status-failed { background: #fee2e2; color: #b91c1c; }
.status-busy { background: #ffedd5; color: #c2410c; }
.status-no_answer { background: #e2e8f0; color: #475569; }
.status-ended { background: #e0e7ff; color: #4338ca; }

.empty-live {
  min-height: 245px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #94a3b8;
  gap: 6px;
}

.empty-live i {
  font-size: 36px;
}

.empty-live strong { color: #475569; }
.live-table td { vertical-align: middle; }

.campaign-editor {
  display: grid;
  gap: 16px;
}

.campaign-editor-head,
.campaign-editor-footer,
.campaign-list-head,
.campaign-filters {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.campaign-editor-head {
  padding: 4px 2px;
}

.form-section {
  padding: 22px;
}

.form-section-title {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid #e2e8f0;
}

.form-section-title > span {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: #ccfbf1;
  color: #0f766e;
  font-weight: 800;
}

.form-section-title h3 {
  margin: 0;
  font-size: 16px;
}

.form-section-title p {
  margin: 3px 0 0;
  color: #64748b;
  font-size: 12px;
}

.switch-card {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid #dbe3ef;
  border-radius: 10px;
  padding: 13px 14px;
  cursor: pointer;
  background: #fbfdff;
}

.switch-card > span {
  display: flex;
  flex-direction: column;
}

.switch-card small { color: #64748b; }

.fields-disabled {
  opacity: .45;
  pointer-events: none;
}

.weekday-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(90px, 1fr));
  gap: 8px;
}

.weekday-grid input {
  position: absolute;
  opacity: 0;
}

.weekday-grid span {
  display: block;
  border: 1px solid #dbe3ef;
  border-radius: 9px;
  padding: 10px 8px;
  text-align: center;
  cursor: pointer;
  color: #64748b;
  font-weight: 600;
}

.weekday-grid input:checked + span {
  background: #ecfdf5;
  border-color: #0f766e;
  color: #047857;
}

.campaign-editor-footer {
  justify-content: flex-end;
  position: sticky;
  bottom: 0;
  z-index: 10;
  background: rgba(244, 247, 251, .94);
  backdrop-filter: blur(8px);
  padding: 12px 0;
}

.campaign-list-head { margin-bottom: 16px; }
.campaign-filters {
  justify-content: flex-start;
  padding: 14px;
  margin-bottom: 14px;
  background: #f8fafc;
  border-radius: 10px;
}
.campaign-filters .input-group { max-width: 380px; }
.campaign-filters .form-select { max-width: 220px; }
}

.metric-label {
  color: #64748b;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.metric-value {
  font-size: 28px;
  font-weight: 700;
  margin-top: 8px;
}

.panel {
  padding: 18px;
}

.users-layout {
  display: grid;
  grid-template-columns: minmax(330px, 390px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.user-create-card { position: sticky; top: 88px; }
.onboarding-options { display: grid; gap: 8px; }
.option-check {
  display: flex;
  gap: 11px;
  padding: 12px;
  border: 1px solid var(--tf-border);
  border-radius: 10px;
  background: #fbfdff;
  cursor: pointer;
}
.option-check > span { display: flex; flex-direction: column; }
.option-check small { color: #64748b; }
.option-check.is-disabled { opacity: .6; cursor: not-allowed; }
.password-strength { height: 4px; border-radius: 999px; background: #e2e8f0; position: relative; margin-top: 9px; }
.password-strength span { display: block; width: 0; height: 100%; border-radius: inherit; background: #ef4444; transition: width .2s; }
.password-strength span[data-score="4"] { background: #f59e0b; }
.password-strength span[data-score="5"] { background: #10b981; }
.password-strength small { display: block; padding-top: 6px; color: #64748b; }
.user-search { max-width: 260px; }
.user-search .input-group-text { background: #fff; }
.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell > div { display: flex; flex-direction: column; }
.user-cell small { color: #64748b; }
.user-avatar { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; background: #e6f7f4; color: #0f766e; font-weight: 800; }
.role-pill { display: inline-flex; padding: 5px 9px; border-radius: 999px; background: #eef2ff; color: #4338ca; font-weight: 600; }
.security-status { color: #b45309; white-space: nowrap; }
.security-status.is-ready { color: #047857; }
.edit-user-row td { background: #f8fafc; padding: 16px; }

.roles-intro {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}
.roles-intro h2 { font-size: 20px; margin: 0 0 4px; }
.roles-intro p { color: #64748b; margin: 0; }
.role-stack { display: grid; gap: 16px; }
.role-card-head { display: grid; grid-template-columns: auto minmax(180px, .8fr) minmax(380px, 1.2fr); gap: 14px; align-items: center; margin-bottom: 18px; }
.role-symbol { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; background: #e6f7f4; color: #0f766e; font-size: 20px; }
.role-copy h2 { font-size: 18px; margin: 0; }
.role-copy p { color: #64748b; margin: 3px 0 0; }
.role-fields { display: grid; grid-template-columns: .75fr 1.25fr; gap: 8px; }
.permission-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.permission-option { display: grid; grid-template-columns: auto auto minmax(0, 1fr); align-items: start; gap: 9px; padding: 11px; border: 1px solid var(--tf-border); border-radius: 10px; background: #fff; cursor: pointer; transition: .15s ease; }
.permission-option > i { color: #64748b; font-size: 16px; }
.permission-option > span { display: flex; min-width: 0; flex-direction: column; }
.permission-option small { color: #64748b; line-height: 1.3; margin-top: 2px; }
.permission-option.is-selected { border-color: #5eead4; background: #f0fdfa; }
.permission-option.is-selected > i { color: #0f766e; }
.role-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--tf-border); }
.appearance-card { max-width: 1100px; }

.table thead th {
  background: #f8fafc;
  color: #475569;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--tf-border);
}

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.status-badge {
  border-radius: 999px;
  padding: 5px 9px;
  font-weight: 600;
}

.history-heading,
.history-results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.history-filters {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) minmax(150px, 1fr) 150px 150px minmax(220px, 1.4fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.history-filter-actions {
  display: flex;
  gap: 8px;
}

.history-metric {
  min-height: 112px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.history-metric > i {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: #f8fafc;
  font-size: 21px;
}

.history-metric strong {
  display: block;
  margin-top: 4px;
  color: #172033;
  font-size: 24px;
}

.history-status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.history-status-grid > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--tf-border);
  border-radius: 10px;
  background: #f8fafc;
}

.history-status-grid strong { color: #172033; font-size: 17px; }
.history-status-grid small { grid-column: 1 / -1; color: #64748b; }
.history-campaigns { max-height: 330px; }
.history-pagination { display: flex; justify-content: flex-end; margin-top: 16px; }

.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #172033 0%, #0f766e 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, .28);
}

@media (max-width: 992px) {
  .sidebar {
    position: fixed;
    width: min(86vw, 290px);
    min-height: 100vh;
    transform: translateX(-105%);
    transition: transform .22s ease;
    box-shadow: 16px 0 45px rgba(15,23,42,.22);
  }

  .app-shell {
    display: block;
  }

  body.sidebar-open { overflow: hidden; }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-close { display: inline-grid; margin-left: auto; border: 0; background: transparent; color: #cbd5e1; }
  .menu-toggle { display: inline-grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--tf-border); border-radius: 9px; background: #fff; color: #334155; font-size: 20px; }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 1010; border: 0; background: rgba(15,23,42,.5); }
  body.sidebar-open .sidebar-backdrop { display: block; }

  .main {
    margin-left: 0;
    width: 100%;
  }

  .topbar {
    position: sticky;
  }

  .users-layout { grid-template-columns: 1fr; }
  .user-create-card { position: static; }
  .permission-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .role-card-head { grid-template-columns: auto 1fr; }
  .role-fields { grid-column: 1 / -1; }
  .history-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .history-search { grid-column: 1 / -1; }

  .live-toolbar,
  .panel-heading {
    align-items: flex-start;
  }

  .live-toolbar {
    flex-direction: column;
  }

  .live-call {
    grid-template-columns: 40px minmax(0, 1fr) auto;
  }

  .flow-grid {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
  }

  .live-call .status-live {
    grid-column: 2;
  }

  .call-timer {
    grid-column: 3;
    grid-row: 1;
  }
}

@media (max-width: 576px) {
  .content { padding: 14px; }
  .topbar { padding: 0 14px; }
  .topbar .text-secondary:not(.small) { display: none; }
  .live-command { padding: 14px; }
  .live-toolbar > .d-flex { width: 100%; justify-content: space-between; }
  .pbx-health { font-size: 12px; }
  .metric-card { min-height: 104px; }
  .flow-grid { grid-template-columns: repeat(2, minmax(110px, 1fr)); }
  .operation-flow { padding: 14px; }
  .campaign-editor-head,
  .campaign-list-head,
  .campaign-filters { align-items: stretch; flex-direction: column; }
  .campaign-editor-head .d-flex { width: 100%; }
  .campaign-editor-head .btn { flex: 1; }
  .weekday-grid { grid-template-columns: repeat(2, 1fr); }
  .campaign-filters .input-group,
  .campaign-filters .form-select { max-width: none; width: 100%; }
  .users-list-card .panel-heading, .roles-intro, .role-card-footer { align-items: stretch; flex-direction: column; }
  .user-search { max-width: none; width: 100%; }
  .permission-grid, .role-fields { grid-template-columns: 1fr; }
  .role-card-footer .btn { width: 100%; }
  .history-heading, .history-results-head { align-items: stretch; flex-direction: column; }
  .history-filters { grid-template-columns: 1fr; }
  .history-search { grid-column: auto; }
  .history-filter-actions .btn { flex: 1; }
  .history-status-grid { grid-template-columns: 1fr; }
  .history-pagination { justify-content: center; overflow-x: auto; }
}
