@import url("https://fonts.googleapis.com/css2?family=Public+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,500;1,600;1,700&display=swap");

:root {
  --bg: #f5f5f9;
  --panel: #ffffff;
  --panel-2: #f8f9fb;
  --text: #566a7f;
  --title: #32475c;
  --muted: #8592a3;
  --line: #d9dee3;
  --primary: #696cff;
  --primary-dark: #5f61e6;
  --danger: #ff3e1d;
  --success: #71dd37;
  --success-text: #03a100;
  --shadow: 0 0.25rem 1rem rgba(161, 172, 184, 0.45);
  --radius: 0.75rem;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Public Sans", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 0.9375rem;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: 100%;
  max-width: 520px;
}

.login-card,
.panel,
.stat-card {
  background: var(--panel);
  border: 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stat-card-button {
  width: 100%;
  text-align: left;
  border: 0;
}

.stat-card-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 0.5rem 1.2rem rgba(161, 172, 184, 0.5);
}

.login-card {
  padding: 2rem;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.75rem;
}

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

h1,
h2,
h3,
.brand,
.stat-card strong {
  color: var(--title);
}

h1 {
  font-size: 1.625rem;
  line-height: 1.35;
  margin-bottom: 0.5rem;
}

h2 {
  font-size: 1.125rem;
  line-height: 1.4;
  margin-bottom: 0.25rem;
}

h3 {
  font-size: 1rem;
  margin-bottom: 0.2rem;
}

.muted,
.td-sub,
.helper-card p,
.panel-head p {
  color: var(--muted);
}

.stack-md > * + *,
.stack-lg > * + * {
  margin-top: 16px;
}

.stack-lg > * + * {
  margin-top: 20px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  font-weight: 500;
  color: var(--title);
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--title);
  border-radius: 0.5rem;
  padding: 0.781rem 0.875rem;
  font: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
textarea:focus {
  outline: 0;
  border-color: var(--primary);
  box-shadow: 0 0 0 0.2rem rgba(105, 108, 255, 0.16);
}

.btn {
  border: 0;
  border-radius: 0.375rem;
  padding: 0.625rem 1rem;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 0.125rem 0.375rem rgba(105, 108, 255, 0.3);
}

.btn-secondary {
  background: #fff;
  color: var(--primary);
  border: 1px solid rgba(105, 108, 255, 0.32);
}

.btn-danger {
  background: rgba(255, 62, 29, 0.12);
  color: var(--danger);
}

.btn:hover {
  transform: translateY(-1px);
}

.alert {
  border-radius: 0.5rem;
  padding: 0.85rem 1rem;
  font-weight: 500;
}

.alert-danger {
  background: rgba(255, 62, 29, 0.12);
  color: var(--danger);
}

.alert-success {
  background: rgba(113, 221, 55, 0.16);
  color: var(--success-text);
}

.helper-card {
  margin-top: 1.5rem;
  padding: 1rem;
  border-radius: 0.75rem;
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.25rem;
  margin: 1.5rem auto 0;
  max-width: 1440px;
  padding: 0.875rem 1.25rem;
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.brand-block,
.user-block,
.nav,
.actions,
.hero-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  font-size: 1.1rem;
  font-weight: 600;
}

.nav a {
  padding: 0.625rem 0.875rem;
  border-radius: 0.5rem;
  color: var(--muted);
  font-weight: 500;
}

.nav a.is-active {
  background: rgba(105, 108, 255, 0.16);
  color: var(--primary);
}

.page-shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 3rem;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.breadcrumbs a {
  color: var(--primary);
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  align-items: end;
  margin-bottom: 1.5rem;
}

.pill {
  background: rgba(113, 221, 55, 0.16);
  color: var(--success-text);
  border-radius: 50rem;
  padding: 0.55rem 0.9rem;
  font-weight: 600;
}

.pill-muted {
  background: rgba(133, 146, 163, 0.15);
  color: var(--muted);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  padding: 1.25rem;
}

.stat-card span,
.stat-card small {
  display: block;
}

.stat-card strong {
  display: block;
  margin: 0.45rem 0;
  font-size: 1.625rem;
  line-height: 1;
}

.stat-card span {
  font-size: 0.8125rem;
  color: var(--muted);
}

.stat-card small {
  color: var(--muted);
}

.panel {
  padding: 1.5rem;
}

.page-shell > .panel + .panel {
  margin-top: 1.5rem;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.panel-tools {
  display: flex;
  align-items: end;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.table-wrap {
  overflow: auto;
}

.row-selected td {
  background: rgba(105, 108, 255, 0.08);
}

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

th,
td {
  text-align: left;
  padding: 0.95rem 0.75rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.text-center {
  text-align: center;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 50rem;
  padding: 0.35rem 0.7rem;
  font-size: 0.86rem;
  font-weight: 600;
}

.status-online {
  background: rgba(113, 221, 55, 0.16);
  color: var(--success-text);
}

.status-offline,
.td-error {
  color: var(--danger);
}

.status-offline {
  background: rgba(255, 62, 29, 0.12);
}

.status-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  vertical-align: middle;
}

.status-dot.status-online {
  background: #71dd37;
  box-shadow: 0 0 0 4px rgba(113, 221, 55, 0.16);
}

.status-dot.status-offline {
  background: #ff3e1d;
  box-shadow: 0 0 0 4px rgba(255, 62, 29, 0.14);
}

.status-dot.status-unknown {
  background: #8592a3;
  box-shadow: 0 0 0 4px rgba(133, 146, 163, 0.14);
}

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 520px) minmax(0, 1fr);
  gap: 24px;
}

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

