:root {
  color-scheme: dark;
  --navy-950: #020a14;
  --navy-900: #061426;
  --navy-850: #081b31;
  --navy-800: #0b2744;
  --blue-active: #66b9ee;
  --blue-active-hover: #7bc7f5;
  --text-on-blue: #03101d;
  --white: #f7fbff;
  --muted: #aabdd1;
  --line: rgba(174, 211, 241, .25);
  --line-strong: rgba(218, 237, 251, .58);
  --surface: rgba(7, 26, 47, .9);
  --surface-dark: #07192c;
  --success: #55d6a0;
  --zoom: 1;
  --radius: 20px;
  --pill-radius: 999px;
  --name-width: clamp(96px, 20vw, 175px);
  --data-width: max(102px, calc((100vw - var(--name-width) - 42px) / 3.5));
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--navy-950);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--white);
  font-family: "Quicksand", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 12% -8%, rgba(45, 120, 183, .22), transparent 30rem),
    var(--navy-900);
}

button,
input { font: inherit; }

button { color: inherit; }

.page {
  width: min(1180px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) clamp(10px, 2.8vw, 34px) max(22px, env(safe-area-inset-bottom));
}

.title {
  margin: 0 0 20px;
  text-align: center;
  font-size: clamp(1.75rem, 4.5vw, 3.15rem);
  font-weight: 500;
  letter-spacing: -.04em;
  line-height: 1.1;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 7px;
}

.tabs {
  display: flex;
  gap: 9px;
  margin-bottom: 11px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 0 0 auto;
  min-width: clamp(130px, 20vw, 205px);
  min-height: 44px;
  padding: 8px 20px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--pill-radius);
  background: var(--surface-dark);
  font-size: clamp(.9rem, 1.7vw, 1.02rem);
  font-weight: 700;
  cursor: pointer;
  transition: background-color .16s ease, border-color .16s ease, transform .16s ease;
}

.tab:hover { border-color: var(--blue-active-hover); }
.tab:active { transform: scale(.98); }

.tab[aria-selected="true"] {
  color: var(--text-on-blue);
  background: var(--blue-active);
  border-color: #c7ebff;
}

.panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 18px 55px rgba(0, 0, 0, .25);
}

.panel[hidden] { display: none; }

.controls {
  padding: clamp(18px, 3.3vw, 34px);
  border-bottom: 1px solid var(--line);
}

.date-wrap {
  width: min(100%, 285px);
  margin-bottom: clamp(24px, 4vw, 38px);
}

.field-label {
  display: block;
  margin: 0 0 7px 3px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 600;
}

.date-input {
  width: 100%;
  height: 46px;
  padding: 0 15px;
  border: 1px solid rgba(255, 255, 255, .74);
  border-radius: 15px;
  outline: none;
  color: #071424;
  background: #f8fbff;
  font-size: .98rem;
  font-weight: 700;
  color-scheme: light;
  transition: border-color .16s ease, box-shadow .16s ease;
}

.date-input:focus {
  border-color: var(--blue-active-hover);
  box-shadow: 0 0 0 3px rgba(102, 185, 238, .22);
}

.selection-label { margin-bottom: 10px; }

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  min-height: 39px;
  padding: 7px 15px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--pill-radius);
  background: var(--surface-dark);
  font-size: clamp(.85rem, 1.5vw, .95rem);
  font-weight: 700;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, transform .15s ease;
}

.tag:hover { border-color: var(--blue-active-hover); }
.tag:active { transform: scale(.97); }

.tag[aria-pressed="true"] {
  color: var(--text-on-blue);
  background: var(--blue-active);
  border-color: #c7ebff;
}

.workspace { padding: 10px 12px 16px; }

.toolbar {
  position: sticky;
  top: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 0 9px;
  background: rgba(7, 26, 47, .97);
}

.zoom-row,
.action-row,
.actions,
.sessions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.action-row {
  justify-content: space-between;
  align-items: flex-start;
}

.actions,
.sessions { flex-wrap: wrap; }

.circle-btn {
  width: 35px;
  height: 35px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 35px;
  padding: 0;
  border: 1px solid rgba(210, 234, 252, .42);
  border-radius: 50%;
  background: var(--surface-dark);
  font-size: 1.05rem;
  cursor: pointer;
}

.circle-btn:hover,
.circle-btn:focus-visible {
  color: var(--text-on-blue);
  background: var(--blue-active);
  border-color: #c7ebff;
  outline: none;
}

.circle-btn:active { transform: scale(.94); }

.action-btn,
.session-chip {
  min-height: 37px;
  padding: 7px 12px;
  border: 1px solid rgba(210, 234, 252, .36);
  border-radius: 12px;
  background: var(--surface-dark);
  font-size: calc(.86rem * var(--zoom));
  font-weight: 700;
}

.action-btn { cursor: pointer; }

