/* PortaSplit Monitor — sachliches, dichtes Daten-UI */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --ink: #0f172a;
  --ink-soft: #334155;
  --muted: #6b7280;
  --line: #e3e6ea;
  --line-strong: #cdd2d8;
  --accent: #0f172a;
  --accent-soft: #eef0f3;
  --green: #15803d;
  --green-soft: #e6f4ec;
  --red: #b91c1c;
  --red-soft: #fbeaea;
  --warn: #92400e;
  --warn-soft: #fdf3e3;
  --radius: 4px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
}

a { color: var(--ink); }
a:hover { text-decoration: underline; }

.muted { color: var(--muted); }
[hidden] { display: none !important; }
body:not([data-account-features="enabled"]) [data-account-feature],
body:not([data-account-features]) [data-account-mode],
body[data-account-features="enabled"] [data-account-mode="disabled"],
body[data-account-features="disabled"] [data-account-mode="enabled"] {
  display: none !important;
}

/* Topbar ----------------------------------------------------------------- */
.topbar {
  background: #0f172a;
  color: #f1f5f9;
  border-bottom: 1px solid #0b1220;
}
.topbar__inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #f1f5f9;
  text-decoration: none;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.brand:hover { text-decoration: none; }
.brand__mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  border-radius: 4px;
  background: #1e293b;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #f8fafc;
}
.brand__text { font-size: 14px; }
.topbar__status {
  display: inline-flex;
  align-items: center;
  gap: 14px;
}
.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: #cbd5e1;
}
.status-dot__dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #64748b;
}
.status-dot[data-state="live"] .status-dot__dot { background: #22c55e; }
.status-dot[data-state="error"] .status-dot__dot { background: #ef4444; }
.status-dot[data-state="connecting"] .status-dot__dot { background: #f59e0b; }

/* Page head -------------------------------------------------------------- */
.page-head {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.page-head__inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px 24px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: end;
}
.page-head h1 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.page-head p {
  margin: 0;
  color: var(--muted);
  max-width: 680px;
}
.project-note {
  margin-top: 8px !important;
  font-size: 13px;
}
.project-note a {
  color: var(--ink);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.head-stats {
  display: grid;
  grid-auto-flow: column;
  gap: 28px;
  margin: 0;
}
.head-stats div { text-align: right; }
.head-stats dt {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 2px;
}
.head-stats dd {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 760px) {
  .page-head__inner { grid-template-columns: 1fr; }
  .head-stats { grid-auto-flow: column; justify-content: start; }
  .head-stats div { text-align: left; }
}

@media (max-width: 760px) {
  .topbar__inner {
    height: auto;
    min-height: 52px;
    padding: 8px 14px;
  }
  .brand__text { font-size: 13px; }
  .topbar__status { gap: 8px; }
  .page-head__inner {
    padding: 20px 14px;
    gap: 16px;
  }
  .page-head h1 { font-size: 20px; }
  .page-head p { font-size: 13px; }
  .head-stats { gap: 20px; }
  .head-stats dd { font-size: 22px; }
  .content { padding: 14px 0 28px; }
  .content__inner {
    padding: 0 12px;
    gap: 12px;
  }
  #map { height: 300px; }
  .panel__head { padding: 12px; }
}

/* Content ---------------------------------------------------------------- */
.content { padding: 24px 0 40px; }
.content__inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 24px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  align-items: start;
  min-width: 0;
}
@media (max-width: 1080px) {
  .content__inner { grid-template-columns: 1fr; }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 0;
}
.panel--map { padding: 0; overflow: hidden; }
#map { width: 100%; height: 460px; }
@media (max-width: 760px) { #map { height: 380px; } }

.panel__head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.panel__title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 12px;
}
.panel__title h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.filters {
  display: grid;
  grid-template-columns: minmax(180px, 1.5fr) minmax(88px, 0.6fr) minmax(100px, 0.6fr) max-content max-content;
  gap: 10px;
  align-items: end;
}
@media (max-width: 900px) {
  .filters { grid-template-columns: minmax(180px, 1fr) repeat(2, minmax(100px, 0.5fr)); }
  .filters .field:first-child { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .filters { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .filters .field:first-child { grid-column: 1 / -1; }
}
.filters .btn { white-space: nowrap; }
.filters #filterReset {
  align-self: end;
  min-width: 106px;
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}
.filters #filterReset:hover { border-color: var(--ink); background: var(--surface); }

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.field > span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
}
.field input[type="text"],
.field input[type="search"],
.field input[type="email"],
.field input[type="date"],
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  padding: 7px 9px;
  min-height: 32px;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid #94a3b8;
  outline-offset: -1px;
  border-color: var(--ink);
}
.field--toggle {
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  min-height: 34px;
  margin-bottom: 0;
  white-space: nowrap;
}
.field--toggle input { flex: 0 0 auto; }
.field--toggle > span {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  color: var(--ink);
  font-size: 13px;
  white-space: nowrap;
}

.combo {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 0;
}
.combo select {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right: 0;
  background: var(--surface-2);
}
.combo input {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

@media (max-width: 420px) {
  .combo { grid-template-columns: 1fr; }
  .combo select {
    border-right: 1px solid var(--line-strong);
    border-bottom: 0;
    border-top-right-radius: var(--radius);
    border-bottom-left-radius: 0;
  }
  .combo input {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    border-bottom-left-radius: var(--radius);
  }
}

.filter-status {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}
.filter-status[data-state="error"] { color: var(--red); }

.subscription-gate {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.subscription-gate strong { display: block; font-size: 13px; }
.subscription-gate span { display: block; color: var(--muted); font-size: 12px; }

/* Table ------------------------------------------------------------------ */
.table-wrap { overflow: visible; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}
#storeTable th:nth-child(1),
#storeTable td:nth-child(1) { width: 38%; }
#storeTable th:nth-child(2),
#storeTable td:nth-child(2),
#storeTable th:nth-child(3),
#storeTable td:nth-child(3) { width: 31%; }
thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
  z-index: 1;
}
thead th.num { width: 36px; padding-right: 6px; text-align: right; }
tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
tbody tr.is-active { background: #eef2ff; }
tbody tr.is-active td { box-shadow: inset 2px 0 0 var(--ink); }
tbody tr.is-online td { background: #fafafe; }

.row-num {
  color: var(--muted);
  text-align: right;
  padding-right: 6px;
  font-variant-numeric: tabular-nums;
}
.store-cell .name { font-weight: 600; }
.store-cell .name,
.store-cell .addr { overflow-wrap: anywhere; }
.store-cell .addr {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 1px;
}
.store-cell .meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11.5px;
}

.article-cell { min-width: 0; }
.article-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: nowrap;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.tag::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--muted);
}
.tag--avail { color: var(--green); }
.tag--avail::before { background: var(--green); }
.tag--out   { color: var(--red); }
.tag--out::before { background: var(--red); }
.tag--none  { color: var(--muted); }
.tag--locked { color: var(--muted); }
.tag--locked::before { background: var(--muted); }
.lock-blur {
  filter: blur(4px);
  opacity: 0.68;
  user-select: none;
}
.lock-label { margin-left: 2px; }
.tag .price {
  color: var(--muted);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  margin-left: 2px;
}

.alert-btn {
  flex: 0 0 auto;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-soft);
  border-radius: var(--radius);
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.alert-btn:hover { border-color: var(--ink); color: var(--ink); }
.alert-btn.is-on { border-color: var(--green); color: var(--green); background: var(--green-soft); }
.alert-btn:disabled { opacity: 0.6; cursor: wait; }

@media (max-width: 760px) {
  .table-wrap,
  #storeTable,
  #storeTable tbody,
  #storeTable tr,
  #storeTable td { display: block; width: 100%; }
  #storeTable tbody td:nth-child(n) { width: 100%; }
  #storeTable thead { display: none; }
  #storeTable tbody {
    display: grid;
    gap: 10px;
  }
  #storeTable tbody tr {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    padding: 12px;
  }
  #storeTable tbody tr:hover { background: var(--surface); }
  #storeTable tbody tr.is-active {
    background: var(--surface);
    box-shadow: inset 3px 0 0 var(--ink);
  }
  #storeTable tbody tr.is-active td { box-shadow: none; }
  #storeTable tbody tr.is-online td { background: transparent; }
  #storeTable tbody td {
    border-bottom: 0;
    padding: 0;
  }
  .row-num { display: none; }
  #storeTable .store-cell {
    padding-bottom: 10px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--line);
  }
  #storeTable .store-cell .name { font-size: 14px; }
  #storeTable .article-cell {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    padding-top: 8px;
  }
  #storeTable .article-cell::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }
  #storeTable .article-line {
    min-width: 0;
    justify-content: flex-end;
    flex-wrap: nowrap;
    gap: 6px;
  }
  #storeTable .tag { font-size: 11.5px; }
  #storeTable .tag .price { margin-left: 0; }
  #storeTable .alert-btn {
    height: 30px;
    padding: 0 8px;
  }
}

