:root {
  color-scheme: light;
  --bg: #f6f7f3;
  --ink: #17211b;
  --muted: #5d6a62;
  --line: #dce2dc;
  --panel: #ffffff;
  --accent: #2f6f73;
  --accent-strong: #1d5054;
  --warm: #b85f35;
  --soft: #e8f1ef;
  --shadow: 0 16px 36px rgba(24, 34, 29, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

.hidden {
  display: none !important;
}

.language-bar {
  position: fixed;
  top: 12px;
  right: 16px;
  z-index: 30;
}

.language-bar label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 24px rgba(24, 34, 29, 0.08);
}

.language-bar select {
  width: auto;
  min-width: 112px;
  padding: 7px 9px;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  width: min(460px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.login-panel {
  width: 100%;
  display: grid;
  gap: 16px;
  padding: 22px;
}

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

.session-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.current-user {
  color: var(--muted);
  font-size: 0.92rem;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  font-size: 1.05rem;
}

h3 {
  margin: 0;
  font-size: 0.95rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 18px;
  align-items: start;
}

.stack {
  display: grid;
  gap: 18px;
}

.panel,
.stat-tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.entry-form,
.panel {
  padding: 18px;
}

.entry-form {
  display: grid;
  gap: 14px;
  position: sticky;
  top: 16px;
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 4px;
}

.section-title p,
label,
legend,
.stat-tile span,
.stat-tile small {
  color: var(--muted);
}

label,
fieldset {
  display: grid;
  gap: 7px;
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  padding: 0 0 7px;
}

.duration-field {
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.duration-field legend {
  grid-column: 1 / -1;
}

.kind-field {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.kind-field legend {
  grid-column: 1 / -1;
}

.kind-field label {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfa;
  color: var(--ink);
}

.kind-field input {
  width: auto;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfa;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 111, 115, 0.16);
}

textarea {
  resize: vertical;
}

.primary-button,
.icon-button,
.secondary-button {
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 700;
}

.primary-button {
  min-height: 46px;
  background: var(--accent);
  color: white;
}

.primary-button:hover,
.icon-button:hover {
  background: var(--accent-strong);
}

.icon-button {
  min-height: 42px;
  padding: 0 15px;
  background: var(--ink);
  color: white;
}

.secondary-button {
  min-height: 42px;
  padding: 0 15px;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
}

.secondary-button:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.status-line {
  min-height: 20px;
  color: var(--warm);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.stat-tile {
  display: grid;
  gap: 5px;
  min-height: 132px;
  padding: 18px;
}

.stat-tile strong {
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1;
}

.chart {
  display: grid;
  grid-template-columns: repeat(30, minmax(5px, 1fr));
  gap: 5px;
  align-items: end;
  height: 170px;
  padding-top: 12px;
}

.bar {
  position: relative;
  min-height: 4px;
  border-radius: 5px 5px 2px 2px;
  background: var(--accent);
}

.bar.zero {
  background: var(--soft);
}

.bar:hover::after {
  content: attr(data-label);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  z-index: 2;
  width: max-content;
  max-width: 180px;
  border-radius: 6px;
  background: var(--ink);
  color: white;
  padding: 6px 8px;
  font-size: 0.78rem;
}

.entries {
  display: grid;
  gap: 10px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(23, 33, 27, 0.72);
}

.modal-panel {
  width: min(760px, 100%);
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.24);
}

.camera-preview {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101613;
  object-fit: cover;
}

.recording-actions {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(130px, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.timer {
  min-width: 48px;
  color: var(--warm);
  font-weight: 800;
  text-align: right;
}

.entry-recordings {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.entry-recording video {
  width: 100%;
  max-height: 320px;
  border-radius: 8px;
  background: #101613;
}

.recording-meta {
  margin-top: 6px;
  color: var(--muted);
}

.entry {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.entry:first-child {
  border-top: 0;
}

.entry-main {
  min-width: 0;
}

.entry-title {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-weight: 800;
}

.pill {
  border-radius: 999px;
  background: #f5e9e2;
  color: var(--warm);
  padding: 3px 9px;
  font-size: 0.78rem;
}

.entry-meta,
.entry-notes {
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.45;
}

.delete-button {
  align-self: start;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  color: var(--muted);
  cursor: pointer;
  padding: 8px 10px;
}

.delete-button:hover {
  border-color: #d8b8a7;
  color: #9d3f24;
}

.user-form {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
  padding: 10px 0 18px;
}

.admin-stats {
  display: grid;
  gap: 10px;
  padding: 8px 0 18px;
}

.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.admin-stat {
  display: grid;
  gap: 5px;
  min-height: 112px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.admin-stat strong {
  font-size: 1.45rem;
  line-height: 1;
}

.admin-stat span,
.admin-stat small {
  color: var(--muted);
}

.users {
  display: grid;
  gap: 10px;
}

.user-row {
  display: grid;
  grid-template-columns: minmax(110px, 0.9fr) minmax(150px, 1.2fr) minmax(120px, 0.8fr) minmax(150px, 1fr) auto auto;
  gap: 10px;
  align-items: end;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.username-label {
  min-height: 43px;
  display: flex;
  align-items: center;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.user-actions {
  display: contents;
}

.empty {
  padding: 24px 0 6px;
  color: var(--muted);
}

@media (max-width: 820px) {
  .language-bar {
    position: static;
    width: min(100% - 32px, 1180px);
    margin: 12px auto 0;
  }

  .language-bar label {
    justify-content: space-between;
  }

  .layout,
  .stats-grid,
  .admin-stats-grid,
  .recording-actions,
  .kind-field,
  .user-form,
  .user-row {
    grid-template-columns: 1fr;
  }

  .timer {
    text-align: left;
  }

  .entry-form {
    position: static;
  }
}

@media print {
  body {
    background: white;
  }

  .shell {
    width: 100%;
    padding: 0;
  }

  .entry-form,
  .icon-button,
  .secondary-button,
  #adminPanel,
  .delete-button {
    display: none;
  }

  .layout {
    display: block;
  }

  .panel,
  .stat-tile {
    box-shadow: none;
    break-inside: avoid;
  }
}
