:root {
  color-scheme: dark;
  --bg: #071018;
  --panel: rgba(13, 24, 32, 0.96);
  --panel-soft: rgba(5, 12, 18, 0.66);
  --line: rgba(156, 184, 198, 0.2);
  --text: #eef6f5;
  --muted: #a7b9bd;
  --dim: #71868c;
  --gold: #dfb75f;
  --green: #70d79b;
  --red: #db8072;
  font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html,
body {
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  background: linear-gradient(180deg, #08131b 0%, #050a0f 100%);
  color: var(--text);
}

body {
  padding: 14px 12px 28px;
}

[hidden] { display: none !important; }

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

button {
  color: inherit;
  cursor: pointer;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px 12px;
}

.auth-card,
.top-panel,
.accordion {
  width: min(430px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.016)), var(--panel);
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.24);
}

.auth-card {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.eyebrow {
  margin: 0;
  color: var(--gold);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 29px;
  line-height: 1.06;
}

h2 {
  font-size: 16px;
}

.auth-copy,
.top-panel p,
.empty-card p,
.role-list p,
.action-card span,
.record-card p,
.last-line {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.auth-choice,
.auth-form,
.portal-shell,
.panel-form,
.record-form,
.role-list,
.feed {
  display: grid;
  gap: 10px;
}

.portal-shell {
  width: min(430px, 100%);
  margin: 0 auto;
}

.auth-choice button,
.auth-form button,
.panel-form button,
.record-form button,
.top-panel button,
#export-json {
  min-height: 44px;
  border: 1px solid rgba(223, 183, 95, 0.38);
  border-radius: 8px;
  background: rgba(223, 183, 95, 0.12);
  color: var(--gold);
  padding: 0 12px;
  font-weight: 900;
}

.auth-form .ghost-button,
.form-head button {
  border-color: rgba(156, 184, 198, 0.2);
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
}

.auth-form label,
.panel-form label,
.record-form label {
  display: grid;
  gap: 6px;
}

.auth-form span,
.panel-form span,
.record-form span,
.summary-grid span,
.admin-grid span,
.record-meta span {
  color: var(--dim);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.auth-form input,
.panel-form input,
.record-form input,
.record-form select,
.record-form textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(3, 9, 14, 0.76);
  color: var(--text);
  padding: 10px 12px;
}

.record-form textarea {
  min-height: 92px;
  resize: vertical;
}

.record-form input[type="file"] {
  padding-top: 11px;
}

.auth-message,
.inline-message {
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.auth-message.is-error,
.inline-message.is-error {
  color: var(--red);
}

.setup-card {
  display: grid;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.setup-banner {
  display: grid;
  gap: 4px;
  border: 1px solid rgba(219, 128, 114, 0.32);
  border-radius: 8px;
  background: rgba(219, 128, 114, 0.08);
  padding: 10px;
}

.setup-banner strong {
  font-size: 13px;
}

.setup-banner span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.top-panel {
  min-height: 142px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 16px;
}

.top-identity,
.profile-identity {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.top-identity > div:last-child,
.profile-identity > div:last-child {
  min-width: 0;
}

.profile-avatar {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  background: linear-gradient(135deg, #1264a3, #62b4e6);
  color: #fff;
  font-size: 18px;
  font-weight: 900;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14), 0 10px 24px rgba(0, 0, 0, 0.24);
}

.profile-avatar.is-large {
  width: 52px;
  height: 52px;
  font-size: 20px;
}

.profile-avatar[data-tone="1"] { background: linear-gradient(135deg, #8f5bff, #df8cff); }
.profile-avatar[data-tone="2"] { background: linear-gradient(135deg, #009f72, #7ee7a6); }
.profile-avatar[data-tone="3"] { background: linear-gradient(135deg, #d86b2f, #ffd166); }
.profile-avatar[data-tone="4"] { background: linear-gradient(135deg, #cc397b, #ff92b7); }
.profile-avatar[data-tone="5"] { background: linear-gradient(135deg, #1264a3, #62b4e6); }
.profile-avatar[data-tone="6"] { background: linear-gradient(135deg, #58713f, #b8d66f); }
.profile-avatar[data-tone="7"] { background: linear-gradient(135deg, #8a5a24, #dfb75f); }

.top-panel h1 {
  margin: 7px 0 8px;
  font-size: 25px;
}

.top-panel button {
  min-height: 32px;
  flex: 0 0 auto;
  border-color: rgba(112, 215, 155, 0.42);
  background: rgba(112, 215, 155, 0.12);
  color: var(--green);
  padding-inline: 10px;
}

.accordion {
  overflow: hidden;
}

.accordion-head {
  width: 100%;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 0;
  background: transparent;
  padding: 0 14px;
  text-align: left;
  font-weight: 900;
}

.accordion-head b {
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.18s ease;
}

.accordion.is-open .accordion-head b {
  transform: rotate(225deg);
}

.accordion-body {
  display: none;
  padding: 0 14px 14px;
  border-top: 1px solid var(--line);
}

.accordion.is-open .accordion-body {
  display: grid;
  gap: 10px;
}

.summary-grid,
.quick-grid,
.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding-top: 14px;
}

.summary-grid article,
.admin-grid article,
.empty-card,
.role-list article,
.action-card,
.record-card {
  border: 1px solid rgba(156, 184, 198, 0.12);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 11px;
}

.summary-grid article,
.admin-grid article {
  min-height: 66px;
  display: grid;
  align-content: space-between;
}

.summary-grid strong,
.admin-grid strong {
  font-size: 18px;
}

.quick-grid {
  padding-top: 14px;
}

.action-card {
  min-height: 78px;
  display: grid;
  align-content: space-between;
  gap: 8px;
  text-align: left;
}

.action-card strong,
.empty-card strong,
.role-list strong,
.record-card strong {
  font-size: 14px;
}

.record-form,
.panel-form {
  padding-top: 14px;
}

.profile-identity {
  padding-top: 14px;
}

.profile-identity strong,
.profile-identity span {
  display: block;
}

.profile-identity strong {
  font-size: 16px;
}

.profile-identity span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.form-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.form-fields {
  display: grid;
  gap: 9px;
}

.split-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.tab-row {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 14px 0 2px;
  scrollbar-width: none;
}

.tab-row::-webkit-scrollbar {
  display: none;
}

.tab-row button {
  min-height: 34px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 900;
}

.tab-row button.is-active {
  border-color: rgba(223, 183, 95, 0.42);
  background: rgba(223, 183, 95, 0.12);
  color: var(--gold);
}

.feed {
  padding-top: 4px;
}

.record-card {
  display: grid;
  gap: 7px;
}

.record-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.record-card small {
  color: var(--dim);
  font-size: 11px;
  line-height: 1.35;
}

.empty-card,
.role-list {
  margin-top: 4px;
}

.role-list article {
  display: grid;
  gap: 5px;
}

.role-list strong {
  color: var(--gold);
}

#export-json {
  width: 100%;
}

@media (max-width: 360px) {
  body {
    padding-inline: 9px;
  }

  h1 {
    font-size: 25px;
  }

  .summary-grid,
  .quick-grid,
  .admin-grid,
  .split-buttons {
    grid-template-columns: 1fr;
  }
}