/* Map pins --------------------------------------------------------------- */
.pin {
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.25);
}
.pin--red   { background: var(--red); }
.pin--green { background: var(--green); }
.pin--blue  {
  background: var(--ink);
  width: 16px; height: 16px;
  box-shadow: 0 0 0 1px #fff, 0 0 0 4px rgba(15, 23, 42, 0.18);
}
.pin--locked { background: #9ca3af; }

/* Buttons ---------------------------------------------------------------- */
.btn,
.icon-btn,
.link {
  font: inherit;
  cursor: pointer;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  font-size: 13px;
}
.btn:hover { border-color: var(--ink); }
.btn--sm { height: 30px; padding: 0 10px; font-size: 12px; }
.btn--primary {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
.btn--primary:hover { background: #1e293b; border-color: #1e293b; }
.btn--ghost {
  background: transparent;
  border-color: transparent;
  color: inherit;
}
.btn--ghost:hover { background: rgba(255, 255, 255, 0.08); border-color: transparent; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.icon-btn {
  width: 30px; height: 30px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-strong); }

.link {
  border: 0;
  background: transparent;
  padding: 0;
  color: inherit;
  text-decoration: none;
}
.link:hover { text-decoration: underline; }

.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row--end { justify-content: flex-end; margin-top: 14px; }

/* Drawer / overlay ------------------------------------------------------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.38);
  display: flex;
  justify-content: flex-end;
}
.overlay[hidden] { display: none; }

.drawer {
  width: min(420px, 100vw);
  height: 100%;
  overflow: auto;
  background: var(--surface);
  border-left: 1px solid var(--line);
  padding: 20px;
}
.drawer--center {
  margin: auto;
  width: min(460px, calc(100vw - 32px));
  height: auto;
  max-height: calc(100vh - 32px);
  border-radius: var(--radius);
  border: 1px solid var(--line);
}
.overlay:has(.drawer--center) { align-items: center; justify-content: center; }

.drawer__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.drawer__head h2 { margin: 0; font-size: 17px; font-weight: 600; }

.notice {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--ink-soft);
  font-size: 13px;
}
.notice[data-state="success"] { border-color: var(--green); background: var(--green-soft); color: var(--green); }
.notice[data-state="error"]   { border-color: var(--red);   background: var(--red-soft);   color: var(--red); }
.notice[data-state="warn"]    { border-color: var(--warn);  background: var(--warn-soft);  color: var(--warn); }

.user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}
.user img {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--accent-soft);
  object-fit: cover;
}
.user strong { display: block; font-size: 14px; }
.user span { font-size: 12px; }

.block {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
  background: var(--surface);
}
.block h3 { margin: 0 0 4px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-soft); }
.block p { margin: 0; color: var(--muted); font-size: 12.5px; }
.block__row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}
.pill.is-active { color: var(--green); border-color: var(--green); background: var(--green-soft); }
.pill.is-inactive { color: var(--red); border-color: var(--red); background: var(--red-soft); }

.toggle {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 30px;
  font-size: 13px;
}
.inline-form { display: flex; gap: 6px; margin-top: 8px; }
.inline-form input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 7px 9px;
  text-transform: uppercase;
}

#alertList { display: flex; flex-direction: column; }
.alert-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  font-size: 13px;
}
.alert-item:first-child { border-top: none; }
.alert-item strong { display: block; }
.alert-item span { display: block; color: var(--muted); font-size: 12px; }
.alert-item button {
  border: 0;
  background: transparent;
  color: var(--red);
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

/* Site footer ------------------------------------------------------------ */
.site-footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  margin-top: 0;
}
.site-footer__inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12.5px;
}
.site-footer nav { display: inline-flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.site-footer a,
.site-footer .link { color: var(--ink-soft); text-decoration: none; }
.site-footer a:hover,
.site-footer .link:hover { color: var(--ink); text-decoration: underline; }

/* Legal pages ------------------------------------------------------------ */
.legal-page {
  max-width: 880px;
  margin: 0 auto;
  padding: 36px 24px 64px;
}
.legal-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px;
}
.legal-card h1 {
  margin: 14px 0 24px;
  font-size: 24px;
  font-weight: 600;
}
.legal-card h2 {
  margin: 22px 0 6px;
  font-size: 15px;
  font-weight: 600;
}
.legal-card p {
  margin: 8px 0;
  color: var(--ink-soft);
}
.legal-card section { border-top: 1px solid var(--line); padding-top: 12px; }
.legal-card section:first-of-type { border-top: 0; padding-top: 0; }
.legal-back-link {
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  color: var(--muted);
}
.legal-back-link:hover { color: var(--ink); text-decoration: underline; }

/* Leaflet popups --------------------------------------------------------- */
.leaflet-popup-content { margin: 12px 14px; font-size: 13px; }
.leaflet-popup-content strong { font-size: 13px; }
.leaflet-popup-content .pop-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 6px;
}
.leaflet-popup-content a { color: var(--ink); }
