/* Kolamku — tema "air kolam": biru-tinta dalam, hijau-teal air, kuning pelet pakan */
:root {
  --deep: #0f2f3a;       /* air dalam: topbar, teks utama */
  --pond: #0e7c86;       /* aksi utama */
  --pond-d: #0a5f67;
  --reed: #3f8f4e;       /* sehat / selesai */
  --feed: #e3a21a;       /* pakan / peringatan ringan */
  --alarm: #c2410c;      /* bahaya */
  --mist: #eef3f2;       /* latar */
  --surface: #ffffff;
  --line: #d6e2e0;
  --muted: #5b7078;
  --r: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --nav-h: 62px;
}
* { -webkit-tap-highlight-color: transparent; }
html, body { background: var(--mist); color: var(--deep); }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px; line-height: 1.45; margin: 0; overscroll-behavior-y: none;
  font-variant-numeric: tabular-nums;
}
a { color: var(--pond-d); text-decoration: none; }
h1, h2, h3, h4, h5 { font-weight: 650; letter-spacing: -.01em; margin: 0; }
.text-muted, .muted { color: var(--muted) !important; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--pond) 55%, white); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- boot & login ---------- */
.boot { display: grid; place-items: center; gap: .5rem; min-height: 100vh; color: var(--muted); }
.boot i { font-size: 2.2rem; color: var(--pond); }
.login { min-height: 100vh; display: grid; align-content: center; padding: 24px; background: var(--deep); }
.login-card { background: var(--surface); border-radius: 20px; padding: 26px 22px; max-width: 400px; width: 100%; margin: 0 auto; }
.login-brand { display: flex; align-items: center; gap: .6rem; margin-bottom: 1.2rem; }
.login-brand img { width: 44px; height: 44px; border-radius: 12px; }
.login-brand h1 { font-size: 1.35rem; }

