:root {
  --ink: #102a2c;
  --ink-soft: #3d5a5c;
  --paper: #f3f7f6;
  --panel: rgba(255, 255, 255, 0.86);
  --line: rgba(16, 42, 44, 0.1);
  --teal: #0e7c78;
  --teal-deep: #0a4f4d;
  --teal-glow: #1fb5ae;
  --accent: #e8a54b;
  --danger: #c23b3b;
  --ok: #1f8a5b;
  --shadow: 0 18px 50px rgba(10, 50, 48, 0.12);
  --radius: 18px;
  --sidebar: 270px;
  --font: "Outfit", system-ui, sans-serif;
  --display: "Source Serif 4", Georgia, serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(31, 181, 174, 0.22), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(232, 165, 75, 0.16), transparent 50%),
    linear-gradient(165deg, #eaf4f3 0%, var(--paper) 45%, #e7eef0 100%);
}

body {
  line-height: 1.5;
}

a {
  color: var(--teal-deep);
  text-decoration: none;
}

a:hover {
  color: var(--teal);
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 1.4rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  background:
    linear-gradient(180deg, rgba(10, 79, 77, 0.97), rgba(14, 60, 58, 0.98)),
    var(--teal-deep);
  color: #edf8f7;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.06);
}

.brand {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  padding: 0.35rem 0.4rem;
  color: inherit;
  text-decoration: none;
}

a.brand:hover {
  color: inherit;
  text-decoration: none;
  opacity: 0.92;
}

.brand-mark {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 0.9rem;
  display: grid;
  place-items: center;
  font-weight: 700;
  background: linear-gradient(145deg, var(--teal-glow), var(--teal));
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.22);
  object-fit: cover;
  flex-shrink: 0;
}

img.brand-mark {
  padding: 0;
  background: #0A4F4D;
}

.brand strong {
  display: block;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.brand small {
  color: rgba(237, 248, 247, 0.7);
  font-size: 0.78rem;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.nav a {
  color: rgba(237, 248, 247, 0.84);
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  font-weight: 500;
  transition: background 0.18s ease, transform 0.18s ease;
}

.nav a:hover,
.nav a.active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.nav a.active {
  box-shadow: inset 3px 0 0 var(--accent);
}

.sidebar-footer {
  display: grid;
  gap: 0.75rem;
}

.user-chip {
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
}

.user-chip span {
  display: block;
  font-weight: 600;
}

.user-chip small {
  color: rgba(237, 248, 247, 0.65);
  text-transform: capitalize;
}

.settings-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.65rem;
  padding: 0.35rem 0.55rem;
  border-radius: 8px;
  color: rgba(237, 248, 247, 0.78);
  font-size: 0.82rem;
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease;
}

.settings-link:hover,
.settings-link.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.settings-link svg {
  flex-shrink: 0;
  opacity: 0.9;
}

.main {
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1.25rem 1.5rem 0.5rem;
}

.topbar-title {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.topbar h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.25rem, 1.7vw, 1.55rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.topbar-subtitle {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 500;
  color: #668888;
  line-height: 1.2;
}

.menu-toggle {
  display: none;
  border: 0;
  background: var(--panel);
  border-radius: 10px;
  width: 2.5rem;
  height: 2.5rem;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.content {
  padding: 1rem 1.5rem 2.5rem;
}

.panel {
  background: var(--panel);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.panel + .panel {
  margin-top: 1rem;
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.panel-head h2 {
  margin: 0;
  font-size: 1.1rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.stats-dash {
  margin-bottom: 0;
}

.stat-time {
  font-size: 1.25rem !important;
}

.dash-filters {
  display: grid;
  grid-template-columns: 1.2fr 1.1fr 1fr 1fr auto;
  gap: 1rem;
  align-items: end;
}

#dashboard-root {
  position: relative;
}

#dashboard-root.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 5;
  border-radius: var(--radius);
  background: rgba(243, 247, 246, 0.55);
  backdrop-filter: blur(1px);
  pointer-events: all;
}

#dashboard-root.is-loading::before {
  content: "";
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 6;
  width: 1.35rem;
  height: 1.35rem;
  border: 2px solid var(--teal);
  border-right-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
}

.pct-bar {
  display: inline-block;
  width: 72px;
  height: 8px;
  margin-right: 0.45rem;
  border-radius: 999px;
  background: rgba(16, 42, 44, 0.08);
  vertical-align: middle;
  overflow: hidden;
}

.pct-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--teal-glow), var(--teal));
  border-radius: inherit;
}

