:root{
  --bg:#f5f7f4;--surface:#fff;--surface2:#eef2ee;--text:#17201a;--muted:#6b756e;
  --line:#dfe5df;--green:#164b32;--green2:#23734b;--lime:#b7d957;--danger:#b53b36;
  --amber:#b87816;--shadow:0 12px 35px rgba(20,45,30,.07);--radius:18px
}
*{box-sizing:border-box}body{margin:0;font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;background:var(--bg);color:var(--text)}
button,input,select,textarea{font:inherit}button{cursor:pointer}
.sidebar{position:fixed;inset:0 auto 0 0;width:250px;background:#102f22;color:#eaf2ec;padding:24px 16px;display:flex;flex-direction:column;z-index:10}
.brand{display:flex;gap:11px;align-items:center;padding:4px 8px 30px}.brand-mark{width:38px;height:38px;border-radius:12px;background:var(--lime);color:#102f22;display:grid;place-items:center;font-weight:900;font-size:20px}.brand strong{display:block;letter-spacing:1.5px;font-size:15px}.brand span{display:block;color:#9eb2a5;font-size:11px;margin-top:2px}
nav{display:grid;gap:5px}.nav-item{border:0;background:transparent;color:#afbeb5;text-align:left;padding:12px 12px;border-radius:11px;display:flex;align-items:center;gap:12px}.nav-item:hover,.nav-item.active{background:#1a4934;color:#fff}.nav-item.active{box-shadow:inset 3px 0 var(--lime)}.nav-item span{font-size:13px}.sidebar-foot{margin-top:auto;color:#81988b;font-size:11px;padding:14px 8px}.status-dot{display:inline-block;width:7px;height:7px;border-radius:50%;background:#80c66c;margin-right:6px}
.main{margin-left:250px;min-height:100vh}.topbar{height:82px;background:rgba(255,255,255,.88);backdrop-filter:blur(10px);border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;padding:0 34px;position:sticky;top:0;z-index:5}.eyebrow{font-size:10px;letter-spacing:1.5px;color:var(--muted);font-weight:750}.topbar h1{margin:3px 0 0;font-size:24px;letter-spacing:-.5px}.top-actions{display:flex;align-items:center;gap:10px}.demo-badge{font-size:9px;font-weight:800;letter-spacing:1px;background:#edf3e7;color:#3d6630;padding:7px 9px;border-radius:8px}.icon-btn,.menu-btn,.close-btn{border:0;background:transparent;color:var(--muted);font-size:20px}.menu-btn{display:none}.content{padding:30px 34px 60px;max-width:1500px;margin:auto}
.hero{display:flex;justify-content:space-between;align-items:flex-end;margin-bottom:24px}.hero h2{font-size:32px;margin:4px 0 6px;letter-spacing:-1px}.hero p{color:var(--muted);margin:0;max-width:700px}.btn{border:1px solid var(--line);border-radius:11px;padding:10px 14px;font-weight:700;background:white;color:var(--text)}.btn.primary{background:var(--green);color:white;border-color:var(--green)}.btn.primary:hover{background:#0f3d29}.btn.secondary:hover{background:var(--surface2)}
.kpis{display:grid;grid-template-columns:repeat(4,1fr);gap:14px;margin-bottom:20px}.card{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow)}.kpi{padding:19px}.kpi-label{font-size:12px;color:var(--muted)}.kpi-value{font-size:28px;font-weight:800;margin:7px 0}.kpi-foot{font-size:11px;color:var(--muted)}.positive{color:var(--green2)}.warning{color:var(--amber)}.negative{color:var(--danger)}
.grid-2{display:grid;grid-template-columns:1.55fr 1fr;gap:18px}.panel{padding:20px}.panel-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:17px}.panel h3{margin:0;font-size:16px}.muted{color:var(--muted);font-size:12px}.chart-wrap{height:300px;position:relative}.chart{width:100%;height:100%}.legend{display:flex;gap:16px;font-size:11px;color:var(--muted)}.legend i{display:inline-block;width:9px;height:9px;border-radius:50%;background:var(--green2);margin-right:5px}.legend i.target{background:#cbd5cc}
.table-card{margin-top:18px;overflow:hidden}.table-scroll{overflow:auto}table{width:100%;border-collapse:collapse;font-size:12px}th,td{padding:13px 16px;border-bottom:1px solid var(--line);text-align:left;white-space:nowrap}th{color:var(--muted);font-size:10px;text-transform:uppercase;letter-spacing:.7px;background:#fafbfa}tr:last-child td{border-bottom:0}.animal{display:flex;gap:10px;align-items:center}.avatar{width:32px;height:32px;border-radius:10px;background:#e5eee7;display:grid;place-items:center;color:var(--green);font-weight:800}.pill{display:inline-flex;padding:5px 8px;border-radius:999px;font-size:10px;font-weight:750}.pill.green{background:#e7f2e8;color:#2e683c}.pill.amber{background:#fbf0dc;color:#8a5d12}.pill.red{background:#f9e5e3;color:#983b35}.pill.gray{background:#edf0ed;color:#68726b}
.assessment{display:grid;gap:10px}.assessment-item{border:1px solid var(--line);border-radius:13px;padding:13px}.assessment-top{display:flex;justify-content:space-between;gap:12px}.assessment-item strong{font-size:13px}.assessment-item p{font-size:11px;color:var(--muted);line-height:1.55;margin:7px 0 0}.action{margin-top:9px;font-size:11px;color:var(--green);font-weight:700}
.filters{display:flex;gap:8px;flex-wrap:wrap}.filters select,.search{border:1px solid var(--line);background:white;border-radius:10px;padding:9px 11px;color:var(--text)}
.empty{padding:40px;text-align:center;color:var(--muted)}.feature-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:14px}.feature{padding:18px}.feature .big{font-size:22px;margin-bottom:10px}.feature h3{margin:0 0 5px;font-size:14px}.feature p{margin:0;color:var(--muted);font-size:11px;line-height:1.6}
.modal{position:fixed;inset:0;background:rgba(10,20,14,.48);display:grid;place-items:center;padding:20px;z-index:30}.modal.hidden,.toast.hidden{display:none}.modal-card{width:min(520px,100%);background:#fff;border-radius:20px;padding:24px;box-shadow:0 25px 70px rgba(0,0,0,.2)}.modal-head{display:flex;justify-content:space-between;margin-bottom:18px}.modal h2{margin:3px 0 0;font-size:20px}.modal form{display:grid;gap:13px}.modal label{font-size:11px;color:var(--muted);font-weight:700;display:grid;gap:6px}.modal input,.modal select,.modal textarea{width:100%;border:1px solid var(--line);border-radius:10px;padding:10px;color:var(--text);background:#fff}.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:10px}.modal-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:5px}.toast{position:fixed;right:24px;bottom:24px;background:#102f22;color:#fff;padding:12px 15px;border-radius:12px;font-size:12px;box-shadow:var(--shadow);z-index:40}
@media(max-width:1050px){.kpis{grid-template-columns:repeat(2,1fr)}.grid-2{grid-template-columns:1fr}.feature-grid{grid-template-columns:1fr 1fr}}
@media(max-width:760px){.sidebar{transform:translateX(-100%);transition:.2s}.sidebar.open{transform:translateX(0)}.main{margin-left:0}.menu-btn{display:block;margin-right:12px}.topbar{justify-content:flex-start;gap:8px;padding:0 18px}.top-actions{margin-left:auto}.content{padding:22px 16px 45px}.hero{display:block}.hero .btn{margin-top:15px}.kpis{grid-template-columns:1fr 1fr}.feature-grid{grid-template-columns:1fr}.topbar h1{font-size:20px}.demo-badge{display:none}}
@media(max-width:430px){.kpis{grid-template-columns:1fr}.form-grid{grid-template-columns:1fr}}
#animalModal .modal-card{
  max-height:90vh;
  overflow-y:auto;
  width:min(560px,94vw);
}
/* ===== Weight page (wm-) ===== */
.wm-sticky { position: sticky; top: 0; z-index: 20; }
@media (min-width: 900px) { .wm-sticky { position: static; } }

.wm-input, .wm-form input, .wm-form select {
  width: 100%; min-height: 44px; font-size: 16px; padding: 8px 12px;
  border: 1px solid #b9c7b9; border-radius: 8px; box-sizing: border-box; background: #fff;
}
.wm-opt {
  display: block; width: 100%; min-height: 48px; text-align: left; padding: 10px 12px;
  margin-top: 6px; font-size: 16px; background: #fff; border: 1px solid #cfd9cf;
  border-radius: 8px; cursor: pointer;
}
.wm-opt:hover { background: #f1f6f1; }

.wm-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 10px; }
@media (min-width: 700px) { .wm-grid { grid-template-columns: repeat(4, 1fr); } }
.wm-stat { background: #f4f8f4; border: 1px solid #dbe5db; border-radius: 10px; padding: 10px; }
.wm-stat b { display: block; font-size: 1.15rem; margin-top: 2px; }

.wm-flag {
  background: #fff4e0; border: 1px solid #e0a030; color: #6b4200;
  border-radius: 8px; padding: 10px 12px; margin-top: 10px;
}
.wm-badge {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  background: #e4efe4; font-size: .85rem; font-weight: 600;
}
.wm-badge.warn { background: #fff4e0; color: #6b4200; }

.wm-state { padding: 16px; text-align: center; }
.wm-state.error { color: #8a1f11; }

.wm-chartbox { width: 100%; overflow: hidden; }
.wm-chartbox canvas { display: block; }

.wm-sort { min-height: 44px; background: none; border: 0; font: inherit; font-weight: 700; cursor: pointer; padding: 0 6px; }
.wm-row { cursor: pointer; }
.wm-row td { padding: 12px 8px; }
.wm-row.is-selected { background: #e4efe4; }

.wm-form label { display: block; margin-top: 10px; font-weight: 600; }
.wm-note { font-size: .85rem; margin-top: 10px; }

.wm-opt:focus-visible, .wm-sort:focus-visible, .wm-row:focus-visible,
.wm-input:focus-visible, .wm-form input:focus-visible, .wm-form select:focus-visible,
.wm-page .btn:focus-visible { outline: 3px solid #1b6ef3; outline-offset: 2px; 
}
/* ===== Weight page: pembetulan susun atur ===== */
.wm-page > * + * { margin-top: 16px; }
.wm-page > .card:not(.panel) { padding: 16px; }
.wm-page .card.panel h3 { margin: 0 0 12px; }
.wm-page .wm-stat { min-width: 0; }
.wm-page .wm-stat b { overflow-wrap: anywhere; }
.wm-sticky { box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.wm-page #addWeightOnlyBtn { margin-left: auto; }
/* ===== Weight page: pembetulan susun atur ===== */
.wm-page > * + * { margin-top: 16px; }
.wm-page > .card:not(.panel) { padding: 16px; }
.wm-page .card.panel h3 { margin: 0 0 12px; }
.wm-page .wm-stat { min-width: 0; }
.wm-page .wm-stat b { overflow-wrap: anywhere; }
.wm-sticky { box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.wm-page #addWeightOnlyBtn { margin-left: auto; }
/* ===== Weight page: label carian (paksa) ===== */
.wm-page .wm-sticky label[for="wmSearch"] {
  display: block !important;
  margin: 0 0 12px 0 !important;
  font-size: 1.25rem !important;
  font-weight: 700 !important;
  line-height: 1.4 !important;
  color: #1f3d2b !important;
}
.wm-page .wm-sticky #wmSearch {
  display: block !important;
  font-size: 1.05rem !important;
  font-weight: 500 !important;
  min-height: 52px !important;
  padding: 10px 14px !important;
  border: 2px solid #b9c7b9 !important;
  border-radius: 10px !important;
}
.wm-page .wm-sticky #wmSearch:focus {
  border-color: #2e7d32 !important;
  outline: none !important;
  box-shadow: 0 0 0 3px rgba(46,125,50,.25) !important;
}
/* ===== Logo MLF ===== */
.brand-logo { width: 100%; }
.brand-logo img { display: block; width: 200px; max-width: 100%; height: auto; border-radius: 12px; }
.brand-sub { display: block; margin-top: 8px; text-align: center; font-size: .8rem; letter-spacing: .04em; color: #cfe0f5; }
/* ===== Palet MLF ===== */
:root{
  --bg:#f2f6fb;
  --surface2:#eaf0f8;
  --line:#dce5f0;
  --text:#17202e;
  --green:#334b69;
  --green2:#5882ad;
  --lime:#76a9e0;
  --shadow:0 12px 35px rgba(30,55,90,.08);
}
.sidebar{ background:#243a54; }
.nav-item{ color:#c9d8ec; }
.nav-item.active,.nav-item:hover{ background:rgba(118,169,224,.18); color:#fff; }
/* ===== Sijil profil ternakan ===== */
#certModal .modal-card{ width:min(760px,94vw); max-height:92vh; overflow-y:auto; padding:24px; background:#fff; }
.cert-head{ text-align:center; border-bottom:3px solid #334b69; padding-bottom:14px; margin-bottom:14px; }
.cert-head img{ width:190px; max-width:60%; height:auto; }
.cert-title{ margin:10px 0 0; font-size:1.1rem; letter-spacing:.16em; font-weight:800; color:#334b69; }
.cert-tag{ font-size:1.7rem; font-weight:800; text-align:center; margin:8px 0 14px; }
.cert-grid{ display:grid; grid-template-columns:repeat(2,1fr); gap:0 22px; }
.cert-row{ display:flex; justify-content:space-between; gap:10px; border-bottom:1px dashed #dce5f0; padding:7px 0; }
.cert-row span{ color:#5b6b80; }
.cert h4{ margin:18px 0 8px; color:#334b69; }
.cert-note{ font-size:.8rem; margin-top:14px; }
.cert-sign{ display:flex; gap:24px; margin-top:30px; }
.cert-sign div{ flex:1; border-top:1px solid #444; padding-top:4px; font-size:.8rem; text-align:center; }
.cert-actions{ display:flex; gap:8px; flex-wrap:wrap; margin-top:18px; }
.cert-actions .btn{ min-height:44px; }
@media (max-width:560px){ .cert-grid{ grid-template-columns:1fr; } }
@media print{
  body > *:not(#certModal){ display:none !important; }
  #certModal{ position:static !important; background:none !important; display:block !important; }
  #certModal .modal-card{ max-height:none !important; overflow:visible !important; box-shadow:none !important; width:100% !important; }
  .cert-actions{ display:none !important; }
}
/* ===== Motion: LIVE + peralihan halaman ===== */
.status-dot{position:relative}
.status-dot::after{content:"";position:absolute;inset:0;border-radius:50%;background:#80c66c;animation:livePulse 2s ease-out infinite}
.demo-badge{display:inline-flex;align-items:center;gap:6px}
.demo-badge::before{content:"";width:7px;height:7px;border-radius:50%;background:#3d8f4f;animation:liveBlink 2s ease-in-out infinite}
@keyframes livePulse{0%{transform:scale(1);opacity:.7}100%{transform:scale(2.6);opacity:0}}
@keyframes liveBlink{0%,100%{opacity:1}50%{opacity:.35}}

#refreshBtn{transition:transform .4s ease}
#refreshBtn:active{transform:rotate(180deg)}

@keyframes pageIn{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none}}
#app > *:not(.wm-page):not(.nm-page){animation:pageIn .25s ease-out both}
.kpis > .card,.feature-grid > .card,.wm-page > *,.nm-page > *{animation:pageIn .3s ease-out both}
.kpis > :nth-child(2),.feature-grid > :nth-child(2),.wm-page > :nth-child(2),.nm-page > :nth-child(2){animation-delay:.05s}
.kpis > :nth-child(3),.feature-grid > :nth-child(3),.wm-page > :nth-child(3),.nm-page > :nth-child(3){animation-delay:.1s}
.kpis > :nth-child(4),.wm-page > :nth-child(4){animation-delay:.15s}
.wm-page > :nth-child(5){animation-delay:.2s}
.wm-page > :nth-child(6){animation-delay:.25s}
.wm-page > :nth-child(n+7){animation-delay:.3s}

@media (prefers-reduced-motion: reduce){
  *,*::before,*::after{animation:none !important;transition:none !important}
}
/* ===== Motion: butang, baris jadual, loading ===== */
.btn{transition:transform .15s ease, background-color .15s ease, box-shadow .15s ease}
.btn:hover{transform:translateY(-1px);box-shadow:0 4px 12px rgba(30,55,90,.12)}
.btn:active{transform:scale(.97);box-shadow:none}
.btn:disabled{opacity:.6;transform:none;box-shadow:none;cursor:not-allowed}

tbody tr{transition:background-color .15s ease}
.hm-row:hover,.wm-row:not(.is-selected):hover{background:#f2f6fb}
.hm-row,.wm-row{cursor:pointer}
.hm-row:active,.wm-row:active{background:#e6eef8}

.nav-item{transition:background-color .15s ease, color .15s ease}
.nm-tab{transition:background-color .2s ease, color .2s ease, transform .15s ease}
.nm-tab:active{transform:scale(.97)}

@keyframes shimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}
.nm-state[role="status"]{
  color:transparent;
  background:linear-gradient(90deg,#dce5f0 25%,#f2f6fb 50%,#dce5f0 75%);
  background-size:200% 100%;
  animation:shimmer 1.4s linear infinite;
  border-radius:10px;
  min-height:56px;
}

@media (prefers-reduced-motion: reduce){
  .btn:hover,.btn:active,.nm-tab:active{transform:none}
}
/* ===== Tipografi + jadual ===== */
:root{ --muted:#56637a; }
body{ font-family:Inter,ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif; font-size:15px; line-height:1.5; }

/* nombor lurus menegak */
td,.kpi-value,.wm-stat b,.nc-stat-val,.nm-qty,.cert-row b{ font-variant-numeric:tabular-nums; }
.kpi-value{ font-size:32px; }
.muted{ font-size:13px; }
.kpi-label{ font-size:13px; }
.kpi-foot{ font-size:12px; }

/* jadual */
table{ font-size:14px; }
th,td{ padding:14px 16px; }
th{ font-size:12px; font-weight:600; text-transform:none; letter-spacing:.02em; color:#56637a; }
.table-card thead th:nth-child(n+4):nth-child(-n+6),
tr.hm-row td:nth-child(n+4):nth-child(-n+6){ text-align:right; }
th[aria-sort]:not(:first-child),
.wm-row td:not(:first-child){ text-align:right; }
.table-scroll thead th{ position:sticky; top:0; background:#fafbfa; z-index:1; }

/* label borang */
.modal label{ font-size:13px; color:#44546a; }
/* ===== Mod padat: laptop (761px - 1440px) ===== */
@media (min-width:761px) and (max-width:1440px){
  :root{ --radius:14px; }

  /* sidebar */
  .sidebar{ width:220px; padding:16px 12px; overflow-y:auto; }
  .main{ margin-left:220px; }
  .brand{ padding:0 6px 14px; }
  .brand-logo img{ width:150px; }
  nav{ gap:2px; }
  .nav-item{
    display:grid; grid-template-columns:26px 1fr; column-gap:10px;
    align-items:center; justify-items:center; padding:9px 12px;
  }
  .nav-item span{ justify-self:start; font-size:14px; }

  /* topbar + ruang kandungan */
  .topbar{ height:64px; padding:0 28px; }
  .topbar h1{ font-size:21px; margin-top:1px; }
  .content{ padding:20px 28px 48px; }

  /* hero */
  .hero{ margin-bottom:16px; }
  .hero h2{ font-size:26px; margin:2px 0 4px; letter-spacing:-.5px; }
  .hero p{ font-size:14px; }

  /* kad KPI */
  .kpis{ gap:12px; margin-bottom:14px; }
  .kpi{ padding:14px 16px; }
  .kpi-value{ font-size:26px; margin:4px 0; }
  .kpi-value small{ font-size:.5em; font-weight:600; color:var(--muted); }

  /* panel dan carta */
  .grid-2{ gap:14px; }
  .panel{ padding:16px 18px; }
  .panel-head{ margin-bottom:12px; }
  .chart-wrap{ height:240px; }
}
/* ===== Sidebar: kemas (laptop) ===== */
@media (min-width:761px) and (max-width:1440px){
  .sidebar{ width:236px; padding:18px 12px; }
  .main{ margin-left:236px; }

  /* logo + tagline satu paksi, lebar hampir sama */
  .brand{ padding:0 4px 16px; margin-bottom:12px; border-bottom:1px solid rgba(255,255,255,.1); }
  .brand-logo{ display:flex; flex-direction:column; align-items:center; }
  .brand-logo img{ width:170px; }
  .brand .brand-sub{
    margin-top:10px; font-size:11px; letter-spacing:.05em;
    color:#9fb4cf; text-align:center; white-space:nowrap;
  }

  /* menu: satu baris, saiz seragam */
  .nav-item{
    grid-template-columns:24px 1fr; column-gap:10px;
    padding:10px 10px; font-size:14px; white-space:nowrap;
  }
  .nav-item span{ font-size:13.5px; font-weight:500; }

  .sidebar-foot{ font-size:11px; padding:12px 6px 0; }
}
/* ===== Ikon menu SVG ===== */
.nav-item svg{ width:20px; height:20px; flex:none; opacity:.8; transition:opacity .15s ease; }
.nav-item:hover svg,.nav-item.active svg{ opacity:1; }
/* ===== Buang tajuk berganda (tajuk halaman = topbar sahaja) ===== */
.hero .eyebrow{ display:none; }
.hero h2,
.wm-page > div:first-child > h2{
  position:absolute; width:1px; height:1px; overflow:hidden;
  clip:rect(0 0 0 0); white-space:nowrap;
}
.hero{ align-items:center; gap:16px; margin-bottom:16px; }
.hero p{ font-size:14px; max-width:640px; }
.hero .btn{ white-space:nowrap; }

@media (min-width:761px) and (max-width:1440px){
  .hero .btn{ min-height:40px; padding:8px 16px; }
}
