:root {
  --bg: #050806;
  --bg-2: #09100b;
  --surface: #0b130e;
  --surface-2: #101d15;
  --text: #eafff2;
  --muted: #8ea59a;
  --line: #1f3529;
  --green: #39ff88;
  --green-2: #9cffbd;
  --green-dark: #0ad66f;
  --lime: #ccff33;
  --cyan: #4ee9ff;
  --coral: #ff5f5f;
  --soft-coral: rgba(255, 95, 95, 0.12);
  --shadow: 0 0 24px rgba(57, 255, 136, 0.16), 0 24px 60px rgba(0, 0, 0, 0.42);
  --glow: 0 0 12px rgba(57, 255, 136, 0.65), 0 0 30px rgba(57, 255, 136, 0.28);
}

* {
  box-sizing: border-box;
  min-width: 0;
  letter-spacing: 0;
}

html {
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  background: var(--bg);
}

body {
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  margin: 0;
  overflow-x: hidden;
  background:
    linear-gradient(180deg, rgba(57, 255, 136, 0.07), transparent 260px),
    linear-gradient(135deg, #050806 0%, #09100b 50%, #050806 100%);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.5;
}

a {
  color: inherit;
}

img,
svg,
canvas {
  max-width: 100%;
}

button,
input,
select {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(1180px, calc(100% - 32px));
  max-width: calc(100vw - 32px);
  margin: 0 auto;
  padding: 22px 0;
}

.brand,
.admin-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
}

.brand {
  max-width: 100%;
  text-shadow: var(--glow);
}

.brand span {
  overflow-wrap: anywhere;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--green);
  border-radius: 8px;
  background: rgba(57, 255, 136, 0.08);
  color: var(--green-2);
  box-shadow: var(--glow);
  font-size: 13px;
}

.brand-logo {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  object-fit: contain;
  filter: drop-shadow(0 0 10px rgba(57, 255, 136, 0.42));
}

.admin-link {
  color: var(--green-2);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  max-width: calc(100vw - 32px);
  overflow-x: hidden;
  margin: 0 auto 56px;
}

.public-page .topbar {
  justify-content: center;
  flex-wrap: wrap;
}

.public-page .app-shell {
  display: flex;
  min-height: calc(100vh - 110px);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: 0;
  padding-bottom: 44px;
}

.intro {
  display: block;
  margin: 22px 0 30px;
}

.public-page .intro {
  width: 100%;
  max-width: 820px;
  min-width: 0;
  text-align: center;
}

.intro h1,
.admin-title h1,
.login-panel h1 {
  width: 100%;
  max-width: min(820px, calc(100vw - 48px));
  margin: 0;
  color: var(--text);
  font-size: 44px;
  line-height: 1.08;
  text-shadow: 0 0 18px rgba(57, 255, 136, 0.24);
}

.lede {
  width: 100%;
  max-width: min(700px, calc(100vw - 48px));
  color: var(--muted);
  font-size: 18px;
}

.public-page .lede {
  margin-right: auto;
  margin-left: auto;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  text-shadow: var(--glow);
}

.grid-two {
  display: grid;
  grid-template-columns: 410px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.single-form {
  width: min(520px, 100%);
  min-width: 0;
  margin: 0 auto;
}

.panel {
  border: 1px solid rgba(57, 255, 136, 0.28);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(16, 29, 21, 0.96), rgba(8, 14, 10, 0.98));
  box-shadow: var(--shadow);
  padding: 24px;
  max-width: 100%;
  overflow-x: hidden;
}

.panel h2 {
  margin: 0 0 18px;
  color: var(--text);
  font-size: 24px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--green-2);
  font-weight: 700;
}

.check-label {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  color: var(--muted);
  font-weight: 400;
  text-align: left;
}

.public-page .check-label {
  text-align: left;
}

.public-page label,
.public-page .panel h2,
.public-page .message {
  text-align: center;
}

.form-panel,
.compact-form {
  display: grid;
  gap: 16px;
}

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #060a08;
  color: var(--text);
  padding: 10px 12px;
}

.public-page input,
.public-page select {
  text-align: center;
}