@media (max-width: 960px) {
  .dash-filters,
  .dash-filters-single-branch {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 560px) {
  .dash-filters {
    grid-template-columns: 1fr;
  }
}

.stat {
  position: relative;
  overflow: hidden;
  padding: 1.15rem 1.2rem;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.stat::after {
  content: "";
  position: absolute;
  inset: auto -20% -40% auto;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(14, 124, 120, 0.12);
}

.stat span {
  display: block;
  color: var(--ink-soft);
  font-size: 0.88rem;
  margin-bottom: 0.35rem;
}

.stat strong {
  font-family: var(--display);
  font-size: 1.8rem;
  letter-spacing: -0.03em;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 0;
  border-radius: 12px;
  padding: 0.7rem 1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled,
.btn.is-loading {
  opacity: 0.72;
  cursor: wait;
  transform: none;
  pointer-events: none;
}

.btn-spinner {
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  animation: btn-spin 0.7s linear infinite;
}

@keyframes btn-spin {
  to {
    transform: rotate(360deg);
  }
}

.btn-primary {
  background: linear-gradient(135deg, var(--teal), var(--teal-deep));
  color: #fff;
  box-shadow: 0 10px 24px rgba(14, 124, 120, 0.28);
}

.btn-primary:hover {
  color: #fff;
}

.btn-accent {
  background: linear-gradient(135deg, #f0b35d, var(--accent));
  color: #2a1c08;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.btn-light {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn-danger {
  background: #fff;
  color: var(--danger);
  border: 1px solid rgba(194, 59, 59, 0.25);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 0.45rem 0.75rem;
  font-size: 0.88rem;
  border-radius: 10px;
}

.table-wrap {
  overflow-x: auto;
}

table.data {
  width: 100%;
  border-collapse: collapse;
}

table.data th,
table.data td {
  text-align: left;
  padding: 0.85rem 0.65rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

table.data th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}

table.data tr:hover td {
  background: rgba(14, 124, 120, 0.04);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-ok {
  background: rgba(31, 138, 91, 0.12);
  color: var(--ok);
}

.badge-warn {
  background: rgba(232, 165, 75, 0.18);
  color: #8a5a12;
}

.badge-muted {
  background: rgba(16, 42, 44, 0.08);
  color: var(--ink-soft);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.form-grid .full {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 0.4rem;
  font-weight: 500;
  font-size: 0.92rem;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="date"],
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  font: inherit;
  background: #fff;
  color: var(--ink);
}

/* Dashboard tabs & summary */
.dash-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 1.25rem;
  margin: 0 0 1rem;
  padding: 0 0.25rem 0.65rem;
  border-bottom: 1px solid var(--line);
}

.dash-tabs a {
  position: relative;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.35rem 0;
}

.dash-tabs a:hover {
  color: var(--ink);
}

.dash-tabs a.active {
  color: var(--ink);
}

.dash-tabs a.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -0.7rem;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--accent);
}

.summary-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(220px, 0.75fr);
  gap: 1.25rem;
  align-items: center;
  margin-bottom: 1.25rem;
}

.dash-filters-single-branch {
  grid-template-columns: 1.4fr 1fr 1fr auto;
}

.dash-filters-single-date.dash-filters-single-branch {
  grid-template-columns: 1.4fr 1fr auto;
}

.dash-filters-single-date:not(.dash-filters-single-branch) {
  grid-template-columns: 1.2fr 1.1fr 1fr auto;
}

/* Admin: no entity filter column */
.dash-filters.dash-filters-no-entity.dash-filters-single-date.dash-filters-single-branch {
  grid-template-columns: 1fr auto;
}

.dash-filters.dash-filters-no-entity.dash-filters-single-date:not(.dash-filters-single-branch) {
  grid-template-columns: 1.2fr 1fr auto;
}

.dash-filters.dash-filters-no-entity.dash-filters-date-range {
  grid-template-columns: 1.2fr 1fr 1fr auto;
}

.chart-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.chart-wrap-modern {
  gap: 1.1rem 1.35rem;
  padding: 0.85rem 1rem;
  border-radius: 16px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.95), rgba(243, 247, 246, 0.72));
  border: 1px solid rgba(16, 42, 44, 0.08);
  box-shadow: 0 10px 28px rgba(10, 50, 48, 0.06);
}

.chart-stage {
  position: relative;
  width: 168px;
  height: 168px;
  flex-shrink: 0;
}

.chart-wrap canvas {
  display: block;
  width: 168px !important;
  height: 168px !important;
}

.chart-center-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  pointer-events: none;
}

.chart-center-label strong {
  font-family: var(--display);
  font-size: 1.45rem;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--ink);
}

.chart-center-label span {
  margin-top: 0.2rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.chart-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.chart-legend-modern {
  min-width: 148px;
  gap: 0.45rem;
}

.chart-legend-modern li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.45rem;
  border-radius: 10px;
  font-size: 0.82rem;
}

