:root {
  color-scheme: light;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "HarmonyOS Sans SC", "MiSans", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "SF Mono", "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  --bg: #f2f3f5;
  --surface: #ffffff;
  --surface-soft: #f8f8f9;
  --ink: #1b1d21;
  --muted: #69707c;
  --faint: #949aa4;
  --line: #e4e6ea;
  --line-strong: #d3d7de;
  --accent: #a85f24;
  --accent-soft: #fbf1e8;
  --danger: #b73d3d;
  --danger-soft: #fdf0f0;
  --success: #227a4b;
  --success-soft: #eef9f2;
  --sidebar: #11151c;
  --sidebar-soft: #1b212b;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow: 0 10px 30px rgba(26, 30, 38, 0.06);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

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

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p {
  margin-block: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  color: inherit;
}

img {
  display: block;
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

::selection {
  background: var(--accent-soft);
}

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

code {
  padding: 2px 5px;
  font-family: var(--mono);
  font-size: 0.9em;
  color: var(--ink);
  background: #eceef2;
  border-radius: 5px;
}

/* ---------- Layout ---------- */

.admin-shell {
  min-height: 100vh;
}

.admin-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  display: flex;
  width: 252px;
  flex-direction: column;
  padding: 22px 16px 16px;
  color: #f4f5f7;
  background: var(--sidebar);
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 8px 22px;
}

.sidebar__mark {
  display: grid;
  width: 36px;
  height: 36px;
  flex: none;
  place-items: center;
  color: #161a20;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  background: #f4f5f7;
  border-radius: 11px;
}

.sidebar__brand-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sidebar__brand-copy strong {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.sidebar__brand-copy span {
  color: #8d96a5;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.16em;
}

.sidebar__nav {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
}

.nav-link {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 10px;
  padding: 0 11px;
  color: #b9c0cb;
  font-size: 13px;
  border-radius: 10px;
  transition:
    color 150ms var(--ease),
    background-color 150ms var(--ease);
}

.nav-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.nav-link.is-active {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.nav-link__dot {
  width: 5px;
  height: 5px;
  flex: none;
  background: #69717e;
  border-radius: 50%;
}

.nav-link.is-active .nav-link__dot {
  background: #ffb168;
  box-shadow: 0 0 0 4px rgba(255, 177, 104, 0.12);
}

.sidebar__section {
  padding: 18px 11px 7px;
  color: #6f7886;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.15em;
}

.sidebar__foot {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
}

.sidebar__foot .nav-link {
  color: #939cab;
}

.logout-form {
  margin: 0;
}

.logout-button {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.admin-main {
  min-height: 100vh;
  margin-left: 252px;
}

.admin-topbar {
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 34px;
  background: rgba(255, 255, 255, 0.82);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.admin-topbar__title {
  color: var(--muted);
  font-size: 12px;
}

.admin-topbar__actions {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
}

.admin-topbar__actions .button {
  min-height: 34px;
}

.topbar-logout {
  margin: 0;
}

.admin-topbar__user {
  color: var(--ink);
  font-weight: 500;
}

.admin-content {
  width: min(100%, 1180px);
  padding: 30px 34px 60px;
}

/* ---------- Headings ---------- */

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.page-heading__copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.page-heading h1 {
  font-size: 28px;
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -0.035em;
}

.page-heading p {
  color: var(--muted);
  font-size: 13px;
}

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

/* ---------- Cards / stats ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.card + .card {
  margin-top: 18px;
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 17px 20px;
  border-bottom: 1px solid var(--line);
}

.card__head h2 {
  font-size: 14px;
  font-weight: 600;
}

.card__head p {
  color: var(--muted);
  font-size: 12px;
}

.card__body {
  padding: 20px;
}

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

.stat-card {
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
}

.stat-card__value {
  font-size: 34px;
  font-weight: 650;
  line-height: 1.05;
  letter-spacing: -0.045em;
}

.stat-card__label {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.quick-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.quick-list a {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 2px;
  color: var(--ink);
  font-size: 13px;
  border-bottom: 1px solid var(--line);
}

.quick-list a:last-child {
  border-bottom: 0;
}

.quick-list a span:last-child {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 10px;
}

.mini-notice {
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.mini-notice:last-child {
  border-bottom: 0;
}

.mini-notice__date {
  color: var(--faint);
  font-family: var(--mono);
  font-size: 10px;
}

.mini-notice__title {
  margin-top: 3px;
  font-size: 13px;
  font-weight: 600;
}

/* ---------- Tables ---------- */

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

.table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}

.table th {
  padding: 11px 14px;
  color: var(--faint);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
}

.table td {
  padding: 13px 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.table tr:last-child td {
  border-bottom: 0;
}

.table tbody tr:hover {
  background: #fafafb;
}

.table__actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.table__actions form {
  display: inline-flex;
  margin: 0;
}

.table__url {
  display: inline-block;
  max-width: 300px;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  vertical-align: bottom;
}

.table__site {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.table__icon {
  display: grid;
  width: 30px;
  height: 30px;
  flex: none;
  place-items: center;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  background: #3e4754;
  border-radius: 8px;
}

.table__icon--paper {
  color: #191b1f;
  background: #ebe8e1;
}

.table__icon--forest {
  color: #bdf8d4;
  background: #1b2821;
}

.table__icon--pink,
.table__icon--rose {
  background: #c94368;
}

.table__icon--blue,
.table__icon--indigo {
  background: #4765b8;
}

.table__icon--red {
  background: #c81832;
}

.table__icon--green,
.table__icon--teal {
  background: #2f6f5a;
}

.table__icon--violet {
  background: #8a55b4;
}

.table__icon--orange {
  background: #c56b2d;
}

/* ---------- Buttons ---------- */

.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 14px;
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color 140ms var(--ease),
    border-color 140ms var(--ease),
    transform 140ms var(--ease);
}

.button:hover {
  background: var(--surface-soft);
  border-color: #bfc4cc;
}

.button:active {
  transform: scale(0.98);
}

.button--primary {
  color: #fff;
  background: var(--ink);
  border-color: var(--ink);
}

.button--primary:hover {
  background: #30343a;
  border-color: #30343a;
}

.button--ghost {
  color: var(--muted);
  background: transparent;
  border-color: transparent;
}

.button--ghost:hover {
  color: var(--ink);
  background: var(--surface-soft);
  border-color: var(--line);
}

.button--danger {
  color: var(--danger);
  background: transparent;
  border-color: #ecc9c9;
}

.button--danger:hover {
  background: var(--danger-soft);
  border-color: #e0aaaa;
}

.button--small {
  min-height: 32px;
  padding: 0 10px;
  font-size: 11.5px;
}

.button--block {
  width: 100%;
}

.button[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.link-button {
  padding: 0;
  color: var(--accent);
  font-size: 13px;
  background: transparent;
  border: 0;
  cursor: pointer;
}

/* ---------- Forms ---------- */

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.form-grid > .card + .card {
  margin-top: 0;
}

.form-grid .field--full {
  grid-column: 1 / -1;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field__label {
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
}

.field__hint {
  color: var(--faint);
  font-size: 11px;
  line-height: 1.5;
}

.field__error {
  color: var(--danger);
  font-size: 11px;
}

.input {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  color: var(--ink);
  font-family: var(--font);
  font-size: 13px;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  transition:
    border-color 140ms var(--ease),
    box-shadow 140ms var(--ease);
}

textarea.input {
  min-height: 120px;
  resize: vertical;
  line-height: 1.65;
}

select.input {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #7b818c 50%),
    linear-gradient(135deg, #7b818c 50%, transparent 50%);
  background-position:
    calc(100% - 16px) calc(50% + 1px),
    calc(100% - 11px) calc(50% + 1px);
  background-repeat: no-repeat;
  background-size: 5px 5px, 5px 5px;
  padding-right: 30px;
}

.input:focus {
  border-color: #9a6a43;
  outline: 0;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input[readonly] {
  color: var(--muted);
  background: var(--surface-soft);
}

.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding-top: 4px;
  font-size: 12.5px;
  line-height: 1.5;
  cursor: pointer;
}

.checkbox input {
  width: 16px;
  height: 16px;
  flex: none;
  margin: 2px 0 0;
  accent-color: var(--ink);
}

.form-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 4px;
}

.form-actions__spacer {
  flex: 1;
}

.form-note {
  padding: 13px 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.upload-field {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.upload-preview {
  width: 72px;
  height: 72px;
  overflow: hidden;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.upload-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.upload-preview--wide {
  width: 144px;
  height: 84px;
}

.upload-input {
  font-size: 12px;
}

/* ---------- Feedback ---------- */

.flash {
  margin-bottom: 18px;
  padding: 12px 14px;
  font-size: 12.5px;
  line-height: 1.6;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.flash--success {
  color: var(--success);
  background: var(--success-soft);
  border-color: #cde7d8;
}

.flash--error {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #efcdcd;
}

.flash--info {
  color: #315d86;
  background: #eef5fb;
  border-color: #d3e3f0;
}

.badge {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  padding: 2px 7px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.badge--on {
  color: var(--success);
  background: var(--success-soft);
  border-color: #d5eadf;
}

.badge--off {
  color: var(--faint);
}

.badge--pin {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: #f0d9c6;
}

.empty {
  padding: 44px 20px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

/* ---------- Auth / install ---------- */

.auth-page {
  display: grid;
  min-height: 100vh;
  margin: 0;
  place-items: center;
  padding: 32px 18px;
  background:
    radial-gradient(60% 55% at 20% 10%, rgba(255, 177, 104, 0.1), transparent 70%),
    radial-gradient(55% 50% at 90% 90%, rgba(80, 120, 160, 0.14), transparent 72%),
    #0a0e14;
}

.auth-shell {
  width: 100%;
  max-width: 460px;
}

.auth-card {
  padding: 30px;
  color: #f4f6f8;
  background: rgba(22, 27, 35, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 24px;
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(24px) saturate(150%);
}

.auth-card--wide {
  max-width: 540px;
  margin-inline: auto;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.auth-brand__mark {
  display: grid;
  width: 36px;
  height: 36px;
  flex: none;
  place-items: center;
  color: #11151c;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  background: #f4f5f7;
  border-radius: 11px;
}

.auth-brand strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.auth-brand > div span {
  display: block;
  color: #8b94a3;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.15em;
}

.auth-card h1 {
  font-size: 28px;
  font-weight: 650;
  line-height: 1.25;
  letter-spacing: -0.035em;
}

.auth-lead {
  margin-top: 10px;
  color: #aeb6c2;
  font-size: 13px;
  line-height: 1.7;
}

.install-steps {
  display: flex;
  gap: 8px;
  margin: 0 0 24px;
  padding: 0;
  list-style: none;
}

.install-steps li {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  color: #727b88;
  font-size: 10px;
  letter-spacing: 0.02em;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 9px;
}

.install-steps li span {
  color: #596270;
  font-family: var(--mono);
  font-size: 9px;
}

.install-steps li.is-active {
  color: #f4f6f8;
  background: rgba(255, 177, 104, 0.1);
  border-color: rgba(255, 177, 104, 0.24);
}

.install-steps li.is-active span {
  color: #ffb168;
}

.install-steps li.is-done {
  color: #a8d9bc;
}

.install-steps li.is-done span {
  color: #8bd8a8;
}

.auth-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 20px 0 0;
}

.auth-summary div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9px;
}

.auth-summary span {
  color: #77808d;
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.08em;
}

.auth-summary strong {
  overflow: hidden;
  color: #e8ebef;
  font-size: 11px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-card .field__label {
  color: #d9dee5;
}

.auth-card .input {
  color: #f4f6f8;
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.16);
}

.auth-card .input:focus {
  border-color: rgba(255, 177, 104, 0.7);
  box-shadow: 0 0 0 3px rgba(255, 177, 104, 0.12);
}

.auth-card .form-stack {
  margin-top: 22px;
}

.auth-card .button--primary {
  color: #11151c;
  background: #f4f5f7;
  border-color: #f4f5f7;
}

.auth-card .button--primary:hover {
  background: #fff;
  border-color: #fff;
}

.auth-card .button--ghost {
  color: #cdd3db;
}

.auth-card .button--ghost:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.13);
}

.auth-card code {
  color: #f1d2b3;
  background: rgba(255, 255, 255, 0.08);
}

.auth-card .flash {
  margin-top: 18px;
  color: #ffd1c8;
  background: rgba(183, 61, 61, 0.16);
  border-color: rgba(255, 150, 150, 0.25);
}

.auth-card .flash--success {
  color: #c9f4da;
  background: rgba(34, 122, 75, 0.2);
  border-color: rgba(139, 216, 168, 0.25);
}

.auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 24px;
}

.auth-hint {
  margin-top: 20px;
  color: #727b88;
  font-size: 11px;
  line-height: 1.6;
}

.requirement-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
}

.requirement-list li {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 9px 10px;
  color: #aeb6c2;
  font-size: 11px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9px;
}

.requirement-list li span {
  color: #77808d;
  font-family: var(--mono);
  font-size: 9px;
}

.requirement-list li.is-ok::before {
  color: #8bd8a8;
  content: "OK · ";
}

.requirement-list li.is-bad::before {
  color: #ff9c9c;
  content: "! · ";
}

/* ---------- Responsive ---------- */

@media (max-width: 980px) {
  .admin-sidebar {
    position: relative;
    inset: auto;
    width: auto;
    padding: 14px 16px 10px;
  }

  .sidebar__brand {
    padding: 0 4px 12px;
  }

  .sidebar__nav {
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .sidebar__nav::-webkit-scrollbar {
    display: none;
  }

  .sidebar__section {
    display: none;
  }

  .nav-link {
    flex: 0 0 auto;
    min-height: 36px;
    padding: 0 10px;
    white-space: nowrap;
  }

  .nav-link__dot {
    display: none;
  }

  .sidebar__foot {
    position: absolute;
    top: 17px;
    right: 16px;
    flex-direction: row;
    padding: 0;
    border: 0;
  }

  .sidebar__foot .nav-link {
    display: none;
  }

  .logout-button {
    width: auto;
    color: #b9c0cb;
  }

  .admin-main {
    margin-left: 0;
  }

  .admin-topbar {
    padding: 0 20px;
  }

  .admin-content {
    padding: 24px 20px 50px;
  }
}

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

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .page-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-topbar__title {
    display: none;
  }

  .admin-topbar {
    min-height: 54px;
    justify-content: flex-end;
  }

  .requirement-list {
    grid-template-columns: 1fr;
  }

  .auth-summary {
    grid-template-columns: 1fr;
  }

  .install-steps {
    gap: 4px;
  }

  .install-steps li {
    padding: 7px 8px;
    font-size: 9.5px;
  }

  .auth-card {
    padding: 24px 20px;
  }

  .auth-card h1 {
    font-size: 25px;
  }

  .table {
    min-width: 620px;
  }
}

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