.check {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
}

.check input {
  width: 18px;
  height: 18px;
}

.agency-list {
  display: grid;
  gap: 1rem;
}

.agency-item {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.125rem 1rem;
  border-radius: 0.75rem;
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.filter-inline {
  display: flex;
  align-items: end;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.timeline-chart {
  display: grid;
  width: 100%;
  gap: 0.75rem;
  align-items: end;
  min-height: 260px;
  padding: 1rem 0 0.25rem;
}

.timeline-bar-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: 100%;
  cursor: pointer;
}

.timeline-bar-wrap-active .timeline-bar {
  border-color: rgba(105, 108, 255, 0.45);
  box-shadow: 0 0 0 0.18rem rgba(105, 108, 255, 0.12);
}

.timeline-value {
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 0.45rem;
}

.timeline-bar {
  height: 180px;
  display: flex;
  align-items: end;
  justify-content: center;
  background: linear-gradient(180deg, #f9fafc 0%, #f2f4f8 100%);
  border-radius: 0.75rem;
  border: 1px solid var(--line);
  padding: 0.35rem;
}

.timeline-bar span {
  width: 100%;
  display: block;
  border-radius: 0.55rem;
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
  min-height: 8px;
}

.timeline-label {
  margin-top: 0.45rem;
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
}

.timeline-note {
  flex: 0 0 100%;
  margin-bottom: 0.75rem;
  padding: 0.75rem 0.9rem;
  border-radius: 0.65rem;
  background: rgba(105, 108, 255, 0.08);
  color: var(--primary-dark);
  font-size: 0.85rem;
  font-weight: 500;
}

.empty-state {
  padding: 1.75rem;
  text-align: center;
  color: var(--muted);
}

.modal-open {
  overflow: hidden;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(50, 71, 92, 0.45);
  z-index: 1000;
}

.modal-backdrop.is-open {
  display: flex;
}

.modal-card {
  width: min(1080px, 100%);
  max-height: 85vh;
  overflow: auto;
  background: #fff;
  border-radius: 1rem;
  box-shadow: 0 1rem 2.5rem rgba(50, 71, 92, 0.25);
  padding: 1.5rem;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.modal-close {
  border: 0;
  background: rgba(105, 108, 255, 0.12);
  color: var(--primary-dark);
  border-radius: 0.5rem;
  padding: 0.65rem 0.9rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.detail-month-hero {
  display: flex;
  justify-content: space-between;
  gap: 1.25rem;
  margin-bottom: 1rem;
  padding: 1.1rem 1.2rem;
  border-radius: 1rem;
  background: linear-gradient(135deg, rgba(105, 108, 255, 0.08) 0%, rgba(105, 108, 255, 0.03) 100%);
  border: 1px solid rgba(105, 108, 255, 0.16);
}

.detail-month-hero__main h3 {
  margin-bottom: 0.3rem;
  font-size: 1.25rem;
}

.detail-month-hero__main p {
  margin-bottom: 0;
}

.detail-month-hero__peak {
  min-width: 150px;
  padding: 0.95rem 1rem;
  border-radius: 0.85rem;
  background: #fff;
  text-align: center;
  box-shadow: 0 0.25rem 0.8rem rgba(161, 172, 184, 0.18);
}

.detail-month-side {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-compact {
  align-self: center;
  min-height: 0;
  padding: 0.5rem 0.9rem;
}

.detail-month-hero__peak span,
.detail-kpi span,
.day-cell span {
  display: block;
  color: var(--muted);
}

.detail-month-hero__peak strong,
.detail-kpi strong {
  display: block;
  color: var(--title);
  line-height: 1;
}

.detail-month-hero__peak strong {
  margin: 0.45rem 0 0.25rem;
  font-size: 2rem;
}

.detail-month-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.detail-peak-banner {
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 0.85rem;
  background: rgba(113, 221, 55, 0.16);
  color: var(--success-text);
  font-weight: 600;
}

.detail-kpi {
  padding: 1rem 1.05rem;
  border-radius: 0.9rem;
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.detail-kpi strong {
  margin-top: 0.45rem;
  font-size: 1.35rem;
}

.table-wrap-soft {
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: #fff;
}

.table-soft th:first-child,
.table-soft td:first-child {
  padding-left: 1rem;
}

.table-soft th:last-child,
.table-soft td:last-child {
  padding-right: 1rem;
}

.day-cell strong {
  display: block;
  color: var(--title);
  font-weight: 600;
}

.day-cell span {
  margin-top: 0.15rem;
  font-size: 0.78rem;
  text-transform: capitalize;
}

.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: rgba(105, 108, 255, 0.12);
  color: var(--primary-dark);
  font-weight: 700;
}

@media (max-width: 1120px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .two-col {
    grid-template-columns: 1fr;
  }

  .detail-month-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .topbar,
  .hero,
  .panel-head,
  .agency-item,
  .brand-block,
  .user-block {
    flex-direction: column;
    align-items: stretch;
  }

  .nav,
  .actions,
  .hero-meta,
  .filter-inline {
    flex-wrap: wrap;
  }

  .stats-grid,
  .grid-2,
  .detail-month-stats {
    grid-template-columns: 1fr;
  }

  .detail-month-hero {
    flex-direction: column;
  }

  .detail-month-side {
    flex-direction: column;
    align-items: stretch;
  }

  .page-shell {
    padding-inline: 16px;
  }
}
