/* ═══════════════════════════════════════════════════════
   we.know Dashboard – CSS (Retool-Style)
   ═══════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f0f0f0;
  color: #333;
  font-size: 13px;
}

/* ─── HEADER ──────────────────────────────────────────── */
.dash-header {
  display: flex;
  align-items: center;
  background: white;
  padding: 0 1.25rem;
  height: 48px;
  border-bottom: 1px solid #e0e0e0;
  gap: 1rem;
  position: relative;
}
.load-progress {
  position: absolute;
  bottom: 0; left: 0;
  width: 100%; height: 3px;
  background: transparent;
  overflow: hidden;
  pointer-events: none;
}
.load-progress-bar {
  height: 100%;
  width: 0%;
  background: #0068ef;
  transition: width 0.25s ease, opacity 0.5s ease 0.3s;
  opacity: 0;
}
.dash-title {
  font-size: 1rem;
  font-weight: 700;
  color: #0068ef;
  flex: 1;
  letter-spacing: -0.01em;
}
.dash-customer {
  color: #111;
  font-size: 0.9rem;
  font-weight: 600;
}

/* ─── TOOLBAR ─────────────────────────────────────────── */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
  padding: 0.6rem 1.25rem;
  background: white;
  border-bottom: 1px solid #e0e0e0;
}
.toolbar-group {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.toolbar-group label {
  font-size: 0.72rem;
  color: #777;
  font-weight: 500;
  text-transform: lowercase;
}
.toolbar-group select,
.toolbar-group input[type="text"] {
  padding: 0.35rem 0.6rem;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  font-size: 0.82rem;
  background: white;
  color: #222;
  min-width: 100px;
}
.toolbar-group select:focus,
.toolbar-group input:focus {
  outline: none;
  border-color: #0068ef;
}

/* ─── IP MATCH (Toggle-Style) ─────────────────────────── */
.ip-match-row {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  overflow: hidden;
  background: white;
}
.ip-match-row input[type="text"] {
  border: none;
  border-right: 1px solid #d0d0d0;
  border-radius: 0;
  padding: 0.35rem 0.6rem;
  font-size: 0.82rem;
  min-width: 140px;
}
.ip-match-row input[type="text"]:focus {
  outline: none;
}
.toggle-btn {
  padding: 0.35rem 0.7rem;
  border: none;
  background: white;
  color: #555;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.toggle-btn + .toggle-btn {
  border-left: 1px solid #d0d0d0;
}
.toggle-btn.active {
  background: #0068ef;
  color: white;
}
.toggle-btn:hover:not(.active) { background: #f0f4ff; }

/* ─── TOOLBAR ACTIONS ─────────────────────────────────── */
.toolbar-actions {
  display: flex;
  gap: 0.4rem;
  align-items: flex-end;
  margin-left: auto;
}
.toolbar-spacer {
  display: inline-block;
  width: 1.8rem;
}
.toolbar-group-ip {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 0.5rem;
  flex-wrap: nowrap;
}
.toolbar-subgroup {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.btn-align-bottom {
  margin-bottom: 1px;
}
.btn-primary {
  padding: 0.38rem 1rem;
  background: #0068ef;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
}
.btn-primary:hover { background: #0054c4; }
.btn-secondary {
  padding: 0.38rem 0.8rem;
  background: white;
  color: #333;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.82rem;
}
.btn-secondary:hover { background: #f5f5f5; }
.btn-nrql {
  padding: 0.38rem 0.8rem;
  background: #0068ef;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.82rem;
}
.btn-nrql:hover { background: #0054c4; }

/* ─── CHART CARDS ─────────────────────────────────────── */
.chart-card {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 1rem;
  margin: 0.75rem 1.25rem;
  min-width: 0;
}
.chart-card-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: #444;
  margin-bottom: 0.75rem;
  text-align: center;
}

.chart-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin: 0.75rem 1.25rem;
}
.chart-grid-2 .chart-card { margin: 0; }

.chart-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.75rem;
  margin: 0.75rem 0;
}
.chart-grid-3 .chart-card { margin: 0; }

.chart-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin: 0.75rem 0;
}
.chart-grid-4 .chart-card { margin: 0; }

.chart-wrap { position: relative; overflow: hidden; height: 200px; }
.ip-chart-wrap   { height: 220px; overflow: hidden; }
.port-intf-wrap  { height: 140px; overflow: hidden; }
.port-bar-wrap   { height: 200px; overflow: hidden; }
.geo-bar-wrap    { height: 220px; overflow: hidden; }
.geo-bubble-wrap  { height: 220px; overflow: hidden; }
.app-bubble-wrap  { height: 260px; overflow: hidden; }

/* Drag-to-select rubber band box */
.drag-select-box {
  position: absolute;
  border: 2px dashed #0068ef;
  background: rgba(0,104,239,0.07);
  border-radius: 2px;
  pointer-events: none;
  z-index: 10;
}
.chart-wrap::-webkit-scrollbar-track { background: #f5f5f5; }

/* ─── COLLAPSIBLE SECTIONS ────────────────────────────── */
.section-collapsible {
  background: white;
  margin: 0.4rem 1.25rem;
  border-radius: 4px;
  border: 1px solid #e0e0e0;
  overflow: hidden;
}
.section-collapsible summary {
  padding: 0.6rem 1rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.82rem;
  color: #333;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  user-select: none;
  list-style: none;
}
.section-collapsible summary::-webkit-details-marker { display: none; }
.section-collapsible summary::before {
  content: '▶';
  font-size: 0.65rem;
  transition: transform 0.15s;
  color: #999;
}
.section-collapsible[open] summary::before { transform: rotate(90deg); }
.section-collapsible summary:hover { background: #fafafa; }
.section-inner { padding: 0.75rem 1rem; border-top: 1px solid #eee; }

/* ─── DATA TABLES ─────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.data-table th {
  background: #f7f7f7;
  padding: 0.45rem 0.75rem;
  text-align: left;
  font-weight: 600;
  color: #555;
  border-bottom: 1px solid #e0e0e0;
  position: sticky;
  top: 0;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.data-table td { padding: 0.4rem 0.75rem; border-bottom: 1px solid #f2f2f2; }
.data-table tr:hover td { background: #f9f9f9; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ─── LOADING ─────────────────────────────────────────── */
.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1.5rem;
  color: #999;
  font-size: 0.82rem;
}
.loading::before {
  content: '';
  width: 16px; height: 16px;
  border: 2px solid #e0e0e0;
  border-top-color: #0068ef;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 0.5rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── NRQL MODAL ──────────────────────────────────────── */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal.hidden { display: none; }
.modal-content {
  background: white;
  border-radius: 6px;
  width: min(680px, 90vw);
  max-height: 80vh;
  overflow: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid #eee;
  font-size: 0.85rem;
  font-weight: 600;
}
.modal-header button {
  background: none; border: none; cursor: pointer;
  font-size: 1rem; color: #666;
}
.modal-content pre {
  padding: 1rem;
  font-size: 0.82rem;
  color: #333;
  white-space: pre-wrap;
  font-family: 'Consolas', 'Monaco', monospace;
}

/* ─── SELECTED LABEL ─────────────────────────────────── */
.selected-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: #0068ef;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  min-height: 1.2rem;
  padding: 0.2rem 0;
  margin-top: 0.25rem;
}
.selected-label:empty { display: none; }

/* Selektierte Tabellenzeile */
.rule-row { border-radius: 3px; padding: 0.1rem 0.3rem; }
.rule-row.sel-active {
  background: rgba(0,104,239,0.12);
  color: #0068ef;
  font-weight: 600;
}

/* ─── FACET TABLE (Synology message etc.) ────────────── */
.facet-table-wrap {
  overflow-y: auto;
  max-height: 320px;
  border: 1px solid #e8e8e8;
  border-radius: 4px;
}
.facet-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.facet-table thead th {
  position: sticky;
  top: 0;
  background: #f7f7f7;
  padding: 0.4rem 0.6rem;
  text-align: left;
  font-weight: 600;
  color: #555;
  border-bottom: 1px solid #e0e0e0;
  white-space: nowrap;
}
.facet-table thead th.col-count { text-align: right; width: 70px; }
.facet-table tbody tr {
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.1s;
}
.facet-table tbody tr:hover    { background: #f0f6ff; }
.facet-table tbody tr.ft-sel   { background: rgba(0,104,239,0.1); }
.facet-table tbody tr.ft-dim   { opacity: 0.35; }
.facet-table td { padding: 0.32rem 0.6rem; vertical-align: top; }
.facet-table td.col-count {
  text-align: right;
  font-weight: 700;
  color: #0068ef;
  white-space: nowrap;
}
.facet-table td.col-msg { word-break: break-all; }
.facet-table-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0.6rem;
  font-size: 0.76rem;
  color: #888;
  border-top: 1px solid #e8e8e8;
}
.facet-table-footer button {
  background: none;
  border: 1px solid #d0d0d0;
  border-radius: 3px;
  padding: 0.15rem 0.5rem;
  font-size: 0.74rem;
  cursor: pointer;
  color: #555;
}
.facet-table-footer button:hover { background: #f0f0f0; }

/* ─── PRESET SYSTEM ──────────────────────────────────── */
#btn-preset-save    { background:#0068ef; color:#fff; border:none; border-radius:3px; padding:0 0.75rem; height:28px; font-size:0.82rem; cursor:pointer; position:relative; }
#btn-preset-save:hover { background:#0054c4; }
#btn-preset-manage  { background:#f0f0f0; border:1px solid #d0d0d0; border-radius:3px; padding:0 0.5rem; height:28px; font-size:0.82rem; cursor:pointer; position:relative; }
#btn-preset-manage:hover { background:#e4e4e4; }
.preset-badge {
  position: absolute; top: -5px; right: -5px;
  background: #e53e3e; color: #fff;
  border-radius: 10px; font-size: 0.65rem; font-weight: 700;
  min-width: 16px; height: 16px; line-height: 16px; text-align: center;
  padding: 0 3px;
}
.preset-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 2000;
}
.preset-overlay.hidden { display: none; }
.preset-modal-inner {
  background: #fff; border-radius: 6px;
  width: min(520px, 92vw); max-height: 80vh;
  display: flex; flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}
.preset-modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e8e8e8;
  font-weight: 600; font-size: 0.9rem;
}
.preset-modal-actions { display: flex; gap: 0.5rem; align-items: center; }
.preset-modal-body { overflow-y: auto; padding: 0.75rem 1rem; flex: 1; }
.preset-empty { color: #888; font-size: 0.85rem; padding: 0.5rem 0; }
.preset-field { margin-bottom: 0.75rem; }
.preset-field-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.3rem;
}
.preset-field-name { font-weight: 600; font-size: 0.8rem; color: #444; }
.preset-values { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.preset-tag {
  display: inline-flex; align-items: center; gap: 0.3rem;
  background: #e8f0ff; border: 1px solid #b3c9f7;
  border-radius: 12px; padding: 0.15rem 0.5rem;
  font-size: 0.76rem; color: #0068ef;
}
.preset-tag .pm-del-val {
  background: none; border: none; cursor: pointer;
  color: #888; font-size: 0.7rem; padding: 0; line-height: 1;
}
.preset-tag .pm-del-val:hover { color: #e53e3e; }
.btn-icon    { background:none; border:none; cursor:pointer; font-size:1rem; color:#666; padding:0.1rem 0.3rem; }
.btn-icon:hover { color:#333; }
.btn-icon-sm { background:none; border:none; cursor:pointer; font-size:0.8rem; color:#aaa; padding:0 0.2rem; }
.btn-icon-sm:hover { color:#e53e3e; }
.btn-danger-sm { background:#fff0f0; border:1px solid #f5c6c6; color:#c53030; border-radius:3px; padding:0.15rem 0.5rem; font-size:0.76rem; cursor:pointer; }
.btn-danger-sm:hover { background:#ffe0e0; }

/* ─── Responsive ──────────────────────────────────────── */
@media (max-width: 900px) {
  .chart-grid-2,
  .chart-grid-3,
  .chart-grid-4 { grid-template-columns: 1fr; }
  .toolbar { gap: 0.4rem; }
  .toolbar-actions { margin-left: 0; }
}

/* ─── NAV ─────────────────────────────────────────────────────── */
.dash-logo {
  display: flex;
  align-items: center;
  text-decoration: none;
  margin-right: 0.5rem;
  flex-shrink: 0;
}
.dash-logo-img {
  height: 28px;
  width: auto;
  display: block;
}
.nav-cust-sel {
  padding: 0.3rem 0.6rem;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  font-size: 0.82rem;
  background: white;
  color: #222;
  cursor: pointer;
  margin-right: 0.75rem;
}
.nav-tabs {
  display: flex;
  gap: 0;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  overflow: hidden;
}
.nav-tab {
  padding: 0.3rem 0.9rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #555;
  text-decoration: none;
  background: white;
  text-transform: lowercase;
  transition: background 0.15s, color 0.15s;
}
.nav-tab + .nav-tab { border-left: 1px solid #d0d0d0; }
.nav-tab.active { background: #0068ef; color: white; }
.nav-tab:hover:not(.active) { background: #f0f4ff; }
.dash-spacer { flex: 1; }
.btn-logout {
  padding: 0.3rem 0.7rem;
  font-size: 0.78rem;
  color: #666;
  text-decoration: none;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  margin-left: 0.5rem;
  background: white;
}
.btn-logout:hover { background: #f5f5f5; color: #333; }

/* ─── LOGIN ────────────────────────────────────────────────────── */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f0f0f0;
}
.login-card {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 2rem 2.5rem;
  width: min(360px, 90vw);
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}
.login-logo {
  margin-bottom: 1.75rem;
  text-align: center;
}
.login-logo-img {
  width: 100%;
  height: auto;
  display: block;
}
.login-subtitle {
  font-size: 0.85rem;
  color: #888;
  margin-bottom: 1.5rem;
}
.login-error {
  background: #fff0f0;
  border: 1px solid #ffcccc;
  color: #cc0000;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  font-size: 0.82rem;
  margin-bottom: 1rem;
}
.login-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 1rem;
}
.login-field label {
  font-size: 0.78rem;
  color: #666;
  font-weight: 500;
}
.login-field input {
  padding: 0.45rem 0.6rem;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  font-size: 0.85rem;
}
.login-field input:focus {
  outline: none;
  border-color: #0068ef;
}
.login-btn {
  width: 100%;
  padding: 0.5rem;
  margin-top: 0.5rem;
  font-size: 0.88rem;
}
