:root {
  color-scheme: dark;
  --bg: #090b0b;
  --surface: #101413;
  --panel: #171d1b;
  --panel-2: #1d2421;
  --line: #2a332f;
  --text: #f1f5ef;
  --muted: #9aa69f;
  --honey: #f2bf36;
  --honey-soft: rgba(242, 191, 54, 0.14);
  --green: #6fd36b;
  --green-soft: rgba(111, 211, 107, 0.14);
  --red: #ef6a5b;
  --orange: #e99145;
  --blue: #6cb7d8;
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
}
button, select { font: inherit; }
.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  border-right: 1px solid var(--line);
  background: #0d100f;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  color: #14150d;
  font-weight: 900;
  background: linear-gradient(135deg, var(--honey), var(--green));
}
.brand h1 { margin: 0; font-size: 20px; letter-spacing: 0; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.nav { display: grid; gap: 8px; }
.nav button {
  border: 0;
  min-height: 42px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  background: transparent;
  border-radius: var(--radius);
  cursor: pointer;
}
.nav button.active, .nav button:hover {
  color: var(--text);
  background: var(--panel);
}
.nav svg { width: 18px; height: 18px; stroke-width: 2; }
.sidebar-footer {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.sidebar-footer strong { display: block; font-size: 13px; }
.sidebar-footer span { color: var(--muted); font-size: 12px; }
.main {
  padding: 24px;
  min-width: 0;
}
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}
.eyebrow {
  margin: 0 0 6px;
  color: var(--honey);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
}
h2 { margin: 0; font-size: 28px; letter-spacing: 0; }
.subtle { color: var(--muted); margin: 6px 0 0; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.search, select {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
}
.button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 38px;
  padding: 0 12px;
  color: var(--text);
  background: var(--panel);
  cursor: pointer;
}
.button.primary {
  color: #161710;
  border-color: transparent;
  background: var(--honey);
  font-weight: 700;
}
.card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.grid { display: grid; gap: 14px; }
.stats { grid-template-columns: repeat(9, minmax(120px, 1fr)); }
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 18px 40px rgba(0,0,0,.16);
}
.metric { padding: 14px; min-height: 104px; }
.metric span { color: var(--muted); font-size: 12px; }
.metric strong { display: block; margin-top: 10px; font-size: 25px; }
.metric small { color: var(--green); }
.metric.warn small { color: var(--orange); }
.metric.bad small { color: var(--red); }
.layout-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr);
  gap: 16px;
  margin-top: 16px;
}
.section { padding: 16px; }
.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.section-title h3 { margin: 0; font-size: 17px; }
.event-list, .timeline, .inspection-list { display: grid; gap: 10px; }
.event {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; background: var(--green); }
.dot.alert { background: var(--red); }
.dot.warn { background: var(--orange); }
.event strong { display: block; font-size: 13px; }
.event p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.event time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.hive-grid { grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.hive-card {
  padding: 14px;
  display: grid;
  gap: 13px;
  cursor: pointer;
  transition: border-color .15s ease, transform .15s ease;
}
.hive-card:hover { border-color: rgba(242,191,54,.72); transform: translateY(-2px); }
.hive-head, .row, .tabs { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.hive-head h3 { margin: 0; font-size: 18px; }
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--green);
  background: var(--green-soft);
  font-size: 12px;
  font-weight: 700;
}
.badge.warn { color: var(--orange); background: rgba(233,145,69,.14); }
.badge.bad { color: var(--red); background: rgba(239,106,91,.14); }
.badge.honey { color: var(--honey); background: var(--honey-soft); }
.row { color: var(--muted); font-size: 13px; }
.row strong { color: var(--text); }
.bar {
  height: 7px;
  border-radius: 999px;
  background: #29302d;
  overflow: hidden;
}
.bar i { display: block; height: 100%; width: var(--v); background: var(--green); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  min-height: 34px;
  padding: 0 12px;
  color: var(--muted);
  background: var(--surface);
  cursor: pointer;
}
.chip.active { color: #17170e; border-color: transparent; background: var(--honey); font-weight: 700; }
.tabs { justify-content: flex-start; margin: 0 0 16px; overflow-x: auto; }
.tab {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
  background: var(--surface);
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
}
.tab.active { color: var(--text); background: var(--panel-2); border-color: rgba(242,191,54,.55); }
.detail-header {
  padding: 16px;
  margin-bottom: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
}
.detail-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.detail-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.info { padding: 14px; background: var(--panel); border-radius: var(--radius); border: 1px solid var(--line); }
.info span { display:block; color: var(--muted); font-size: 12px; }
.info strong { display:block; margin-top: 8px; font-size: 18px; }
.chart-wrap { min-height: 270px; }
.chart {
  width: 100%;
  height: 240px;
  display: block;
}
.chart-label { fill: var(--muted); font-size: 11px; }
.hive-twin {
  display: grid;
  gap: 12px;
  max-width: 760px;
}
.body-box {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.frames {
  display: grid;
  grid-template-columns: repeat(5, minmax(54px, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.frame {
  min-height: 86px;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 8px 5px;
  font-size: 12px;
  color: #11150f;
  font-weight: 700;
}
.frame.brood { background: #b97b55; }
.frame.honey { background: #f2bf36; }
.frame.pollen { background: #b7d86c; }
.frame.feed { background: #d1ad6a; }
.frame.wax { background: #e8dca8; }
.frame.dry { background: #c6c9bd; }
.frame.empty { background: #56605a; color: var(--text); }
.frame.separator { background: #78b9c9; }
.map-shell { height: 560px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
#map { position: relative; width: 100%; height: 100%; background: #121817; }
.map-notice { margin-bottom: 12px; }
.map-controls {
  padding: 12px;
  margin-bottom: 12px;
}
.coordinate-form {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(150px, 1fr) auto auto;
  gap: 10px;
  align-items: end;
}
.coordinate-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}
.coordinate-form input { width: 100%; }
.map-status {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}
.map-status.bad { color: var(--red); }
.map-error {
  position: absolute;
  z-index: 2;
  left: 12px;
  right: 12px;
  bottom: 12px;
  max-width: 620px;
  box-shadow: 0 14px 30px rgba(0,0,0,.35);
}
.nomad-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.preset-grid { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.warehouse-summary {
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  margin-bottom: 16px;
}
.warehouse-tabs { margin-top: 4px; }
.warehouse-table {
  display: grid;
  gap: 8px;
}
.warehouse-row {
  display: grid;
  grid-template-columns: minmax(190px, 1.35fr) minmax(100px, .7fr) minmax(80px, .55fr) minmax(100px, .75fr) minmax(120px, .8fr) minmax(170px, 1.1fr);
  gap: 10px;
  align-items: center;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
}
.warehouse-row strong { color: var(--text); }
.warehouse-head {
  background: transparent;
  color: var(--honey);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.preset {
  padding: 16px;
  display: grid;
  gap: 12px;
}
.preset ul { margin: 0; padding-left: 18px; color: var(--muted); }
.preset-select {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.notice {
  padding: 12px;
  border: 1px solid rgba(242,191,54,.3);
  border-radius: var(--radius);
  background: var(--honey-soft);
  color: #f7dfa1;
}
.record-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 260px) auto;
  gap: 10px;
  align-items: stretch;
  margin-bottom: 14px;
}
.record-form textarea {
  min-height: 74px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  padding: 11px 12px;
  font: inherit;
}
.file-field {
  display: grid;
  align-content: center;
  gap: 7px;
  padding: 10px;
  border: 1px dashed rgba(242,191,54,.42);
  border-radius: var(--radius);
  background: var(--honey-soft);
  color: var(--muted);
  font-size: 12px;
}
.file-field input { max-width: 100%; color: var(--muted); }
.record-list { display: grid; gap: 10px; }
.attachment {
  display: inline-flex;
  width: fit-content;
  margin-top: 8px !important;
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--honey) !important;
  background: var(--honey-soft);
}
.hidden { display: none !important; }
.mobile-nav { display: none; }

@media (max-width: 1180px) {
  .stats { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
  .layout-2 { grid-template-columns: 1fr; }
  .warehouse-row { grid-template-columns: minmax(180px, 1fr) repeat(2, minmax(90px, .6fr)); }
  .warehouse-row span:nth-child(5), .warehouse-row span:nth-child(6) { grid-column: span 1; }
  .warehouse-head span:nth-child(5), .warehouse-head span:nth-child(6) { display: none; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .mobile-nav {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 10px;
    border-bottom: 1px solid var(--line);
    background: #0d100f;
  }
  .mobile-nav button { flex: 0 0 auto; }
  .main { padding: 16px; }
  .topbar, .detail-header { grid-template-columns: 1fr; display: grid; }
  .stats, .detail-grid, .frames, .warehouse-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .coordinate-form { grid-template-columns: 1fr; }
  .warehouse-row { grid-template-columns: 1fr; }
  .warehouse-head { display: none; }
  .record-form { grid-template-columns: 1fr; }
  h2 { font-size: 24px; }
}
