:root {
  --navy: #2a338f;
  --navy-dark: #1c235f;
  --ink: #1b1b1b;
  --muted: #5c6478;
  --line: #e4e6ee;
  --paper: #f4f6fb;
  --card: #ffffff;
  --danger: #9d1c2b;
  --danger-bg: #fdecee;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--navy);
  color: white;
  padding: 10px 16px;
  cursor: pointer;
}

button:hover { background: var(--navy-dark); }

input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: white;
  width: 100%;
}

input:focus,
select:focus {
  outline: 2px solid #c9cef0;
  border-color: var(--navy);
}

select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: white;
  width: 100%;
}

input.check {
  width: auto;
  margin: 0;
}

.check-line {
  flex-direction: row;
  align-items: center;
  color: var(--ink);
}

.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 64px 1fr;
  min-height: 100vh;
}

.side {
  grid-row: 1 / span 2;
  background: white;
  color: var(--ink);
  padding: 20px 16px;
  border-right: 1px solid var(--line);
}

.brand {
  display: block;
  color: var(--ink);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 4px 12px 28px;
  text-decoration: none;
}

.side .brand-mark {
  display: block;
  height: 36px;
  width: auto;
}

.brand-mark {
  display: block;
  height: 48px;
  width: auto;
}

.side nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.side nav a {
  color: var(--navy);
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 8px;
}

.side nav a:hover,
.side nav a.active {
  background: #e7eaf8;
  color: var(--navy);
  text-decoration: none;
}

.side nav button {
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--navy);
  padding: 10px 12px;
}

.side nav button:hover,
.side .subnav.open > button {
  background: #e7eaf8;
  color: var(--navy);
}

.side .sub {
  display: none;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}

.side .subnav.open .sub { display: flex; }

.side .sub a { padding-left: 28px; }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 28px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  min-width: 0;
}

.crumbs a { color: var(--muted); }
.crumbs span:last-child { color: var(--ink); font-weight: 600; }

.account {
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
}

.account form { margin: 0; }

.account button {
  background: transparent;
  color: var(--navy);
  border: 1px solid var(--line);
  padding: 6px 12px;
}

.account button:hover { background: var(--paper); }

.content { padding: 28px; }

h1 { margin: 0 0 20px; font-size: 28px; }
h2 { margin: 0 0 16px; font-size: 16px; }

.lead { color: var(--muted); margin: -8px 0 20px; }

.total { margin: 0 0 12px; font-weight: 600; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  margin: 0 0 12px;
}

.filters label { min-width: 180px; flex: 1; }

.filters button,
.filters a.button { height: 42px; }

.filters a.button {
  display: inline-flex;
  align-items: center;
  padding: 0 16px;
}

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px;
}

.presets a {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 12px;
  background: white;
  text-decoration: none;
}

.presets a:hover { background: var(--paper); text-decoration: none; }

.pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  color: var(--muted);
}

.pager-links { display: flex; gap: 12px; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.page-head h1 { margin: 0; }

dialog.sheet {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px;
  width: min(420px, calc(100% - 32px));
  box-shadow: 0 16px 40px rgba(28, 35, 95, 0.18);
}

dialog.sheet::backdrop { background: rgba(28, 35, 95, 0.45); }

.sheet h2 { margin-top: 0; }

.sheet-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

button.ghost {
  background: transparent;
  color: var(--navy);
  border: 1px solid var(--line);
}

button.ghost:hover { background: var(--paper); }

.muted { color: var(--muted); }

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat, .panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
}

.stat p { margin: 0 0 8px; color: var(--muted); }
.stat strong { font-size: 32px; color: var(--navy); }

.panel + .panel { margin-top: 16px; }

.stack {
  display: grid;
  grid-template-columns: minmax(220px, 420px) max-content;
  gap: 12px;
  align-items: end;
  margin: 0 0 16px;
}

.fields {
  display: grid;
  grid-template-columns: minmax(220px, 420px);
  gap: 12px;
}

.fields.legal-fields {
  grid-template-columns: minmax(280px, 720px);
}

.fields textarea {
  min-height: 220px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: white;
  width: 100%;
}

.fields textarea:focus {
  outline: 2px solid #c9cef0;
  border-color: var(--navy);
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

th, td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
}

th { color: var(--muted); font-weight: 600; font-size: 13px; }
tr:hover td { background: #f8f9fd; }

.error {
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 0 0 16px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.file {
  display: block;
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  color: var(--ink);
  text-decoration: none;
}

.file img,
.file video {
  display: block;
  width: 100%;
  height: 180px;
  object-fit: cover;
  background: #ddd;
}

.file span {
  display: block;
  padding: 10px 12px;
  font-size: 13px;
}

.file-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 0 12px 12px;
}

.file-actions a { font-size: 13px; }

.file-actions form { margin: 0; }

.file-actions button { margin: 0; }

.share-hint {
  flex-basis: 100%;
  margin: 0;
  font-size: 13px;
}

.legal-link {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 20;
  font-size: 13px;
  color: var(--muted);
}

.login-page .legal-link { color: #d7dbf4; }

.legal {
  width: min(720px, 100%);
  background: white;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px;
}

.legal .brand {
  color: var(--navy);
  margin: 0 0 8px;
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.legal h1 { font-size: 24px; }
.legal h1 + h1 { margin-top: 28px; }

.login-page, .guest-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-page { background: var(--navy-dark); }

.login-card {
  width: min(400px, 100%);
  background: white;
  border-radius: 16px;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-card .brand {
  color: var(--navy);
  margin: 0;
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-card h1 { margin: 0; }
.login-card button { margin-top: 6px; }
.login-card a { font-size: 14px; }

a.button {
  display: block;
  background: var(--navy);
  color: white;
  border-radius: 8px;
  padding: 10px 16px;
  text-align: center;
  text-decoration: none;
}

a.button:hover {
  background: var(--navy-dark);
  text-decoration: none;
}

.guest {
  width: min(1100px, 100%);
}

.guest-photos {
  display: block;
  align-content: start;
}

.guest-photos .guest {
  margin: 0 auto;
}

.guest-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.guest-bar h1 { margin: 0; }

.guest-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.guest-actions button { margin: 0; }

.share-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
}

.share-progress[hidden] { display: none; }

.share-progress-track {
  flex: 1;
  height: 8px;
  background: var(--line);
  border-radius: 99px;
  overflow: hidden;
}

.share-progress-fill {
  height: 100%;
  width: 0;
  background: var(--navy);
}

#share-percent {
  min-width: 3em;
  color: var(--muted);
  font-size: 14px;
}

.pick { position: relative; }

.pick label { display: block; cursor: pointer; }

.pick input {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 22px;
  height: 22px;
}

@media (max-width: 800px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
  }

  .side {
    grid-row: auto;
    padding: 16px;
  }

  .brand { margin: 0 0 12px; }

  .side nav { flex-direction: column; }

  .top { padding: 12px 16px; }
  .content { padding: 16px; }

  .stats, .stack { grid-template-columns: 1fr; }
  .page-head { align-items: flex-start; flex-direction: column; }

  .guest-photos .grid { grid-template-columns: 1fr; }
  .guest-bar { align-items: stretch; flex-direction: column; }
}
