:root {
    --soil: #1b5e3b;
    --soil-dark: #0f2918;
    --leaf: #2f9e62;
    --gold: #e3b23c;
    --cream: #f4efe4;
    --paper: #fffdf8;
    --ink: #1a241c;
    --muted: #5c6b60;
    --line: #d9d2c3;
    --danger: #b42318;
    --ok: #157347;
    --shadow: 0 18px 40px rgba(15, 41, 24, 0.14);
    --font: "Segoe UI", system-ui, -apple-system, sans-serif;
    --radius: 18px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; font-family: var(--font); color: var(--ink); background: var(--cream); }
a { color: var(--soil); }
img { max-width: 100%; }
.guest-body { background:
    radial-gradient(1200px 500px at 10% -10%, #cfe8d4, transparent),
    linear-gradient(180deg, #eef6ef, var(--cream)); }
body.guest-body .rotate-please,
html.is-native-app:not(.is-tablet) .rotate-please,
body.is-native-app:not(.is-tablet) .rotate-please { display: none !important; }
.app-body { padding-bottom: 84px; }
.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; justify-content: space-between; align-items: center;
    gap: 12px; padding: 12px 16px;
    background: var(--soil-dark); color: #fff;
}
.brand { display: flex; gap: 10px; align-items: center; color: #fff; text-decoration: none; }
.brand img { width: 36px; height: 36px; }
.brand small { display: block; opacity: .75; font-weight: 500; }
.topbar-right { display: flex; gap: 10px; align-items: center; }
.who { font-size: 13px; opacity: .85; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge-dot {
    background: var(--gold); color: #1a241c; font-weight: 700;
    min-width: 22px; height: 22px; border-radius: 99px;
    display: inline-flex; align-items: center; justify-content: center; font-size: 12px;
}
.tabbar {
    display: flex; gap: 6px; padding: 10px 12px;
    background: #163522; position: sticky; top: 60px; z-index: 19;
}
.tabbar a {
    color: #d7eadc; text-decoration: none; padding: 8px 12px;
    border-radius: 999px; font-size: 14px;
}
.tabbar a.on { background: var(--leaf); color: #fff; }
main { max-width: 1100px; margin: 0 auto; padding: 20px 16px 40px; }
.login-wrap { display: grid; grid-template-columns: 1.1fr .9fr; gap: 28px; align-items: center; min-height: 92vh; }
html.is-native-app .login-wrap,
body.guest-body .login-wrap {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: 1fr !important;
    min-height: auto !important;
    padding: 16px !important;
    gap: 16px !important;
}
html.is-native-app .login-hero h1 { font-size: 32px !important; }
html.is-native-app main { max-width: 100% !important; padding: 12px 12px 24px !important; }
html.is-native-app .login-card { width: 100%; }
html.is-native-app.is-tablet .login-wrap,
html.is-native-app body.is-tablet .login-wrap {
    display: grid !important;
    grid-template-columns: 1.05fr .95fr !important;
    align-items: center;
    min-height: 88vh !important;
    padding: 24px 32px !important;
    gap: 28px !important;
}
.login-hero h1 { font-size: 42px; margin: 8px 0 12px; color: var(--soil-dark); }
.login-hero p { color: var(--muted); line-height: 1.55; max-width: 38ch; }
.eyebrow { letter-spacing: .12em; text-transform: uppercase; font-size: 12px; color: var(--leaf); font-weight: 700; }
.hero-mark { width: 72px; height: 72px; }
.role-pills { display: flex; flex-wrap: wrap; gap: 8px; padding: 0; list-style: none; }
.role-pills li { background: #fff; border: 1px solid var(--line); padding: 6px 12px; border-radius: 999px; font-size: 13px; }
.login-card, .card {
    background: var(--paper); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
}
.login-card h2, .card h2, .page-head h1 { margin-top: 0; }
.page-head p, .muted, .fine { color: var(--muted); }
.fine { font-size: 13px; }
label { display: block; margin: 12px 0 6px; font-weight: 600; font-size: 14px; }
input, select, textarea {
    width: 100%; padding: 12px 12px; border-radius: 12px;
    border: 1px solid var(--line); background: #fff; font: inherit;
}
.btn-primary, .btn-ghost, button.btn-primary, button.btn-ghost {
    display: inline-flex; align-items: center; justify-content: center;
    border: 0; border-radius: 12px; padding: 12px 16px; font: inherit; cursor: pointer;
    text-decoration: none;
}
.btn-primary { background: var(--soil); color: #fff; width: 100%; margin-top: 16px; font-weight: 700; }
.geo-cascade { display: grid; gap: 0; margin-top: 4px; }
.geo-cascade select { margin-bottom: 4px; }
.btn-ghost { background: transparent; color: inherit; border: 1px solid currentColor; }
.topbar .btn-ghost { color: #fff; padding: 6px 10px; font-size: 13px; }
.apk-dl-fab {
    position: fixed; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    z-index: 40; background: #0f2918; color: #fff;
    padding: 8px 12px; border-radius: 999px; font-weight: 800; font-size: 12px;
    text-decoration: none; box-shadow: 0 8px 18px rgba(15,41,24,.28);
}
body.DffsApp .apk-dl-fab, html.is-native-app .apk-dl-fab { display: none; }
html.is-native-app .apk-dl-link,
html.is-native-app a.btn-ghost[href="/Home/Apk"],
html.is-native-app a[href="/Home/Apk"]:not(#apkUpdateBar) { display: none !important; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: auto; }
.flash { padding: 10px 12px; border-radius: 12px; margin: 12px 0; }
.flash.ok { background: #e3f6ea; color: var(--ok); }
.flash.err { background: #fde8e6; color: var(--danger); }
.field-error { color: var(--danger); font-size: 13px; }
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin: 16px 0; }
.stat { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 14px; }
.stat b { display: block; font-size: 28px; color: var(--soil); }
.stat.warn b { color: #9a6700; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2 > .user-list-card { grid-column: 1 / -1; }
.row-2, .row-3 { display: grid; gap: 10px; }
.row-2 { grid-template-columns: 1fr 1fr; }
.row-3 { grid-template-columns: 1fr 1fr 1fr; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: #eef6ef; }
.pill.farmer { background: #d8f3e2; }
.pill.penyuluh { background: #dce8ff; }
.pill.backoffice { background: #fff1c2; }
.pill.owner { background: #eadbff; }
.pill.new { background: #ffe8cc; }
.pill.assigned { background: #dce8ff; }
.pill.accepted { background: #d8f3e2; }
.pill.done { background: #eee; }
.feed, .cards, .people { list-style: none; padding: 0; margin: 0; }
.feed li a, .mini-link { display: block; text-decoration: none; color: inherit; padding: 10px 0; border-bottom: 1px solid var(--line); }
.feed .unread { background: #fff8e1; margin: 0 -10px; padding: 0 10px; border-radius: 10px; }
.feed strong, .mini strong { display: block; }
.feed span, .mini span { display: block; color: var(--muted); font-size: 13px; }
.mini { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: center; }
.conflict-row { background: #fff1f0; }
.conflict-flag { background: #b42318; color: #fff; font-weight: 900; width: 28px; height: 28px; border-radius: 99px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.mini img { width: 84px; height: 84px; object-fit: cover; border-radius: 12px; background: #eee; }
.big-cam {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-decoration: none; color: #fff; background: linear-gradient(160deg, var(--leaf), var(--soil-dark));
    border-radius: 24px; padding: 28px 16px; margin: 8px 0 20px; box-shadow: var(--shadow);
}
.cam-ico { font-size: 42px; }
.cam-box { position: relative; min-height: 180px; border: 2px dashed var(--line); border-radius: 16px; overflow: hidden; background: #f7f3ea; }
.cam-box img { display: block; width: 100%; max-height: 320px; object-fit: cover; }
.cam-pick { display: flex; align-items: center; justify-content: center; min-height: 180px; cursor: pointer; }
.cam-pick input { display: none; }
.hero-photo { width: 100%; max-height: 380px; object-fit: cover; border-radius: 14px; background: #eee; }
.solve-thumbs {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
    margin: 10px 0;
}
.solve-thumbs img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 12px;
    background: #eee;
    cursor: zoom-in;
    display: block;
}
.photo-zoom {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(8, 16, 12, 0.92);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
}
.photo-zoom.is-open { display: flex; }
.photo-zoom img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 40px rgba(0,0,0,.45);
}
.photo-zoom-close {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1;
    background: #fff;
    color: #1b3a4a;
    border: 0;
    border-radius: 999px;
    font-weight: 800;
    padding: 8px 14px;
    cursor: pointer;
}
.solve-box .live-cam { margin: 12px 0; }
.solve-box video { width: 100%; max-height: 240px; object-fit: cover; border-radius: 12px; background: #111; }
.meta { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; }
.meta dt { color: var(--muted); font-weight: 600; }
.meta dd { margin: 0; }
.people li { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.people .btn-primary { width: auto; margin: 0; }
.inline { display: inline; }
.maps-btn { display: inline-block !important; width: auto !important; margin-top: 8px; padding: 10px 16px !important; }
.home-back {
    display: inline-block; margin-bottom: 10px; color: var(--soil); font-weight: 800;
    text-decoration: none; font-size: 16px;
}
.home-back:active { opacity: .7; }
.reset-pw { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.reset-pw input { width: 130px; padding: 8px; font-size: 13px; }
.user-filters {
    display: grid;
    grid-template-columns: minmax(140px, 1.4fr) minmax(110px, .8fr) repeat(3, minmax(120px, 1fr)) auto;
    gap: 8px;
    align-items: end;
    margin: 0 0 10px;
}
.user-filters label { margin: 0 0 4px; font-size: 12px; }
.user-filters input, .user-filters select { padding: 8px 10px; font-size: 13px; }
.user-filters .filter-actions .btn-ghost { width: auto; margin: 0; padding: 8px 12px; }
.loc-block { display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: inherit; font-size: 13px; }
.loc-block span { display: block; }
#filterEmpty { margin: 12px 0 0; }
@media (max-width: 1100px) {
    .user-filters { grid-template-columns: 1fr 1fr; }
    .user-filters .q { grid-column: 1 / -1; }
}
html.is-native-app .user-filters { grid-template-columns: 1fr 1fr; }
html.is-native-app .user-filters .q { grid-column: 1 / -1; }
@media (max-width: 860px) {
    .login-wrap, .grid-2, .stats, .row-3 { grid-template-columns: 1fr; }
    .login-wrap { min-height: auto; padding-top: 20px; }
    .tabbar { top: auto; bottom: 0; position: fixed; left: 0; right: 0; justify-content: space-around; }
    .app-body { padding-bottom: 92px; }
    .who { display: none; }
    .meta { grid-template-columns: 1fr; }
    .people li { flex-direction: column; align-items: stretch; }
}