input:focus,
select:focus {
  outline: 3px solid rgba(57, 255, 136, 0.18);
  border-color: var(--green);
  box-shadow: var(--glow);
}

input::placeholder {
  color: #5f766b;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid rgba(57, 255, 136, 0.24);
  border-radius: 8px;
  padding: 10px 15px;
  color: var(--text);
  background: rgba(57, 255, 136, 0.08);
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
}

.button:hover {
  border-color: var(--green);
  box-shadow: var(--glow);
}

.button.primary {
  border-color: var(--green);
  background: var(--green);
  color: #041006;
  box-shadow: var(--glow);
}

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

.button.secondary {
  border-color: rgba(78, 233, 255, 0.34);
  background: rgba(78, 233, 255, 0.08);
  color: var(--text);
}

.button.ghost {
  border-color: var(--line);
}

.button.danger {
  border-color: rgba(255, 95, 95, 0.48);
  background: var(--soft-coral);
  color: #ffb3b3;
}

.button.small {
  min-height: 36px;
  padding: 7px 10px;
  font-size: 14px;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--green);
  padding: 0;
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-shadow: 0 0 12px rgba(57, 255, 136, 0.4);
  cursor: pointer;
}

.public-page .button.primary {
  width: 100%;
}

.message,
.hint {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
}

.message.success {
  color: var(--green-2);
}

.message.error {
  color: #ffb3b3;
}

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

.section-head h2 {
  margin: 0;
}

.sort-controls {
  display: grid;
  grid-template-columns: minmax(220px, 320px) auto;
  gap: 12px;
  align-items: end;
  margin: 0 0 18px;
}

.modal {
  width: min(92vw, 520px);
  max-width: calc(100vw - 24px);
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
  overflow-x: hidden;
}

.modal.wide-modal {
  width: min(92vw, 900px);
}

#historyDialog {
  width: min(92vw, 900px) !important;
  max-width: calc(100vw - 24px) !important;
  overflow-x: hidden !important;
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.modal-content {
  border: 1px solid rgba(57, 255, 136, 0.3);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  max-width: 100%;
  padding: 24px;
  box-shadow: var(--shadow);
}

.modal-content p {
  color: var(--text);
}

.modal-content.wide {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

#historyDialog .modal-content {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.legal-modal {
  max-height: 82vh;
  overflow: auto;
}

.legal-modal p {
  color: var(--muted);
}

.legal-modal h2 {
  color: #ffffff;
}

.legal-modal strong {
  color: var(--text);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 22px;
}

.admin-shell {
  margin-top: 22px;
}

.login-panel {
  max-width: 460px;
  margin: 56px auto;
}

.admin-dashboard {
  display: grid;
  gap: 22px;
  min-width: 0;
}

.admin-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  min-width: 0;
}

.admin-title > div {
  min-width: 0;
  max-width: 100%;
}

.export-actions,
.inline-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

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

.table-wrap {
  overflow-x: auto;
  max-width: 100%;
}

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

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

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

tr:hover td {
  background: rgba(57, 255, 136, 0.04);
}

input[type="checkbox"] {
  width: 22px;
  min-height: 22px;
  accent-color: var(--green);
}

.name-button {
  display: inline-block;
  border: 0;
  background: transparent;
  color: var(--green);
  max-width: 100%;
  padding: 0;
  font-weight: 800;
  text-decoration: underline;
  white-space: normal;
  overflow-wrap: anywhere;
  cursor: pointer;
  text-shadow: 0 0 12px rgba(57, 255, 136, 0.38);
}

.stack-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.stack-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
  padding: 10px;
}

.stack-item strong {
  overflow-wrap: anywhere;
}

.history-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
  color: var(--muted);
  max-width: 100%;
  overflow-wrap: anywhere;
  overflow-x: hidden;
}

.history-meta span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.legal-footer {
  display: flex;
  justify-content: center;
  gap: 18px;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto 28px;
}

.cookie-banner {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  width: min(560px, calc(100% - 36px));
  border: 1px solid rgba(57, 255, 136, 0.34);
  border-radius: 8px;
  background: rgba(5, 8, 6, 0.96);
  box-shadow: var(--shadow);
  padding: 16px;
  min-width: 0;
}

