:root {
  color-scheme: light;
  --page: #f4f6fb;
  --surface: #ffffff;
  --surface-soft: #f8f9fc;
  --text: #20243a;
  --muted: #737991;
  --line: #e8eaf1;
  --brand: #6558d3;
  --brand-dark: #5145bd;
  --brand-soft: #f0efff;
  --green: #238567;
  --green-soft: #e9f7f1;
  --red: #bf4c58;
  --red-soft: #fff0f1;
  --shadow: 0 16px 42px rgb(34 40 77 / 6%);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #141622;
  --surface: #1d2030;
  --surface-soft: #24283a;
  --text: #eff0fa;
  --muted: #a0a5bd;
  --line: #32364b;
  --brand: #a59aff;
  --brand-dark: #b7adff;
  --brand-soft: #302d4d;
  --green: #79d5b5;
  --green-soft: #223b35;
  --red: #ff9ba4;
  --red-soft: #46292f;
  --shadow: 0 16px 42px rgb(0 0 0 / 18%);
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    color-scheme: dark;
    --page: #141622;
    --surface: #1d2030;
    --surface-soft: #24283a;
    --text: #eff0fa;
    --muted: #a0a5bd;
    --line: #32364b;
    --brand: #a59aff;
    --brand-dark: #b7adff;
    --brand-soft: #302d4d;
    --green: #79d5b5;
    --green-soft: #223b35;
    --red: #ff9ba4;
    --red-soft: #46292f;
    --shadow: 0 16px 42px rgb(0 0 0 / 18%);
  }
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

.shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 2;
  display: flex;
  width: 250px;
  flex-direction: column;
  padding: 28px 18px 20px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 0 8px 48px;
  color: var(--text);
  font: 800 17px ui-sans-serif, system-ui, sans-serif;
  text-decoration: none;
  letter-spacing: -.5px;
}

.brand-mark, .avatar {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 12px;
  background: var(--brand);
  color: white;
  font: 800 17px ui-sans-serif, system-ui, sans-serif;
}

.brand-mark { width: 34px; height: 34px; }
.brand-light { color: var(--muted); font-weight: 500; }
.navigation { display: grid; gap: 7px; }

.nav-link {
  display: flex;
  min-height: 45px;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  transition: background .16s ease, color .16s ease;
}

.nav-link:hover { background: var(--surface-soft); color: var(--text); }
.nav-link.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 700; }
.nav-icon { width: 18px; font-size: 19px; text-align: center; }

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: auto;
  padding: 14px 9px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #45b68e; }
.main { min-height: 100vh; margin-left: 250px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  height: 72px;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(22px, 5vw, 64px);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
}