/* ---------- layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; background: var(--deep); color: #fff;
  padding: calc(8px + var(--safe-t)) 12px 8px; display: flex; align-items: center; gap: 8px;
}
.topbar h1 { font-size: 1.05rem; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { background: transparent; border: 0; color: inherit; width: 40px; height: 40px; border-radius: 10px; font-size: 1.25rem; display: grid; place-items: center; }
.icon-btn:active { background: rgba(255,255,255,.14); }
.sync-badge { border: 0; border-radius: 99px; padding: 5px 11px; font-size: .78rem; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,.14); color: #fff; }
.sync-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: #7ddc8f; }
.sync-badge.offline .dot { background: #aab8bd; }
.sync-badge.pending .dot { background: var(--feed); }
.sync-badge.error .dot { background: #ff8a65; }
.sync-badge.syncing .dot { background: #fff; animation: pulse 1s infinite alternate; }
@keyframes pulse { to { opacity: .25; } }

#view { padding: 14px 14px calc(var(--nav-h) + var(--safe-b) + 28px); max-width: 880px; margin: 0 auto; }
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface);
  border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, 1fr);
  padding-bottom: var(--safe-b); height: calc(var(--nav-h) + var(--safe-b));
}
.bottom-nav a { display: grid; place-items: center; align-content: center; gap: 1px; color: var(--muted); font-size: .7rem; font-weight: 600; }
.bottom-nav a i { font-size: 1.3rem; }
.bottom-nav a.active { color: var(--pond-d); }
.bottom-nav a.fab-nav i { background: var(--pond); color: #fff; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; margin-top: -18px; box-shadow: 0 4px 12px rgba(14,124,134,.4); font-size: 1.5rem; }
.banner { background: #fff8e1; border: 1px solid #f1dc9a; color: #6b5200; border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; font-size: .88rem; display: flex; gap: 8px; align-items: center; }
.banner.info { background: #e6f4f5; border-color: #b8dde0; color: var(--pond-d); }

/* ---------- komponen ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 12px; }
.page-head h2 { font-size: 1.15rem; }
.sect { margin: 20px 0 8px; display: flex; align-items: center; justify-content: space-between; }
.sect h3 { font-size: .95rem; }
.card-x { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 10px; }
.card-x.flush { padding: 0; overflow: hidden; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 640px) { .stats.cols-4 { grid-template-columns: repeat(4, 1fr); } .stats.cols-3 { grid-template-columns: repeat(3, 1fr); } }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 11px 13px; }
.stat .lbl { font-size: .74rem; color: var(--muted); font-weight: 600; }
.stat .val { font-size: 1.35rem; font-weight: 700; line-height: 1.2; margin-top: 2px; }
.stat .sub { font-size: .74rem; color: var(--muted); }
.stat.good .val { color: var(--reed); }
.stat.warn .val { color: #b27800; }
.stat.bad .val { color: var(--alarm); }

.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; font-size: .72rem; font-weight: 650; background: #e4ecea; color: var(--deep); white-space: nowrap; }
.chip-active { background: #d7efe0; color: #1f6b34; }
.chip-prep, .chip-warn { background: #fdf0cc; color: #7a5600; }
.chip-done, .chip-muted { background: #e4ecea; color: var(--muted); }
.chip-bad { background: #fbdcd0; color: #8f2f06; }
.chip-info { background: #d9eef0; color: var(--pond-d); }

/* kartu siklus: strip "tinggi air" di kiri = progres hari menuju panen */
.cycle-card { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; margin-bottom: 10px; color: inherit; }
.cycle-card .tank { width: 14px; background: #dbe8e6; position: relative; flex: none; }
.cycle-card .tank > i { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(180deg, #2aa3ad, var(--pond)); }
.cycle-card .tank.late > i { background: linear-gradient(180deg, #f1b94a, var(--feed)); }
.cycle-card .body { padding: 12px 14px; flex: 1; min-width: 0; }
.cycle-card .row1 { display: flex; justify-content: space-between; gap: 8px; align-items: start; }
.cycle-card h4 { font-size: 1.02rem; }
.mini { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 10px; }
.mini div { font-size: .72rem; color: var(--muted); }
.mini b { display: block; font-size: .98rem; color: var(--deep); }

.alert-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; margin-bottom: 8px; background: #fff; border: 1px solid var(--line); border-left-width: 5px; color: inherit; }
.alert-row.danger { border-left-color: var(--alarm); }
.alert-row.warn { border-left-color: var(--feed); }
.alert-row.info { border-left-color: var(--pond); }
.alert-row i { font-size: 1.1rem; margin-top: 1px; }
.alert-row.danger i { color: var(--alarm); } .alert-row.warn i { color: #b27800; } .alert-row.info i { color: var(--pond); }

.task { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface); width: 100%; border-left: 0; border-right: 0; border-top: 0; text-align: left; color: inherit; }
.task:last-child { border-bottom: 0; }
.task .check { width: 28px; height: 28px; border-radius: 8px; border: 2px solid #9db3b3; display: grid; place-items: center; color: #fff; flex: none; }
.task.done .check { background: var(--reed); border-color: var(--reed); }
.task.done .t { text-decoration: line-through; color: var(--muted); }
.task.late .check { border-color: var(--alarm); }
.task .t { flex: 1; min-width: 0; }
.task small { color: var(--muted); display: block; }

.tabs-x { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; margin: 0 -14px; padding-left: 14px; padding-right: 14px; scrollbar-width: none; }
.tabs-x::-webkit-scrollbar { display: none; }
.tabs-x a { flex: none; padding: 7px 14px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); color: var(--deep); font-weight: 600; font-size: .85rem; }
.tabs-x a.active { background: var(--deep); color: #fff; border-color: var(--deep); }

.btn-pond { background: var(--pond); color: #fff; border: 0; border-radius: 12px; padding: 10px 16px; font-weight: 650; }
.btn-pond:active { background: var(--pond-d); }
.btn-ghost { background: var(--surface); color: var(--deep); border: 1px solid var(--line); border-radius: 12px; padding: 9px 14px; font-weight: 600; }
.btn-sm-x { padding: 5px 10px; font-size: .82rem; border-radius: 9px; }
.btn-danger-x { background: #fff; color: var(--alarm); border: 1px solid #efc4b2; border-radius: 12px; padding: 9px 14px; font-weight: 600; }
.fab { position: fixed; right: 16px; bottom: calc(var(--nav-h) + var(--safe-b) + 16px); z-index: 25; width: 54px; height: 54px; border-radius: 50%; background: var(--pond); color: #fff; border: 0; font-size: 1.6rem; box-shadow: 0 6px 16px rgba(14,124,134,.45); display: grid; place-items: center; }

.list-x { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; margin-bottom: 10px; }
.li { display: flex; align-items: center; gap: 10px; padding: 11px 13px; border-bottom: 1px solid var(--line); color: inherit; }
.li:last-child { border-bottom: 0; }
.li .grow { flex: 1; min-width: 0; }
.li .ttl { font-weight: 600; }
.li small { color: var(--muted); display: block; }
.li .acts { display: flex; gap: 2px; }
.li .acts button { background: transparent; border: 0; color: var(--muted); width: 34px; height: 34px; border-radius: 8px; font-size: 1.05rem; }
.li .acts button:active { background: var(--mist); }

.tile-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 12px; display: grid; justify-items: center; gap: 6px; font-weight: 650; color: var(--deep); }
.tile i { font-size: 1.8rem; color: var(--pond); }
.tile:active { background: #e6f4f5; }
.tile.feed i { color: #b27800; } .tile.dead i { color: var(--alarm); }

.tbl-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 10px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .84rem; }
.tbl th { text-align: left; font-size: .72rem; color: var(--muted); font-weight: 650; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #f6faf9; }
.tbl td { padding: 8px 10px; border-bottom: 1px solid #edf3f2; white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .r { text-align: right; }
.tbl tfoot td { font-weight: 700; background: #f6faf9; }
.pos { color: var(--reed); font-weight: 650; } .neg { color: var(--alarm); font-weight: 650; }

.empty { text-align: center; padding: 34px 18px; color: var(--muted); }
.empty i { font-size: 2.3rem; color: #9db8b9; display: block; margin-bottom: 6px; }
.empty b { color: var(--deep); display: block; margin-bottom: 2px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: .9rem; }
.kv dt { color: var(--muted); font-weight: 500; } .kv dd { margin: 0; font-weight: 650; text-align: right; }
.cycle-hero { background: var(--deep); color: #fff; border-radius: var(--r); padding: 14px 16px; margin-bottom: 12px; }
.cycle-hero .big { font-size: 1.5rem; font-weight: 700; }
.cycle-hero .sub { color: #a9c3c8; font-size: .82rem; }
.cycle-hero .bar { height: 8px; border-radius: 6px; background: rgba(255,255,255,.15); margin-top: 10px; overflow: hidden; }
.cycle-hero .bar i { display: block; height: 100%; background: linear-gradient(90deg, #2aa3ad, #7ddc8f); border-radius: 6px; }
.chart-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px 6px; margin-bottom: 10px; }
.chart-box h4 { font-size: .82rem; color: var(--muted); font-weight: 650; margin-bottom: 4px; }
svg.chart { width: 100%; height: auto; display: block; }
svg.chart text { font-size: 10px; fill: var(--muted); }

/* ---------- SweetAlert2 form ---------- */
.ff-swal.swal2-popup { border-radius: 18px; padding: 18px 16px 16px; width: min(94vw, 460px); font-family: inherit; }
.ff-swal .swal2-title { font-size: 1.1rem; padding: 0 0 8px; text-align: left; justify-content: flex-start; color: var(--deep); }
.ff-swal .swal2-html-container { margin: 0; padding: 0; text-align: left; font-size: .95rem; }
.ff-swal .swal2-actions { margin: 14px 0 0; width: 100%; gap: 8px; }
.ff-swal .swal2-actions button { flex: 1; border-radius: 12px; font-weight: 650; }
.ff-swal .swal2-styled.swal2-confirm { background: var(--pond); }
.ff-swal .swal2-styled.swal2-deny { background: #fff; color: var(--deep); border: 1px solid var(--line); }
.ff-swal .swal2-styled.swal2-cancel { background: #fff; color: var(--deep); border: 1px solid var(--line); }
.ff-form .form-label { font-size: .8rem; font-weight: 650; color: var(--muted); margin-bottom: 3px; }
.ff-form .form-control, .ff-form .form-select { border-radius: 10px; border-color: var(--line); min-height: 42px; font-size: 1rem; }
.ff-form .form-control:focus, .ff-form .form-select:focus { border-color: var(--pond); box-shadow: 0 0 0 3px rgba(14,124,134,.18); }
.ff-form .hint { font-size: .74rem; color: var(--muted); margin-top: 2px; }
.ff-form .form-check-input:checked { background-color: var(--pond); border-color: var(--pond); }
.stepper { display: flex; gap: 8px; align-items: stretch; }
.stepper button { width: 52px; border-radius: 10px; border: 1px solid var(--line); background: var(--mist); font-size: 1.4rem; font-weight: 700; color: var(--deep); }
.stepper input { text-align: center; font-size: 1.5rem; font-weight: 700; }
.swal2-container { padding: 10px; }

/* ---------- print ---------- */
@media print {
  .topbar, .bottom-nav, .fab, .no-print, .tabs-x { display: none !important; }
  body, html { background: #fff; }
  #view { padding: 0; max-width: none; }
  .tbl-wrap, .card-x, .stat { border-color: #bbb; break-inside: avoid; }
}
