:root {
  --teal: #0f9d8f; --teal-d: #0b7d72; --teal-l: #e3f5f2;
  --ink: #17202a; --ink2: #5b6670; --ink3: #98a2ab; --line: #e6eaec;
  --bg: #f4f6f6; --card: #fff;
  --red: #e5484d; --red-l: #fdecec; --amber: #f59e0b; --amber-l: #fff4de;
  --blue: #3b82f6; --blue-l: #e8f0fe; --purple: #8b5cf6; --purple-l: #f1ebff; --green: #16a34a; --green-l: #e6f6ec;
  --breed: #ef4f6c; --med: #3b82f6; --ship: #f59e0b; --etc: #8a949c;
  --r: 16px; --tab: 64px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 16px/1.45 system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif; overscroll-behavior-y: contain; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
.hide { display: none !important; }

/* 상단 */
.top { position: sticky; top: 0; z-index: 20; background: var(--card); padding: 12px 16px 10px; padding-top: calc(12px + env(safe-area-inset-top)); display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.top h1 { font-size: 19px; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .back { font-size: 26px; line-height: 1; padding: 4px 8px 4px 0; }
.farm-sel { font-weight: 800; font-size: 19px; color: var(--teal-d); border: 0; background: transparent; padding: 0; max-width: 60vw; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; padding: 6px 10px; border-radius: 99px; background: var(--green-l); color: var(--green); white-space: nowrap; }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.off { background: #eceff1; color: var(--ink2); }
.pill.wait { background: var(--amber-l); color: #b06a00; }

main { padding: 14px 16px calc(var(--tab) + 28px + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; }
.sec { margin: 18px 0 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sec h2 { font-size: 18px; margin: 0; }
.sec h2 b { color: var(--teal); }
.link { color: var(--teal-d); font-weight: 700; font-size: 14px; padding: 6px 10px; background: var(--teal-l); border-radius: 99px; }
.card { background: var(--card); border-radius: var(--r); padding: 14px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.muted { color: var(--ink2); }
.small { font-size: 13px; }
.empty { text-align: center; color: var(--ink3); padding: 26px 10px; }

/* 숫자 타일 (키우소 방식) */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tile { background: var(--card); border-radius: 14px; padding: 12px 4px; text-align: center; border: 1.5px solid transparent; }
.tile .n { font-size: 24px; font-weight: 500; display: block; line-height: 1.2; }
.tile .l { font-size: 13px; font-weight: 700; display: block; margin-top: 2px; white-space: nowrap; }
.tile.on { border-color: var(--teal); }
.tile.hot { color: #fff; }
.tile.hot.breed { background: linear-gradient(160deg, #f8617c, var(--breed)); }
.tile.hot.med { background: linear-gradient(160deg, #5c9bff, var(--med)); }
.tile.hot.ship { background: linear-gradient(160deg, #fbb53b, var(--ship)); }
.tile.hot.etc { background: linear-gradient(160deg, #a2abb2, var(--etc)); }
.tile.zero .n { color: var(--ink3); }

.tabs { display: flex; border-bottom: 1px solid var(--line); margin: 6px -16px 12px; padding: 0 16px; background: var(--card); }
.tabs button { flex: 1; padding: 12px 0 10px; font-weight: 600; color: var(--ink3); border-bottom: 2.5px solid transparent; }
.tabs button.on { color: var(--ink); border-color: var(--ink); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 8px 14px; border-radius: 99px; background: var(--card); border: 1.5px solid var(--line); font-weight: 600; font-size: 15px; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip.t.on { background: var(--teal); border-color: var(--teal); }

/* 할 일 목록 */
.todo { display: flex; align-items: center; gap: 10px; padding: 12px 2px; border-bottom: 1px solid var(--line); }
.todo:last-child { border: 0; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--etc); }
.dot.breed { background: var(--breed); } .dot.med { background: var(--med); } .dot.ship { background: var(--ship); }
.todo .t { flex: 1; min-width: 0; }
.todo .t b { display: block; font-size: 15px; }
.todo .t span { font-size: 13px; color: var(--ink2); }
.btn-s { padding: 8px 12px; border-radius: 10px; background: var(--teal-l); color: var(--teal-d); font-weight: 700; font-size: 14px; white-space: nowrap; }
.late { color: var(--red); font-weight: 700; }

/* 소 카드 */
.search { display: flex; gap: 8px; align-items: center; background: var(--card); border-radius: 14px; padding: 4px 4px 4px 14px; border: 1.5px solid var(--line); }
.search input { flex: 1; border: 0; outline: 0; padding: 10px 0; font-size: 18px; background: transparent; min-width: 0; }
.search button { padding: 10px 12px; font-size: 18px; }
.cow { display: flex; gap: 12px; align-items: center; background: var(--card); border-radius: 14px; padding: 12px 14px; margin-bottom: 8px; width: 100%; text-align: left; }
.cow .sn { font-size: 22px; font-weight: 800; letter-spacing: .5px; min-width: 76px; }
.cow .meta { flex: 1; min-width: 0; font-size: 14px; color: var(--ink2); }
.cow .meta b { color: var(--ink); font-size: 15px; }
.sx { font-weight: 800; margin-right: 4px; }
.sx.f { color: var(--red); } .sx.m { color: var(--blue); } .sx.c { color: var(--purple); } .sx.p { color: #a16207; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.tag { font-size: 12px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: #eef1f2; color: var(--ink2); }
.tag.red { background: var(--red-l); color: var(--red); } .tag.amber { background: var(--amber-l); color: #b06a00; }
.tag.blue { background: var(--blue-l); color: var(--blue); } .tag.teal { background: var(--teal-l); color: var(--teal-d); }
.tag.wait { background: var(--amber-l); color: #b06a00; }

/* 개체 상세 */
.hero { display: flex; gap: 14px; align-items: center; }
.hero .big { font-size: 34px; font-weight: 800; letter-spacing: 1px; }
.kv { display: grid; grid-template-columns: 84px 1fr; gap: 6px 10px; font-size: 15px; margin-top: 12px; }
.kv dt { color: var(--ink2); } .kv dd { margin: 0; font-weight: 600; }
.box { border-radius: 14px; padding: 12px 14px; margin-top: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: 15px; }
.box.teal { background: var(--teal-l); } .box.pink { background: #fdf0f2; }
.box span { color: var(--ink2); margin-right: 8px; }
.acts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.act { background: var(--card); border-radius: 14px; padding: 12px 2px 10px; text-align: center; font-weight: 700; font-size: 14px; }
.act i { display: block; font-style: normal; font-size: 24px; margin-bottom: 2px; }
.tl { position: relative; padding-left: 18px; }
.tl::before { content: ""; position: absolute; left: 4px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl .it { position: relative; padding: 0 0 14px; }
.tl .it::before { content: ""; position: absolute; left: -18px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--etc); border: 2px solid var(--bg); }
.tl .it.breed::before { background: var(--breed); } .tl .it.med::before { background: var(--med); } .tl .it.ship::before { background: var(--ship); }
.tl .it b { font-size: 15px; } .tl .it div { font-size: 13px; color: var(--ink2); }

/* 하단 탭 */
nav.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--card); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(6, 1fr); height: calc(var(--tab) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); }
nav.tabbar a { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 12px; font-weight: 700; color: var(--ink3); text-decoration: none; }
nav.tabbar a i { font-style: normal; font-size: 22px; line-height: 1; filter: grayscale(1); opacity: .6; }
nav.tabbar a.on { color: var(--ink); } nav.tabbar a.on i { filter: none; opacity: 1; }
nav.tabbar a.plus i { width: 50px; height: 50px; border-radius: 50%; background: var(--teal); color: #fff; display: grid; place-items: center; font-size: 30px; filter: none; opacity: 1; margin-top: -22px; box-shadow: 0 6px 16px rgba(15,157,143,.35); }

/* 큰 선택 버튼 / 폼 */
.big-choice { display: grid; gap: 12px; }
.big-choice button { background: var(--card); border-radius: 18px; padding: 20px 18px; text-align: left; display: flex; gap: 14px; align-items: center; font-size: 19px; font-weight: 800; }
.big-choice button i { font-style: normal; font-size: 34px; }
.big-choice button small { display: block; font-size: 14px; font-weight: 500; color: var(--ink2); margin-top: 2px; }
.f-label { font-weight: 800; font-size: 16px; margin: 18px 0 8px; display: flex; justify-content: space-between; align-items: baseline; }
.f-label small { font-weight: 500; color: var(--ink3); font-size: 13px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.opt { background: var(--card); border: 2px solid var(--line); border-radius: 14px; padding: 12px 4px; font-weight: 700; font-size: 15px; text-align: center; }
.opt i { display: block; font-style: normal; font-size: 24px; }
.opt.on { border-color: var(--teal); background: var(--teal-l); color: var(--teal-d); }
.lv { padding: 16px 4px; font-size: 18px; }
.lv.on.g { border-color: var(--green); background: var(--green-l); color: var(--green); }
.lv.on.a { border-color: var(--amber); background: var(--amber-l); color: #b06a00; }
.lv.on.r { border-color: var(--red); background: var(--red-l); color: var(--red); }
.inp { width: 100%; border: 1.5px solid var(--line); border-radius: 12px; padding: 13px 14px; background: var(--card); font-size: 17px; outline: 0; }
.inp:focus { border-color: var(--teal); }
textarea.inp { min-height: 96px; resize: vertical; }
.photos { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.ph { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: #dfe5e7; }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph button { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; font-size: 15px; line-height: 1; }
.cam { display: flex; gap: 8px; }
.cam label { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 16px; border-radius: 14px; background: var(--ink); color: #fff; font-weight: 800; font-size: 17px; }
.cam label.alt { background: var(--card); color: var(--ink); border: 1.5px solid var(--line); flex: .6; }
.cam input { display: none; }
.primary { display: block; width: 100%; padding: 17px; border-radius: 16px; background: var(--teal); color: #fff; font-weight: 800; font-size: 18px; margin-top: 22px; }
.primary:disabled { opacity: .5; }
.ghost { display: block; width: 100%; padding: 14px; border-radius: 14px; background: var(--card); border: 1.5px solid var(--line); font-weight: 700; margin-top: 10px; }
.danger { color: var(--red); }
.sticky-bottom { position: sticky; bottom: calc(var(--tab) + 10px + env(safe-area-inset-bottom)); }

/* 축사 배치도 */
.barn { display: grid; grid-template-columns: 1fr 34px 1fr; gap: 8px; }
.barn .col { display: grid; gap: 8px; align-content: start; }
.aisle { background: repeating-linear-gradient(180deg, #e9eded 0 14px, #f4f6f6 14px 28px); border-radius: 10px; writing-mode: vertical-rl; display: flex; align-items: center; justify-content: center; color: var(--ink3); font-weight: 700; letter-spacing: 6px; font-size: 13px; }
.pen { background: var(--card); border-radius: 14px; border: 2px solid var(--line); padding: 10px 12px; text-align: left; display: flex; justify-content: space-between; align-items: center; min-height: 64px; }
.pen b { font-size: 22px; }
.pen span { font-size: 13px; color: var(--ink2); text-align: right; }
.pen.alert { box-shadow: 0 0 0 3px var(--red-l); }

/* 시트·뷰어 */
.sheet-bg { position: fixed; inset: 0; background: rgba(10,20,25,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 720px; max-height: 88vh; overflow-y: auto; border-radius: 22px 22px 0 0; padding: 10px 16px calc(20px + env(safe-area-inset-bottom)); }
.sheet .grab { width: 44px; height: 5px; border-radius: 3px; background: #cfd6d9; margin: 0 auto 10px; }
.sheet h3 { margin: 4px 0 4px; font-size: 20px; }
.viewer { position: fixed; inset: 0; z-index: 60; background: #000; display: flex; align-items: center; justify-content: center; }
.viewer img { max-width: 100%; max-height: 100%; }
.viewer button { position: absolute; top: calc(14px + env(safe-area-inset-top)); right: 14px; color: #fff; font-size: 30px; }

/* 보고 */
.rep { background: var(--card); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; }
.rep .h { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--ink2); }
.rep .h b { color: var(--ink); }
.lvl { font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 99px; }
.lvl.정상 { background: var(--green-l); color: var(--green); } .lvl.주의 { background: var(--amber-l); color: #b06a00; } .lvl.긴급 { background: var(--red); color: #fff; }
.rep p { margin: 6px 0; white-space: pre-wrap; }
.thumbs { display: flex; gap: 6px; overflow-x: auto; }
.thumbs img { width: 84px; height: 84px; object-fit: cover; border-radius: 10px; flex: none; background: #dfe5e7; }

/* 달력 */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; gap: 2px; }
.cal .w { font-size: 13px; color: var(--ink3); padding: 6px 0; }
.cal button { padding: 8px 0 12px; border-radius: 12px; font-size: 16px; position: relative; }
.cal button.out { color: #c8cfd3; }
.cal button.today { background: var(--teal); color: #fff; font-weight: 800; }
.cal button.sel { outline: 2px solid var(--teal); }
.cal .dots { position: absolute; left: 0; right: 0; bottom: 3px; display: flex; justify-content: center; gap: 2px; }
.cal .dots i { width: 5px; height: 5px; border-radius: 50%; }

/* 로그인 */
.login { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 30px 24px; max-width: 440px; margin: 0 auto; }
.login .logo { width: 120px; height: 120px; border-radius: 50%; margin: 0 auto 12px; display: block; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
html.has-login { background: #1f4d36 url(/static/login-bg.jpg) center / cover no-repeat; min-height: 100%; }
html.has-login body { background: transparent; }
html.has-login #app { background: transparent; }
html.has-login .login { box-sizing: border-box; width: calc(100% - 32px); background: rgba(255,255,255,.93); border-radius: 22px; min-height: auto; margin: 6vh auto; box-shadow: 0 10px 40px rgba(0,0,0,.25); text-align: center; }
html.has-login .login form { text-align: left; }
.login h1 { margin: 0 0 4px; font-size: 26px; }

#toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--tab) + 22px + env(safe-area-inset-bottom)); z-index: 80; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast { background: rgba(23,32,42,.92); color: #fff; padding: 11px 18px; border-radius: 12px; font-size: 15px; max-width: 90vw; transition: opacity .4s; }
.toast.ok { background: var(--teal-d); } .toast.warn { background: #b06a00; } .toast.err { background: var(--red); }
.toast.out { opacity: 0; }
.banner { background: var(--amber-l); color: #8a5300; border-radius: 12px; padding: 10px 14px; font-size: 14px; margin-bottom: 10px; }
.banner.red { background: var(--red-l); color: var(--red); }
.spin { display: inline-block; width: 18px; height: 18px; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: s .8s linear infinite; vertical-align: -3px; }
@keyframes s { to { transform: rotate(360deg); } }

/* 우방 색: 거세비육 빨강 · 미경산비육 보라 · 경산비육 파랑 · 임신우 형광 */
.pen.k-castr { border-color: #e5484d; background: #fdecec; } .pen.k-castr b { color: #c62828; }
.pen.k-heifer { border-color: #8b5cf6; background: #f1ebff; } .pen.k-heifer b { color: #6d28d9; }
.pen.k-cow { border-color: #3b82f6; background: #e8f0fe; } .pen.k-cow b { color: #1d4ed8; }
.pen.k-preg { border-color: #9be000; background: #efffb0; box-shadow: 0 0 0 2px #d4ff3a inset; } .pen.k-preg b { color: #3f6200; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--ink2); margin: 10px 0; align-items: center; }
.sw { display: inline-block; width: 14px; height: 14px; border-radius: 4px; margin-right: 5px; vertical-align: -2px; border: 2px solid #cfd6d9; background: #fff; }
.sw.k-castr { border-color: #e5484d; background: #fdecec; } .sw.k-heifer { border-color: #8b5cf6; background: #f1ebff; }
.sw.k-cow { border-color: #3b82f6; background: #e8f0fe; } .sw.k-preg { border-color: #9be000; background: #d4ff3a; }

/* 업무보고함 */
.chipbtn { border: 1.5px solid var(--line, #d5dde0); background: #fff; border-radius: 999px; padding: 6px 12px; font-size: 14px; }
.chipbtn.on { border-color: var(--teal, #0f9d8f); background: var(--teal-l, #e3f5f2); font-weight: 700; }
.rep .memo2 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.repd .memo-full { white-space: pre-wrap; font-size: 17px; line-height: 1.55; background: #f6f8f8; border-radius: 12px; padding: 12px; }
.repd .bigph { display: block; width: 100%; border-radius: 12px; margin-bottom: 8px; background: #dfe5e7; }

nav.tabbar a { font-size: 11.5px; }
nav.tabbar .tbadge { position: absolute; top: 4px; left: 54%; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--red, #e53935); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
.rep .keepb { font-size: 12px; padding: 2px 7px; border-radius: 8px; background: #fff3d6; color: #8a5a00; }
.rep .leftb { font-size: 12px; color: var(--ink3); }
.rep.sel { outline: 3px solid var(--teal); }
.rep .ck { width: 22px; height: 22px; margin-right: 4px; }
.selbar { position: sticky; top: 56px; z-index: 5; display: flex; gap: 8px; align-items: center; background: var(--bg); padding: 8px 0; }
.rdact { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
