/* Žvalgas – compact, calm UI. Layout rules unchanged; this file is the visual layer. */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #f3f4f6; --panel: #ffffff; --panel-2: #f9fafb; --ink: #111827; --ink-2: #374151; --muted: #6b7280; --line: #e5e7eb; --line-2: #d1d5db;
  --accent: #0f766e; --accent-2: #115e59; --accent-soft: #e6f4f1; --accent-ink: #ffffff;
  --warn: #b45309; --bad: #b91c1c; --good: #047857;
  --row-hover: #f6f9f8; --row-active: #e6f4f1;
  --radius: 8px; --radius-s: 6px;
  --shadow: 0 1px 2px rgba(17, 24, 39, .06), 0 1px 1px rgba(17, 24, 39, .04);
  --shadow-2: 0 8px 24px rgba(17, 24, 39, .12);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 13.5px/1.4 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; font-feature-settings: 'tnum' 1, 'cv11' 1; }
body.app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
a { color: var(--accent); }
.muted { color: var(--muted); }
button, input { font: inherit; color: inherit; }

/* controls */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border: 1px solid var(--line-2); background: var(--panel); border-radius: var(--radius-s); color: var(--ink-2); text-decoration: none; cursor: pointer; line-height: 1.25; font-weight: 500; transition: border-color .12s, background .12s, box-shadow .12s; }
.btn:hover { border-color: var(--accent); color: var(--accent-2); background: var(--panel-2); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.btn.small { padding: 2px 8px; font-size: 11.5px; }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-weight: 500; }
.link:hover { text-decoration: underline; }
input[type=number], input[type=search], input[type=text], input[type=password] { padding: 6px 8px; border: 1px solid var(--line-2); border-radius: var(--radius-s); background: var(--panel); transition: border-color .12s, box-shadow .12s; }
input:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15, 118, 110, .15); }
input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }

/* login */
.login { height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(1200px 600px at 50% -10%, #dbeee9 0%, var(--bg) 60%); }
.login-box { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px 26px 24px; width: min(360px, 100%); display: grid; gap: 14px; box-shadow: var(--shadow-2); }
.login-box h1 { margin: 0 0 4px; font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.login-box label { display: grid; gap: 6px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.login-box input { padding: 9px 10px; font-size: 14px; color: var(--ink); }
.login-box button { padding: 10px; border: 0; border-radius: var(--radius-s); background: var(--accent); color: var(--accent-ink); font-weight: 600; cursor: pointer; }
.login-box button:hover { background: var(--accent-2); }
.err { color: var(--bad); margin: 0; font-size: 13px; }

/* header */
.top { flex: 0 0 auto; display: flex; align-items: center; gap: 14px; padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line); z-index: 1200; }
.brand { font-weight: 700; font-size: 17px; letter-spacing: -.01em; white-space: nowrap; }
.brand #count { font-weight: 500; font-size: 12.5px; }
.meta { flex: 1; font-size: 12px; }
nav { display: flex; gap: 8px; align-items: center; }
.who { font-size: 12.5px; padding: 0 2px; }

/* filters */
.filters { flex: 0 0 auto; display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px 16px; padding: 8px 16px 10px; background: var(--panel); border-bottom: 1px solid var(--line); margin: 0; z-index: 1100; position: relative; }
.filters fieldset { border: 0; padding: 0; margin: 0; display: flex; align-items: center; gap: 6px 8px; flex-wrap: wrap; }
.filters legend { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); width: 100%; padding: 0; margin-bottom: 3px; font-weight: 600; }
.filters input[type=number] { width: 84px; }
.filters input[type=search] { width: 190px; }
.filters label { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; color: var(--ink-2); }
.filters .actions { align-items: center; }
.filters .actions #shown { font-size: 12px; margin-left: 6px; }

/* dropdowns */
.dd { position: relative; }
.dd summary { list-style: none; user-select: none; }
.dd summary::-webkit-details-marker { display: none; }
.dd summary::after { content: '▾'; color: var(--muted); margin-left: 6px; font-size: 11px; }
.dd-menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 1300; min-width: 250px; max-width: 360px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-2); padding: 10px; }
.dd-menu input[type=search] { width: 100%; margin-bottom: 8px; }
.dd-actions { font-size: 12px; margin-bottom: 6px; color: var(--muted); }
.dd-list { max-height: 320px; overflow: auto; display: grid; gap: 1px; }
.dd-list label { display: flex; justify-content: space-between; gap: 8px; padding: 4px 6px; border-radius: 5px; white-space: nowrap; }
.dd-list label:hover { background: var(--row-hover); }
.dd-list label .n { color: var(--muted); font-size: 11.5px; }
.dd-list label[hidden] { display: none; }

