:root {
  --bg: #14170f;
  --surface: #1d2216;
  --surface-2: #262c1d;
  --border: #3a4230;
  --text: #edefe3;
  --text-muted: #99a38a;
  --free: #7fb069;
  --busy: #c4622e;
  --overdue: #d64545;
  --brass: #c9a227;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
  padding-bottom: 40px;
}

h1,
h2,
h3,
.disp {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.mono {
  font-family: 'JetBrains Mono', monospace;
}

a {
  color: inherit;
}

button {
  font-family: inherit;
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(var(--bg) 88%, transparent);
  padding: 18px 16px 8px;
}

.topbar .eyebrow {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brass);
  margin: 0 0 2px;
}

.topbar h1 {
  font-size: 22px;
  margin: 0 0 14px;
}

.tabs {
  display: flex;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
}

.tab {
  flex: 1;
  text-align: center;
  padding: 9px 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Space Grotesk', sans-serif;
}

.tab.active {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border);
}

.wrap {
  padding: 14px 16px 0;
}

.chiprow {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 14px;
  scrollbar-width: none;
}

.chiprow::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: 0 0 auto;
  padding: 7px 13px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
}

.chip.active {
  background: var(--brass);
  border-color: var(--brass);
  color: #241d05;
  font-weight: 600;
}

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

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 12px 11px;
  overflow: hidden;
  text-align: left;
  color: var(--text);
}

.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.card.st-free::before {
  background: var(--free);
}

.card.st-busy::before {
  background: var(--busy);
}

.card.st-overdue::before {
  background: var(--overdue);
}

.card.st-service::before {
  background: var(--brass);
}

.rivet {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 8px;
}

.vtype-icon {
  width: 22px;
  height: 22px;
  color: var(--text-muted);
  flex: 0 0 auto;
}

.led {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: 0 0 auto;
  margin-top: 2px;
}

.led.st-free {
  background: var(--free);
  box-shadow: 0 0 6px var(--free);
}

.led.st-busy {
  background: var(--busy);
  box-shadow: 0 0 6px var(--busy);
}

.led.st-overdue {
  background: var(--overdue);
  box-shadow: 0 0 6px var(--overdue);
  animation: pulse 1.4s infinite;
}

.led.st-service {
  background: var(--brass);
  box-shadow: 0 0 6px var(--brass);
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

.plate {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 14.5px;
  letter-spacing: 0.04em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 3px 7px;
  display: inline-block;
  margin-bottom: 6px;
}

.vname {
  font-size: 13.5px;
  font-weight: 600;
  font-family: 'Space Grotesk', sans-serif;
  margin: 0 0 2px;
}

.vmeta {
  font-size: 11px;
  color: var(--text-muted);
  margin: 0 0 8px;
}

.statusline {
  font-size: 11.5px;
  margin: 0;
  line-height: 1.5;
}

.statusline.service {
  color: var(--brass);
  font-weight: 600;
}

.statusline b {
  color: var(--text);
}

.statusline.free {
  color: var(--free);
  font-weight: 600;
}

.statusline.overdue {
  color: var(--overdue);
}

.empty {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-muted);
}

.empty i {
  font-size: 15px;
}

.fab {
  position: fixed;
  right: 18px;
  bottom: 22px;
  z-index: 25;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--brass);
  border: none;
  color: #241d05;
  font-size: 24px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 7, 4, 0.72);
  z-index: 50;
  display: none;
  align-items: flex-end;
  justify-content: center;
}

.overlay.open {
  display: flex;
}

.sheet {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 18px 18px 24px;
  animation: slideup 0.2s ease-out;
}

@keyframes slideup {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

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

.sheet-head h2 {
  margin: 0;
  font-size: 18px;
}

.closebtn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  line-height: 1;
  padding: 2px 6px;
}

label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin: 12px 0 5px;
  font-weight: 500;
}

label:first-of-type {
  margin-top: 0;
}

input[type='text'],
input[type='datetime-local'],
input[type='date'],
select,
textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 11px;
  font-size: 14px;
  font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brass);
}

textarea {
  resize: vertical;
  min-height: 56px;
}

.btnrow {
  display: flex;
  gap: 8px;
  margin-top: 18px;
}

.btn {
  flex: 1;
  padding: 11px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  font-family: 'Space Grotesk', sans-serif;
}

.btn.primary {
  background: var(--brass);
  border-color: var(--brass);
  color: #241d05;
}

.btn.danger {
  background: transparent;
  border-color: var(--overdue);
  color: var(--overdue);
}

.btn:active {
  transform: scale(0.98);
}

.err {
  color: var(--overdue);
  font-size: 12px;
  margin-top: 5px;
}

.detail-status {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 14px;
}

.section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 18px 0 8px;
  font-weight: 600;
}

