:root {
  --bg: #f4f6f8;
  --white: #ffffff;
  --ink: #121826;
  --muted: #667085;
  --line: #e6e8ec;
  --navy: #0f2744;
  --blue: #1d4ed8;
  --danger: #b42318;
  --ok-bg: #ecfdf3;
  --ok-ink: #067647;
  --err-bg: #fef3f2;
  --err-ink: #b42318;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  --sans: Inter, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
}

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

a { color: inherit; }

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px 1fr;
}

.sidebar {
  background: var(--white);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand, .brand-plain {
  display: block;
}

.brand-logo {
  display: block;
  width: 168px;
  height: auto;
}

.brand-plain .brand-logo {
  width: 210px;
  margin-bottom: 8px;
}

.sidebar nav {
  display: grid;
  gap: 4px;
  margin-top: 28px;
}

.sidebar nav a {
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 8px;
  color: #344054;
  font-weight: 500;
}

.sidebar nav a.active,
.sidebar nav a:hover { background: #f2f4f7; color: var(--ink); }

.aside-foot {
  margin-top: auto;
  display: flex;
  gap: 10px;
  align-items: center;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.aside-foot strong { display: block; font-size: 13px; }
.aside-foot a { color: var(--muted); font-size: 12px; }
.aside-foot form { margin: 0; }
.text-button {
  background: none;
  border: 0;
  padding: 0;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #eef2f6;
  color: var(--navy);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 12px;
  flex: none;
}

.main { padding: 28px 32px 56px; min-width: 0; }

.topbar { margin-bottom: 20px; }

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 { margin: 0; font-size: 28px; line-height: 1.2; font-weight: 600; letter-spacing: -0.03em; }
h2 { margin: 0; font-size: 16px; font-weight: 600; }

.muted, .lede { color: var(--muted); margin: 6px 0 0; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat, .card, .auth-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.stat { padding: 16px 18px; }
.stat span { display: block; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.stat strong { display: block; margin-top: 6px; font-size: 26px; letter-spacing: -0.03em; }

.card { padding: 18px 18px 8px; margin-bottom: 16px; }
.card.narrow { max-width: 480px; padding-bottom: 18px; }
.card-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.upload-form, .stack { display: grid; gap: 12px; }
.upload-form { grid-template-columns: 1.1fr 1.4fr auto; align-items: end; padding-bottom: 12px; }
.stack-form { grid-template-columns: 1fr; max-width: 560px; }
.stack-form .form-action { justify-content: flex-start; }
.form-action { display: flex; align-items: end; }

label { display: block; color: #344054; font-size: 13px; font-weight: 600; }

input[type="text"], input[type="password"], input[type="email"], input[type="file"] {
  width: 100%;
  margin-top: 6px;
  background: var(--white);
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  min-height: 40px;
  padding: 8px 12px;
}

input[type="file"] { padding: 7px 12px; }

input:focus-visible, .btn:focus-visible, .password-toggle:focus-visible, a:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.password-field {
  position: relative;
  display: block;
  margin-top: 6px;
}
.password-field input[type="text"],
.password-field input[type="password"] {
  margin-top: 0;
  padding-right: 44px;
}
.password-toggle {
  position: absolute;
  top: 50%;
  right: 4px;
  width: 36px;
  height: 36px;
  margin-top: -18px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.password-toggle:hover { color: var(--ink); }
.password-toggle svg { width: 18px; height: 18px; }
.password-toggle svg[hidden] { display: none !important; }
.auth-links { display: flex; justify-content: flex-end; }
.auth-links a { color: var(--navy); font-size: 13px; font-weight: 600; text-decoration: none; }
.auth-links a:hover { text-decoration: underline; }
.reset-link {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bg);
  word-break: break-all;
  font-size: 13px;
}
.reset-link a { color: var(--navy); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid #d0d5dd;
  background: var(--white);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-small { min-height: 32px; padding: 0 10px; font-size: 12px; }
.btn-danger { color: var(--danger); border-color: #f3c7c3; background: #fff; }

.banner { margin: 0 0 14px; padding: 10px 12px; border-radius: 8px; font-weight: 500; }
.banner.ok { background: var(--ok-bg); color: var(--ok-ink); }
.banner.err { background: var(--err-bg); color: var(--err-ink); }

.table-wrap { overflow-x: auto; margin: 0 -6px 10px; }
table { width: 100%; min-width: 860px; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--line);
}
td { padding: 14px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr.is-focus td { background: #f8fafc; }
.doc-name { display: block; }
.file-name { display: block; color: var(--muted); font-size: 12px; }
.nowrap { white-space: nowrap; color: var(--muted); }
.qr-thumb { display: block; width: 72px; height: 72px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.link-row, .actions { display: flex; gap: 8px; align-items: center; }
.actions form { margin: 0; }
.secure-link {
  display: block;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--blue);
  font-size: 12px;
}
.banner.err[hidden] { display: none; }

.empty { color: var(--muted); padding: 8px 0 16px; }

.status-page {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 40px 24px;
  background:
    linear-gradient(180deg, #ffffff 0%, var(--bg) 42%, #e9eef3 100%);
}

.status-panel {
  width: min(520px, 100%);
  text-align: center;
}

.status-panel .brand-logo {
  width: 168px;
  margin: 0 auto 18px;
}

.status-mark {
  margin: 0;
  font-size: clamp(92px, 18vw, 148px);
  line-height: 0.8;
  font-weight: 600;
  letter-spacing: -0.07em;
  color: transparent;
  -webkit-text-stroke: 1.5px var(--navy);
}

.status-panel h1 {
  margin-top: 18px;
  font-size: clamp(28px, 4vw, 36px);
}

.status-panel .lede {
  max-width: 34em;
  margin: 12px auto 0;
  font-size: 16px;
}

.status-actions {
  margin-top: 28px;
}

.status-actions .btn {
  min-width: 196px;
  padding: 0 22px;
}

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--bg);
  padding: 24px;
}
.auth-card { width: min(420px, 100%); padding: 28px; display: grid; gap: 14px; }
.auth-card h1 { font-size: 24px; }
.auth-card .btn { width: 100%; }

@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .sidebar nav { grid-template-columns: 1fr 1fr; margin-top: 16px; }
  .aside-foot { margin-top: 16px; }
  .upload-form, .stats { grid-template-columns: 1fr; }
  .main { padding: 20px 16px 40px; }
}
