:root {
  color-scheme: light;
  --bg: #f3f4f7;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --text: #1d2433;
  --muted: #697586;
  --line: #d8dbe0;
  --accent: #5856d6;
  --accent-2: #3399ff;
  --accent-3: #2eb85c;
  --brand-gradient: linear-gradient(135deg, #5856d6 0%, #3399ff 100%);
  --soft: #eef2ff;
  --sidebar: #212631;
  --sidebar-muted: #aab3c2;
  --sidebar-line: rgba(255, 255, 255, .08);
  --danger: #fff0ed;
  --danger-line: #f0c8bf;
  --topbar: rgba(255, 255, 255, .92);
  --shadow: rgba(23, 32, 42, .07);
  --code-bg: #f8faf9;
}

:root[data-theme="dark"],
body[data-theme="dark"] {
  color-scheme: dark;
  --bg: #10151b;
  --panel: #171e26;
  --panel-2: #1d2630;
  --text: #eef3f7;
  --muted: #9aa8b6;
  --line: #2f3b48;
  --accent: #82b7d8;
  --accent-2: #d8aa55;
  --accent-3: #3f7fa5;
  --brand-gradient: linear-gradient(135deg, #8bc3e7 0%, #4d86aa 55%, #274f68 100%);
  --soft: #172b39;
  --sidebar: #0f141b;
  --sidebar-muted: #9aa8b6;
  --sidebar-line: rgba(255, 255, 255, .08);
  --danger: #3b211d;
  --danger-line: #734239;
  --topbar: rgba(17, 22, 20, .92);
  --shadow: rgba(0, 0, 0, .22);
  --code-bg: #111816;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
  overflow-x: hidden;
}

a {
  color: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 58px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: var(--topbar);
  backdrop-filter: blur(12px);
}

.app-shell .topbar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 216px;
  height: 100vh;
  min-height: 0;
  padding: 16px 12px;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 18px;
  border-right: 1px solid var(--sidebar-line);
  border-bottom: 0;
  background: var(--sidebar);
  color: #fff;
  box-shadow: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 800;
  text-decoration: none;
}

.app-shell .brand {
  min-height: 44px;
  padding: 0 8px 16px;
  border-bottom: 1px solid var(--sidebar-line);
  color: #fff;
}

.brand img {
  display: block;
  width: 44px;
  height: 30px;
  object-fit: cover;
  object-position: left center;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.app-shell .brand img {
  border-color: var(--sidebar-line);
}

.brand span {
  display: inline-block;
  font-size: 15px;
  white-space: nowrap;
}

nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.app-shell nav {
  display: grid;
  align-content: start;
  gap: 4px;
}

nav a,
.button,
button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  padding: 10px 14px;
  text-decoration: none;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

nav a {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

nav a:hover {
  color: var(--text);
  background: var(--soft);
  border-color: var(--line);
}

.app-shell nav a {
  width: 100%;
  justify-content: flex-start;
  height: 40px;
  padding: 0 10px;
  border-radius: 6px;
  color: var(--sidebar-muted);
}

.app-shell nav a:hover {
  color: #fff;
  background: rgba(255, 255, 255, .08);
  border-color: transparent;
}

.app-shell nav a[href*="dashboard"] {
  color: #fff;
  background: rgba(88, 86, 214, .22);
}

button,
.button {
  background: var(--brand-gradient);
  color: var(--bg);
  border-color: color-mix(in srgb, var(--accent) 70%, #000 10%);
}

.button,
button {
  min-height: 34px;
  padding: 7px 11px;
  font-size: 13px;
}

.theme-toggle {
  width: 42px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  background: var(--panel-2);
  border-color: var(--line);
}

.app-shell .theme-toggle {
  width: 100%;
  height: 40px;
  justify-content: center;
  background: rgba(255, 255, 255, .06);
  border-color: var(--sidebar-line);
}

.app-shell::before {
  content: "";
  position: fixed;
  inset: 0 auto 0 216px;
  width: 4px;
  height: auto;
  background: var(--brand-gradient);
  z-index: 9;
}

nav a {
  display: inline-flex;
  align-items: center;
  height: 38px;
}

.stats article,
.panel,
.card {
  border-top: 3px solid transparent;
}

.stats article:first-child {
  border-top-color: var(--accent);
}

.stats article:nth-child(2) {
  border-top-color: var(--accent-2);
}

.stats article:nth-child(3) {
  border-top-color: var(--accent-3);
}

.panel h2 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel h2::before {
  content: "";
  width: 8px;
  height: 18px;
  border-radius: 999px;
  background: var(--brand-gradient);
  flex: 0 0 auto;
}

.row:hover,
.card:hover,
.files a:hover {
  border-color: color-mix(in srgb, var(--accent) 38%, var(--line));
  background: var(--soft);
}

select:focus,
input:focus,
textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 34%, transparent);
  border-color: var(--accent);
}

.theme-icon {
  position: relative;
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--accent-2);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-2) 22%, transparent);
}

.theme-icon::before,
.theme-icon::after {
  content: "";
  position: absolute;
  border-radius: 999px;
}

.theme-icon::before {
  inset: 4px;
  background: var(--panel-2);
  transform: translate(5px, -5px);
}

.theme-toggle[data-theme-state="dark"] .theme-icon {
  background: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 22%, transparent);
}

.theme-toggle[data-theme-state="dark"] .theme-icon::before {
  inset: 7px auto auto 7px;
  width: 4px;
  height: 4px;
  background: var(--bg);
  box-shadow:
    -8px 2px 0 var(--bg),
    4px -8px 0 var(--bg),
    9px 5px 0 var(--bg);
  transform: none;
}

