:root {
  color-scheme: dark;
  --bg: #181a1d;
  --panel: #24272b;
  --panel-2: #30343a;
  --line: #454b53;
  --text: #f1f5f9;
  --muted: #aeb8c3;
  --blue: #1f75b6;
  --blue-2: #2d8fe0;
  --green: #197a39;
  --yellow: #b88b12;
  --red: #a73535;
  --shadow: 0 20px 60px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 Arial, Helvetica, sans-serif;
}

button, input, select {
  font: inherit;
}

input, select {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  border: 1px solid #5b636e;
  border-radius: 5px;
  background: #2d3237;
  color: var(--text);
  padding: 8px 10px;
}

button, .link-button {
  border: 0;
  border-radius: 5px;
  background: var(--blue);
  color: white;
  min-height: 36px;
  padding: 8px 13px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

button:hover, .link-button:hover { background: var(--blue-2); }

button.ghost, .ghost {
  background: #3b4148;
  border: 1px solid #59616c;
}

.icon-button {
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 50%;
  background: #3a3f46;
  font-size: 20px;
}

.topbar {
  min-height: 76px;
  padding: 14px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid #272b30;
  background: #1d2024;
}

h1, h2, p { margin: 0; }
h1 { font-size: 28px; }
h2 { font-size: 18px; margin-bottom: 12px; }
.eyebrow { color: #7db7ef; font-weight: 700; margin-bottom: 4px; }
.top-actions { display: flex; gap: 8px; }

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand img {
  width: 150px;
  height: auto;
  display: block;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(260px, 330px) 1fr;
  min-height: calc(100vh - 76px);
}

.sidebar {
  padding: 16px;
  border-right: 1px solid #292e34;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: calc(100vh - 76px);
  overflow: auto;
  scrollbar-gutter: stable;
}

.sidebar input,
.sidebar select,
.sidebar button {
  max-width: 100%;
}

.sidebar .two input {
  padding-left: 7px;
  padding-right: 7px;
  font-size: 13px;
}

.workspace {
  padding: 16px;
  overflow: auto;
  max-height: calc(100vh - 76px);
}

.panel {
  background: var(--panel);
  border-radius: 8px;
  padding: 16px;
  border: 1px solid #2f343b;
}

.panel.wide { margin-top: 14px; }
.panel.collapsed-panel { display: none; }
.stack { display: grid; gap: 9px; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
label { color: var(--muted); display: grid; gap: 5px; min-width: 0; }

.mode-tabs {
  display: inline-flex;
  background: #383e45;
  border: 1px solid #4a525d;
  border-radius: 8px;
  padding: 3px;
}

.mode-tabs button {
  background: transparent;
  min-height: 30px;
  padding: 5px 14px;
}

.mode-tabs button.active { background: var(--blue); }
.view { display: none; }
.view.active { display: block; }

.summary-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
}

.summary-grid article {
  background: var(--panel);
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 14px;
}

.summary-grid span { color: var(--muted); display: block; }
.summary-grid strong { font-size: 26px; }

.chart-grid {
  display: grid;
  gap: 10px;
}

.chart-row {
  display: grid;
  grid-template-columns: minmax(82px, 120px) minmax(0, 1fr) minmax(36px, auto);
  gap: 10px;
  align-items: center;
}

.chart-track {
  height: 28px;
  border-radius: 5px;
  background: #20252a;
  border: 1px solid #3a424b;
  overflow: hidden;
}

.chart-bar {
  height: 100%;
  min-width: 2px;
}

.chart-bar.green { background: var(--green); }
.chart-bar.yellow { background: var(--yellow); }
.chart-bar.red { background: var(--red); }
.chart-row strong { text-align: right; }

.toolbar {
  margin-top: 14px;
  display: grid;
  grid-template-columns: minmax(140px, 220px) minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.toolbar.compact {
  margin-top: 0;
  grid-template-columns: minmax(140px, 220px) auto;
}

.checkline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.checkline input { width: auto; min-height: auto; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.section-title span { color: var(--muted); }

.stock-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}

.stock-card, .list-card {
  text-align: left;
  min-height: 0;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.08);
  background: var(--panel-2);
  padding: 13px;
  color: var(--text);
  display: grid;
  gap: 4px;
}

.stock-card.green { background: var(--green); }
.stock-card.yellow { background: var(--yellow); color: #141414; }
.stock-card.red { background: var(--red); }
.stock-card:hover, .list-card:hover { filter: brightness(1.08); }
.muted { color: var(--muted); }
.yellow .muted { color: #2a220a; }

.calendar-grid {
  overflow: auto;
  display: grid;
  gap: 5px;
  align-items: stretch;
}

.calendar-cell {
  min-width: 136px;
  min-height: 48px;
  border-radius: 6px;
  background: #2e3338;
  border: 1px solid #3f4650;
  padding: 8px;
  color: var(--text);
  font-size: 12px;
}

.calendar-cell.header {
  background: #3a3f46;
  font-weight: 700;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 2;
}

.calendar-cell.item {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 210px;
}

.calendar-cell.green { background: var(--green); }
.calendar-cell.yellow { background: var(--yellow); color: #141414; }
.calendar-cell.red { background: var(--red); }

.list {
  display: grid;
  gap: 9px;
}

.list-card {
  grid-template-columns: 1fr auto;
  cursor: pointer;
}

.list-card strong { font-size: 15px; }
.badge {
  padding: 4px 8px;
  border-radius: 999px;
  background: #3e4650;
  color: white;
  font-size: 12px;
  align-self: start;
}

.badge.green { background: var(--green); }
.badge.yellow { background: var(--yellow); color: #16130b; }
.badge.red { background: var(--red); }

.festival-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 9px;
}

.festival-form.collapsed,
.equipment-picker.collapsed {
  display: none;
}

.festival-form button { grid-column: span 2; }
.equipment-picker { margin-top: 14px; }
.equipment-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  margin-top: 10px;
  max-height: 280px;
  overflow: auto;
}

.equipment-option {
  border: 1px solid #454d57;
  border-radius: 7px;
  padding: 9px;
  display: flex;
  gap: 9px;
  align-items: flex-start;
  background: #2f343a;
}

.equipment-option input { width: auto; min-height: auto; margin-top: 3px; }
.festival-calendar {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 20;
}

.modal.hidden, .toast.hidden { display: none; }
.modal-card {
  position: relative;
  width: min(760px, 100%);
  max-height: min(820px, 90vh);
  overflow: auto;
  background: #252a30;
  border: 1px solid #49515c;
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

#modalClose { position: absolute; right: 12px; top: 12px; }
#modalContent { padding-right: 28px; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.modal-form { display: grid; gap: 10px; margin-top: 14px; }

.toast {
  position: fixed;
  bottom: 18px;
  right: 18px;
  background: #101418;
  border: 1px solid #4d5966;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  z-index: 30;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #15191d;
}

.login-shell {
  width: min(420px, calc(100vw - 28px));
}

.login-panel {
  background: var(--panel);
  border: 1px solid #373f48;
  border-radius: 8px;
  padding: 26px;
  display: grid;
  gap: 22px;
  box-shadow: var(--shadow);
}

.login-logo {
  width: 190px;
  height: auto;
  margin-bottom: 14px;
  display: block;
}

.login-form {
  display: grid;
  gap: 13px;
}

.form-message {
  min-height: 20px;
  color: #ffb4b4;
}

@media (max-width: 950px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar, .workspace { max-height: none; }
  .sidebar { border-right: 0; border-bottom: 1px solid #292e34; }
  .toolbar { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .festival-form { grid-template-columns: 1fr; }
  .festival-form button { grid-column: auto; }
}
