:root {
  --green: #16a34a;
  --green-dark: #0f7a38;
  --sky: #0284c7;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --soft: #f8fafc;
  --white: #ffffff;
  --danger: #dc2626;
  --warning: #d97706;
  --radius: 22px;
  --shadow: 0 22px 55px rgba(15, 23, 42, 0.08);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, system-ui, -apple-system, Segoe UI, sans-serif; color: var(--ink); background: #eef7ef; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top left, #bbf7d0, transparent 32%), radial-gradient(circle at bottom right, #bae6fd, transparent 32%), #f8fafc; }
.login-card { width: min(440px, 100%); background: white; border: 1px solid var(--line); border-radius: 30px; padding: 28px; box-shadow: var(--shadow); }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.brand img { width: 52px; height: 52px; }
.brand strong { font-size: 30px; letter-spacing: -1px; }
.brand span { color: var(--green); }
.login-card h1 { margin: 10px 0 8px; font-size: 28px; }
.login-card p { margin: 0 0 22px; color: var(--muted); line-height: 1.6; }
.form-grid { display: grid; gap: 14px; }
.field label { display: block; margin-bottom: 7px; color: #334155; font-weight: 700; font-size: 14px; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid var(--line); border-radius: 16px; padding: 13px 14px; background: #fff; outline: none; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--green); box-shadow: 0 0 0 4px rgba(22,163,74,.12); }
.btn { border: 0; border-radius: 999px; padding: 12px 18px; font-weight: 800; cursor: pointer; display: inline-flex; justify-content: center; align-items: center; gap: 8px; transition: .2s ease; }
.btn-primary { background: var(--green); color: white; box-shadow: 0 14px 30px rgba(22,163,74,.22); }
.btn-primary:hover { background: var(--green-dark); transform: translateY(-1px); }
.btn-soft { background: #ecfdf5; color: var(--green-dark); border: 1px solid #bbf7d0; }
.btn-line { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.login-actions { display: grid; gap: 10px; margin-top: 18px; }
.login-note { margin-top: 18px; padding: 14px; border-radius: 18px; background: #f1f5f9; color: var(--muted); font-size: 14px; }
.app { min-height: 100vh; display: grid; grid-template-columns: 280px 1fr; }
.sidebar { background: #0f172a; color: white; padding: 22px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand { margin-bottom: 24px; }
.sidebar .brand img { width: 44px; height: 44px; }
.sidebar .brand strong { font-size: 26px; }
.sidebar small { display: block; color: #94a3b8; margin-top: 2px; }
.nav { display: grid; gap: 7px; margin-top: 22px; }
.nav a { padding: 12px 14px; border-radius: 16px; color: #cbd5e1; display: flex; align-items: center; gap: 10px; font-weight: 700; }
.nav a.active, .nav a:hover { background: rgba(255,255,255,.1); color: white; }
.side-card { margin-top: 26px; padding: 16px; border-radius: 20px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.1); }
.side-card b { display: block; margin-bottom: 6px; }
.side-card p { margin: 0; color: #cbd5e1; font-size: 14px; line-height: 1.5; }
.main { padding: 24px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 24px; }
.topbar h1 { margin: 0; font-size: 30px; letter-spacing: -0.8px; }
.topbar p { margin: 5px 0 0; color: var(--muted); }
.user-pill { background: white; border: 1px solid var(--line); border-radius: 999px; padding: 10px 14px; display: flex; gap: 10px; align-items: center; box-shadow: 0 8px 20px rgba(15,23,42,.05); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--green), var(--sky)); color: white; display: grid; place-items: center; font-weight: 900; }
.grid { display: grid; gap: 18px; }
.stats { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.card { background: white; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.stat-card span { color: var(--muted); font-weight: 700; font-size: 13px; }
.stat-card strong { display: block; margin-top: 8px; font-size: 32px; letter-spacing: -1px; }
.stat-card em { display: block; margin-top: 4px; color: var(--muted); font-style: normal; font-size: 13px; }
.two-col { grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr); align-items: start; }
.three-col { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 14px; }
.section-title h2 { margin: 0; font-size: 20px; }
.section-title p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.map { position: relative; height: 430px; border-radius: 24px; overflow: hidden; background: linear-gradient(135deg, #d9f99d, #bbf7d0 45%, #bae6fd); border: 1px solid #bbf7d0; }
.map::before { content: ""; position: absolute; inset: 0; background-image: linear-gradient(rgba(15,23,42,.06) 1px, transparent 1px), linear-gradient(90deg, rgba(15,23,42,.06) 1px, transparent 1px); background-size: 40px 40px; }
.fence-area { position: absolute; left: 15%; top: 18%; width: 62%; height: 55%; border: 3px dashed rgba(22, 163, 74, .8); border-radius: 38% 45% 32% 48%; background: rgba(255,255,255,.18); }
.pin { position: absolute; z-index: 2; transform: translate(-50%, -50%); display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: white; border: 4px solid var(--green); box-shadow: 0 10px 25px rgba(15,23,42,.16); cursor: pointer; }
.pin[data-status="Çit Dışı"] { border-color: var(--danger); animation: pulse 1.4s infinite; }
.pin[data-status="Düşük Pil"], .pin[data-status="Sinyal Zayıf"] { border-color: var(--warning); }
.pin-label { position: absolute; top: 44px; white-space: nowrap; background: rgba(15,23,42,.9); color: white; border-radius: 999px; padding: 5px 9px; font-size: 12px; font-weight: 800; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(220,38,38,.35); } 50% { box-shadow: 0 0 0 14px rgba(220,38,38,0); } }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.toolbar input, .toolbar select { border: 1px solid var(--line); border-radius: 999px; padding: 11px 14px; background: white; outline: none; min-width: 170px; }
.table-wrap { overflow-x: auto; border-radius: 18px; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; background: white; }
th, td { text-align: left; padding: 14px 15px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: #475569; font-size: 13px; background: #f8fafc; }
tr:hover td { background: #fbfefc; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; font-size: 12px; font-weight: 900; background: #ecfdf5; color: #047857; }
.badge.danger { background: #fef2f2; color: #b91c1c; }
.badge.warn { background: #fffbeb; color: #b45309; }
.progress { height: 9px; width: 90px; border-radius: 999px; background: #e2e8f0; overflow: hidden; display: inline-block; vertical-align: middle; margin-right: 8px; }
.progress i { display: block; height: 100%; background: var(--green); }
.progress.low i { background: var(--danger); }
.progress.mid i { background: var(--warning); }
.alert-list { display: grid; gap: 10px; }
.alert { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: start; padding: 13px; border: 1px solid var(--line); border-radius: 18px; background: white; }
.dot { width: 12px; height: 12px; margin-top: 5px; border-radius: 50%; background: var(--green); }
.dot.high { background: var(--danger); }
.dot.medium { background: var(--warning); }
.alert b { display: block; margin-bottom: 3px; }
.alert p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.45; }
.detail { display: grid; gap: 12px; }
.detail-row { display: flex; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.detail-row span { color: var(--muted); }
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: none; align-items: center; justify-content: center; padding: 18px; z-index: 80; }
.modal-backdrop.show { display: flex; }
.modal { width: min(560px, 100%); background: white; border-radius: 28px; padding: 22px; box-shadow: 0 40px 90px rgba(15,23,42,.35); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head h2 { margin: 0; }
.close { border: 0; background: #f1f5f9; width: 38px; height: 38px; border-radius: 50%; cursor: pointer; font-size: 20px; }
.mobile-menu { display: none; }
@media (max-width: 1000px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 280px; transform: translateX(-110%); transition: .25s ease; z-index: 70; }
  .sidebar.open { transform: translateX(0); }
  .mobile-menu { display: inline-flex; }
  .stats, .three-col, .two-col { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; }
}
@media (max-width: 640px) {
  .main { padding: 16px; }
  .topbar { flex-direction: column; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .map { height: 360px; }
  .user-pill { width: 100%; }
}

/* HerdNav v4 - gerçek harita ve rota deneyimi */
.map-layout { grid-template-columns: minmax(0, 1.35fr) minmax(340px, .65fr); align-items: start; }
.map-card { padding: 18px; }
.map-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.real-map { height: 660px; width: 100%; border-radius: 24px; overflow: hidden; border: 1px solid #bbf7d0; background: #dbeafe; box-shadow: inset 0 0 0 1px rgba(255,255,255,.55); }
.map-info-strip { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 14px; color: #334155; }
.map-info-strip span { background: #f8fafc; border: 1px solid var(--line); border-radius: 999px; padding: 8px 11px; font-size: 13px; }
.map-side { align-content: start; }
.leaflet-popup-content { margin: 12px 14px; min-width: 210px; }
.popup-title { font-weight: 900; font-size: 15px; margin-bottom: 4px; }
.popup-meta { color: #64748b; font-size: 12px; margin-bottom: 10px; }
.popup-grid { display: grid; gap: 5px; font-size: 13px; }
.popup-grid div { display: flex; justify-content: space-between; gap: 14px; }
.popup-grid span { color: #64748b; }
.sg-marker { width: 42px; height: 42px; border-radius: 50%; background: white; display: grid; place-items: center; border: 4px solid var(--green); box-shadow: 0 12px 26px rgba(15,23,42,.24); font-size: 19px; }
.sg-marker.danger { border-color: var(--danger); animation: pulse 1.4s infinite; }
.sg-marker.warn { border-color: var(--warning); }
.sg-marker-label { position: absolute; left: 50%; top: 44px; transform: translateX(-50%); white-space: nowrap; background: rgba(15,23,42,.92); color: white; border-radius: 999px; padding: 5px 9px; font-size: 12px; font-weight: 900; }
.route-summary { display: grid; gap: 10px; }
.route-card { border: 1px solid var(--line); border-radius: 18px; padding: 13px; background: #f8fafc; }
.route-card b { display: block; margin-bottom: 5px; }
.route-card p { margin: 0; color: var(--muted); line-height: 1.45; font-size: 14px; }
.route-metrics { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; margin-top: 12px; }
.route-metric { padding: 12px; border-radius: 16px; background: white; border: 1px solid var(--line); }
.route-metric span { display: block; color: var(--muted); font-size: 12px; font-weight: 800; }
.route-metric strong { display: block; margin-top: 4px; font-size: 18px; }
@media (max-width: 1100px) { .map-layout { grid-template-columns: 1fr; } .real-map { height: 520px; } }
@media (max-width: 640px) { .real-map { height: 430px; } .map-actions { justify-content: flex-start; } }

/* Leaflet kritik CSS - harita kutucuklari ve markerlarin dosyayi dogrudan acinca bozulmamasi icin yerel yedek */
.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer { position: absolute; left: 0; top: 0; }
.leaflet-container { overflow: hidden; position: relative; outline-offset: 1px; font-family: Inter, system-ui, -apple-system, Segoe UI, sans-serif; }
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow { user-select: none; -webkit-user-drag: none; }
.leaflet-tile::selection { background: transparent; }
.leaflet-safari .leaflet-tile { image-rendering: -webkit-optimize-contrast; }
.leaflet-safari .leaflet-tile-container { width: 1600px; height: 1600px; transform-origin: 0 0; }
.leaflet-marker-icon,
.leaflet-marker-shadow { display: block; }
.leaflet-container .leaflet-overlay-pane svg { max-width: none !important; max-height: none !important; }
.leaflet-container .leaflet-marker-pane img,
.leaflet-container .leaflet-shadow-pane img,
.leaflet-container .leaflet-tile-pane img,
.leaflet-container img.leaflet-image-layer,
.leaflet-container .leaflet-tile { max-width: none !important; max-height: none !important; padding: 0; }
.leaflet-container img.leaflet-tile { width: 256px; height: 256px; }
.leaflet-container.leaflet-touch-zoom { touch-action: pan-x pan-y; }
.leaflet-container.leaflet-touch-drag { touch-action: pinch-zoom; }
.leaflet-container.leaflet-touch-drag.leaflet-touch-zoom { touch-action: none; }
.leaflet-tile { filter: inherit; visibility: hidden; }
.leaflet-tile-loaded { visibility: inherit; }
.leaflet-zoom-box { width: 0; height: 0; box-sizing: border-box; z-index: 800; }
.leaflet-overlay-pane svg { -moz-user-select: none; }
.leaflet-pane { z-index: 400; }
.leaflet-tile-pane { z-index: 200; }
.leaflet-overlay-pane { z-index: 400; }
.leaflet-shadow-pane { z-index: 500; }
.leaflet-marker-pane { z-index: 600; }
.leaflet-tooltip-pane { z-index: 650; }
.leaflet-popup-pane { z-index: 700; }
.leaflet-map-pane canvas { z-index: 100; }
.leaflet-map-pane svg { z-index: 200; }
.leaflet-control { position: relative; z-index: 800; pointer-events: visiblePainted; pointer-events: auto; }
.leaflet-top,
.leaflet-bottom { position: absolute; z-index: 1000; pointer-events: none; }
.leaflet-top { top: 0; }
.leaflet-right { right: 0; }
.leaflet-bottom { bottom: 0; }
.leaflet-left { left: 0; }
.leaflet-control { float: left; clear: both; }
.leaflet-right .leaflet-control { float: right; }
.leaflet-top .leaflet-control { margin-top: 10px; }
.leaflet-bottom .leaflet-control { margin-bottom: 10px; }
.leaflet-left .leaflet-control { margin-left: 10px; }
.leaflet-right .leaflet-control { margin-right: 10px; }
.leaflet-control-zoom a { background: #fff; border-bottom: 1px solid #ccc; width: 30px; height: 30px; line-height: 30px; display: block; text-align: center; text-decoration: none; color: #111; font-weight: 900; }
.leaflet-control-zoom a:first-child { border-top-left-radius: 8px; border-top-right-radius: 8px; }
.leaflet-control-zoom a:last-child { border-bottom-left-radius: 8px; border-bottom-right-radius: 8px; border-bottom: 0; }
.leaflet-control-attribution { background: rgba(255,255,255,.8); padding: 3px 7px; font-size: 11px; }
.leaflet-popup { position: absolute; text-align: center; margin-bottom: 20px; }
.leaflet-popup-content-wrapper { padding: 1px; text-align: left; border-radius: 14px; background: white; box-shadow: 0 18px 38px rgba(15,23,42,.22); }
.leaflet-popup-content { line-height: 1.4; }
.leaflet-popup-tip-container { width: 40px; height: 20px; position: absolute; left: 50%; margin-left: -20px; overflow: hidden; pointer-events: none; }
.leaflet-popup-tip { width: 17px; height: 17px; padding: 1px; margin: -10px auto 0; transform: rotate(45deg); background: white; box-shadow: 0 18px 38px rgba(15,23,42,.22); }
.leaflet-interactive { cursor: pointer; }

/* HerdNav v6 - Ürün API ve cihaz bağlantı altyapısı */
.telemetry-list { display: grid; gap: 10px; }
.telemetry-row { display: grid; grid-template-columns: 1.4fr .8fr .55fr .65fr 1.25fr; gap: 12px; align-items: center; border: 1px solid var(--line); background: #f8fafc; border-radius: 18px; padding: 12px; }
.telemetry-row small, .telemetry-row span { display: block; color: var(--muted); font-size: 12px; font-weight: 800; }
.telemetry-row b { font-size: 14px; }
.api-flow { display: grid; gap: 10px; }
.api-flow div { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 18px; padding: 13px; background: #f8fafc; }
.api-flow b { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 12px; background: linear-gradient(135deg, var(--green), var(--blue)); color: #fff; }
.code-block { white-space: pre-wrap; overflow: auto; background: #0f172a; color: #dbeafe; padding: 16px; border-radius: 18px; font-size: 13px; line-height: 1.55; }
.small-code { min-height: 180px; }
.endpoint-list { display: grid; gap: 10px; }
.endpoint-list div { display: grid; grid-template-columns: 70px 1fr; gap: 4px 12px; align-items: start; border: 1px solid var(--line); background: #f8fafc; border-radius: 16px; padding: 12px; }
.endpoint-list b { color: var(--green); }
.endpoint-list span { font-weight: 900; }
.endpoint-list small { grid-column: 2; color: var(--muted); }
.api-events { display: grid; gap: 10px; }
.api-event { border: 1px solid var(--line); border-radius: 16px; background: #f8fafc; overflow: hidden; }
.api-event summary { cursor: pointer; padding: 13px 15px; display: flex; justify-content: space-between; gap: 12px; }
.api-event summary span { color: var(--muted); }
.api-event pre { margin: 0; background: #0f172a; color: #dbeafe; padding: 14px; overflow: auto; font-size: 12px; }
.muted { color: var(--muted); }
@media (max-width: 980px) { .telemetry-row { grid-template-columns: 1fr; } .endpoint-list div { grid-template-columns: 1fr; } .endpoint-list small { grid-column: auto; } }

/* v7 backend status */
.backend-status-line{
  margin: -6px 0 18px;
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
}
.backend-status-line small{color:#64748b;}
.backend-pill{
  display:inline-flex;
  align-items:center;
  gap:7px;
  border-radius:999px;
  padding:8px 12px;
  font-size:12px;
  font-weight:900;
  border:1px solid #cbd5e1;
  background:#f8fafc;
  color:#334155;
}
.backend-pill:before{content:"";width:8px;height:8px;border-radius:999px;background:#94a3b8;display:inline-block;}
.backend-pill.online{background:#ecfdf5;border-color:#86efac;color:#166534;}
.backend-pill.online:before{background:#22c55e;box-shadow:0 0 0 4px rgba(34,197,94,.15);}
.backend-pill.offline{background:#fff7ed;border-color:#fed7aa;color:#9a3412;}
.backend-pill.offline:before{background:#f97316;box-shadow:0 0 0 4px rgba(249,115,22,.15);}

/* HerdNav v9 auth additions */
.auth-urun-grid { display:grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap:10px; margin-top:16px; }
.auth-urun { border:1px solid rgba(22,163,74,.18); background:#f8fff9; border-radius:18px; padding:12px; font-size:13px; }
.auth-urun b { display:block; margin-bottom:4px; }
.login-message { min-height:22px; color:#dc2626; font-weight:700; margin-top:10px; }
.role-badge { display:inline-flex; padding:6px 10px; border-radius:999px; background:#eefcf3; color:#166534; font-weight:800; font-size:12px; }
.role-badge.admin { background:#fff1f2; color:#be123c; }
.role-badge.worker { background:#eff6ff; color:#1d4ed8; }
.user-pill { gap:10px; }
.user-pill .btn { padding:8px 12px; }
@media (max-width: 860px) { .auth-urun-grid { grid-template-columns:1fr; } .user-pill .btn { display:none; } }

/* HerdNav v11 - akıllı uyarı aksiyonları */
.alert { align-items: flex-start; }
.alert-actions { display:flex; gap:8px; flex-wrap:wrap; justify-content:flex-end; margin-left:auto; }
.btn-mini { padding:7px 10px; font-size:12px; border-radius:10px; }
.empty { padding:18px; border:1px dashed #cbd5e1; border-radius:14px; color:#64748b; background:#f8fafc; }
.notice-grid { display:grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap:12px; margin-top:16px; }
.notice-card { border:1px solid #e2e8f0; border-radius:16px; padding:14px; background:#f8fafc; }
.notice-card b { display:block; color:#0f172a; margin-bottom:5px; }
.notice-card span { font-size:13px; color:#64748b; }
@media (max-width:900px){ .notice-grid{grid-template-columns:1fr 1fr;} .alert-actions{width:100%; justify-content:flex-start;} }
@media (max-width:560px){ .notice-grid{grid-template-columns:1fr;} }

.login-route-note{background:#f0fdf4;border:1px solid #bbf7d0;color:#166534;border-radius:16px;padding:10px 12px;font-size:14px}
.auth-urun-grid button.auth-urun{border:1px solid #e2e8f0;background:#fff;text-align:left;cursor:pointer;font:inherit}
.auth-urun-grid button.auth-urun:hover{border-color:#16a34a;box-shadow:0 8px 24px rgba(22,163,74,.12)}

.login-brand{display:flex;justify-content:center;margin-bottom:18px}.login-brand img{width:min(340px,92%);height:auto;display:block}.login-card .brand.login-brand{gap:0}.login-card .brand.login-brand:hover{transform:none}
