:root {
  --bg: #eef3f4;
  --surface: #ffffff;
  --surface-soft: #f7faf9;
  --surface-strong: #e4eeec;
  --text: #172026;
  --muted: #63727a;
  --line: #d6e1e2;
  --primary: #0f766e;
  --primary-strong: #0b5f59;
  --primary-soft: #dff3f0;
  --primary-text: #073b37;
  --danger: #b42318;
  --danger-soft: #fff1f0;
  --warn-bg: #fff7dc;
  --warn: #8a5a00;
  --ok-bg: #e8f7ee;
  --ok: #166534;
  --shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
  --sidebar-width: 240px;
  --topbar-height: 58px;
}

[data-theme="dark"] {
  --bg: #101616;
  --surface: #172121;
  --surface-soft: #1d2929;
  --surface-strong: #263535;
  --text: #eef6f4;
  --muted: #a9b8b6;
  --line: #314241;
  --primary: #35c3b4;
  --primary-strong: #6ee7d8;
  --primary-soft: #123d3a;
  --primary-text: #d9fffa;
  --danger: #ff8a80;
  --danger-soft: #3b1d1b;
  --warn-bg: #3a2d10;
  --warn: #ffd56a;
  --ok-bg: #123722;
  --ok: #86efac;
  --shadow: 0 14px 36px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

body.sidebar-open {
  overflow: hidden;
}

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

img {
  max-width: 100%;
}

button,
input,
select {
  color-scheme: light;
}

[data-theme="dark"] button,
[data-theme="dark"] input,
[data-theme="dark"] select {
  color-scheme: dark;
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  display: flex;
  width: min(var(--sidebar-width), 86vw);
  transform: translateX(-100%);
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow);
  transition: transform 180ms ease;
}

.sidebar.is-open {
  transform: translateX(0);
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(9, 17, 17, 0.46);
}

.sidebar-head,
.sidebar-foot {
  padding: 16px;
}

.sidebar-head {
  display: flex;
  min-height: var(--topbar-height);
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand {
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 900;
  letter-spacing: 0;
}

.sidebar-nav {
  display: grid;
  gap: 4px;
  padding: 14px 10px;
}

.nav-link {
  position: relative;
  display: flex;
  min-height: 42px;
  align-items: center;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 750;
  padding: 9px 12px 9px 18px;
}

.nav-link:hover,
.nav-link:focus-visible {
  background: var(--surface-soft);
  color: var(--text);
}

.nav-link.active {
  background: var(--primary-soft);
  color: var(--primary-text);
}

.nav-link.active::before {
  position: absolute;
  top: 9px;
  bottom: 9px;
  left: 7px;
  width: 4px;
  border-radius: 999px;
  background: var(--primary);
  content: "";
}

.sidebar-foot {
  display: grid;
  gap: 10px;
  margin-top: auto;
  border-top: 1px solid var(--line);
}

.sidebar-foot .inline-form {
  width: 100%;
}

.user-email {
  min-width: 0;
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}

.content-shell {
  min-width: 0;
}

.content-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  min-height: var(--topbar-height);
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.topbar-left {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.topbar-title {
  min-width: 0;
  color: var(--text);
  font-size: 1rem;
  font-weight: 850;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button,
.theme-toggle {
  display: inline-flex;
  width: 38px;
  min-width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-weight: 850;
}

.icon-button:hover,
.theme-toggle:hover {
  background: var(--surface-soft);
}

.sidebar-close {
  display: inline-flex;
}

.page {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 18px 14px 40px;
}

.page-title {
  margin: 4px 0 18px;
}

h1,
h2 {
  margin: 0 0 10px;
  line-height: 1.2;
}

h1 {
  font-size: 1.65rem;
}

h2 {
  font-size: 1.1rem;
}

p {
  margin: 0 0 8px;
}

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

small {
  display: block;
}

.panel,
.row-card,
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 16px;
  margin-bottom: 16px;
}

.narrow,
.auth-panel {
  max-width: 460px;
  margin: 18px auto;
}

.grid-list,
.form-stack,
.photo-grid {
  display: grid;
  gap: 12px;
}

.row-card {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 14px;
}

.row-card p {
  color: var(--muted);
  margin: 4px 0;
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: #ffffff;
  padding: 10px 16px;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
  text-align: center;
}

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

.button.secondary {
  color: var(--primary-text);
  background: var(--primary-soft);
}

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

.button.full {
  width: 100%;
}

.inline-form {
  display: inline-flex;
  margin: 0;
}

.logout-button {
  display: inline-flex;
  width: 100%;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 8px 12px;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

.logout-button:hover {
  background: var(--surface-strong);
}

.alert {
  padding: 12px 14px;
  margin-bottom: 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.alert-error {
  color: #7a271a;
  background: var(--danger-soft);
  border-color: #ffd0cc;
}

[data-theme="dark"] .alert-error {
  color: #ffbbb5;
  border-color: #6e302b;
}

.alert-success {
  color: #14532d;
  background: #ecfdf3;
  border-color: #bbf7d0;
}

[data-theme="dark"] .alert-success {
  color: #b9f6cc;
  background: #102f1d;
  border-color: #285b3c;
}

.status {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.92rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-ok {
  color: var(--ok);
  background: var(--ok-bg);
}

.status-warn {
  color: var(--warn);
  background: var(--warn-bg);
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 750;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
}

input[type="file"] {
  padding: 9px;
}

.form-grid {
  display: grid;
  gap: 12px;
}

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

.check input {
  width: auto;
  min-height: auto;
}

.check-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

.photo-field {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.preview {
  display: none;
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.preview.is-visible {
  display: block;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
}

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

tr:last-child td {
  border-bottom: 0;
}

th {
  color: var(--muted);
  font-size: 0.88rem;
}

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

.columns,
.photo-grid {
  display: grid;
  gap: 18px;
}

.submission-photo {
  width: 100%;
  max-height: 520px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

@media (min-width: 769px) {
  body.sidebar-open {
    overflow: auto;
  }

  .sidebar {
    transform: none;
    box-shadow: none;
  }

  .sidebar-close,
  .menu-button,
  .sidebar-backdrop {
    display: none;
  }

  .content-shell {
    margin-left: var(--sidebar-width);
  }

  .content-topbar {
    padding-inline: 24px;
  }

  .page {
    padding: 28px 24px 56px;
  }

  .form-grid {
    grid-template-columns: 1fr 1fr;
    align-items: end;
  }

  .columns {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }

  .photo-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