/* layout: only the table scrolls; the map stays put */
.split { --map-w: 42%; flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 6px minmax(280px, var(--map-w)); }
.split.table-only { grid-template-columns: 1fr; }
.split.table-only .map-wrap, .split.table-only .splitter { display: none; }
.splitter { cursor: col-resize; background: var(--line); position: relative; z-index: 5; transition: background .12s; }
.splitter:hover, .splitter.dragging { background: var(--accent); }
.splitter::after { content: ''; position: absolute; top: 0; bottom: 0; left: -4px; right: -4px; }
body.resizing { cursor: col-resize; user-select: none; }
body.resizing .map-wrap { pointer-events: none; }
.table-wrap { min-height: 0; overflow: auto; background: var(--panel); }
.map-wrap { min-height: 0; background: var(--panel); }
#map { width: 100%; height: 100%; }

/* table */
table { border-collapse: collapse; width: 100%; background: var(--panel); }
th, td { padding: 6px 9px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; white-space: nowrap; }
th { position: sticky; top: 0; background: var(--panel-2); cursor: pointer; user-select: none; font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); z-index: 2; box-shadow: inset 0 -1px 0 var(--line-2); }
th:hover { color: var(--ink-2); }
th.sorted-asc, th.sorted-desc { color: var(--accent-2); }
th.sorted-asc::after { content: ' ↑'; } th.sorted-desc::after { content: ' ↓'; }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--row-hover); }
tbody tr.active { background: var(--row-active); box-shadow: inset 3px 0 0 var(--accent); }
tbody tr.gone td { opacity: .5; text-decoration: line-through; }
td.thumb { width: 74px; padding: 4px 6px; position: relative; }
td.thumb img { width: 64px; height: 44px; object-fit: cover; border-radius: 5px; display: block; background: var(--bg); }
td.addr { white-space: normal; min-width: 230px; }
td.addr a { font-weight: 600; text-decoration: none; color: var(--ink); }
td.addr a:hover { color: var(--accent-2); text-decoration: underline; }
td.addr .sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
td.num:nth-child(4) { font-weight: 600; }

