:root {
  --bg: #eef4f5;
  --card: #fff;
  --text: #263340;
  --muted: #5c6b78;
  --line: #d4dde3;
  --accent: #349aaa;
  --accent-dark: #25717d;
  --danger: #b91c1c;
  --radius: 12px;
  --touch: 48px;
}

* { box-sizing: border-box; }

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 84px;
  padding: 0.35rem max(1rem, env(safe-area-inset-right, 0px)) 0.35rem max(1rem, env(safe-area-inset-left, 0px));
  background: linear-gradient(128deg, #25717d 0%, #349aaa 52%, #3aaeb9 100%);
  color: #fff;
  box-shadow: 0 2px 10px rgba(37, 113, 125, 0.28);
}
.topbar-start { min-width: 0; flex: 1 1 auto; }
.topbar-end {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.15rem;
  flex-shrink: 0;
  max-width: 46%;
}
.topbar-page {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.82;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.topbar-user {
  font-size: 0.84rem;
  font-weight: 600;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.22);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.brand {
  display: inline-flex;
  align-items: center;
  color: #fff;
  text-decoration: none;
  min-width: 0;
}
.brand--logo .brand-logo {
  display: block;
  height: clamp(64px, 18vw, 76px);
  width: auto;
  max-width: min(340px, 78vw);
  object-fit: contain;
  object-position: left center;
  background: transparent;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.22));
}
@media (max-width: 420px) {
  .topbar { min-height: 76px; }
  .brand--logo .brand-logo { height: 58px; }
  .topbar-end { max-width: 42%; }
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}
.topbar-nav a {
  color: rgba(255, 255, 255, 0.92);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
}
.topbar-nav a.is-active,
.topbar-nav a:hover {
  background: rgba(0, 0, 0, 0.12);
  color: #fff;
}
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; }
  .topbar-nav { order: 3; width: 100%; justify-content: flex-start; }
  .topbar-end { order: 2; }
}

.main {
  max-width: 58rem;
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
}

