:root {
  --bg: #f6f7fb;
  --card: #fff;
  --text: #1f2937;
  --muted: #6b7280;
  --pri: #2563eb;
  --ok: #16a34a;
  --warn: #f59e0b;
  --bad: #dc2626;
  --line: #e5e7eb;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
button:disabled, .btn:disabled { opacity: .55; cursor: not-allowed; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", Arial, sans-serif;
}
.wrap { max-width: 980px; margin: 0 auto; padding: 16px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  margin: 12px 0;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.subcard { border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin: 12px 0; background: #f9fafb; }
h1 { font-size: 24px; margin: 8px 0 12px; }
h2 { font-size: 18px; margin: 6px 0 10px; }
.muted { color: var(--muted); font-size: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn {
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--pri);
  color: #fff;
  text-decoration: none;
  display: inline-block;
  font-size: 15px;
  cursor: pointer;
}
.btn.secondary { background: #e5e7eb; color: #111827; }
.btn.ok { background: var(--ok); }
.btn.warn { background: var(--warn); }
.btn.bad { background: var(--bad); }
button { border: 1px solid var(--line); border-radius: 7px; background: #fff; padding: 7px 10px; cursor: pointer; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-size: 15px; background: white; }
.field { margin: 10px 0; }
.checks { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.checks input { width: auto; }
.grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(150px,1fr)); gap: 10px; }
.form-grid, .filter-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(180px,1fr)); gap: 10px; }
.filter-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; }
.slot { border: 1px solid var(--line); border-radius: 8px; padding: 12px; text-align: center; background: #fff; cursor: pointer; }
.slot.available { border-color: #86efac; background: #f0fdf4; }
.slot.booked, .slot.maintenance, .slot.disabled, .slot.expired { background: #f3f4f6; color: #9ca3af; cursor: not-allowed; }
.slot.selected { background: #dbeafe; border-color: #2563eb; color: #1d4ed8; font-weight: 700; }
.slot.mine { background: #fffbeb; border-color: #f59e0b; }
.badge { border-radius: 999px; padding: 3px 9px; font-size: 13px; }
.badge.idle { background: #dcfce7; color: #166534; }
.badge.reserved { background: #dbeafe; color: #1d4ed8; }
.badge.in_use { background: #ffedd5; color: #9a3412; }
.badge.maintenance, .badge.disabled { background: #fee2e2; color: #991b1b; }
table { width: 100%; border-collapse: collapse; background: white; }
th, td { border-bottom: 1px solid var(--line); padding: 8px; text-align: left; font-size: 14px; vertical-align: top; }
th { background: #f9fafb; }
.actions { white-space: nowrap; }
.actions button { margin: 2px; }
.tabs { display: flex; gap: 8px; overflow: auto; padding-bottom: 8px; }
.tab { white-space: nowrap; border: 1px solid var(--line); border-radius: 999px; background: #fff; padding: 8px 12px; cursor: pointer; }
.tab.active { background: #2563eb; color: #fff; border-color: #2563eb; }
.msg { padding: 10px; border-radius: 8px; background: #f3f4f6; margin: 8px 0; white-space: pre-wrap; }
.nav a { margin-right: 10px; }
.admin-layout { display: grid; grid-template-columns: 180px 1fr; gap: 14px; }
.side .btn { display: block; margin-bottom: 8px; text-align: left; width: 100%; }

.equipment-scan .card { padding: 14px; }
.scan-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
}
.scan-head.no-image { grid-template-columns: 1fr; }
.equipment-thumb {
  width: 86px;
  height: 86px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f3f4f6;
}
.today-visual {
  border: 1px solid #dbe3ef;
  background: #f8fbff;
  border-radius: 8px;
  padding: 12px;
  margin: 12px 0;
}
.day-rail { margin-top: 6px; }
.rail-scale {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  color: #64748b;
  font-size: 12px;
  margin-bottom: 6px;
}
.rail-scale span:nth-child(2), .rail-scale span:nth-child(3) { text-align: center; }
.rail-scale span:last-child { text-align: right; }
.rail-track {
  position: relative;
  height: 42px;
  border-radius: 8px;
  overflow: hidden;
  background: repeating-linear-gradient(90deg, #eef6f0 0, #eef6f0 6.9%, #e2ecff 7%, #e2ecff 7.1%);
  border: 1px solid #d7e0ea;
}
.rail-free {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(22,163,74,.08), rgba(37,99,235,.08));
}
.time-block {
  position: absolute;
  top: 5px;
  bottom: 5px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}
.time-block.active { background: #2563eb; }
.time-block.maintenance { background: #dc2626; }
.equipment-image-preview {
  width: 96px;
  height: 72px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f3f4f6;
}

@media (max-width: 700px) {
  .admin-layout { display: block; }
  .wrap { padding: 12px; }
  .grid { grid-template-columns: repeat(2,1fr); }
  .filter-row { grid-template-columns: 1fr; }
  table { font-size: 12px; display: block; overflow: auto; }
  .btn { width: auto; }
  .card { border-radius: 8px; }
  .scan-head { grid-template-columns: 1fr auto; }
  .equipment-thumb { width: 72px; height: 72px; }
  .time-block { font-size: 11px; padding: 0 4px; }
}

.compact-hero { padding-block: clamp(28px, 8vw, 72px); }
.action-card { max-width: 620px; }
.back-button, .text-button {
  appearance: none; border: 0; background: transparent; color: #475569; cursor: pointer;
  min-height: 40px; padding: 6px 4px; font: inherit;
}
.back-button:hover, .text-button:hover { color: #1d4ed8; }
.equipment-list-card { display: grid; grid-template-columns: 140px 1fr; gap: 16px; align-items: center; }
.equipment-list-image { width: 140px; height: 105px; object-fit: cover; border-radius: 8px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.slot-grid { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.night-quick-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.slot { font: inherit; width: 100%; display: flex; flex-direction: column; gap: 4px; align-items: center; }
.slot small { font-weight: 400; }
.slot.started, .slot.expired { background: #f1f5f9; border-color: #cbd5e1; color: #64748b; cursor: not-allowed; }
.slot.booked { background: #fff1f2; border-color: #fecdd3; color: #9f1239; cursor: not-allowed; }
.slot.mine { background: #eff6ff; border-color: #93c5fd; color: #1d4ed8; cursor: not-allowed; }
.slot.unavailable, .slot.disabled, .slot.maintenance { background: #f8fafc; border-color: #cbd5e1; color: #64748b; cursor: not-allowed; }
.slot.selected { box-shadow: inset 0 0 0 2px #2563eb; }
.selection-summary { border: 1px solid #cbd5e1; border-radius: 10px; background: #f8fafc; padding: 14px; }
.summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0; }
.summary-grid dt { color: #64748b; font-size: 13px; }
.summary-grid dd { margin: 3px 0 0; font-weight: 600; }
.mobile-confirm { display: none; }
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(150px,1fr)); gap: 10px; }
.metric-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: #fff; }
.metric-card strong { display: block; font-size: 24px; margin-top: 5px; }
.bulk-bar { position: sticky; top: 8px; z-index: 3; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: #eff6ff; border: 1px solid #93c5fd; border-radius: 10px; padding: 10px; }
.pagination { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; }
.chart-bars { display: flex; gap: 6px; min-height: 180px; align-items: end; overflow-x: auto; padding: 12px 0; }
.chart-bar { min-width: 38px; flex: 1; max-width: 72px; text-align: center; color: #475569; font-size: 11px; }
.chart-bar i { display: block; background: #2563eb; border-radius: 5px 5px 0 0; min-height: 3px; margin-bottom: 5px; }
.help-section { scroll-margin-top: 12px; }
.error { color: #991b1b; background: #fef2f2; }

@media (max-width: 700px) {
  .equipment-list-card { grid-template-columns: 1fr; }
  .equipment-list-image { width: 100%; height: 180px; }
  .night-quick-grid { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: 1fr; }
  .booking-page { padding-bottom: 92px; }
  .booking-page #desktopSubmit { display: none; }
  .mobile-confirm { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 10px; background: #fff; border-top: 1px solid #cbd5e1; box-shadow: 0 -4px 18px rgba(15,23,42,.12); padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
  .mobile-confirm[hidden] { display: none; }
  .mobile-confirm span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .side { display: flex; gap: 6px; overflow-x: auto; position: sticky; top: 0; z-index: 5; }
  .side .btn { flex: 0 0 auto; width: auto; }
}
