:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-alt: #eef0f3;
  --border: #cdd3db;
  --text: #14161a;
  --text-dim: #4b525c;
  --accent: #1d4ed8;
  --accent-dim: #1e40af;
  --danger: #b91c1c;
  --success: #15803d;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 3rem;
}

.hidden { display: none !important; }

/* Visible focus ring for keyboard navigation on every interactive element */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 0.6rem 1rem;
  z-index: 100;
  border-radius: 0 0 8px 0;
}
.skip-link:focus {
  left: 0;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}

.topbar h1 { font-size: 1.15rem; margin: 0; }

.profile-bar { display: flex; gap: 0.5rem; align-items: center; }

.tabs {
  display: flex;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}

.tab-btn {
  flex: 1 0 auto;
  padding: 0.85rem 1rem;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.95rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

main { max-width: 720px; margin: 0 auto; padding: 1rem; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-top: 1rem;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

h2 {
  font-size: 1rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 1.5rem 0 0.75rem;
}
h2:first-child { margin-top: 0; }

.session-form {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.form-row { margin-bottom: 0.75rem; }
.form-row label { display: block; font-size: 0.85rem; color: var(--text-dim); margin-bottom: 0.25rem; }

input, select, textarea {
  width: 100%;
  padding: 0.6rem 0.7rem;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
}

textarea { resize: vertical; }

.inline-pair { display: flex; gap: 0.5rem; }
.inline-pair input { flex: 1; }
.inline-pair select { flex: 0 0 80px; }

.entries { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 0.75rem; }

.entry-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 0.5rem;
  padding: 0.75rem;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  position: relative;
}

.entry-row .field { display: flex; flex-direction: column; gap: 0.25rem; }
.entry-row .field label { font-size: 0.72rem; color: var(--text-dim); }

.remove-entry-btn {
  grid-column: 1 / -1;
  justify-self: end;
  background: none;
  border: none;
  color: var(--danger);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0.25rem 0;
}

button {
  cursor: pointer;
  font-size: 0.9rem;
  border-radius: 8px;
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  margin-top: 0.5rem;
}

.btn-secondary {
  background: var(--panel-alt);
  color: var(--text);
}

.add-entry-btn { width: 100%; margin-bottom: 0.75rem; }

.form-status { font-size: 0.85rem; margin-top: 0.5rem; min-height: 1.2em; font-weight: 600; }
.form-status.success { color: var(--success); }
.form-status.error { color: var(--danger); }

.history { display: flex; flex-direction: column; gap: 0.6rem; }

.session-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}

.session-card .session-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

.session-card .session-date { font-weight: 600; }
.session-card .session-notes { color: var(--text-dim); font-size: 0.85rem; margin-top: 0.35rem; }

.session-card ul { margin: 0.5rem 0 0; padding-left: 1.1rem; font-size: 0.9rem; }
.session-card li { margin-bottom: 0.2rem; }

.delete-session-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.8rem;
}
.delete-session-btn:hover { color: var(--danger); }

.empty-state { color: var(--text-dim); font-size: 0.9rem; padding: 0.5rem 0; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem;
  text-align: center;
}

.stat-card .value { font-size: 1.5rem; font-weight: 700; }
.stat-card .label { font-size: 0.75rem; color: var(--text-dim); margin-top: 0.2rem; }

.stats-table table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.stats-table th, .stats-table td { text-align: left; padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--border); }
.stats-table th { color: var(--text-dim); font-weight: 500; }

@media (min-width: 640px) {
  .form-row { display: flex; align-items: center; gap: 0.5rem; }
  .form-row label { min-width: 100px; margin-bottom: 0; }
  .form-row input, .form-row textarea { flex: 1; }
}
