* { box-sizing: border-box; }
:root {
  --bg: #0f1419;
  --panel: #1a212b;
  --panel-2: #222b38;
  --border: #2e3a49;
  --text: #e6edf3;
  --muted: #8b97a7;
  --accent: #e30613;       /* Ooredoo red */
  --accent-2: #1f6feb;
  --ok: #2ea043;
  --fail: #d1242f;
}
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 18px; }
.tabs { display: flex; gap: 6px; }
.tab {
  background: transparent; border: 1px solid transparent; color: var(--muted);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 14px;
}
.tab:hover { color: var(--text); background: var(--panel-2); }
.tab.active { color: #fff; background: var(--accent); }
.tab.settings-tab.active { background: var(--accent-2); }

main { max-width: min(1680px, 96vw); margin: 0 auto; padding: 24px 20px 60px; }
.view { display: none; }
.view.active { display: block; }
h2 { margin-top: 0; }

.hint, .muted { color: var(--muted); font-size: 13px; }
.row-between { display: flex; align-items: center; justify-content: space-between; }

/* query box */
.query-box { display: flex; gap: 10px; align-items: stretch; margin-top: 8px; }
.msisdn-input {
  display: flex; align-items: center; background: var(--panel);
  border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
}
.msisdn-input .prefix {
  padding: 0 12px; color: var(--muted); background: var(--panel-2);
  height: 100%; display: flex; align-items: center; border-right: 1px solid var(--border);
}
.msisdn-input input {
  background: transparent; border: none; color: var(--text);
  padding: 12px 14px; font-size: 16px; width: 220px; outline: none;
}

.btn {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  padding: 10px 16px; border-radius: 8px; cursor: pointer; font-size: 14px;
}
.btn:hover:not(:disabled) { background: #2c3848; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.1); }

/* result */
.result { margin-top: 22px; }
.hidden { display: none !important; }
.json-view {
  background: #0b0f14; border: 1px solid var(--border); border-radius: 8px;
  padding: 14px; overflow: auto; max-height: 460px; font-size: 12.5px;
  line-height: 1.5; white-space: pre; color: #c9d6e3;
}
.json-view .j-key { color: #79c0ff; }
.json-view .j-str { color: #a5d6ff; }
.json-view .j-num { color: #f2cc60; }
.json-view .j-bool { color: #ff7b72; }
.json-view .j-null { color: #8b949e; font-style: italic; }

.summary-cards { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 16px; min-width: 140px;
}
.card .k { font-size: 11px; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; }
.card .v { font-size: 16px; font-weight: 600; margin-top: 4px; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.ok { background: rgba(46,160,67,.15); color: #4ac26b; }
.pill.fail { background: rgba(209,36,47,.15); color: #ff6b73; }
.pill.warn { background: rgba(210,153,34,.15); color: #e3b341; }

/* placeholder */
.placeholder {
  background: var(--panel); border: 1px dashed var(--border); border-radius: 10px;
  padding: 28px; text-align: center; margin-top: 12px;
}

/* table */
.table-wrap { overflow-x: auto; margin-top: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; background: var(--panel); position: sticky; top: 0; }
tbody tr:hover { background: var(--panel-2); }

/* view all hover */
.viewall { position: relative; }
.viewall .link { color: var(--accent-2); cursor: pointer; text-decoration: underline; }
.viewall .tip {
  display: none; position: absolute; right: 0; top: 100%; z-index: 50;
  background: #0b0f14; border: 1px solid var(--border); border-radius: 8px;
  padding: 12px; width: 460px; max-height: 360px; overflow: auto;
  white-space: pre; font-size: 11.5px; color: #c9d6e3; box-shadow: 0 8px 24px rgba(0,0,0,.5);
  text-align: left;
}
.viewall:hover .tip { display: block; }

/* settings */
.settings-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 20px; margin-bottom: 20px;
}
.badge {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px;
  padding: 2px 10px; font-size: 12px; color: var(--muted);
}
.field { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--muted); }
.field input {
  background: #0b0f14; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); padding: 10px 12px; font-size: 13px; font-family: ui-monospace, monospace;
}
.field input:disabled { opacity: .7; }
.actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

/* modal */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  width: min(760px, 92vw); max-height: 86vh; display: flex; flex-direction: column;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 600;
}
.modal-close { background: transparent; border: none; color: var(--muted); font-size: 18px; cursor: pointer; }
.modal-banner { padding: 12px 18px; font-weight: 600; }
.modal-banner.ok { background: rgba(46,160,67,.12); color: #4ac26b; }
.modal-banner.fail { background: rgba(209,36,47,.12); color: #ff6b73; }
.modal-card .json-view { margin: 0 18px 18px; }

.spinner { color: var(--muted); margin-top: 16px; }

/* accordion (jobs) */
.acc { border: 1px solid var(--border); border-radius: 10px; margin-top: 12px; overflow: hidden; background: var(--panel); }
.acc-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; cursor: pointer; user-select: none;
}
.acc-head:hover { background: var(--panel-2); }
.acc-title { display: flex; align-items: center; gap: 10px; }
.caret { color: var(--muted); font-size: 11px; width: 12px; }
.acc-right { display: flex; align-items: center; gap: 12px; }
.acc-count { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
.acc-append { padding: 6px 12px; font-size: 13px; }
.acc-body { display: none; padding: 0 16px 16px; }
.acc.open .acc-body { display: block; }

.job-controls { display: flex; gap: 10px; margin: 4px 0 14px; }
.pager { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.pg-goto { display: inline-flex; align-items: center; gap: 6px; margin-left: 6px; }
.pg-input {
  width: 80px; background: #0b0f14; border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); padding: 7px 9px; font-size: 13px;
}
.resp-cell { max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.resp-link { color: var(--accent-2); cursor: pointer; text-decoration: underline; font-size: 12px; }

/* modal form body */
.modal-body-pad { padding: 18px; overflow: auto; }
.modal-body-pad .field { margin-top: 12px; }
.modal-body-pad textarea, .modal-body-pad select, .modal-body-pad input {
  background: #0b0f14; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); padding: 10px 12px; font-size: 13px; width: 100%;
  font-family: ui-monospace, monospace;
}
.modal-body-pad textarea { resize: vertical; }

.cc-list { display: flex; flex-wrap: wrap; gap: 8px; }
.cc-item {
  display: flex; align-items: center; gap: 6px; cursor: pointer;
  background: #0b0f14; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; font-size: 13px; width: auto;
}
.cc-item input { width: auto; }

/* ---- analysis page ---- */
.an-controls { display: flex; align-items: flex-end; gap: 20px; flex-wrap: wrap; margin-bottom: 16px; }
.field.inline { flex-direction: column; gap: 6px; }
.field.inline select {
  background: #0b0f14; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); padding: 8px 12px; font-size: 13px; min-width: 220px;
}
.subtabs { display: flex; gap: 6px; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.subtab {
  background: transparent; border: none; border-bottom: 2px solid transparent;
  color: var(--muted); padding: 10px 14px; cursor: pointer; font-size: 14px;
}
.subtab:hover { color: var(--text); }
.subtab.active { color: #fff; border-bottom-color: var(--accent); }
.tabview h4 { margin: 22px 0 8px; }

.barwrap { background: #0b0f14; border-radius: 4px; height: 14px; overflow: hidden; border: 1px solid var(--border); }
.bar { background: var(--accent-2); height: 100%; }

/* pivot builder */
.pivot-builder { display: grid; grid-template-columns: 220px 1fr; gap: 14px; margin: 12px 0; }
.pivot-fields, .pzone {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 10px;
}
.pivot-zones { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.zone-label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 8px; }
.dropzone { min-height: 40px; display: flex; flex-wrap: wrap; gap: 6px; align-content: flex-start;
  border: 1px dashed var(--border); border-radius: 8px; padding: 8px; background: #0b0f14; }
.dropzone.drag-over { border-color: var(--accent-2); background: #10243f; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; cursor: grab; user-select: none;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 9px; font-size: 12px;
}
.chip-x { cursor: pointer; color: var(--muted); font-weight: 700; }
.chip-x:hover { color: var(--fail); }
.pivot-aggrow { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.pivot-aggrow select { background: #0b0f14; border: 1px solid var(--border); border-radius: 6px; color: var(--text); padding: 6px 10px; }

/* global filters bar */
.filters-bar {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; margin-bottom: 18px;
}
.filters-add { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filters-add select {
  background: #0b0f14; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); padding: 8px 12px; font-size: 13px;
}
.filters-active { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.filters-active:empty { margin-top: 0; }
.filter-pill {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px;
}
.filter-name { font-size: 12px; font-weight: 600; color: var(--text); }
.filter-pill input[type=number] { width: 90px; }
.filter-pill input[type=number], .filter-pill input[type=date] {
  background: #0b0f14; border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); padding: 5px 8px; font-size: 12px;
}
.filter-rm { cursor: pointer; color: var(--muted); font-weight: 700; padding-left: 2px; }
.filter-rm:hover { color: var(--fail); }

/* rich multi-select dropdown */
.dd { position: relative; }
.dd-btn {
  background: #0b0f14; border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); padding: 5px 10px; font-size: 12px; cursor: pointer; min-width: 110px; text-align: left;
}
.dd-panel {
  position: absolute; top: 110%; left: 0; z-index: 60; width: 260px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.5); padding: 10px;
}
.dd-search { width: 100%; background: #0b0f14; border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); padding: 6px 8px; font-size: 12px; margin-bottom: 8px; }
.dd-actions { display: flex; gap: 8px; margin-bottom: 8px; }
.dd-actions button {
  flex: 1; background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); padding: 5px; font-size: 11px; cursor: pointer;
}
.dd-actions button:hover { background: #2c3848; }
.dd-list { max-height: 240px; overflow: auto; display: flex; flex-direction: column; gap: 4px; }
.dd-item { display: flex; align-items: center; gap: 6px; font-size: 12px; cursor: pointer; }
.dd-item input { width: auto; }

.pivot-table th, .pivot-table td { text-align: right; }
.pivot-table th:first-child, .pivot-table td:first-child { text-align: left; }
.pivot-table .tot, .pivot-table tr.tot td { font-weight: 700; }
tr.tot td { font-weight: 700; background: var(--panel); }
.acc-analyse { padding: 6px 12px; font-size: 13px; }

/* compact tables inside job accordions + pivot so all columns fit the window */
.acc-body table, .pivot-table { font-size: 12px; }
.acc-body th, .acc-body td, .pivot-table th, .pivot-table td { padding: 6px 8px; }
.acc-body table { width: 100%; }

/* pivot row drill-down */
.pivot-table tr.expandable td:first-child { cursor: pointer; }
.tree-tog { display: inline-block; width: 16px; color: var(--accent-2); cursor: pointer; }
.tree-sp { display: inline-block; width: 16px; }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 32px; width: min(360px, 92vw);
}
.login-title { font-size: 28px; font-weight: 800; text-align: center; margin-bottom: 22px; }
.login-card .field { margin-top: 14px; }
.login-card input {
  background: #0b0f14; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); padding: 10px 12px; font-size: 14px; width: 100%;
}
.login-err { color: #ff6b73; font-size: 13px; margin-top: 12px; min-height: 16px; text-align: center; }

/* auto-stop banner */
.autostop-banner {
  background: rgba(209,36,47,.12); border: 1px solid var(--fail); color: #ff9aa0;
  border-radius: 8px; padding: 10px 14px; margin: 4px 0 12px; font-size: 13px;
}
.logout-link { cursor: pointer; }
