:root {
  --bg: #f3f4ef;
  --panel: #ffffff;
  --ink: #19181a;
  --muted: #666165;
  --line: #d9d6cd;
  --btn: #166a57;
  --btn-hover: #0f5a49;
  --error-bg: #fef3f2;
  --error-ink: #7a1c1c;
  --table-head-bg: #e8eee6;
  --table-head-ink: #1f2c26;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(circle at top right, #d8e6df 0%, var(--bg) 46%);
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

body {
  min-height: 100vh;
}

html.theme-dark,
body.theme-dark {
  --bg: #14181d;
  --panel: #1b232c;
  --ink: #e9edf2;
  --muted: #a8b4c0;
  --line: #31404f;
  --error-bg: #3a1f22;
  --error-ink: #f1c4c9;
  --table-head-bg: #27333f;
  --table-head-ink: #eef3f8;
  background: var(--bg);
}

.wrap {
  max-width: min(1760px, 100%);
  margin: 0 auto;
  padding: 20px 10px 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

h1 {
  margin: 0;
  font-size: 2rem;
}

.panel {
  margin-top: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px 3px 3px;
  background: var(--panel);
  max-width: 340px;
}

.user-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  background: #d9e2ee;
  border: 1px solid var(--line);
}

.user-name {
  font-size: 0.85rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
  user-select: none;
}

.checkbox-inline input {
  width: 14px;
  height: 14px;
  accent-color: var(--btn);
}

.field-control {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.85rem;
  min-height: 32px;
}

#session-search {
  min-width: 260px;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.78rem;
  color: var(--muted);
  background: var(--panel);
}

.error-box {
  border: 1px solid #d33f3f;
  border-radius: 8px;
  background: var(--error-bg);
  color: var(--error-ink);
  padding: 8px 10px;
  font-size: 0.85rem;
  margin-bottom: 10px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.sessions-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 1220px;
  font-size: 0.84rem;
  background: var(--panel);
}

body.theme-dark .table-wrap {
  scrollbar-color: #44515f #1b232c;
}

body.theme-dark .table-wrap::-webkit-scrollbar {
  height: 12px;
}

body.theme-dark .table-wrap::-webkit-scrollbar-track {
  background: #1b232c;
}

body.theme-dark .table-wrap::-webkit-scrollbar-thumb {
  background: #44515f;
  border-radius: 999px;
  border: 2px solid #1b232c;
}

.sessions-table th,
.sessions-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
  background: transparent;
}

.sessions-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--table-head-bg);
  color: var(--table-head-ink);
  box-shadow: inset 0 -1px 0 var(--line);
}

.sessions-table tbody,
.sessions-table tbody tr,
.sessions-table tbody td {
  background: var(--panel);
}

.sessions-table tbody tr:hover td {
  background: rgba(22, 106, 87, 0.08);
}


.sort-btn {
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 600;
  font-size: 0.8rem;
  padding: 0;
  cursor: pointer;
}

.sort-btn:hover {
  color: var(--btn-hover);
}

.mono-cell {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.8rem;
}

.muted-cell {
  color: var(--muted);
}

.empty-cell {
  text-align: center;
  color: var(--muted);
  padding: 24px 12px;
  background: var(--panel);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: lowercase;
}

.status-active {
  color: #0a6b46;
  border-color: #86d4b1;
  background: #e8fff3;
}

.status-paused {
  color: #7a5800;
  border-color: #f1d284;
  background: #fff8e5;
}

.status-orphaned {
  color: #5a3a8d;
  border-color: #cbb0ef;
  background: #f4ecff;
}

.status-closed {
  color: #6e7280;
  border-color: #c2c7d1;
  background: #eef1f6;
}

.hidden {
  display: none;
}

.action-btn {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 6px 10px;
  cursor: pointer;
}

.action-btn:hover {
  border-color: var(--btn-hover);
  color: var(--btn-hover);
}

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

.login-theme-btn {
  position: fixed;
  top: 12px;
  right: 12px;
}

.login-card {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  padding: 26px 22px;
  text-align: center;
}

.login-card h1 {
  font-size: 1.6rem;
}

.muted {
  margin: 10px 0 18px;
  color: var(--muted);
}

.signin-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  text-decoration: none;
  border-radius: 10px;
  background: var(--btn);
  color: #fff;
  padding: 10px 14px;
  font-size: 0.95rem;
  font-weight: 600;
}

.signin-btn:hover {
  background: var(--btn-hover);
}

.footnote {
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.8rem;
}

@media (max-width: 900px) {
  .wrap {
    padding: 16px 8px 30px;
  }

  h1 {
    font-size: 1.5rem;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-end;
  }

  #session-search {
    min-width: 190px;
  }
}

/* Hard dark-mode override to prevent white rendering artifacts in table area */
body.theme-dark .panel,
body.theme-dark .table-wrap,
body.theme-dark .sessions-table,
body.theme-dark .sessions-table thead,
body.theme-dark .sessions-table tbody,
body.theme-dark .sessions-table th,
body.theme-dark .sessions-table td,
body.theme-dark .empty-cell {
  background: #1b232c !important;
}

body.theme-dark .sessions-table tbody tr:hover td {
  background: #24303b !important;
}

body.theme-dark .table-wrap::-webkit-scrollbar-corner {
  background: #1b232c;
}

body.theme-dark .sessions-table thead th {
  background: var(--table-head-bg) !important;
  color: var(--table-head-ink) !important;
}