.breadcrumbs { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.breadcrumbs strong { color: var(--text); font-weight: 600; }
.crumb-separator { color: #b6bac9; }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.auth-widget { display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; font-size: 13px; text-decoration: none; }

.litau-auth-button {
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.litau-auth-button:hover { border-color: var(--brand); color: var(--brand-dark); }
.litau-auth-message { color: var(--muted); font-size: 12px; }
.content { width: min(1050px, 100%); min-height: calc(100vh - 130px); margin: 0 auto; padding: 42px clamp(22px, 5vw, 64px) 60px; }
.page-heading { margin: 0 0 8px; font: 800 clamp(25px, 3vw, 32px) ui-sans-serif, system-ui, sans-serif; letter-spacing: -.8px; }
.page-subtitle { margin: 0 0 30px; color: var(--muted); font-size: 14px; line-height: 1.65; }
.eyebrow { margin: 0 0 8px; color: var(--brand); font-size: 11px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.card { min-width: 0; padding: 23px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); box-shadow: var(--shadow); }
.card.full { grid-column: 1 / -1; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 8px; font: 700 16px ui-sans-serif, system-ui, sans-serif; }
.card-description { margin: 0 0 18px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.identity { display: flex; align-items: center; gap: 16px; }
.identity-mark { display: grid; width: 52px; height: 52px; flex: 0 0 auto; place-items: center; border-radius: 16px; background: var(--brand-soft); color: var(--brand-dark); font: 800 20px ui-sans-serif, system-ui, sans-serif; }
.identity-name { margin: 0 0 4px; font: 700 18px ui-sans-serif, system-ui, sans-serif; overflow-wrap: anywhere; }
.identity-email { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 9px; border-radius: 99px; background: var(--green-soft); color: var(--green); font-size: 11px; font-weight: 700; }
.badge.warning { background: var(--red-soft); color: var(--red); }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.button { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; padding: 0 14px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--text); cursor: pointer; font-size: 12px; font-weight: 700; text-decoration: none; transition: .15s ease; }
.button:hover { border-color: var(--brand); color: var(--brand-dark); }
.button.primary { border-color: var(--brand); background: var(--brand); color: #fff; }
.button.primary:hover { background: var(--brand-dark); }
.button.danger { border-color: #efc3c6; color: var(--red); }
.button.danger:hover { border-color: var(--red); background: var(--red-soft); }
.button.small { min-height: 32px; padding: 0 10px; font-size: 11px; }
.button:disabled { cursor: not-allowed; opacity: .55; }
.quick-links { display: grid; gap: 10px; }
.quick-link { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); color: var(--text); cursor: pointer; text-align: left; }
.quick-link:hover { border-color: var(--brand); }
.quick-link span:first-child { font-size: 13px; font-weight: 600; }
.quick-link span:last-child { color: var(--muted); font-size: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field { display: grid; gap: 7px; min-width: 0; }
.field label { color: var(--muted); font-size: 12px; font-weight: 600; }
.field input, .field select { width: 100%; height: 42px; padding: 0 11px; border: 1px solid var(--line); border-radius: 8px; outline: none; background: var(--surface); color: var(--text); font-size: 13px; }
.field input:focus, .field select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 15%, transparent); }
.field input[readonly] { background: var(--surface-soft); color: var(--muted); }
.field-note { color: var(--muted); font-size: 11px; }
.section-label { margin: 26px 0 12px; font: 700 14px ui-sans-serif, system-ui, sans-serif; }
.session-list, .app-list { display: grid; gap: 10px; }
.session-row, .app-row { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 13px; border: 1px solid var(--line); border-radius: 10px; }
.session-info, .app-info { min-width: 0; }
.session-name, .app-name { display: block; margin-bottom: 4px; font-size: 12px; font-weight: 700; overflow-wrap: anywhere; }
.session-meta, .app-meta { display: block; color: var(--muted); font-size: 11px; line-height: 1.5; overflow-wrap: anywhere; }
.empty-state { padding: 22px 14px; border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); font-size: 12px; line-height: 1.6; text-align: center; }
.notice { padding: 13px 14px; border: 1px solid #e8e1ff; border-radius: 10px; background: var(--brand-soft); color: var(--brand-dark); font-size: 12px; line-height: 1.6; }
.notice.error { border-color: #f0c6c9; background: var(--red-soft); color: var(--red); }
.notice.success { border-color: #c7e9dc; background: var(--green-soft); color: var(--green); }
.loading-card { display: flex; min-height: 180px; align-items: center; justify-content: center; gap: 12px; color: var(--muted); font-size: 13px; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.footer { display: flex; justify-content: space-between; gap: 20px; padding: 17px clamp(22px, 5vw, 64px); border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.footer span:first-child { font-weight: 700; }

@media (max-width: 760px) {
  .sidebar { position: static; width: auto; height: auto; padding: 15px 18px 0; border-right: 0; }
  .brand { margin: 0 3px 15px; }
  .navigation { display: flex; gap: 4px; overflow-x: auto; }
  .nav-link { min-height: 40px; flex: 0 0 auto; gap: 7px; padding: 0 10px; font-size: 12px; }
  .nav-icon { font-size: 16px; }
  .sidebar-footer { display: none; }
  .main { margin-left: 0; }
  .topbar { height: 58px; padding: 0 18px; }
  .auth-widget { gap: 6px; }
  .litau-auth-message { display: none; }
  .content { min-height: calc(100vh - 185px); padding: 28px 18px 42px; }
  .footer { padding: 15px 18px; }
}

@media (max-width: 560px) {
  .grid, .form-grid { grid-template-columns: 1fr; }
  .card.full { grid-column: auto; }
  .card { padding: 18px; }
  .session-row, .app-row { align-items: flex-start; }
  .session-row .button, .app-row .button { flex: 0 0 auto; }
  .footer { flex-direction: column; gap: 5px; }
}
