/* ============================================================
   KANDANG — Global Styles
   Aesthetic: Warm organic / earthy farmhouse
   Fonts: Lora (display) + DM Sans (body)
============================================================ */

:root {
  --cream:     #F7F3EC;
  --cream-dark:#EDE6D6;
  --brown:     #6B4C2A;
  --brown-mid: #8C6340;
  --brown-lt:  #C4A882;
  --green:     #4A7C59;
  --green-lt:  #D4EAD7;
  --amber:     #D47C1A;
  --amber-lt:  #FAECD0;
  --red:       #B94040;
  --red-lt:    #F5DADA;
  --text:      #2C1E0F;
  --text-mid:  #6B5840;
  --text-lt:   #A89078;
  --border:    rgba(107,76,42,0.15);
  --border-md: rgba(107,76,42,0.25);
  --radius:    12px;
  --radius-sm: 8px;
  --shadow:    0 2px 16px rgba(107,76,42,0.10);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--cream);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* ---- Typography ---- */
h1, h2, h3 { font-family: 'Lora', serif; font-weight: 500; line-height: 1.25; }
h1 { font-size: 2rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; }

/* ---- Layout ---- */
.page {
  min-height: 100vh;
  padding-bottom: 88px;
}
.hidden { display: none !important; }

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ---- Topbar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--cream);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-logo {
  font-family: 'Lora', serif;
  font-size: 2rem;
  font-weight: 500;
  color: var(--brown);
}
.topbar-logo .logo-dot { color: var(--amber); }
.logo-double-letter {
  position: relative;
  display: inline-block;
  isolation: isolate;
}
.logo-double-letter::after {
  content: attr(data-letter);
  position: absolute;
  left: 0.07em;
  top: 0.08em;
  color: var(--brown-mid);
  opacity: 0.42;
  z-index: -1;
  pointer-events: none;
}
.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(460px, calc(100% - 16px));
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: rgba(247, 243, 236, 0.92);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 8px 26px rgba(44, 30, 15, 0.14);
  padding: 8px;
  z-index: 80;
}
.bottom-nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 8px;
  min-height: 44px;
  font-size: 13px;
  line-height: 1;
  text-align: center;
  text-decoration: none;
  font-family: 'DM Sans', sans-serif;
  color: var(--text-mid);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.bottom-nav-btn:hover {
  background: var(--cream-dark);
  color: var(--brown);
}
.bottom-nav-btn.active {
  background: var(--brown);
  color: var(--cream);
  border-color: rgba(107, 76, 42, 0.35);
}

/* ---- Cards ---- */
.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s, transform 0.1s;
  text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn-primary  { background: var(--brown); color: var(--cream); }
.btn-primary:hover  { opacity: 0.88; }
.btn-outline  { background: transparent; border: 1px solid var(--border-md); color: var(--text-mid); }
.btn-outline:hover  { background: var(--cream-dark); }
.btn-danger   { background: var(--red-lt); color: var(--red); border: 1px solid rgba(185,64,64,0.2); }
.btn-success  { background: var(--green); color: #fff; }
.btn-success:hover { opacity: 0.88; }
.btn-full { width: 100%; }

/* ---- Form Elements ---- */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-mid);
  margin-bottom: 5px;
}
input[type="email"],
input[type="password"],
input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-md);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brown-lt);
  box-shadow: 0 0 0 3px rgba(107,76,42,0.08);
}
textarea { resize: vertical; min-height: 72px; }
.form-hint { font-size: 12px; color: var(--text-lt); margin-top: 4px; }

/* ---- Auth Page ---- */
#page-auth {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--cream);
  padding: 2rem 1.25rem;
}
.auth-box {
  width: 100%;
  max-width: 380px;
}
.auth-header { text-align: center; margin-bottom: 2rem; }
.auth-header .logo-big {
  font-family: 'Lora', serif;
  font-size: 2.2rem;
  color: var(--brown);
  display: block;
  margin-bottom: 4px;
}
.auth-header .logo-big .logo-dot { color: var(--amber); }
.auth-header p { color: var(--text-lt); font-size: 14px; }
.auth-divider {
  text-align: center;
  margin: 1.25rem 0;
  font-size: 13px;
  color: var(--text-lt);
}
.auth-toggle {
  text-align: center;
  margin-top: 1.25rem;
  font-size: 13px;
  color: var(--text-mid);
}
.auth-toggle a {
  color: var(--brown);
  cursor: pointer;
  text-decoration: underline;
}
.auth-error {
  background: var(--red-lt);
  color: var(--red);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 1rem;
  display: none;
}

