:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --text: #0b0b0b;
  --muted: #686868;
  --line: #d8d8d2;
  --soft: #efefeb;
  --inverse: #ffffff;
  --success: #147a42;
  --danger: #b42318;
  --radius: 16px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); }
a { color: inherit; }
button, input, textarea { font: inherit; }
button { color: inherit; }
h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(2rem, 4vw, 3.7rem); line-height: .98; letter-spacing: -.055em; margin-bottom: 12px; }
h2 { font-size: 1.15rem; letter-spacing: -.02em; }
code { font-family: "SFMono-Regular", Consolas, monospace; font-size: .84rem; overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.eyebrow { color: var(--muted); font-size: .69rem; font-weight: 750; letter-spacing: .16em; margin-bottom: 10px; }
.microcopy { color: var(--muted); font-size: .72rem; line-height: 1.5; overflow-wrap: anywhere; }
.brand { font-size: 1.1rem; font-weight: 900; text-decoration: none; letter-spacing: -.08em; }
.brand-dot { color: var(--muted); }
.admin-header {
  height: 66px; padding: 0 clamp(20px, 4vw, 60px); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; background: color-mix(in srgb, var(--bg) 90%, transparent);
  position: sticky; top: 0; z-index: 20; backdrop-filter: blur(16px);
}
.header-actions { display: flex; gap: 8px; align-items: center; }
.header-actions form { margin: 0; }
.admin-shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 44px 0 80px; }
.admin-narrow { width: min(820px, calc(100% - 40px)); }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 30px; }
.page-heading h1 { margin-bottom: 8px; }
.button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px;
  border: 1px solid var(--text); border-radius: 999px; background: var(--text); color: var(--inverse);
  text-decoration: none; font-weight: 700; cursor: pointer; transition: transform .15s ease, opacity .15s ease;
}
.button:hover { transform: translateY(-1px); opacity: .9; }
.button:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--text) 24%, transparent); outline-offset: 2px;
}
.button-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.button-small { min-height: 34px; padding: 0 13px; font-size: .78rem; }
.button-block { width: 100%; }
.app-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.app-card, .panel, .public-card, .auth-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.app-card { padding: 22px; }
.app-card-heading, .route-summary, .section-heading { display: flex; justify-content: space-between; gap: 16px; }
.app-identity { display: flex; align-items: center; gap: 13px; min-width: 0; }
.app-identity h2 { margin: 0 0 6px; }
.app-identity h2 a { text-decoration: none; }
.app-icon { width: 48px; height: 48px; border-radius: 12px; object-fit: cover; flex: 0 0 auto; border: 1px solid var(--line); }
.app-icon-placeholder { display: grid; place-items: center; background: var(--text); color: var(--inverse); font-weight: 850; }
.arrow-link { text-decoration: none; font-size: 1.2rem; }
.status, .platform, .status-toggle {
  display: inline-flex; align-items: center; width: fit-content; border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 8px; font-size: .67rem; font-weight: 750; background: transparent;
}
.status-on { border-color: color-mix(in srgb, var(--success) 35%, var(--line)); color: var(--success); }
.status-off { color: var(--muted); }
.status-toggle { cursor: pointer; }
.copy-field {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin: 20px 0;
  background: var(--soft); border: 1px solid var(--line); border-radius: 10px; min-width: 0;
}
.copy-field code { flex: 1; min-width: 0; }
.copy-button {
  flex: 0 0 auto; border: 0; background: transparent; color: var(--muted); padding: 4px;
  font-size: .72rem; font-weight: 750; text-decoration: none; cursor: pointer;
}
.platform-row { display: flex; align-items: center; gap: 7px; }
.platform { color: var(--muted); }
.platform-ready { background: var(--text); border-color: var(--text); color: var(--inverse); }
.route-count { margin-left: auto; color: var(--muted); font-size: .72rem; }
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 20px -22px -22px; background: var(--line); border-radius: 0 0 var(--radius) var(--radius); overflow: hidden; }
.metric-grid div { background: var(--surface); padding: 16px 22px; }
.metric-grid dt { color: var(--muted); font-size: .7rem; }
.metric-grid dd { margin: 5px 0 0; font-size: 1.5rem; font-weight: 800; letter-spacing: -.05em; }
.empty-state { text-align: center; padding: 80px 20px; border: 1px dashed var(--line); border-radius: var(--radius); }
.empty-mark { display: block; font-size: 2rem; margin-bottom: 18px; }
.auth-shell, .public-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(440px, 100%); padding: clamp(28px, 6vw, 48px); }
.stack { display: grid; gap: 16px; }
.stack-sm { display: grid; gap: 10px; }
.stack-lg { display: grid; gap: 28px; }
label { display: grid; gap: 7px; color: var(--muted); font-size: .75rem; font-weight: 650; }
label span small { font-weight: 500; }
input, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 11px 12px;
  color: var(--text); background: var(--surface);
}
textarea { resize: vertical; line-height: 1.5; }
input:disabled { background: var(--soft); color: var(--muted); }
fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 15px; }
legend { width: 100%; border-bottom: 1px solid var(--line); padding-bottom: 9px; margin-bottom: 16px; font-size: .8rem; font-weight: 800; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.check-row { display: flex; align-items: center; gap: 8px; }
.check-row input { width: auto; }
.panel { padding: clamp(20px, 3vw, 30px); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; }
.notice { margin: 16px 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 9px; font-size: .84rem; background: var(--soft); }
.notice-error { border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); color: var(--danger); }
.notice ul { margin: 8px 0 0; padding-left: 20px; }
.back-link { display: inline-block; color: var(--muted); text-decoration: none; font-size: .78rem; margin-bottom: 28px; }
.detail-hero { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
.app-identity-large { align-items: flex-start; }
.app-icon-large { width: 78px; height: 78px; border-radius: 20px; }
.hero-qr img { width: 86px; height: 86px; }
.copy-field-large { margin-bottom: 34px; background: var(--surface); }
.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 18px; align-items: start; }
.detail-main { display: grid; gap: 18px; }
.detail-aside { min-width: 0; }
.sticky-panel { position: sticky; top: 84px; }
.section-heading { align-items: flex-start; margin-bottom: 20px; }
.section-heading h2 { margin-bottom: 0; }
.count-badge { display: grid; place-items: center; min-width: 30px; height: 30px; padding: 0 8px; border-radius: 999px; background: var(--soft); font-size: .75rem; font-weight: 800; }
.route-create-form { display: grid; grid-template-columns: 1fr 1.3fr 1.3fr auto; align-items: end; gap: 9px; padding: 16px 0 20px; border-bottom: 1px solid var(--line); }
.route-list { display: grid; }
.route-row { padding: 18px 0; border-bottom: 1px solid var(--line); }
.route-row:last-child { border-bottom: 0; padding-bottom: 0; }
.route-summary code { display: block; margin-top: 6px; color: var(--muted); }
.route-actions { display: flex; align-items: center; gap: 7px; }
.route-metrics { display: flex; gap: 18px; color: var(--muted); font-size: .72rem; margin-top: 12px; }
.route-metrics strong { color: var(--text); margin-left: 4px; }
details { margin-top: 12px; }
summary { cursor: pointer; color: var(--muted); font-size: .72rem; font-weight: 700; }
.route-edit-form { display: grid; grid-template-columns: 1fr 1.2fr 1.2fr auto; align-items: end; gap: 8px; margin-top: 12px; padding: 14px; background: var(--soft); border-radius: 10px; }
.empty-inline { padding: 24px 0 4px; color: var(--muted); font-size: .82rem; }
.diagnostic-list { list-style: none; padding: 0; margin: 20px 0; display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); }
.diagnostic-list li { display: flex; justify-content: space-between; padding: 11px; background: var(--surface); font-size: .78rem; }
.ok { color: var(--success); }
.warn { color: var(--danger); }
.text-link { color: var(--text); font-size: .78rem; font-weight: 750; text-decoration-thickness: 1px; text-underline-offset: 3px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }
.analytics-table { display: grid; border: 1px solid var(--line); }
.analytics-row { display: grid; grid-template-columns: 1fr 100px 100px; padding: 10px 13px; border-bottom: 1px solid var(--line); font-size: .76rem; }
.analytics-row:last-child { border: 0; }
.analytics-head { color: var(--muted); background: var(--soft); font-weight: 750; }
.public-card { width: min(510px, 100%); padding: clamp(32px, 7vw, 64px); text-align: center; }
.public-card h1 { font-size: clamp(2.3rem, 8vw, 4.5rem); }
.public-lead { color: var(--muted); line-height: 1.65; }
.service-card { text-align: left; }
.service-status { width: fit-content; display: flex; align-items: center; gap: 8px; margin: 30px 0; font-size: .75rem; font-weight: 750; }
.service-status span { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px color-mix(in srgb, var(--success) 15%, transparent); }
.landing-icon { width: 84px; height: 84px; margin: 0 auto 30px; border-radius: 22px; object-fit: cover; border: 1px solid var(--line); }
.landing-qr { width: 178px; height: 178px; margin: 22px auto 6px; display: block; }
.qr-caption { color: var(--muted); font-size: .72rem; }
.store-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin: 26px 0; }
.error-code { font-size: .72rem; font-weight: 900; letter-spacing: .2em; }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #090909;
    --surface: #111111;
    --text: #f4f4f0;
    --muted: #a1a19a;
    --line: #30302d;
    --soft: #1a1a18;
    --inverse: #0a0a0a;
    --success: #5bd68e;
    --danger: #ff7b70;
  }
}

@media (max-width: 850px) {
  .app-grid, .detail-layout { grid-template-columns: 1fr; }
  .sticky-panel { position: static; }
  .route-create-form, .route-edit-form { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 600px) {
  .admin-shell { width: min(100% - 24px, 1180px); padding-top: 28px; }
  .admin-header { padding: 0 12px; }
  .page-heading { align-items: flex-start; }
  .page-heading > .button { display: none; }
  .form-grid, .route-create-form, .route-edit-form { grid-template-columns: 1fr; }
  .detail-hero { align-items: flex-start; }
  .hero-qr { display: none; }
  .copy-field { align-items: flex-start; flex-wrap: wrap; }
  .copy-field code { flex-basis: 100%; }
  .route-summary { flex-direction: column; }
  .analytics-row { grid-template-columns: 1fr 70px 70px; }
}
