:root {
  color-scheme: light;
  --bg: #f5f5f1;
  --surface: #ffffff;
  --ink: #171714;
  --muted: #62625b;
  --line: #d7d7cf;
  --line-strong: #aaa99f;
  --accent: #f4d64e;
  --accent-hover: #e8c83c;
  --danger: #fff0ec;
  --danger-line: #b54f3e;
  --info: #edf4ff;
  --focus: #1769d2;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 18px;
  line-height: 1.55;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
}

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

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

.login-shell {
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  place-items: center;
  padding: clamp(1rem, 4vw, 2rem);
}

.login-panel {
  width: min(100%, 430px);
}

.login-brand {
  display: inline-block;
  margin-bottom: clamp(2.5rem, 8vh, 5rem);
  color: var(--ink);
  font-size: 1.08rem;
  font-weight: 400;
  letter-spacing: -0.025em;
  text-decoration: none;
}

.login-heading {
  margin-bottom: 1.35rem;
}

.login-heading h1 {
  margin: 0 0 0.55rem;
  font-size: clamp(1.75rem, 6vw, 2.3rem);
  line-height: 1.13;
  font-weight: 400;
  letter-spacing: -0.04em;
}

.login-heading p {
  margin: 0;
  color: var(--muted);
}

.login-notice,
.login-error {
  margin-bottom: 1rem;
  padding: 0.75rem 0.8rem;
  border-radius: 8px;
}

.login-notice {
  border: 1px solid #7797bf;
  background: var(--info);
}

.login-error {
  border: 1px solid var(--danger-line);
  background: var(--danger);
}

.login-form {
  display: grid;
  gap: 0.9rem;
}

.field {
  display: grid;
  gap: 0.35rem;
  font-weight: 400;
}

.field input {
  width: 100%;
  min-height: 50px;
  padding: 0.68rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface);
  font-weight: 400;
}

.field input:focus {
  border-color: var(--focus);
}

.password-field {
  position: relative;
  display: block;
}

.password-field input {
  padding-right: 6.8rem;
}

.show-password {
  position: absolute;
  top: 3px;
  right: 3px;
  min-height: 44px;
  padding: 0.45rem 0.65rem;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #315f9c;
  font-weight: 400;
  cursor: pointer;
}

.show-password:hover {
  background: #efefe9;
}

.login-button {
  min-height: 50px;
  margin-top: 0.25rem;
  padding: 0.7rem 1rem;
  border: 1px solid var(--ink);
  border-radius: 9px;
  background: var(--accent);
  font-weight: 400;
  cursor: pointer;
}

.login-button:hover {
  background: var(--accent-hover);
}

.login-button:disabled {
  cursor: wait;
  opacity: 0.62;
}

@media (max-width: 480px) {
  .login-shell {
    place-items: start stretch;
    padding-top: max(1.25rem, env(safe-area-inset-top));
    padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
  }

  .login-brand {
    margin-bottom: clamp(2.25rem, 10vh, 4rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* --- access request, cabinet pages (keys, admin) --- */

.field textarea {
  width: 100%;
  min-height: 7.5rem;
  padding: 0.68rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface);
  font: inherit;
  resize: vertical;
}

.field textarea:focus {
  border-color: var(--focus);
}

.field-hint {
  color: var(--muted);
  font-size: 1rem;
}

.honeypot {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.login-links {
  margin: 1.4rem 0 0;
  color: var(--muted);
}

.login-links a,
.inline-link {
  color: #315f9c;
  text-underline-offset: 3px;
}

.login-success h2 {
  margin: 0 0 0.6rem;
  font-size: 1.6rem;
  font-weight: 400;
  line-height: 1.2;
}

.login-success p {
  margin: 0 0 0.8rem;
}

.page-shell {
  width: min(100% - 2rem, 980px);
  margin: 0 auto;
  padding: max(1rem, env(safe-area-inset-top)) 0 max(3rem, env(safe-area-inset-bottom));
}

.topnav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1rem;
  padding: 0.5rem 0 1.5rem;
  border-bottom: 1px solid var(--line);
}

.topnav .login-brand {
  margin: 0 auto 0 0;
}

.topnav a,
.topnav button {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 0.4rem;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}

.topnav a[aria-current="page"] {
  text-decoration: underline;
  text-underline-offset: 6px;
}

.page-title {
  margin: 2rem 0 0.5rem;
  font-size: clamp(1.75rem, 5vw, 2.3rem);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.03em;
}

.page-lead {
  max-width: 62ch;
  margin: 0 0 1.75rem;
  color: var(--muted);
}

.card {
  margin: 0 0 1.25rem;
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.3rem;
  font-weight: 400;
}

.row-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
}

.row-form .field {
  flex: 1 1 16rem;
}

.key-reveal {
  display: grid;
  gap: 0.6rem;
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid #7797bf;
  border-radius: 10px;
  background: var(--info);
}

.key-reveal code,
.code-block {
  display: block;
  overflow-x: auto;
  padding: 0.7rem 0.8rem;
  border-radius: 8px;
  background: #171714;
  color: #f5f5f1;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1rem;
  line-height: 1.5;
  white-space: pre;
  word-break: normal;
}

.list {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.list-item {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 0;
  border-top: 1px solid var(--line);
}

.list-item:first-child {
  border-top: 0;
}

.list-main {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
  flex: 1 1 18rem;
}

.list-meta {
  color: var(--muted);
  font-size: 1rem;
  overflow-wrap: anywhere;
}

.list-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.button-small {
  min-height: 44px;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface);
  cursor: pointer;
}

.button-small:hover {
  background: #efefe9;
}

.button-small.danger {
  border-color: var(--danger-line);
  color: #8f3326;
}

.empty-state {
  margin: 0;
  color: var(--muted);
}

.badge {
  display: inline-block;
  padding: 0.05rem 0.55rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--muted);
  font-size: 1rem;
}
