:root {
  --bg-top: #eaf2fd;
  --bg-mid: #f4f7fc;
  --bg-bot: #f6f8fd;
  --card: #fff;
  --ink: #0f1b2d;
  --muted: #46566c;
  --line: #d5deec;
  --field: #6b7c93;
  --acc: #0f766e;
  --acc-d: #0b5e58;
  --acc-ink: #fff;
  --link: #0b5e58;
  --soft: #dff3f0;
  --ok-bg: #dcf5e6;
  --ok: #0b5a2c;
  --warn-bg: #fff1d1;
  --warn: #6b4300;
  --bad-bg: #fde3e3;
  --bad: #8a1c1c;
  --info-bg: #e3ecff;
  --info: #1b3f9e;
  --nav-bg-top: #eef3fb;
  --nav-bg-bot: #e9f0fa;
  --nav-act: #dde6f5;
  --nav-cur: #14246b;
  --focus: #1c4fd0;
  --r: 18px;
  --r-btn: 14px;
  --btn: 52px;
  --side: 260px;
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --font: "Segoe UI", Roboto, "Helvetica Neue", Arial, system-ui, sans-serif;
  --shadow: 0 2px 10px rgba(30, 60, 120, 0.08);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font: 400 17px/1.5 var(--font);
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 55%, var(--bg-bot) 100%) fixed;
  overflow-wrap: anywhere;
}

h1,
h2,
h3 {
  line-height: 1.25;
  margin: 0 0 var(--s3);
  overflow-wrap: break-word;
}

h1 {
  font-size: clamp(24px, 5vw, 32px);
  font-weight: 800;
}

h2 {
  font-size: 20px;
  font-weight: 700;
}

h3 {
  font-size: 17px;
  font-weight: 700;
}

p {
  margin: 0 0 var(--s3);
}

a {
  color: var(--link);
}

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

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 12px 16px;
  background: var(--card);
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  border-radius: 0 0 12px 0;
}

.skip:focus {
  left: 0;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

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

button {
  cursor: pointer;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: var(--btn);
  min-width: 44px;
  padding: 0 var(--s4);
  border-radius: var(--r-btn);
  border: 2px solid var(--acc);
  background: var(--acc);
  color: var(--acc-ink);
  font-weight: 700;
  text-decoration: none;
}

.btn:hover:not(:disabled) {
  background: var(--acc-d);
  border-color: var(--acc-d);
}

.btn.sec {
  background: #fff;
  color: var(--acc-d);
  border-color: var(--acc);
}

.btn.sec:hover:not(:disabled) {
  background: var(--soft);
}

.btn.danger {
  background: #fff;
  color: var(--bad);
  border-color: var(--bad);
}

.btn.danger:hover:not(:disabled) {
  background: var(--bad-bg);
}

.btn.full {
  width: 100%;
}

.btn.sm {
  min-height: 44px;
  padding: 0 12px;
  font-size: 15px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: var(--s4);
  margin-bottom: var(--s4);
}

.grid {
  display: grid;
  gap: var(--s4);
}

.grid > .card {
  margin-bottom: 0;
}

.g3 {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
}

.g2 {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s3);
  align-items: center;
}

.stack {
  display: grid;
  gap: var(--s3);
}

.tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  background: var(--info-bg);
  color: var(--info);
  margin: 0 4px 4px 0;
}

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

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

.tag.bad {
  background: var(--bad-bg);
  color: var(--bad);
}

.notice {
  border-radius: 12px;
  padding: var(--s3) var(--s4);
  margin-bottom: var(--s4);
  background: var(--info-bg);
  color: var(--ink);
  border-left: 6px solid var(--info);
}

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

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

.notice.bad {
  background: var(--bad-bg);
  border-color: var(--bad);
}

.kpi {
  font-size: 28px;
  font-weight: 800;
  margin: 0 0 var(--s2);
}

.kpi-label {
  color: var(--muted);
  font-weight: 600;
  margin: 0;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: var(--s1);
}

.field {
  margin-bottom: var(--s4);
}

.hint,
.err {
  display: block;
  margin-top: var(--s1);
  font-size: 15px;
}

.hint {
  color: var(--muted);
  font-weight: 400;
}

.err {
  color: var(--bad);
  font-weight: 600;
}

input[type="text"],
input[type="search"],
input[type="checkbox"],
textarea {
  width: 100%;
  min-height: var(--btn);
  padding: 10px 14px;
  border: 2px solid var(--field);
  border-radius: var(--r-btn);
  background: #fff;
}

input[type="checkbox"] {
  width: 24px;
  height: 24px;
  min-height: 24px;
  min-width: 24px;
  padding: 0;
  flex: none;
}

.checks {
  display: flex;
  gap: var(--s3);
  align-items: flex-start;
}

.checks label {
  font-weight: 500;
  margin: 0;
}

.preline {
  white-space: pre-line;
}