.chart-legend-modern li:hover {
  background: rgba(14, 124, 120, 0.06);
}

.chart-legend-modern span {
  color: var(--ink-soft);
}

.chart-legend-modern em {
  font-style: normal;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.chart-legend i {
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 3px;
  margin-right: 0.45rem;
  vertical-align: middle;
}

.chart-legend-modern i {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  margin-right: 0;
  box-shadow: 0 0 0 3px rgba(16, 42, 44, 0.04);
}

.lg-in { background: #1f8a5b; }
.lg-out { background: #e8a54b; }
.lg-miss { background: #c23b3b; }
.lg-rej { background: #5c2a2a; }

.history-filters {
  display: grid;
  grid-template-columns: 1.4fr 1fr auto;
  gap: 0.85rem;
  align-items: end;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

table.data tr.row-missed td {
  background: rgba(194, 59, 59, 0.08);
}

table.data tr.row-missed:hover td {
  background: rgba(194, 59, 59, 0.12);
}

table.data tr.row-missed .call-pill,
table.data tr.row-missed td {
  color: #a32828;
}

.sim-number {
  font-size: 0.92rem;
  letter-spacing: -0.01em;
}

@media (max-width: 720px) {
  .history-filters {
    grid-template-columns: 1fr;
  }
}

.call-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.call-pill::before {
  content: "";
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
}

.call-in { color: #1f8a5b; }
.call-in::before { background: #1f8a5b; }
.call-out { color: #b57418; }
.call-out::before { background: #e8a54b; }
.call-miss { color: #c23b3b; }
.call-miss::before { background: #c23b3b; }
.call-rej { color: #5c2a2a; }
.call-rej::before { background: #5c2a2a; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.85rem;
}

.kpi {
  padding: 1rem 1.05rem;
  border-radius: 14px;
  background: linear-gradient(160deg, #fff, rgba(243, 247, 246, 0.9));
  border: 1px solid var(--line);
}

.kpi span {
  display: block;
  color: var(--ink-soft);
  font-size: 0.82rem;
  margin-bottom: 0.4rem;
}

.kpi strong {
  font-family: var(--display);
  font-size: 1.65rem;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.kpi-time {
  font-size: 1.35rem !important;
}

.kpi-warn strong {
  color: var(--danger);
}

.branch-summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.mobile-tag {
  display: inline-block;
  margin-top: 0.25rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--teal-deep);
  background: rgba(14, 124, 120, 0.1);
}

.branch-summary-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  padding: 1rem 1.1rem 1.15rem;
  display: grid;
  gap: 0.85rem;
}

a.branch-summary-card.branch-drill {
  color: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

a.branch-summary-card.branch-drill:hover {
  color: inherit;
  border-color: rgba(14, 124, 120, 0.35);
  box-shadow: 0 12px 28px rgba(10, 50, 48, 0.1);
  transform: translateY(-2px);
}

.branch-drill-cta {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--teal-deep);
}

.branch-summary-card header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.65rem;
}

.branch-summary-card header strong {
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.branch-summary-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.bsm {
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(243, 247, 246, 0.6);
}

.bsm span {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  margin-bottom: 0.35rem;
}

.bsm strong {
  font-family: var(--display);
  font-size: 1.55rem;
  letter-spacing: -0.03em;
  line-height: 1;
}

.bsm-in strong { color: #1f8a5b; }
.bsm-out strong { color: #b57418; }
.bsm-miss strong { color: #c23b3b; }
.bsm-nocb {
  grid-column: 1 / -1;
  background: rgba(194, 59, 59, 0.06);
  border-color: rgba(194, 59, 59, 0.18);
}

.bsm-nocb strong {
  color: var(--danger);
}

.sim-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}

.sim-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  padding: 1rem 1.1rem 1.15rem;
  display: grid;
  gap: 0.9rem;
}

.sim-card header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.sim-card header strong {
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.sim-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem 0.75rem;
}

.sim-metrics > div {
  display: grid;
  gap: 0.15rem;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  background: rgba(14, 124, 120, 0.05);
}

.sim-metrics span {
  font-size: 0.75rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sim-metrics strong {
  font-size: 1rem;
}

.sim-recent h3 {
  margin: 0 0 0.55rem;
  font-size: 0.88rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sim-call-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-top: 1px solid var(--line);
  font-size: 0.9rem;
}

.sim-call-meta {
  display: grid;
  gap: 0.2rem;
  text-align: right;
  color: var(--ink-soft);
  font-size: 0.82rem;
}

@media (max-width: 960px) {
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .sim-metrics {
    grid-template-columns: 1fr;
  }

  .sim-call-row {
    flex-direction: column;
  }

  .sim-call-meta {
    text-align: left;
  }
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid rgba(14, 124, 120, 0.28);
  border-color: var(--teal);
}

textarea {
  min-height: 110px;
  resize: vertical;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 0.5rem;
}

.alert {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  margin-bottom: 1rem;
  font-weight: 500;
}

.alert-success {
  background: rgba(31, 138, 91, 0.12);
  color: #145c3c;
}

.alert-error {
  background: rgba(194, 59, 59, 0.12);
  color: #8a2222;
}

.muted {
  color: var(--ink-soft);
}

.empty {
  padding: 1.5rem;
  text-align: center;
  color: var(--ink-soft);
}

/* Auth */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.auth-card {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 2rem 1.6rem;
  animation: rise 0.45s ease both;
}

.auth-card .brand {
  color: var(--ink);
  margin-bottom: 1.4rem;
}

.auth-card .brand small {
  color: var(--ink-soft);
}

.auth-card h1 {
  margin: 0 0 0.35rem;
  font-family: var(--display);
  font-size: 1.8rem;
}

.auth-card .lead {
  margin: 0 0 1.4rem;
  color: var(--ink-soft);
}

.auth-card form {
  display: grid;
  gap: 0.9rem;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.sidebar-backdrop {
  display: none;
}

@media (max-width: 960px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .menu-toggle {
    display: inline-grid;
    place-items: center;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, var(--sidebar));
    z-index: 40;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
  }

  .sidebar.open {
    transform: none;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(8, 28, 28, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
    z-index: 30;
  }

  .sidebar-backdrop.show {
    opacity: 1;
    pointer-events: auto;
  }
}

@media (max-width: 560px) {
  .stats {
    grid-template-columns: 1fr;
  }

  .content,
  .topbar {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}

/* PPC client tags */
.client-number-cell {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.client-number-btn {
  border: none;
  background: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: var(--teal-deep);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.client-number-btn:hover {
  color: var(--teal);
}

.ppc-tag-badge {
  display: inline-block;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #fff;
  background: var(--teal);
  vertical-align: middle;
}

.ppc-tag-badge.is-empty {
  display: none;
}

.ppc-remark {
  display: inline-block;
  font-size: 0.75rem;
  color: #668888;
  font-style: italic;
}

.ppc-remark.is-empty {
  display: none;
}

.ppc-remark-field {
  display: grid;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: #668888;
}

.ppc-remark-field input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  font: inherit;
  color: var(--ink);
}

.report-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.report-card {
  display: block;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  padding: 1.1rem 1.15rem;
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.report-card:hover {
  color: inherit;
  border-color: rgba(14, 124, 120, 0.35);
  box-shadow: 0 12px 28px rgba(10, 50, 48, 0.1);
  transform: translateY(-2px);
}

.report-card strong {
  display: block;
  font-size: 1.05rem;
  margin-bottom: 0.35rem;
}

.report-card p {
  margin: 0;
  color: #668888;
  font-size: 0.9rem;
  line-height: 1.4;
}

.report-summary-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1rem;
}

.ppc-modal[hidden] {
  display: none !important;
}

.ppc-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.ppc-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 28, 28, 0.45);
}

.ppc-modal-card {
  position: relative;
  width: min(100%, 22rem);
  background: #fff;
  border-radius: 16px;
  padding: 1.1rem 1.15rem 1.2rem;
  box-shadow: 0 24px 48px rgba(10, 50, 48, 0.22);
  display: grid;
  gap: 0.55rem;
}

.ppc-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.ppc-modal-head h3 {
  margin: 0;
  font-size: 1.05rem;
}

.ppc-modal-x {
  border: none;
  background: transparent;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: #668888;
}

.ppc-modal-number {
  margin: 0;
  font-weight: 600;
  color: var(--ink);
}

.ppc-tag-options {
  display: grid;
  gap: 0.4rem;
}

.ppc-tag-option.is-current {
  border-color: var(--teal);
  background: rgba(14, 124, 120, 0.1);
  font-weight: 700;
}

.ppc-modal-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.85rem;
}

.inline-edit {
  display: inline-block;
  margin-right: 0.35rem;
}

.inline-edit > summary {
  list-style: none;
  cursor: pointer;
}

.inline-edit > summary::-webkit-details-marker {
  display: none;
}

.inline-edit-form {
  margin-top: 0.5rem;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  display: grid;
  gap: 0.5rem;
  min-width: 14rem;
}

.inline-edit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.order-arrows {
  display: inline-flex;
  flex-direction: column;
  gap: 0.15rem;
}

.order-arrow-form {
  display: inline;
  margin: 0;
}

.order-arrow {
  min-width: 2rem;
  padding: 0.2rem 0.45rem;
  line-height: 1;
  font-size: 0.75rem;
}

.order-arrow:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