.cookie-banner p {
  margin: 0;
  color: var(--muted);
  min-width: 0;
  overflow-wrap: break-word;
}

canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: auto;
  border: 1px solid rgba(57, 255, 136, 0.3);
  border-radius: 8px;
  background: var(--bg-2);
  box-shadow: inset 0 0 22px rgba(57, 255, 136, 0.08);
}

.hidden {
  display: none !important;
}

@media (max-width: 880px) {
  .intro,
  .grid-two,
  .admin-grid,
  .admin-title {
    grid-template-columns: 1fr;
  }

  .admin-title {
    display: grid;
    align-items: start;
  }

  .intro h1,
  .admin-title h1,
  .login-panel h1 {
    font-size: 34px;
  }

  .sort-controls {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .topbar,
  .section-head,
  .modal-actions,
  .cookie-banner {
    align-items: stretch;
    flex-direction: column;
  }

  .cookie-banner {
    grid-template-columns: 1fr;
  }

  .topbar {
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
  }

  .app-shell {
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
  }

  .public-page .app-shell {
    min-height: auto;
    justify-content: flex-start;
    padding-bottom: 24px;
  }

  .intro h1,
  .admin-title h1,
  .login-panel h1 {
    font-size: 26px;
    max-width: 100%;
    white-space: normal !important;
    word-break: break-word;
    overflow-wrap: anywhere !important;
  }

  .public-page .intro h1,
  .public-page .lede {
    max-width: min(100%, 330px);
    min-width: 0;
    margin-right: auto;
    margin-left: auto;
    word-break: normal;
    overflow-wrap: break-word;
  }

  .lede {
    font-size: 17px;
    overflow-wrap: anywhere;
  }

  .panel {
    padding: 18px;
  }

  .modal {
    width: calc(100vw - 24px);
  }

  .modal.wide-modal {
    width: calc(100vw - 24px);
  }

  #historyDialog {
    width: calc(100vw - 24px) !important;
  }

  .modal-content {
    padding: 16px;
  }

  .cookie-banner {
    position: static;
    right: 12px;
    bottom: 12px;
    left: 12px;
    width: min(100% - 24px, 560px);
    margin: 16px auto 24px;
    max-height: 42vh;
    overflow: auto;
  }
}

@media (max-width: 720px) {
  .topbar {
    justify-content: center;
    text-align: center;
  }

  .brand {
    justify-content: center;
    font-size: 16px;
  }

  .nav-actions,
  .export-actions,
  .inline-form {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .admin-link,
  .nav-actions .button,
  .export-actions .button,
  .inline-form .button {
    width: 100%;
  }

  .admin-shell {
    margin-top: 8px;
  }

  .login-panel {
    margin: 28px auto;
  }

  .admin-title {
    gap: 16px;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
  }

  .admin-title > div,
  .admin-title h1 {
    display: block;
    width: 100%;
    max-width: 320px !important;
    white-space: normal !important;
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
  }

  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .section-head .button,
  .sort-controls .button {
    width: 100%;
  }

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

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  table {
    border-collapse: separate;
    border-spacing: 0;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 12px;
  }

  tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
    padding: 8px 10px;
  }

  tr.empty-row {
    padding: 14px;
  }

  td {
    display: grid;
    grid-template-columns: 1fr;
    gap: 4px;
    align-items: start;
    border-bottom: 1px solid rgba(31, 53, 41, 0.72);
    padding: 10px 0;
    overflow-wrap: anywhere;
  }

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

  td::before {
    content: attr(data-label);
    color: var(--green-2);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
  }

  tr.empty-row td {
    display: block;
    border-bottom: 0;
  }

  tr.empty-row td::before {
    content: none;
  }

  td .button {
    width: 100%;
  }

  td .name-button {
    display: block;
    width: 100%;
    max-width: 280px !important;
    white-space: normal !important;
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
    text-align: left;
  }

  .stack-item {
    grid-template-columns: 1fr;
  }

  .stack-item span {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .history-meta {
    display: grid;
    grid-template-columns: 1fr;
  }
}