.action-btn:hover,
.action-btn.primary {
  color: var(--text-on-blue);
  background: var(--blue-active);
  border-color: #c7ebff;
}

.action-btn:disabled { opacity: .55; cursor: wait; }
.session-chip { color: #d8edfc; cursor: pointer; }
.session-chip:disabled { cursor: default; opacity: 1; }
.session-chip.online::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(85, 214, 160, .12);
}

.status {
  min-height: 20px;
  margin: 1px 1px 0;
  color: var(--muted);
  font-size: .78rem;
}

.status.success { color: var(--success); }
.status.error { color: #ff9aa1; }

.grid-host {
  position: relative;
  max-height: min(68vh, 720px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(2, 12, 23, .38);
  overscroll-behavior: contain;
}

table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

col.name-col { width: var(--name-width); }
col.data-col { width: var(--data-width); }

th,
td {
  padding: calc(7px * var(--zoom)) calc(8px * var(--zoom));
  border-top: 1px solid rgba(174, 211, 241, .11);
  border-right: 1px solid rgba(174, 211, 241, .13);
  text-align: center;
  vertical-align: middle;
  font-size: calc(.84rem * var(--zoom));
}

tr > *:last-child { border-right: 0; }

thead th {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: 46px;
  background: #081d33;
  border-top: 0;
  border-bottom: 1px solid rgba(174, 211, 241, .3);
  font-weight: 700;
}

.name-head,
.name-cell {
  position: sticky;
  left: 0;
  z-index: 45;
  background: #09223c;
  border-right: 1px solid rgba(174, 211, 241, .32);
}

.name-cell {
  z-index: 20;
  text-align: left;
  font-weight: 600;
}

.head-inner {
  position: relative;
  padding-right: 19px;
}

.column-reset {
  position: absolute;
  top: 50%;
  right: 0;
  width: 19px;
  height: 19px;
  display: grid;
  place-items: center;
  padding: 0;
  transform: translateY(-50%);
  border: 1px solid rgba(210, 234, 252, .4);
  border-radius: 50%;
  background: #020d18;
  cursor: pointer;
}

.column-reset:hover {
  color: var(--text-on-blue);
  background: var(--blue-active);
}

.attendance-cell {
  min-width: 86px;
  min-height: 39px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 8px;
  border: 1px solid rgba(210, 234, 252, .3);
  border-radius: 12px;
  background: #07192c;
  cursor: pointer;
  user-select: none;
  transition: background-color .14s ease, border-color .14s ease, transform .14s ease;
}

.attendance-cell:hover { border-color: var(--blue-active-hover); }
.attendance-cell:active { transform: scale(.97); }

.attendance-cell.has-value {
  color: var(--text-on-blue);
  background: var(--blue-active);
  border-color: #c7ebff;
}

.cell-emoji { font-size: calc(.95rem * var(--zoom)); }
.cell-label { font-size: calc(.73rem * var(--zoom)); }

.empty-state {
  display: grid;
  min-height: 130px;
  place-items: center;
  padding: 22px;
  color: var(--muted);
  text-align: center;
}

.hatim-frame {
  display: block;
  width: 100%;
  height: min(82vh, 950px);
  min-height: 620px;
  border: 0;
  background: var(--navy-900);
}

.dialog-backdrop {
  position: fixed;
  z-index: 200;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 7, 14, .74);
  backdrop-filter: blur(7px);
}

.dialog-backdrop[hidden] { display: none; }

.dialog {
  width: min(100%, 350px);
  padding: 19px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  background: #071b30;
  box-shadow: 0 24px 75px rgba(0, 0, 0, .42);
}

.dialog p { margin: 0 0 17px; line-height: 1.5; }

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

@media (max-width: 640px) {
  :root {
    --name-width: clamp(105px, 35vw, 145px);
    --data-width: max(98px, calc((100vw - var(--name-width) - 26px) / 1.65));
  }

  .page { padding-inline: 8px; }
  .title { margin-bottom: 18px; }
  .tabs { gap: 7px; }

  .tab {
    min-width: 128px;
    min-height: 41px;
    padding: 7px 15px;
  }

  .panel { border-radius: 17px; }
  .controls { padding: 16px 12px 20px; }
  .date-wrap { width: min(100%, 230px); margin-bottom: 22px; }
  .date-input { height: 43px; border-radius: 13px; }
  .tag-list { gap: 7px; }
  .tag { min-height: 36px; padding: 6px 12px; }
  .workspace { padding: 8px 7px 12px; }
  .action-row { flex-direction: column; }
  .sessions { width: 100%; }
  .grid-host { border-radius: 13px; }
  .hatim-frame { min-height: 74vh; }
}

@media (max-width: 380px) {
  .title { font-size: 1.55rem; }
  .tab { min-width: 118px; font-size: .84rem; }
  .tag { font-size: .82rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