h1 { margin: 0 0 0.35rem; font-size: 1.5rem; }
h1.page-title { font-size: 1.35rem; margin-top: 0.15rem; }
body.has-user > .main > h1.page-title {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
h2 { margin: 0 0 0.75rem; font-size: 1.1rem; }
.lead { color: var(--muted); margin: 0 0 1rem; }
.muted { color: var(--muted); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem 1.2rem;
  margin-bottom: 1rem;
  box-shadow: 0 2px 12px rgba(38, 51, 64, 0.06);
}

.msg { padding: 0.65rem 0.85rem; border-radius: 8px; }
.msg--ok { background: #ecfdf5; color: #047857; }
.msg--err { background: #fef2f2; color: var(--danger); }
.msg--warn { background: #fffbeb; color: #92400e; }
.hint { font-size: 0.88rem; color: var(--muted); }

.form label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  margin: 0.55rem 0 0.25rem;
}
.form input[type="text"],
.form input[type="email"],
.form input[type="password"],
.form input[type="date"],
.form input[type="file"],
.form select {
  width: 100%;
  min-height: var(--touch);
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}
.row {
  display: grid;
  gap: 0.5rem 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
}
.check { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; min-height: var(--touch); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  background: var(--card);
  color: var(--text);
  font: inherit;
}
.btn--primary { background: var(--accent); color: #fff; }
.btn--accent { background: #0d9488; color: #fff; }
.btn--ghost { border-color: var(--line); background: #fff; }
.btn--danger { color: var(--danger); border-color: #fecaca; }
.btn--tiny { min-height: 36px; padding: 0.25rem 0.55rem; font-size: 0.82rem; }

.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; align-items: center; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.data th, table.data td { border-bottom: 1px solid var(--line); padding: 0.5rem 0.35rem; text-align: left; vertical-align: top; }
table.data th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.small { font-size: 0.82rem; }
.actions { white-space: nowrap; }
.inline { display: inline; }

.tag { display: inline-block; padding: 0.15rem 0.45rem; border-radius: 6px; background: #e2e8f0; font-size: 0.75rem; }
.tag--ok { background: #d1fae5; color: #047857; }

.list { list-style: none; padding: 0; margin: 0; }
.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--line);
}

.app-foot {
  max-width: 58rem;
  margin: 0 auto;
  padding: 1.25rem 1rem calc(1.5rem + env(safe-area-inset-bottom));
  font-size: 0.82rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
  background: var(--card);
}
.app-foot-legal {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  margin-bottom: 0.65rem;
}
.app-foot-legal a {
  color: var(--accent-dark);
  font-weight: 600;
  text-decoration: none;
}
.app-foot-legal a:hover { text-decoration: underline; }
.app-foot-legal .sep { opacity: 0.45; }
.app-foot-meta,
.app-foot-note {
  margin: 0.25rem 0;
  font-size: 0.78rem;
}
.app-foot-license {
  margin: 0.65rem 0 0;
  font-size: 0.76rem;
  line-height: 1.45;
}
.app-foot-license a { color: var(--accent-dark); }

.legal-doc h2 { margin: 1.1rem 0 0.4rem; font-size: 1rem; }
.legal-doc-meta { margin-top: 1rem; font-size: 0.8rem; color: var(--muted); }

.check-row { border: none; margin: 0 0 0.75rem; padding: 0; display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem; }
.check-row .check { font-weight: 600; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.small { font-size: 0.85rem; }

.card--form { padding: 0.7rem 0.85rem 0.85rem; }
.card-title { margin-bottom: 0.45rem !important; font-size: 1.05rem; }

.label-meta {
  font-weight: 500;
  font-size: 0.72rem;
  opacity: 0.65;
}

.form--dispo label { margin: 0.28rem 0 0.12rem; font-size: 0.76rem; }
.form--dispo input,
.form--dispo select {
  min-height: 42px;
  padding: 0.38rem 0.5rem;
  font-size: 1rem;
}
.msg.compact { padding: 0.45rem 0.6rem; margin-bottom: 0.35rem; font-size: 0.82rem; }

.dispo-fold {
  margin: 0.15rem 0 0.35rem;
  font-size: 0.82rem;
}
.dispo-fold > summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
  list-style: none;
  padding: 0.2rem 0;
}
.dispo-fold > summary::-webkit-details-marker { display: none; }
.dispo-fold > summary::before { content: "▸ "; }
.dispo-fold[open] > summary::before { content: "▾ "; }
.dispo-fold[open] > summary { color: var(--text); margin-bottom: 0.25rem; }

.grid-seats {
  display: grid;
  gap: 0.35rem 0.45rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 0.35rem;
}
.grid-seats .span-all { grid-column: 1 / -1; }
.grid-people {
  display: grid;
  gap: 0.35rem 0.45rem;
  grid-template-columns: 1fr 1fr;
  margin-top: 0.25rem;
}
.check--inline {
  min-height: auto;
  margin: 0.35rem 0 0.15rem;
  font-size: 0.82rem;
}
.file-compact { margin-top: 0.25rem; }
.file-compact .file-link { display: block; font-size: 0.78rem; margin-top: 0.15rem; }

.dispo-files {
  margin: 0.55rem 0 0.45rem;
  padding: 0.55rem 0.5rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(52, 154, 170, 0.05);
}
.dispo-files__title {
  margin: 0 0 0.2rem;
  font-size: 0.88rem;
  font-weight: 700;
}
details.dispo-files > summary.dispo-files__title {
  cursor: pointer;
  list-style: disclosure-closed;
}
details.dispo-files[open] > summary.dispo-files__title {
  list-style: disclosure-open;
  margin-bottom: 0.35rem;
}
@media (min-width: 641px) {
  details.dispo-files > summary.dispo-files__title {
    cursor: default;
    list-style: none;
    pointer-events: none;
  }
  details.dispo-files > summary.dispo-files__title::-webkit-details-marker {
    display: none;
  }
  details.dispo-files .dispo-files__grid {
    display: grid;
  }
}
.dispo-files__lead { margin: 0 0 0.45rem; }
.dispo-files__grid {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 520px) {
  .dispo-files__grid { grid-template-columns: 1fr; }
}

.dropzone-wrap { display: block; margin: 0; cursor: pointer; }
.dropzone-label {
  display: block;
  font-size: 0.76rem;
  font-weight: 600;
  margin: 0 0 0.28rem;
  color: var(--text);
}
.dropzone {
  position: relative;
  border: 2px dashed #c5d0dc;
  border-radius: 12px;
  background: #fff;
  padding: 0.75rem 0.6rem 0.65rem;
  text-align: center;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  min-height: 7.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.dropzone--over {
  border-color: var(--accent, #349aaa);
  background: rgba(52, 154, 170, 0.06);
  box-shadow: 0 0 0 3px rgba(52, 154, 170, 0.12);
}
.dropzone--stored {
  border-style: solid;
  border-color: #86c99a;
  background: linear-gradient(180deg, #f3fbf5 0%, #fff 55%);
  box-shadow: 0 1px 0 rgba(22, 101, 52, 0.06);
}
.dropzone--pending {
  border-style: solid;
  border-color: var(--accent, #349aaa);
  background: linear-gradient(180deg, rgba(52, 154, 170, 0.1) 0%, #fff 60%);
  box-shadow: 0 1px 0 rgba(52, 154, 170, 0.08);
}
.dropzone--missing {
  border-style: solid;
  border-color: #f59e0b;
  background: linear-gradient(180deg, #fffbeb 0%, #fff 55%);
}
.dropzone__pill--missing {
  color: #92400e;
  background: #fef3c7;
  border: 1px solid #fcd34d;
}
.tag--warn {
  color: #92400e;
  background: #fef3c7;
  border: 1px solid #fcd34d;
}
.dropzone__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  font-size: 0;
  z-index: 2;
}
.dropzone__idle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  pointer-events: none;
  padding: 0.2rem 0;
}
.dropzone__upload-glyph {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  background: rgba(52, 154, 170, 0.12);
  position: relative;
  margin-bottom: 0.15rem;
}
.dropzone__upload-glyph::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 42%;
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 9px solid var(--accent-dark, #2a7a8a);
  transform: translate(-50%, -50%);
}
.dropzone__upload-glyph::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 28%;
  width: 14px;
  height: 2px;
  background: var(--accent-dark, #2a7a8a);
  transform: translateX(-50%);
  box-shadow: -5px -4px 0 0 var(--accent-dark, #2a7a8a), 5px -4px 0 0 var(--accent-dark, #2a7a8a);
}
.dropzone__hint {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.25;
}
.dropzone__hint-sub {
  font-size: 0.68rem;
  color: var(--muted);
}
.dropzone__file {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.28rem;
  width: 100%;
  pointer-events: none;
  padding: 0.15rem 0.25rem 0;
}
.dropzone__sheet {
  width: 3.1rem;
  height: 3.85rem;
  border-radius: 6px 6px 4px 4px;
  position: relative;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 0.45rem;
}
.dropzone__sheet::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 1rem;
  height: 1rem;
  background: linear-gradient(135deg, rgba(255,255,255,0.55) 50%, rgba(0,0,0,0.06) 50%);
  border-bottom-left-radius: 4px;
}
.dropzone__sheet.is-pdf {
  background: linear-gradient(165deg, #fff5f5 0%, #fecaca 35%, #f87171 100%);
}
.dropzone__sheet.is-image {
  background: linear-gradient(165deg, #f0fdf4 0%, #bbf7d0 35%, #4ade80 100%);
}
.dropzone__ext {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: #fff;
  background: rgba(0, 0, 0, 0.28);
  padding: 0.12rem 0.35rem;
  border-radius: 3px;
}
.dropzone__fname {
  margin: 0.15rem 0 0;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.3;
}
.dropzone__meta { margin: 0; }
.dropzone__pill {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 0.18rem 0.45rem;
  border-radius: 999px;
}
.dropzone__pill--stored {
  color: #166534;
  background: #dcfce7;
  border: 1px solid #86efac;
}
.dropzone__pill--pending {
  color: #0e5f6e;
  background: #e0f7fa;
  border: 1px solid #7dd3e0;
}
.dropzone__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  justify-content: center;
  align-items: center;
  position: relative;
  z-index: 3;
  margin-top: 0.1rem;
}
.dropzone__open {
  pointer-events: auto;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--accent-dark, #2a7a8a);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.dropzone__share {
  pointer-events: auto;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--accent, #349aaa);
  background: var(--accent, #349aaa);
  color: #fff;
  cursor: pointer;
}
.dropzone__share:hover {
  filter: brightness(1.05);
}
.dropzone__replace {
  font-size: 0.62rem;
  color: var(--muted);
  line-height: 1.25;
}

.dispo-share-cell { min-width: 6.5rem; }
.dispo-share-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.4rem;
  align-items: center;
  margin-bottom: 0.2rem;
}
.btn--share {
  padding: 0.15rem 0.45rem;
  font-size: 0.68rem;
  border-color: var(--accent, #349aaa);
  color: var(--accent-dark, #2a7a8a);
}
.btn--share.is-busy,
.dropzone__share.is-busy {
  opacity: 0.65;
  pointer-events: none;
}

@media (max-width: 640px) {
  .dropzone {
    min-height: 2.75rem;
    padding: 0.4rem 0.55rem;
  }
  .dropzone__upload-glyph,
  .dropzone__hint--desk,
  .dropzone__replace {
    display: none !important;
  }
  .dropzone__idle {
    padding: 0;
  }
  .dropzone__hint-sub {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--accent-dark, #2a7a8a);
  }
  .dropzone__file {
    align-items: flex-start;
    text-align: left;
    width: 100%;
  }
  .dropzone__sheet {
    display: none;
  }
  .dropzone__fname {
    font-size: 0.74rem;
    margin: 0 0 0.15rem;
  }
  .dropzone__meta {
    margin: 0 0 0.2rem;
  }
  .dropzone__actions {
    justify-content: flex-start;
    margin-top: 0;
  }
}

.kartenali-toast {
  position: fixed;
  left: 50%;
  bottom: max(1rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 10050;
  max-width: min(22rem, calc(100vw - 2rem));
  padding: 0.65rem 0.85rem;
  background: #0f172a;
  color: #f8fafc;
  font-size: 0.82rem;
  line-height: 1.4;
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.25);
}
.kartenali-toast[hidden] {
  display: none !important;
}
.kartenali-toast__msg {
  margin: 0 0 0.5rem;
}
.kartenali-toast__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
  margin: 0;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.65rem;
}
.btn--block { flex: 1 1 100%; width: 100%; }

.lead.compact { margin-bottom: 0.35rem; font-size: 0.88rem; }
.user-admin-list { list-style: none; margin: 0; padding: 0; }
.user-admin-item { padding: 0.65rem 0; border-bottom: 1px solid var(--line); }
.user-admin-item:last-child { border-bottom: 0; }
.user-admin-head strong { display: block; }
.user-admin-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin-top: 0.35rem; }
.user-admin-pw { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; flex: 1 1 100%; }
.user-admin-pw input[type="password"] {
  flex: 1 1 8rem;
  min-height: 36px;
  max-width: 12rem;
  font-size: 0.9rem;
}
.inline { display: inline; }

.steps { margin: 0.5rem 0 1rem 1.1rem; padding: 0; }
.steps li { margin-bottom: 0.45rem; }
.code-sample {
  background: #1e293b;
  color: #e2e8f0;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.4;
}
