:root {
  font-size: 16px;
  --blue: #0066cc;
  --blue-dark: #0056aa;
  --gray-light: #f5f7fb;
  --card-border: #e4e7ef;
  --text-muted: #5f6b7a;
  --text-strong: #0f172a;
  --shadow-soft: 0 18px 48px rgba(15, 23, 42, 0.08);
  --table-stripe: #f8fafc;
}

* { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }
body {
  margin: 0;
  padding: 12px 12px 20px;
  font-family: "Segoe UI", Arial, sans-serif;
  background: var(--gray-light);
  color: var(--text-strong);
  min-height: 100vh;
}

.page {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  gap: 18px;
  min-height: 100vh;
  align-items: start;
}

.card {
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  box-shadow: var(--shadow-soft);
  padding: 12px 14px;
}

/* Header */
.top-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 12px 14px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.brand img {
  height: 46px;
  width: auto;
  border-radius: 0;
  object-fit: contain;
}
.brand-text {
  display: grid;
  gap: 4px;
}
.eyebrow {
  margin: 0;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
h1 {
  margin: 0;
  font-size: 2rem;
  letter-spacing: 0.01em;
}
.subtitle {
  margin: 0;
  font-size: 0.96rem;
  color: var(--text-muted);
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.time-stack {
  display: grid;
  gap: 4px;
  text-align: right;
  min-width: 170px;
}
.time-label {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.87rem;
}
.time-value {
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.logout-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 999px;
  border: none;
  background: var(--blue);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  box-shadow: 0 12px 24px rgba(0, 102, 204, 0.2);
  transition: background 0.2s ease, transform 0.1s ease;
}
.logout-btn:hover { background: var(--blue-dark); }
.logout-btn:active { transform: translateY(1px); }

/* Menu */
.menu-wrapper { position: relative; }
.menu-toggle {
  border: 1px solid var(--card-border);
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
  font-weight: 900;
  font-size: 1.1rem;
}
.menu-toggle:focus-visible {
  outline: 3px solid rgba(0, 102, 204, 0.3);
  outline-offset: 2px;
}
.menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(1px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease;
  z-index: 24;
}
.menu-overlay.open {
  opacity: 1;
  pointer-events: all;
}
.menu-drawer {
  position: fixed;
  top: 0;
  right: -320px;
  width: min(320px, 86vw);
  height: 100vh;
  background: #fff;
  box-shadow: -18px 0 40px rgba(15, 23, 42, 0.18);
  border-left: 1px solid var(--card-border);
  transition: right 180ms ease;
  z-index: 25;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 18px 18px 16px;
  box-sizing: border-box;
}
.menu-drawer.open {
  right: 0;
}
.menu-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.menu-drawer__header h3 {
  margin: 0;
}
.menu-close {
  border: none;
  background: #f3f6fb;
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  font-weight: 800;
}
.menu-drawer__body {
  display: grid;
  gap: 10px;
  margin: 14px 0;
  align-content: start;
  grid-auto-rows: min-content;
}
.menu-signed {
  margin: 0 0 6px;
  font-weight: 700;
  color: var(--text-strong);
}
.menu-link,
.menu-link.as-button {
  display: block;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  text-decoration: none;
  color: var(--text-strong);
  font-weight: 700;
  background: #fff;
  cursor: pointer;
  text-align: left;
  height: 50px;
  display: flex;
  align-items: center;
}
.menu-link:hover,
.menu-link.as-button:hover {
  background: #f5f8ff;
}
.menu-link.danger { color: #b00020; border-color: rgba(176,0,32,0.2); }

/* Card + table */
.table-card {
  display: grid;
  gap: 14px;
  padding: 12px 12px 18px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.card-header h2 {
  margin: 2px 0 0;
  font-size: 1.35rem;
}
.muted-note {
  margin: 0;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.95rem;
  background: #f3f6fb;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--card-border);
}
.table-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.table-controls .page-info {
  font-weight: 600;
  color: var(--text-strong);
}
.table-controls button {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: #fff;
  cursor: pointer;
  font-weight: 700;
  transition: background 0.2s ease;
}
.table-controls button:hover:not(:disabled) {
  background: #f3f6fb;
}
.table-controls button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.table-controls select {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  font-weight: 600;
}

.table-wrapper {
  overflow-x: auto;
  width: 100%;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  background: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
  position: relative;
  min-height: 280px;
}
table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}
th, td {
  padding: 12px 10px;
  text-align: center;
  font-size: 0.95rem;
  line-height: 1.3;
  white-space: nowrap;
}
th {
  font-weight: 700;
  color: var(--text-strong);
  background: #f7f8fc;
  border-bottom: 1px solid var(--card-border);
}
td { color: #111; }
tbody tr.data-row { background: #fff; }
tbody tr.data-row.row-alt { background: var(--table-stripe); }
tbody tr[data-session-id] { cursor: pointer; transition: background-color 0.2s ease, transform 0.1s ease; }
tbody tr[data-session-id]:hover { background-color: #eef3ff; }
.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: linear-gradient(180deg, rgba(245,247,251,0.95), rgba(255,255,255,0.95));
  z-index: 5;
  text-align: center;
}
.empty-circle {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 3px solid rgba(0,102,204,0.25);
  border-top-color: rgba(0,102,204,0.8);
  animation: spin 1s linear infinite;
}
.empty-text {
  margin: 0;
  font-weight: 700;
  color: var(--text-muted);
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Sort arrows */
thead th[data-sort-key] { user-select: none; }
thead th[data-sort-key] .sort-arrow {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
}
thead th[data-sort-key] .sort-arrow.active { color: var(--text-strong); font-weight: 700; }
thead th[data-sort-key]:hover .sort-arrow:not(.active) { color: var(--blue-dark); }

/* Formula colors */
.formula-A-color { color: #00f0f0; }
.formula-B-color { color: #aa91e6; }
.formula-C-color { color: #f441ff; }

/* Details panel */
.details-panel { display: none; }
.details-panel.open { display: table-row; }
.details-wrapper { overflow: hidden; height: 0; transition: height 300ms ease; will-change: height; }
.details-panel.open .details-wrapper { height: auto; }
.details-panel.open td { padding: 14px 12px; background: #f5f7fc; }
.details-panel-container {
  display: grid;
  gap: 12px;
  padding: 10px 4px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.details-panel-container > div {
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 12px 12px 18px;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.04);
}
.details-panel-container h3 {
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 10px 0;
}
.details-panel-container p,
.details-panel-container strong {
  text-align: left !important;
  line-height: 1.35;
  margin: 2px 0;
  font-size: 0.94rem;
  color: var(--text-strong);
}
.details-panel img { height: 20px; width: auto; margin-right: 6px; vertical-align: middle; }
.details-panel-container h3.user-comments-heading { margin-top: 26px; margin-bottom: 8px; }

/* Responsive */
@media (max-width: 900px) {
  body { padding: 20px 12px 28px; }
  .page { gap: 14px; }
  .brand img { height: 46px; }
  .table-card { padding: 16px 14px 22px; }
  table { min-width: unset; table-layout: auto; }
  th, td { padding: 10px 8px; font-size: 0.93rem; white-space: normal; word-break: break-word; overflow-wrap: anywhere; }
  .time-stack { min-width: 160px; }
}
@media (max-width: 620px) {
  .top-card { flex-direction: column; align-items: flex-start; }
  .header-actions { width: 100%; justify-content: flex-start; }
  body.mobile-mode .mobile-hide { display: none !important; }
  body.mobile-mode .mobile-only { display: block !important; }
  .details-panel-container { grid-template-columns: 1fr; }
  .details-panel.open td { padding: 10px 8px; }
  .table-wrapper { -webkit-overflow-scrolling: touch; }
}

/* Hidden by default */
.mobile-only { display: none; }

/* Footer */
.site-footer {
  margin-top: 20px;
  padding: 18px 12px 10px;
  text-align: center;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.95rem;
}