.receipt-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.receipt-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.receipt-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.receipt-tag {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 3px 5px;
  font-size: 9.5px;
  font-weight: 600;
  text-align: center;
  background: rgba(6, 7, 4, 0.75);
  color: var(--text);
}

.addreceipt-btn {
  aspect-ratio: 1;
  border-radius: 8px;
  border: 1.5px dashed var(--border);
  background: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  gap: 4px;
}

.small-note {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

.resv-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 11px;
  margin-bottom: 8px;
}

.resv-item .who {
  font-size: 13px;
  font-weight: 600;
}

.resv-item .when {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.resv-actions {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}

.resv-actions button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: 7px;
  padding: 6px 9px;
  font-size: 11px;
  font-weight: 600;
}

.resv-actions button.start {
  border-color: var(--brass);
  color: var(--brass);
}

.resv-actions button.cancel {
  border-color: var(--overdue);
  color: var(--overdue);
}

.badge-scheduled {
  font-size: 10.5px;
  color: var(--brass);
  margin-top: 3px;
  display: block;
}

.statusline.free .badge-scheduled {
  font-weight: 500;
}

.to-badge {
  font-size: 11px;
  margin: 5px 0 0;
  font-weight: 600;
}

.to-badge.soon {
  color: var(--brass);
}

.to-badge.overdue {
  color: var(--overdue);
}

.to-badge.ok {
  color: var(--text-muted);
  font-weight: 500;
}

.to-panel {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
}

.to-panel-row {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  padding: 4px 0;
}

.to-panel-row span:first-child {
  color: var(--text-muted);
}

.to-panel-row span:last-child {
  font-family: 'JetBrains Mono', monospace;
}

.to-status-line {
  font-size: 12.5px;
  font-weight: 600;
  margin: 8px 0 2px;
}

.to-status-line.ok {
  color: var(--free);
}

.to-status-line.soon {
  color: var(--brass);
}

.to-status-line.overdue {
  color: var(--overdue);
}

.fuel-panel {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
}

.fuel-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
}

.fuel-row .flabel {
  font-size: 12px;
  color: var(--text-muted);
}

.fuel-row .fval {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 700;
}

.fuel-row .fval.good {
  color: var(--free);
}

.fuel-row .fval.bad {
  color: var(--overdue);
}

.fuel-note {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.fuel-extra {
  display: none;
}

.fuel-extra.show {
  display: block;
}

.take-row {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.take-row .btn {
  flex: 1;
}

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.cal-head button {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 7px;
  width: 30px;
  height: 30px;
  font-size: 15px;
}

.cal-head .cal-title {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 14px;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-dow {
  text-align: center;
  font-size: 10px;
  color: var(--text-muted);
  padding-bottom: 4px;
}

.cal-cell {
  aspect-ratio: 1;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  position: relative;
  font-size: 11.5px;
  color: var(--text-muted);
}

.cal-cell.has-events {
  color: var(--text);
  border-color: var(--border-strong, var(--border));
  cursor: pointer;
}

.cal-cell.today {
  border-color: var(--brass);
}

.cal-cell.empty {
  background: transparent;
  border: none;
}

.cal-dots {
  display: flex;
  gap: 2px;
}

.cal-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
}

.agenda-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
}

.agenda-item:last-child {
  border-bottom: none;
}

.agenda-tag {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
  flex: 0 0 auto;
  margin-left: 8px;
}

.agenda-tag.tag-resv {
  background: rgba(201, 162, 39, 0.18);
  color: var(--brass);
}

.agenda-tag.tag-busy {
  background: rgba(196, 98, 46, 0.18);
  color: var(--busy);
}

.agenda-tag.tag-done {
  background: rgba(127, 176, 105, 0.18);
  color: var(--free);
}

.period-row {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
}

.stat-card h3 {
  margin: 0 0 12px;
  font-size: 13.5px;
}

.barrow {
  margin-bottom: 10px;
}

.barrow-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 4px;
}

.barrow-label .val {
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}

.bartrack {
  height: 8px;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
}

.barfill {
  height: 100%;
  border-radius: 4px;
  background: var(--brass);
}

.hist-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
}

.hist-row:last-child {
  border-bottom: none;
}

.hist-left b {
  font-weight: 600;
}

.hist-left .sub {
  color: var(--text-muted);
  font-size: 11px;
}

.hist-right {
  color: var(--text-muted);
  font-size: 11px;
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 9px;
  font-size: 13px;
  z-index: 80;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.toast.show {
  opacity: 1;
}

.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 13px;
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(6, 7, 4, 0.9);
  z-index: 90;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lightbox.open {
  display: flex;
}

.lightbox img {
  max-width: 100%;
  max-height: 90vh;
  border-radius: 10px;
}