/* ---- Dashboard ---- */
.dash-header {
  padding: 1.5rem 1.25rem 1rem;
}
.dash-date {
  font-size: 13px;
  color: var(--text-lt);
  margin-bottom: 4px;
}
.metrics-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 1.25rem;
}
.metric-card {
  background: var(--cream-dark);
  border-radius: var(--radius-sm);
  padding: 14px 12px;
  text-align: center;
}
.metric-card .m-label {
  font-size: 12px;
  color: var(--text-mid);
  margin-bottom: 4px;
  font-weight: 500;
}
.metric-card .m-val {
  font-size: 26px;
  font-weight: 600;
  font-family: 'Lora', serif;
  color: var(--brown);
  line-height: 1.05;
}
.metric-card .m-sub {
  font-size: 12px;
  color: var(--text-lt);
  margin-top: 3px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.section-title { font-size: 13px; font-weight: 500; color: var(--text-mid); text-transform: uppercase; letter-spacing: 0.06em; }

/* Donut chart section */
.chart-section {
  padding: 0 1.25rem 1.25rem;
}
.chart-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.egg-bars {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.egg-group-card {
  padding: 0;
}
.egg-group-head {
  margin-bottom: 6px;
  padding: 0 2px;
}
.egg-group-head h3 {
  font-size: 14px;
  font-weight: 500;
  color: var(--brown);
}
.egg-group-items {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.egg-bar-card {
  background: linear-gradient(180deg, #fff 0%, #fdf8f1 100%);
  border: 1px solid var(--border);
  border-radius: 14px;
  min-height: 108px;
  padding: 12px 12px 16px;
  box-shadow: 0 6px 18px rgba(107, 76, 42, 0.08);
}
.egg-bar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.egg-bar-meta { min-width: 0; }
.egg-bar-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.egg-bar-sub {
  font-size: 11px;
  color: var(--text-lt);
}
.egg-bar-stat {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-family: 'Lora', serif;
  color: var(--brown);
  flex-shrink: 0;
}
.egg-bar-stat span {
  font-size: 22px;
  font-weight: 500;
  line-height: 1;
}
.egg-bar-stat small {
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  color: var(--text-lt);
}
.egg-bar-track {
  --progress: 0%;
  position: relative;
  height: 18px;
  margin-top: 2px;
  border-radius: 999px;
  background: linear-gradient(180deg, #efe3d0 0%, #e4d2b8 100%);
  border: 1px solid rgba(140, 99, 64, 0.25);
  overflow: visible;
}
.egg-bar-fill {
  height: 100%;
  width: var(--progress);
  min-width: 2px;
  border-radius: inherit;
  background: linear-gradient(90deg, #d47c1a 0%, #8c6340 85%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
  transition: width 900ms cubic-bezier(0.2, 0.85, 0.2, 1);
}
.egg-bar-marker {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  background: #fff8ed;
  border: 1px solid rgba(107, 76, 42, 0.2);
  box-shadow: 0 6px 14px rgba(107, 76, 42, 0.18);
  transition: left 900ms cubic-bezier(0.2, 0.85, 0.2, 1);
  pointer-events: none;
}
.egg-bar-marker .chicken-photo {
  width: 30px;
  height: 30px;
}
@media (prefers-reduced-motion: reduce) {
  .egg-bar-fill,
  .egg-bar-marker {
    transition: none;
  }
}
.chart-inner {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.chart-wrap {
  position: relative;
  width: 160px;
  height: 160px;
  flex-shrink: 0;
}
.chart-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
}
.chart-center .big { font-size: 26px; font-weight: 500; font-family: 'Lora', serif; color: var(--brown); }
.chart-center .sm  { font-size: 11px; color: var(--text-lt); }
.chart-legend { flex: 1; display: flex; flex-direction: column; gap: 9px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.legend-dot  { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.legend-name { flex: 1; color: var(--text-mid); }
.legend-val  { font-weight: 500; color: var(--text); }
.legend-pct  { font-size: 11px; color: var(--text-lt); min-width: 30px; text-align: right; }

/* Flock cards */
.flock-section { padding: 0 1.25rem 1.25rem; }
.flock-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.flock-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.flock-card-top { display: flex; align-items: center; gap: 10px; }
.flock-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.chicken-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}
.flock-card-name  { font-size: 13px; font-weight: 500; color: var(--text); }
.flock-card-count { font-size: 11px; color: var(--text-lt); }
.flock-card-eggs  { font-size: 22px; font-family: 'Lora', serif; font-weight: 500; color: var(--brown); }
.flock-card-sub   { font-size: 11px; color: var(--text-lt); }
.progress-track   { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.progress-fill    { height: 100%; border-radius: 2px; transition: width 0.4s ease; }

/* CTA button */
.cta-section { padding: 0 1.25rem 2rem; }
.btn-cta {
  width: 100%;
  padding: 14px;
  background: var(--brown);
  color: var(--cream);
  border: none;
  border-radius: var(--radius);
  font-family: 'Lora', serif;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.btn-cta:hover  { opacity: 0.88; }
.btn-cta:active { transform: scale(0.98); }
.btn-cta.already {
  background: var(--green-lt);
  color: var(--green);
  border: 1px solid rgba(74,124,89,0.3);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1.25rem;
  color: var(--text-lt);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state p { font-size: 14px; line-height: 1.6; margin-bottom: 1.25rem; }

/* ---- Modal ---- */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(44,30,15,0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  padding: 0;
}
@media (min-height: 600px) {
  #modal-overlay { align-items: center; padding: 1rem; }
}
#modal-content {
  background: var(--cream);
  width: 100%;
  max-width: 480px;
  border-radius: var(--radius) var(--radius) 0 0;
  overflow: hidden;
  max-height: 92vh;
  overflow-y: auto;
}
@media (min-height: 600px) {
  #modal-content { border-radius: var(--radius); max-height: 88vh; }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--cream);
  position: sticky;
  top: 0;
}
.modal-header h3 { font-size: 1rem; }
.modal-close {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border-md);
  background: none;
  font-size: 16px;
  color: var(--text-mid);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--cream-dark); }
.modal-body   { padding: 1.25rem; }
.modal-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  background: var(--cream);
  position: sticky;
  bottom: 0;
}

/* ---- Egg Input Rows ---- */
.egg-rows { display: flex; flex-direction: column; gap: 10px; margin-bottom: 1rem; }
.egg-input-group {
  background: linear-gradient(180deg, #fff 0%, #fdf8f1 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
}
.egg-input-group-head {
  padding-bottom: 8px;
  margin-bottom: 10px;
  border-bottom: 1px dashed rgba(107, 76, 42, 0.2);
}
.egg-input-group-head h4 {
  font-size: 14px;
  color: var(--brown);
  font-family: 'Lora', serif;
  font-weight: 500;
}
.egg-group-note { margin-bottom: 0; }
.egg-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s, background 0.15s;
}
.egg-row.filled { border-color: rgba(74,124,89,0.4); background: #fafffe; }
.egg-row-icon {
  width: 38px; height: 38px;
  border-radius: 50%;
  font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.egg-row-meta { flex: 1; min-width: 0; }
.egg-row-name { font-size: 13px; font-weight: 500; }
.egg-row-sub  { font-size: 11px; color: var(--text-lt); }
.counter      { display: flex; align-items: center; gap: 8px; }
.counter-btn  {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border-md);
  background: var(--cream);
  font-size: 18px;
  font-weight: 400;
  color: var(--brown);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  user-select: none;
  transition: background 0.1s;
  line-height: 1;
}
.counter-btn:hover  { background: var(--cream-dark); }
.counter-btn:active { transform: scale(0.92); }
.counter-val { font-size: 16px; font-weight: 500; font-family: 'Lora', serif; color: var(--brown); min-width: 28px; text-align: center; }
.pct-pill {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--cream-dark);
  color: var(--text-lt);
  flex-shrink: 0;
  min-width: 38px;
  text-align: center;
}
.pct-pill.good { background: var(--green-lt);  color: var(--green); }
.pct-pill.mid  { background: var(--amber-lt);  color: var(--amber); }
.pct-pill.bad  { background: var(--red-lt);    color: var(--red); }

.total-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--cream-dark);
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}
.total-bar .tl { font-size: 13px; color: var(--text-mid); }
.total-bar .tv { font-size: 16px; font-weight: 500; font-family: 'Lora', serif; color: var(--brown); }

/* ---- Settings Page ---- */
.settings-section { padding: 1.25rem 0; }
.settings-section + .settings-section { border-top: 1px solid var(--border); }
.settings-section h3 { margin-bottom: 1rem; }
.kandang-setting-group {
  background: linear-gradient(180deg, #fff 0%, #fdf8f1 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  margin-bottom: 10px;
}
.kandang-setting-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding: 2px 4px 8px;
  border-bottom: 1px dashed rgba(107, 76, 42, 0.18);
}
.kandang-setting-head h4 {
  font-size: 14px;
  color: var(--brown);
  font-family: 'Lora', serif;
  font-weight: 500;
}
.kandang-setting-head span {
  font-size: 12px;
  color: var(--text-lt);
}
.kandang-setting-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.kandang-setting-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.flock-setting-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
}
.flock-setting-info { flex: 1; }
.flock-setting-name  { font-size: 14px; font-weight: 500; }
.flock-setting-count { font-size: 12px; color: var(--text-lt); }
.flock-setting-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-md);
  background: none;
  font-size: 14px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-mid);
}
.icon-btn:hover { background: var(--cream-dark); }
.icon-btn.danger:hover { background: var(--red-lt); color: var(--red); border-color: rgba(185,64,64,0.3); }