/* badges */
.badge { display: inline-block; font-size: 11px; line-height: 1.5; padding: 0 6px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); color: var(--ink-2); vertical-align: 1px; }
.badge.new { background: #ecfdf5; border-color: #a7f3d0; color: var(--good); }
.badge.drop { background: #ecfdf5; border-color: #a7f3d0; color: var(--good); }
.badge.rise { background: #fff7ed; border-color: #fed7aa; color: var(--warn); }
.badge.grp { cursor: pointer; background: #f5f3ff; border-color: #ddd6fe; color: #5b21b6; font: inherit; font-size: 11px; font-weight: 500; }
.badge.grp:hover { background: #ede9fe; }
.badge.repost { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.badge.join { background: #e0f2fe; border-color: #bae6fd; color: #075985; }
.src-aruodas { color: #c2410c; } .src-domoplius { color: #0f766e; } .src-kampas { color: #1d4ed8; } [class^="src-agency"] { color: #7c3aed; }

/* merged objects */
tr.grouped td { background: #fbfaff; }
tr.subrow td { background: #f5f3ff; border-bottom: 1px dashed var(--line-2); font-size: 12.5px; }
tr.subrow td.thumb img { width: 48px; height: 34px; }
tr.subrow .diff { background: #fef3c7; border-radius: 3px; padding: 0 3px; }

/* stars (per-user favourites) */
.star { position: absolute; left: 3px; top: 1px; border: 0; background: rgba(255,255,255,.9); border-radius: 999px; padding: 0 5px; font-size: 13px; line-height: 18px; cursor: pointer; color: #9ca3af; box-shadow: var(--shadow); }
.star:hover { color: #d97706; }
.star.on { color: #d97706; }
.star.theirs:not(.on) { color: #db2777; }
.star small { font-size: 9px; margin-left: 1px; vertical-align: top; color: #db2777; font-weight: 700; }
tr.viewed td.addr a { color: var(--muted); font-weight: 500; }
tr.viewed td.thumb img { opacity: .75; }
tr.starred td { background: #fffbeb; }
tr.starred.grouped td { background: #fff7db; }

/* map pins: N = namas, B = butas */
.pin-wrap { background: none; border: 0; }
.pin { position: relative; display: flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; color: #fff; font: 700 11.5px/1 var(--font); border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.35); }
.pin.approx { border-style: dashed; opacity: .85; }
.pin.gone { opacity: .35; }
.pin.multi { box-shadow: 0 0 0 2px #7c3aed, 0 1px 3px rgba(0,0,0,.35); }
.pin i { position: absolute; right: -6px; bottom: -6px; font-style: normal; font-size: 9px; background: #111827; color: #fff; border-radius: 8px; padding: 0 4px; line-height: 12px; }
.pin .st { position: absolute; top: -8px; font-size: 12px; line-height: 1; font-weight: 700; text-shadow: 0 0 2px #fff, 0 0 2px #fff, 0 1px 1px rgba(0,0,0,.4); }
.pin .st.me { right: -7px; color: #f59e0b; }
.pin .st.them { left: -7px; color: #e11d48; }
.prow { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
.pstar { border: 1px solid var(--line-2); background: var(--panel); border-radius: 999px; padding: 2px 9px; font: inherit; font-size: 12px; cursor: pointer; color: var(--ink-2); }
.pstar:hover { border-color: #f59e0b; color: #b45309; }
.pstar.on { background: #fffbeb; border-color: #fcd34d; color: #b45309; font-weight: 600; }
.ptheirs { font-size: 11.5px; color: #e11d48; white-space: nowrap; }
.pbtns { display: inline-flex; gap: 5px; }
.pstar.prep:hover { border-color: var(--bad); color: var(--bad); }
.pstar.prep.on { background: #fef2f2; border-color: #fecaca; color: var(--bad); font-weight: 600; }

/* "Pranešti" flag in the table + its dialog */
.rep { border: 0; background: none; padding: 0 3px; margin-left: 2px; cursor: pointer; color: #c4c9d1; font: inherit; font-size: 12px; vertical-align: 1px; line-height: 1; }
.rep:hover { color: var(--bad); }
.rep.on { color: var(--bad); }
.rep small { font-size: 9.5px; font-weight: 700; margin-left: 1px; vertical-align: top; }
tr:hover .rep { color: #9ca3af; }
tr:hover .rep.on, .rep.on { color: var(--bad); }
dialog.rdlg { border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px 16px; width: min(460px, calc(100vw - 32px)); box-shadow: var(--shadow-2); color: var(--ink); font: inherit; }
dialog.rdlg::backdrop { background: rgba(17, 24, 39, .4); }
.rdlg h2 { margin: 0 0 4px; font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.rdlg #rd-sub { font-size: 12.5px; margin-bottom: 10px; }
.rdlg .prev { font-size: 12px; color: var(--ink-2); background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 6px 9px; margin-bottom: 8px; max-height: 140px; overflow: auto; display: grid; gap: 4px; }
.rdlg textarea { width: 100%; min-height: 110px; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: var(--radius-s); font: inherit; color: var(--ink); resize: vertical; box-sizing: border-box; }
.rdlg textarea:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15, 118, 110, .15); }
.rdlg .acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.leaflet-container { font-family: var(--font); }
.leaflet-popup-content-wrapper { border-radius: var(--radius); box-shadow: var(--shadow-2); }
.leaflet-popup-content { margin: 10px 12px; font: 12.5px/1.4 var(--font); }
.leaflet-popup-content img { width: 100%; height: 120px; object-fit: cover; border-radius: 6px; margin-bottom: 6px; }
.leaflet-popup-content .p { font-weight: 700; font-size: 15px; }
.leaflet-bar a { color: var(--ink-2); }

/* runs log (inside the scrolling table pane) */
.runs { padding: 8px 16px 16px; font-size: 12px; border-top: 1px solid var(--line); background: var(--panel-2); }
.runs summary { cursor: pointer; padding: 4px 0; font-weight: 500; color: var(--ink-2); }
.runs table { width: auto; background: transparent; margin-top: 6px; }
.runs th, .runs td { padding: 2px 8px; border: 0; font-size: 12px; position: static; box-shadow: none; text-transform: none; letter-spacing: 0; }
.synclog pre { white-space: pre-wrap; font-size: 11px; max-height: 240px; overflow: auto; background: var(--panel); padding: 8px; border-radius: 6px; border: 1px solid var(--line); }

/* mobile bars (hidden on desktop) */
.mbar { display: none; }

@media (max-width: 980px) {
  body.app { height: 100vh; height: 100dvh; overflow: hidden; }
  .top { padding: 7px 10px; gap: 8px; }
  .top .meta { display: none; }
  .brand { font-size: 15px; }
  .brand #count { display: none; }
  nav .btn { padding: 5px 8px; font-size: 12px; }
  #toggle-view { display: none; }

  /* 1) filters: one small bar, expands to the form */
  .mbar { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 8px 12px; border: 0; border-bottom: 1px solid var(--line);
          background: var(--panel); font-size: 13px; font-weight: 500; color: var(--ink-2); text-align: left; cursor: pointer; }
  .mbar .chev { color: var(--muted); transition: transform .15s; }
  .mbar[aria-expanded="true"] .chev { transform: rotate(180deg); }
  .mbar[aria-expanded="true"] { color: var(--accent-2); }
  .filters { display: none; max-height: 55vh; overflow: auto; padding: 8px 10px 10px; gap: 8px 10px; }
  .filters.open { display: flex; }
  .filters input[type=search] { width: 150px; }
  .filters .actions #shown { display: block; width: 100%; margin: 4px 0 0; }

  /* 2) list: collapsed = the selected row only, expanded = ~5 rows, horizontal scroll for the columns */
  .split { display: flex; flex-direction: column; min-height: 0; }
  .splitter { display: none; }
  .table-wrap { flex: 0 0 auto; display: flex; flex-direction: column; max-height: 50vh; overflow: hidden; border-bottom: 1px solid var(--line); }
  .table-wrap #list-toggle { flex: 0 0 auto; }
  .table-wrap table { display: block; overflow: auto; flex: 1 1 auto; min-height: 0; -webkit-overflow-scrolling: touch; }
  .table-wrap table thead, .table-wrap table tbody { display: table; width: max-content; min-width: 100%; }
  .table-wrap thead th { position: static; }
  .split.list-collapsed .table-wrap table { max-height: 62px; }
  .split.list-collapsed thead { display: none; }
  .split.list-collapsed tbody tr { display: none; }
  .split.list-collapsed tbody tr.active { display: table-row; }
  .split:not(.list-collapsed) .table-wrap table { max-height: calc(5 * 62px + 30px); }
  .split:not(.list-collapsed) tbody tr.subrow { display: none; }
  td.addr { min-width: 200px; max-width: 260px; }
  td.addr a { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .runs, #empty { display: none; }

  /* 3) map takes the rest */
  .map-wrap { flex: 1 1 auto; min-height: 160px; }
}