.skeleton {
  height: 18px;
  border-radius: 8px;
  background: linear-gradient(90deg, #cdd7e8, #e6ecf6, #cdd7e8);
  background-size: 200% 100%;
  animation: sk 1.4s linear infinite;
  margin-bottom: var(--s2);
}

@keyframes sk {
  to {
    background-position: -200% 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

.app {
  display: grid;
  grid-template-columns: var(--side) minmax(0, 1fr);
  min-height: 100vh;
}

.side {
  background: linear-gradient(180deg, var(--nav-bg-top), var(--nav-bg-bot));
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  gap: 6px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  font-size: 20px;
  font-weight: 800;
  text-decoration: none;
  min-height: 44px;
  padding: 0 10px;
  margin-bottom: 10px;
}

.logo svg {
  flex: none;
}

.side nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.navb {
  display: flex;
  align-items: center;
  min-height: 60px;
  padding: 0 18px;
  border-radius: 14px;
  color: var(--ink);
  font-size: 19px;
  font-weight: 600;
  text-decoration: none;
}

.navb:hover {
  background: #e4ebf6;
}

.navb[aria-current="page"] {
  background: var(--nav-act);
  color: var(--nav-cur);
  font-weight: 800;
}

.col {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.top {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s3);
  min-height: 64px;
  padding: var(--s3) var(--s5);
}

.who {
  margin-right: auto;
  font-weight: 600;
  color: var(--muted);
}

#main {
  min-width: 0;
  padding: 0 var(--s5) var(--s6);
}

#main > .wrap,
.wrap {
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

.state {
  max-width: 640px;
}

.state.loading .skeleton:nth-child(2) {
  width: 70%;
}

.state.loading .skeleton:nth-child(3) {
  width: 55%;
}

.state.loading .skeleton:nth-child(4) {
  width: 85%;
}

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--s5);
}

.gate-card {
  width: min(100%, 440px);
}

.gate-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: var(--s4);
}

.gate-brand svg {
  width: 48px;
  height: 48px;
}

.money.in {
  color: var(--ok);
  font-weight: 700;
}

.money.out {
  color: var(--ink);
  font-weight: 700;
}

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

.tw {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

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

table.data th {
  font-size: 14px;
  color: var(--muted);
  font-weight: 700;
}

table.data a {
  font-weight: 700;
  text-decoration: none;
}

table.data a:hover {
  text-decoration: underline;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

dialog {
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: var(--s5);
  max-width: min(480px, calc(100vw - 32px));
  width: 100%;
  box-shadow: 0 12px 40px rgba(20, 40, 80, 0.2);
  color: var(--ink);
}

dialog::backdrop {
  background: rgba(15, 27, 45, 0.45);
}

.dlg-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s3);
  margin-top: var(--s4);
  justify-content: flex-end;
}

.head-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s3);
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--s4);
}

.count {
  color: var(--muted);
  font-weight: 600;
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }

  .side {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 12px;
    gap: 8px;
  }

  .logo {
    margin: 0;
  }

  .side nav {
    flex-direction: row;
    flex-wrap: wrap;
    flex: 1 1 auto;
    gap: 6px;
  }

  .navb {
    min-height: 48px;
    font-size: 17px;
    width: auto;
  }

  .top {
    padding: 12px 16px;
  }

  #main {
    padding: 0 16px 24px;
  }
}

@media (max-width: 600px) {
  body {
    font-size: 16px;
  }

  :root {
    --btn: 48px;
  }

  .tw {
    overflow: visible;
  }

  table.data,
  table.data thead,
  table.data tbody,
  table.data th,
  table.data td,
  table.data tr {
    display: block;
    width: 100%;
  }

  table.data thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  table.data tr {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 12px;
    margin-bottom: 12px;
  }

  table.data td {
    border: 0;
    padding: 6px 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: 4px 12px;
    text-align: right;
  }

  table.data td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
    text-align: left;
  }
}

@media (max-width: 360px) {
  .btn,
  .navb,
  input[type="text"],
  input[type="search"],
  textarea {
    min-height: 44px;
  }
}

.invite {
  min-width: 0;
}

.invite .field {
  margin-bottom: 0;
}

.invite select {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 2px solid var(--field);
  border-radius: var(--r-btn);
  background: #fff;
}

.consent-text {
  margin-block: var(--s4);
}

.consent-text summary,
.gate-card .checks label {
  min-height: 44px;
}

.gate-card .checks input[type="checkbox"] {
  width: 44px;
  height: 44px;
}

.consent-text summary {
  padding-block: 10px;
  cursor: pointer;
}

.consent-copy {
  max-height: 40vh;
  overflow: auto;
  overflow-wrap: anywhere;
  padding: var(--s3);
  border: 1px solid var(--field);
  border-radius: var(--r-btn);
}

#consent-err[hidden],
.gate-card button[hidden],
.invite [hidden],
.top .err[hidden] {
  display: none;
}
