@font-face {
  font-family: "InterLocal";
  src: url("/assets/vendor/fonts/Inter-Variable.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "VazirLocal";
  src: url("/assets/vendor/fonts/Vazirmatn-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "VazirLocal";
  src: url("/assets/vendor/fonts/Vazirmatn-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

body {
  margin: 0;
  background: #f4f7f8;
  color: #172026;
  font-family: "VazirLocal", "InterLocal", "Segoe UI", sans-serif;
  font-feature-settings: "tnum" 1, "ss01" 1;
}

.container {
  max-width: 1260px;
  margin: 0 auto;
  padding: 1.5rem;
}

.hero {
  margin-bottom: 1.5rem;
}

.hero h1 {
  margin-bottom: 0.25rem;
}

.hero p {
  margin-top: 0;
}

.presence-strip {
  position: sticky;
  top: 0.55rem;
  z-index: 40;
  display: flex;
  gap: 0.65rem;
  margin-bottom: 1rem;
  padding: 0.5rem;
  border: 1px solid #d7e2ea;
  border-radius: 10px;
  background: rgba(244, 247, 248, 0.94);
  backdrop-filter: blur(5px);
}

.presence-pill {
  min-width: 170px;
  display: inline-flex;
  align-items: baseline;
  gap: 0.45rem;
  padding: 0.38rem 0.6rem;
  border-radius: 999px;
  border: 1px solid #cfdbe4;
  background: #ffffff;
}

.presence-label {
  font-size: 0.78rem;
  color: #5a6974;
}

.presence-value {
  font-size: 1rem;
  color: #172026;
}

#connected-devices-pill.online {
  border-color: #8fd9b4;
  background: #ecfbf3;
}

#connected-devices-pill.offline {
  border-color: #e5c2c2;
  background: #fff3f3;
}

.grid.two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.grid.two > .card {
  width: 100%;
  min-width: 0;
}

.card {
  background: #fff;
  border: 1px solid #dce4ea;
  border-radius: 8px;
  padding: 1rem;
}

#calendar-toggle {
  min-height: 2rem;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.status {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.status-clock-panel {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.status-clock {
  width: 56px;
  height: 56px;
  border-radius: 50%;
}

.status-time-info {
  display: inline-flex;
  flex-direction: column;
  gap: 0.1rem;
}

.status-countdown {
  min-width: 3ch;
  font-size: 0.82rem;
  color: #4a5a65;
}

.status-clock-time {
  font-size: 0.82rem;
  color: #2f414d;
}

#next-connection-estimate {
  word-break: break-word;
}

.status.online {
  background: #d7f6e6;
  color: #0b6c3d;
}

.status.offline {
  background: #fbe3e3;
  color: #9b1d1d;
}

table.primary {
  width: 100%;
  font-size: 0.9rem;
  min-width: 420px;
}

table.primary th,
table.primary td {
  padding: 0.45rem 0.4rem;
  border-bottom: 1px solid #e9eef2;
}

table.primary tbody tr:nth-child(even) {
  background: #f9fbfc;
}

.row-live {
  font-weight: 600;
  color: #0b6c3d;
}

.timeline-list {
  display: grid;
  gap: 0.45rem;
}

.timeline-row {
  display: grid;
  grid-template-columns: 56px 1fr 58px;
  align-items: center;
  gap: 0.5rem;
}

.timeline-label {
  font-size: 0.82rem;
  color: #4a5a65;
}

.timeline-track {
  position: relative;
  height: 14px;
  border-radius: 999px;
  background: #e7edf1;
  overflow: hidden;
}

.timeline-bar {
  position: absolute;
  top: 0;
  height: 100%;
  border-radius: 999px;
  background: #1396e0;
}

.timeline-total {
  text-align: right;
  font-size: 0.8rem;
  color: #4a5a65;
}

.chart-wrap {
  position: relative;
  min-height: 240px;
}

.heatmap-grid {
  display: grid;
  grid-template-columns: 28px repeat(7, minmax(0, 1fr));
  gap: 4px;
  font-size: 0.68rem;
  width: 100%;
}

.heatmap-wrap {
  width: 100%;
  overflow: hidden;
  -webkit-overflow-scrolling: touch;
}

.heatmap-head {
  text-align: center;
  color: #4a5a65;
  padding-bottom: 2px;
  white-space: nowrap;
}

.heatmap-hour {
  color: #4a5a65;
  text-align: right;
  padding-right: 4px;
  line-height: 14px;
}

.heatmap-cell {
  height: 14px;
  border-radius: 3px;
  background: #edf2f5;
}

.heatmap-tooltip {
  position: fixed;
  z-index: 1100;
  pointer-events: none;
  max-width: 280px;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  background: rgba(25, 33, 40, 0.95);
  color: #f6f9fb;
  font-family: "VazirLocal", "InterLocal", "Segoe UI", sans-serif;
  font-size: 0.8rem;
  line-height: 1.35;
  direction: rtl;
  unicode-bidi: plaintext;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .heatmap-tooltip {
    max-width: calc(100vw - 16px);
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 900px) {
  .grid.two {
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
  }

  .grid.two > .card {
    width: 100%;
    box-sizing: border-box;
  }

  .timeline-row {
    grid-template-columns: 48px 1fr 52px;
  }

  .chart-wrap {
    min-height: 220px;
  }
}

@media (min-width: 901px) {
  table.primary {
    min-width: 0;
  }
}

@media (max-width: 640px) {
  .container {
    padding: 0.8rem;
  }

  .presence-strip {
    top: 0.35rem;
    gap: 0.45rem;
    padding: 0.42rem;
    flex-wrap: wrap;
  }

  .presence-pill {
    min-width: 0;
    flex: 1 1 100%;
  }

  .hero h1 {
    font-size: 1.4rem;
  }

  .hero p,
  .hero small,
  .card p {
    font-size: 0.88rem;
  }

  .card {
    padding: 0.75rem;
  }

  .grid.two {
    width: 100%;
  }

  .grid.two > .card {
    width: 100%;
  }

  .calendar-row {
    display: block;
  }

  .calendar-row label {
    display: block;
    margin-bottom: 0.35rem;
  }

  #calendar-toggle {
    display: block;
    width: 100%;
    box-sizing: border-box;
  }

  .status-row {
    align-items: flex-start;
    gap: 0.5rem;
  }

  .status-clock-panel {
    flex-wrap: wrap;
    max-width: 100%;
  }

  .status-time-info {
    min-width: 0;
  }

  table.primary {
    font-size: 0.82rem;
    min-width: 380px;
  }

  table.primary th,
  table.primary td {
    padding: 0.38rem 0.32rem;
    white-space: nowrap;
  }

  .timeline-row {
    grid-template-columns: 42px 1fr 46px;
    gap: 0.35rem;
  }

  .timeline-track {
    height: 12px;
  }

  .timeline-label,
  .timeline-total {
    font-size: 0.74rem;
  }

  .heatmap-grid {
    grid-template-columns: 34px repeat(7, minmax(36px, 1fr));
    gap: 3px;
    font-size: 0.67rem;
    min-width: 360px;
  }

  .heatmap-wrap {
    overflow-x: auto;
    overflow-y: hidden;
  }

  .heatmap-cell {
    height: 11px;
    border-radius: 2px;
  }

  .chart-wrap {
    min-height: 200px;
  }
}