/* Chicken type picker */
.chicken-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 1rem; }
.chicken-option {
  border: 1px solid var(--border-md);
  border-radius: var(--radius-sm);
  padding: 10px 6px;
  text-align: center;
  cursor: pointer;
  background: #fff;
  font-family: inherit;
  color: inherit;
  transition: border-color 0.15s, background 0.15s;
}
.chicken-option:hover { background: var(--cream-dark); }
.chicken-option.selected { border-color: var(--brown); background: var(--amber-lt); }
.chicken-option:focus-visible {
  outline: 2px solid rgba(107, 76, 42, 0.35);
  outline-offset: 2px;
}
.chicken-option .icon  {
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  margin-bottom: 4px;
}
.chicken-option .icon .chicken-photo {
  width: 28px;
  height: 28px;
}
.chicken-option .cname { font-size: 11px; color: var(--text-mid); }

/* Kandang editor modal */
.flock-editor-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}
.flock-editor-row {
  display: grid;
  grid-template-columns: 1fr 92px auto;
  gap: 8px;
  align-items: center;
}
.flock-editor-row select,
.flock-editor-row input[type="number"] {
  margin: 0;
}
.flock-editor-add {
  margin-top: 2px;
}

/* ---- Grafik Page ---- */
.chart-page-section { padding: 1.25rem 1.25rem 0; }
.chart-filter {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 1rem;
}
.chart-select {
  position: relative;
}
.chart-select-trigger {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(140, 99, 64, 0.35);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(252, 244, 231, 0.95));
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  box-shadow: 0 6px 14px rgba(107, 76, 42, 0.1);
}
.chart-select-trigger::after {
  content: '▾';
  font-size: 11px;
  color: var(--brown-mid);
  transition: transform 0.18s ease;
}
.chart-select.open .chart-select-trigger::after {
  transform: rotate(180deg);
}
.chart-select-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  background: #fffdf8;
  border: 1px solid rgba(140, 99, 64, 0.28);
  border-radius: 12px;
  box-shadow: 0 12px 24px rgba(107, 76, 42, 0.16);
  padding: 6px;
  display: none;
  z-index: 30;
}
.chart-select.open .chart-select-menu {
  display: block;
}
.chart-select-option {
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-mid);
  text-align: left;
  padding: 8px 10px;
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
}
.chart-select-option:hover {
  background: #f7efdf;
  color: var(--text);
}
.chart-select-option.active {
  background: #f2e2c6;
  color: var(--brown);
  font-weight: 600;
}
.js-enabled .chart-native-select {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  border: 0 !important;
}
.chart-intro-card {
  background: radial-gradient(circle at 18% 15%, rgba(255, 233, 197, 0.95) 0%, rgba(255, 247, 233, 0.88) 42%, rgba(255, 255, 255, 0.95) 100%);
  border: 1px solid rgba(140, 99, 64, 0.22);
  border-radius: 16px;
  box-shadow: 0 14px 28px rgba(107, 76, 42, 0.12);
  padding: 14px;
  margin-bottom: 12px;
}
.chart-intro-head p {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-lt);
  margin-bottom: 3px;
}
.chart-intro-head h3 {
  font-size: 1.05rem;
  color: var(--brown);
  margin-bottom: 10px;
}
.chart-intro-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.chart-pill {
  border-radius: 12px;
  border: 1px solid rgba(140, 99, 64, 0.18);
  background: rgba(255, 255, 255, 0.88);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.chart-pill span {
  font-size: 10px;
  color: var(--text-lt);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.chart-pill strong {
  font-size: 12px;
  color: var(--text);
  font-weight: 600;
}
.graph-stage {
  background:
    radial-gradient(circle at 92% 4%, rgba(245, 210, 151, 0.22), transparent 38%),
    linear-gradient(180deg, #fff 0%, #fcf4e7 100%);
  border: 1px solid rgba(140, 99, 64, 0.22);
  border-radius: 18px;
  padding: 12px;
  box-shadow: 0 12px 28px rgba(107, 76, 42, 0.1);
}
.chart-board {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 8px;
  align-items: stretch;
}
.chart-y-axis {
  height: 260px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-end;
  font-size: 10px;
  color: var(--text-lt);
  padding: 4px 0 34px;
}
.graph-scroll {
  overflow-x: auto;
  padding-bottom: 6px;
}
.chart-plot {
  min-height: 260px;
  display: flex;
  align-items: stretch;
  gap: 10px;
  min-width: max-content;
  padding: 6px 4px 0;
  background-image:
    linear-gradient(to top, rgba(140, 99, 64, 0.1) 1px, transparent 1px);
  background-size: 100% 25%;
  border-radius: 10px;
}
.chart-day {
  width: max(52px, calc(var(--bar-count, 1) * 10px + 14px));
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
}
.chart-cluster {
  height: 220px;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  padding: 8px 2px 0;
}
.chart-cluster-empty {
  width: 100%;
  height: 2px;
  border-top: 1px dashed rgba(140, 99, 64, 0.3);
}
.chart-bar {
  --bar-hue: 28;
  width: 9px;
  height: 8%;
  border-radius: 999px;
  background: linear-gradient(
    180deg,
    hsl(var(--bar-hue) 86% 78%) 0%,
    hsl(var(--bar-hue) 74% 58%) 44%,
    hsl(var(--bar-hue) 68% 36%) 100%
  );
  border: 1px solid hsl(var(--bar-hue) 52% 32% / 0.45);
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  transform-origin: bottom center;
  transition: filter 0.2s ease, transform 0.2s ease, height 0.85s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.chart-bar:hover {
  filter: saturate(1.08) brightness(1.03);
  transform: translateY(-2px);
}
.chart-bar-value {
  position: absolute;
  top: -18px;
  font-size: 10px;
  font-weight: 600;
  color: var(--brown);
  white-space: nowrap;
  opacity: 0;
  transform: translateY(3px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.chart-bar:hover .chart-bar-value {
  opacity: 1;
  transform: translateY(0);
}
.chart-bar-icon {
  position: absolute;
  top: -14px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff8ed;
  border: 1px solid rgba(107, 76, 42, 0.2);
  box-shadow: 0 4px 10px rgba(107, 76, 42, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transform: translateY(0);
  transition: transform 0.25s ease;
}
.chart-bar:hover .chart-bar-icon {
  transform: translateY(-2px);
}
.chart-bar-icon .chicken-photo {
  width: 16px;
  height: 16px;
}
.chart-day-total {
  font-size: 11px;
  color: var(--brown);
  font-weight: 600;
}
.chart-day-label {
  font-size: 10px;
  color: var(--text-mid);
  max-width: 100%;
  text-align: center;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- Toast ---- */
#toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--cream);
  padding: 10px 20px;
  border-radius: 99px;
  font-size: 13px;
  z-index: 200;
  white-space: nowrap;
  animation: toast-in 0.2s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateX(-50%) translateY(10px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* ---- Loading spinner ---- */
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--brown);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 3rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Responsive ---- */
@media (max-width: 400px) {
  .flock-grid { grid-template-columns: 1fr; }
  .metrics-row { grid-template-columns: repeat(3, 1fr); }
  .bottom-nav {
    width: calc(100% - 12px);
    border-radius: 14px;
    gap: 6px;
    padding: 7px;
  }
  .bottom-nav-btn {
    padding: 9px 6px;
    font-size: 12px;
  }
  .chart-intro-metrics {
    grid-template-columns: 1fr;
  }
  .chart-board {
    grid-template-columns: 28px 1fr;
    gap: 6px;
  }
  .chart-day {
    width: max(44px, calc(var(--bar-count, 1) * 8px + 12px));
  }
  .chart-cluster {
    gap: 2px;
  }
  .chart-bar {
    width: 7px;
  }
  .chart-bar-icon {
    width: 18px;
    height: 18px;
    top: -12px;
    font-size: 10px;
  }
  .chart-bar-icon .chicken-photo {
    width: 13px;
    height: 13px;
  }
  .chart-day-label {
    max-width: 100%;
    font-size: 9px;
  }
}
