:root {
  color-scheme: dark;
  --bg: #0d1319;
  --surface: #17202a;
  --surface-2: #202c38;
  --text: #edf4f8;
  --muted: #9fb0bd;
  --line: #31404d;
  --accent: #43c6ac;
  --accent-dark: #123f3a;
  --danger: #ff6b6b;
  --danger-dark: #52272b;
  --radius: 16px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: radial-gradient(circle at top right, #172a35 0, var(--bg) 34rem); color: var(--text); min-height: 100vh; }
a { color: inherit; }
h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(1.8rem, 5vw, 2.8rem); margin-bottom: .25rem; }
h2 { font-size: 1.15rem; }
button, input { font: inherit; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hidden { display: none; }
.eyebrow { color: var(--accent); font-size: .75rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; margin-bottom: .35rem; }

.topbar { height: 68px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); padding: 0 max(1rem, calc((100% - 1180px) / 2)); background: rgba(13, 19, 25, .88); backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 5; }
.brand { text-decoration: none; font-weight: 800; }
.user-menu, .button-row, .section-heading { display: flex; align-items: center; gap: .75rem; }
.user-menu form { margin: 0; }
.page { max-width: 1180px; margin: 0 auto; padding: 2rem 1rem 4rem; }
.hero { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }

.grid { display: grid; gap: 1rem; }
.controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card { background: rgba(23, 32, 42, .92); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; box-shadow: 0 18px 50px rgba(0, 0, 0, .16); }
.section { margin-top: 1rem; }
.section-heading { justify-content: space-between; }
.section-heading h1, .section-heading h2 { margin-bottom: 0; }

.button { display: inline-flex; justify-content: center; align-items: center; border: 1px solid transparent; border-radius: 10px; padding: .72rem 1rem; color: var(--text); text-decoration: none; cursor: pointer; font-weight: 750; transition: transform .15s, opacity .15s; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .5; cursor: wait; transform: none; }
.button-primary { background: var(--accent); color: #07231f; }
.button-secondary { background: var(--surface-2); border-color: var(--line); }
.button-danger { background: var(--danger-dark); color: #ffb2b2; border-color: #7b343b; }
.button-small { padding: .4rem .65rem; font-size: .8rem; }

.status { padding: .55rem .8rem; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; white-space: nowrap; font-size: .9rem; }
.status-dot { width: .65rem; height: .65rem; border-radius: 50%; background: var(--danger); display: inline-block; margin-right: .35rem; }
.status-online .status-dot { background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.alert { padding: .8rem 1rem; border-radius: 10px; margin-bottom: 1rem; }
.alert-error { color: #ffc2c2; background: var(--danger-dark); border: 1px solid #7b343b; }
.alert-success { color: #a4f8e7; background: var(--accent-dark); border: 1px solid #246c61; }

.gallery { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .8rem; margin-top: 1rem; }
.image-card { background: var(--surface-2); border-radius: 10px; overflow: hidden; text-decoration: none; border: 1px solid var(--line); }
.image-card img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.image-card span { display: block; padding: .55rem .7rem; color: var(--muted); font-size: .8rem; }
.image-detail img { display: block; width: 100%; max-height: 72vh; object-fit: contain; background: #050709; border-radius: 10px; margin: 1.25rem 0; }
.metadata { display: flex; gap: 2rem; flex-wrap: wrap; }
.metadata div { display: grid; gap: .2rem; }
.metadata dt { color: var(--muted); font-size: .8rem; }
.metadata dd { margin: 0; }

.table-wrap { overflow-x: auto; margin: 1rem -1.25rem -1.25rem; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th, td { text-align: left; padding: .8rem 1.25rem; border-top: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: .75rem; text-transform: uppercase; }
.payload { max-width: 420px; overflow-wrap: anywhere; color: var(--muted); }
code { color: #a4f8e7; }
.empty { text-align: center; color: var(--muted); padding: 2rem; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: min(100%, 420px); background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 2rem; box-shadow: 0 30px 80px rgba(0, 0, 0, .35); }
.login-icon { width: 58px; height: 58px; margin-bottom: 1rem; }
.stack { display: grid; gap: 1rem; }
label { display: grid; gap: .4rem; color: var(--muted); font-size: .9rem; }
input { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: .8rem; color: var(--text); background: var(--bg); outline: none; }
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(67, 198, 172, .15); }

@media (max-width: 760px) {
  .controls { grid-template-columns: 1fr; }
  .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { align-items: flex-start; flex-direction: column; }
  .button-row { align-items: stretch; flex-direction: column; }
  .user-menu > span { display: none; }
}
