:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #607083;
  --line: #dce2e8;
  --primary: #176b5f;
  --primary-dark: #0e4f46;
  --accent: #d98d2b;
  --danger: #a33a3a;
}

* {
  box-sizing: border-box;
}

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

a {
  color: var(--primary);
  text-decoration: none;
}

.topbar {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  font-weight: 700;
  color: var(--text);
}

.nav {
  display: flex;
  gap: 18px;
  align-items: center;
  font-size: 14px;
}

.shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 20px 56px;
}

.auth-panel,
.panel,
.notice {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.auth-panel {
  max-width: 420px;
  margin: 42px auto;
  padding: 28px;
}

h1 {
  margin: 0 0 8px;
  font-size: 28px;
}

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

.form {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 600;
  font-size: 14px;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
  background: #fff;
}

button {
  border: 0;
  border-radius: 6px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.primary {
  background: var(--primary);
  color: #fff;
}

.primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.secondary {
  background: #e9edf1;
  color: var(--text);
}

.danger-button {
  background: var(--danger);
  color: #fff;
}

.danger-button:hover:not(:disabled) {
  background: #812d2d;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.timer {
  font-size: 34px;
  font-weight: 800;
  color: var(--primary-dark);
  font-variant-numeric: tabular-nums;
}

.panel {
  padding: 22px;
  margin-bottom: 18px;
}

.notice {
  padding: 14px 16px;
  margin-bottom: 18px;
  color: var(--danger);
}

.progress-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.progress {
  height: 12px;
  background: #e6eceb;
  border-radius: 999px;
  overflow: hidden;
}

.progress > div {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.actions {
  display: flex;
  gap: 12px;
  margin-top: 18px;
}

#capture-video,
#capture-canvas {
  display: none;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
}

.inline-form {
  display: contents;
}

.hours-input {
  max-width: 110px;
}

.filterbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.filterbar input,
.filterbar select {
  width: auto;
}

.segmented {
  display: flex;
  background: #e9edf1;
  border-radius: 8px;
  padding: 4px;
}

.segmented a {
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--text);
}

.segmented .active {
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.messages {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.message {
  padding: 10px 12px;
  border-radius: 6px;
  background: #e9edf1;
}

.message.error {
  background: #f6dddd;
  color: var(--danger);
}

.message.success {
  background: #ddf0e6;
  color: var(--primary-dark);
}

.screenshot-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 8px;
}

.shot-tile {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  background: #dfe5ea;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: zoom-in;
}

.shot-tile:hover,
.shot-tile:focus-visible,
.shot-tile.is-selected {
  border-color: var(--primary);
  outline: 2px solid rgba(23, 107, 95, 0.22);
}

.shot-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.shot-tile span {
  position: absolute;
  right: 3px;
  bottom: 3px;
  max-width: calc(100% - 6px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(8, 16, 24, 0.72);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.4;
}

body.gallery-open {
  overflow: hidden;
}

.gallery-modal[hidden] {
  display: none;
}

.gallery-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.gallery-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 15, 22, 0.78);
}

.gallery-panel {
  position: absolute;
  inset: 22px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #101820;
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.gallery-toolbar,
.gallery-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  background: #17212b;
}

.gallery-meta {
  display: flex;
  min-width: 0;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 13px;
}

.gallery-meta span {
  color: #c7d2dd;
}

.gallery-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.gallery-controls button {
  min-width: 40px;
  min-height: 34px;
  padding: 6px 10px;
}

.gallery-stage {
  position: relative;
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  min-width: 0;
  min-height: 0;
}

.gallery-image-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #0b1118;
}

.gallery-image-wrap.is-scrollable {
  align-items: flex-start;
  justify-content: flex-start;
  overflow: auto;
}

#gallery-image {
  display: block;
  max-width: 100%;
  max-height: 100%;
  transform-origin: top left;
  transition: transform 120ms ease;
}

#gallery-image.is-zoomed {
  max-width: none;
  max-height: none;
}

.gallery-nav {
  border-radius: 0;
  background: #121b25;
  color: #fff;
  font-size: 30px;
  line-height: 1;
}

.gallery-nav:hover {
  background: #1f2d39;
}

.gallery-footer {
  justify-content: center;
  color: #c7d2dd;
  font-size: 13px;
}

@media (max-width: 700px) {
  .topbar,
  .page-head,
  .progress-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav,
  .filterbar {
    gap: 10px;
  }

  .timer {
    font-size: 28px;
  }

  table {
    display: block;
    overflow-x: auto;
  }

  .screenshot-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .gallery-panel {
    inset: 0;
    border-radius: 0;
  }

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

  .gallery-stage {
    grid-template-columns: 38px 1fr 38px;
  }

  .gallery-nav {
    font-size: 24px;
  }
}

@media (min-width: 701px) and (max-width: 1100px) {
  .screenshot-grid {
    grid-template-columns: repeat(8, minmax(0, 1fr));
  }
}