.theme-toggle[data-theme-state="dark"] .theme-icon::after {
  inset: -4px;
  background:
    linear-gradient(var(--accent), var(--accent)) 50% 0 / 2px 5px no-repeat,
    linear-gradient(var(--accent), var(--accent)) 50% 100% / 2px 5px no-repeat,
    linear-gradient(var(--accent), var(--accent)) 0 50% / 5px 2px no-repeat,
    linear-gradient(var(--accent), var(--accent)) 100% 50% / 5px 2px no-repeat;
}

.shell {
  width: min(1320px, calc(100vw - 32px));
  margin: 22px auto 56px;
  min-width: 0;
}

.app-shell .shell {
  width: auto;
  max-width: none;
  margin: 18px 18px 48px 234px;
}

.app-auth .topbar {
  min-height: 64px;
}

.heading {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 18px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 1px 2px var(--shadow);
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 14px;
}

h1,
h2,
h3 {
  margin: 0 0 10px;
  line-height: 1.15;
}

h1 {
  font-size: 32px;
}

h2 {
  font-size: 20px;
}

h3 {
  font-size: 15px;
  margin-top: 18px;
}

p {
  margin: 0;
}

.heading p,
.section-head p,
small,
.muted {
  color: var(--muted);
}

.panel,
.card,
.stats article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px var(--shadow);
}

.panel {
  padding: 14px;
  margin-bottom: 12px;
}

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

.stats article {
  padding: 16px;
}

.stats b {
  display: block;
  font-size: 30px;
}

.stats span {
  color: var(--muted);
}

.table {
  display: grid;
  gap: 8px;
}

.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(110px, 140px) minmax(0, auto);
  gap: 14px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-decoration: none;
  background: var(--panel-2);
}

.row span:first-child {
  min-width: 0;
}

.row strong,
.row small {
  display: block;
  overflow-wrap: anywhere;
}

.pill {
  justify-self: end;
  border-radius: 999px;
  background: color-mix(in srgb, var(--soft) 88%, var(--accent) 12%);
  color: var(--accent);
  padding: 6px 10px;
  font-weight: 700;
  font-size: 13px;
}

.grid {
  display: grid;
  gap: 14px;
}

.cards {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.card {
  min-height: 116px;
  padding: 18px;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card strong {
  overflow-wrap: anywhere;
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--text);
  background: var(--panel-2);
  font: inherit;
}

textarea {
  resize: vertical;
}

.wide,
.form button {
  grid-column: 1 / -1;
}

.form button {
  justify-self: start;
}

.compact-form {
  grid-template-columns: 160px minmax(180px, 1fr) minmax(180px, 1fr) auto;
  align-items: end;
}

.compact-form .wide {
  grid-column: span 2;
}

.compact-form button {
  grid-column: auto;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 14px;
  align-items: start;
}

.crm-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.panel,
.layout,
.crm-grid,
.table,
.row,
.form {
  min-width: 0;
}

dl {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 8px 14px;
  margin: 0 0 18px;
}

dt {
  color: var(--muted);
  font-weight: 700;
}

dd {
  margin: 0;
}

.pre,
pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  font: 14px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.message {
  border-top: 1px solid var(--line);
  padding: 18px 0 0;
  margin-top: 18px;
}

.message div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.files {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.files a {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-decoration: none;
}

.copy-box {
  min-height: 190px;
  margin-bottom: 14px;
  font-size: 14px;
  line-height: 1.5;
}

.copy-box.compact {
  min-height: 135px;
}

.content-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.content-item {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.content-item > div {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.content-item strong {
  margin-right: auto;
}

.content-item a {
  justify-self: start;
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.equipment-panel details {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.venue-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.venue-facts article {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.venue-facts strong {
  color: var(--accent);
}

.venue-facts span {
  color: var(--text);
  font-size: 14px;
}

.venue-panel details {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.equipment-panel summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 800;
}

.venue-panel summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 800;
}

.equipment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.equipment-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 14px;
}

.equipment-grid ul {
  margin: 0;
  padding-left: 18px;
  color: var(--text);
}

.equipment-grid li + li {
  margin-top: 6px;
}

.notice {
  margin-bottom: 18px;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line));
  border-radius: 8px;
  background: var(--soft);
  padding: 12px 14px;
}

.notice.danger {
  background: var(--danger);
  border-color: var(--danger-line);
}

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

.auth {
  min-height: calc(100vh - 150px);
  display: grid;
  place-items: center;
}

.auth .panel {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
}

@media (max-width: 760px) {
  .app-shell .topbar {
    position: sticky;
    inset: auto;
    width: auto;
    height: auto;
    min-height: 58px;
    padding: 12px 16px;
    background: var(--sidebar);
  }

  .app-shell::before {
    inset: 58px 0 auto;
    width: auto;
    height: 3px;
  }

  .app-shell .shell {
    width: min(1180px, calc(100vw - 32px));
    margin: 22px auto 56px;
  }

  .app-shell nav {
    display: flex;
  }

  .app-shell nav a,
  .app-shell .theme-toggle {
    width: auto;
  }

  .topbar,
  .heading,
  .section-head,
  .message div {
    align-items: stretch;
    flex-direction: column;
  }

  .stats,
  .layout,
  .crm-grid,
  .compact-form,
  .form,
  .row {
    grid-template-columns: 1fr;
  }

  .pill {
    justify-self: start;
  }

  .brand img {
    width: 42px;
  }
}
