/* ECS Web theme. Every colour is a token; --accent comes from the user's preference. */
:root {
  --accent: #1f6fd1;
  --accent-ink: #ffffff;
  --accent-soft: color-mix(in srgb, var(--accent) 14%, var(--surface));
  --accent-line: color-mix(in srgb, var(--accent) 45%, var(--border));
  --bg: #eef1f5;
  --surface: #ffffff;
  --surface-2: #f6f8fa;
  --surface-3: #e9edf2;
  --border: #d4dae2;
  --text: #1b2430;
  --text-muted: #5d6b7c;
  --title-bg: color-mix(in srgb, var(--accent) 88%, #0b1220);
  --title-ink: #ffffff;
  --danger: #c62f2f;
  --ok: #1e8a4c;
  --warn: #b7791f;
  --shadow: 0 8px 24px rgba(15, 23, 42, .14), 0 1px 3px rgba(15, 23, 42, .10);
  --radius: 8px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --fs: 13px;
  --row: 30px;
  color-scheme: light;
}
:root[data-density="compact"] { --fs: 12px; --row: 26px; }
:root[data-density="large"] { --fs: 15px; --row: 36px; }

:root[data-mode="dark"] {
  --bg: #0f141b;
  --surface: #171e27;
  --surface-2: #1d2530;
  --surface-3: #263040;
  --border: #2e3a4a;
  --text: #e3e9f1;
  --text-muted: #96a3b4;
  --title-bg: color-mix(in srgb, var(--accent) 45%, #0b0f15);
  --shadow: 0 8px 24px rgba(0, 0, 0, .5), 0 1px 3px rgba(0, 0, 0, .4);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-mode="system"] {
    --bg: #0f141b; --surface: #171e27; --surface-2: #1d2530; --surface-3: #263040;
    --border: #2e3a4a; --text: #e3e9f1; --text-muted: #96a3b4;
    --title-bg: color-mix(in srgb, var(--accent) 45%, #0b0f15);
    --shadow: 0 8px 24px rgba(0, 0, 0, .5), 0 1px 3px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: var(--fs)/1.4 var(--font); }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--text-muted); }
.hidden { display: none !important; }
svg.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8;
        stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; height: var(--row); padding: 0 14px;
       border: 1px solid var(--border); border-radius: 6px; background: var(--surface); cursor: pointer;
       white-space: nowrap; }
.btn:hover { background: var(--surface-3); }
.btn:focus-visible, .inp:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn[disabled] { opacity: .45; cursor: default; }
.inp { height: var(--row); padding: 0 8px; border: 1px solid var(--border); border-radius: 6px;
       background: var(--surface); min-width: 0; }
textarea.inp { height: auto; padding: 8px; resize: vertical; }
label.fld { display: grid; gap: 4px; font-size: .92em; color: var(--text-muted); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-rows: 40px 1fr 26px; height: 100vh; }
.titlebar { display: flex; align-items: stretch; background: var(--title-bg); color: var(--title-ink);
            user-select: none; min-width: 0; }
.ecs-btn { display: flex; align-items: center; gap: 8px; padding: 0 16px 0 12px; border: 0;
           background: rgba(255, 255, 255, .12); color: inherit; font-weight: 700; letter-spacing: .5px;
           cursor: pointer; }
.ecs-btn:hover, .ecs-btn[aria-expanded="true"] { background: rgba(255, 255, 255, .24); }
.ecs-btn .logo { width: 24px; height: 24px; border-radius: 5px; background: #fff; display: grid; place-items: center;
                 color: var(--title-bg); font-size: 11px; font-weight: 800; }
.tabs { display: flex; align-items: flex-end; gap: 2px; padding: 6px 6px 0; overflow-x: auto; flex: 1;
        scrollbar-width: none; min-width: 0; }
.tab { display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 8px 0 14px; max-width: 220px;
       border-radius: 8px 8px 0 0; background: rgba(255, 255, 255, .10); color: rgba(255, 255, 255, .88);
       cursor: pointer; white-space: nowrap; flex: none; }
.tab span { overflow: hidden; text-overflow: ellipsis; }
.tab:hover { background: rgba(255, 255, 255, .18); }
.tab.active { background: var(--bg); color: var(--text); }
.tab .x { width: 20px; height: 20px; border: 0; border-radius: 4px; background: none; color: inherit;
          display: grid; place-items: center; cursor: pointer; opacity: .7; padding: 0; }
.tab .x:hover { background: rgba(127, 127, 127, .25); opacity: 1; }
.tab.home { padding-right: 14px; }
.tb-right { display: flex; align-items: center; }
.tb-right button { width: 44px; height: 100%; border: 0; background: none; color: inherit; cursor: pointer;
                   display: grid; place-items: center; }
.tb-right button:hover { background: rgba(255, 255, 255, .16); }
.tb-right button.close:hover { background: #c42b1c; }

.workspace { position: relative; overflow: hidden; }
.pane { position: absolute; inset: 0; display: none; }
.pane.active { display: block; }
.pane iframe { width: 100%; height: 100%; border: 0; display: block; background: var(--bg); }

/* toolbar tab */
.toolbar { padding: 18px 20px; overflow: auto; height: 100%; display: flex; flex-wrap: wrap;
           align-content: flex-start; gap: 18px; }
.tgroup { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px 12px; }
.tgroup h3 { margin: 0 0 8px; font-size: 11px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase;
             color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.tgroup h3 i { width: 10px; height: 10px; border-radius: 3px; background: var(--g); }
.tgroup .row { display: flex; gap: 6px; flex-wrap: wrap; }
.tool { width: 78px; height: 74px; border: 1px solid transparent; border-radius: 8px; background: none;
        display: grid; place-items: center; align-content: center; gap: 6px; cursor: pointer; padding: 4px; }
.tool:hover { background: var(--surface-2); border-color: var(--border); }
.tool .ic { width: 38px; height: 38px; border-radius: 9px; display: grid; place-items: center;
            background: color-mix(in srgb, var(--g) 70%, var(--surface)); color: #1b2430; }
:root[data-mode="dark"] .tool .ic { background: color-mix(in srgb, var(--g) 40%, var(--surface)); color: #fff; }
@media (prefers-color-scheme: dark) { :root[data-mode="system"] .tool .ic { background: color-mix(in srgb, var(--g) 40%, var(--surface)); color: #fff; } }
.tool .ic svg.i { width: 22px; height: 22px; }
.tool .cap { font-size: 12px; }

/* ECS menu (cascading popup, like the Delphi popupMenu1) */
.menu { position: fixed; z-index: 1000; min-width: 210px; padding: 4px; background: var(--surface);
        color: var(--text); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow);
        list-style: none; margin: 0; }
.menu li { position: relative; }
.menu .mi { display: flex; align-items: center; gap: 10px; width: 100%; height: 30px; padding: 0 10px 0 12px;
            border: 0; background: none; border-radius: 5px; text-align: left; cursor: pointer; white-space: nowrap; }
.menu .mi:hover, .menu li.open > .mi { background: var(--accent-soft); }
.menu .mi[disabled] { color: var(--text-muted); opacity: .55; cursor: default; background: none; }
.menu .mi .chev { margin-left: auto; opacity: .6; }
.menu .sep { height: 1px; margin: 4px 6px; background: var(--border); }
.menu .menu { display: none; top: -5px; left: 100%; position: absolute; }
.menu li.open > .menu { display: block; }

/* status bar (stat1: 9 panels) */
.status { display: flex; align-items: stretch; background: var(--surface); border-top: 1px solid var(--border);
          font-size: 12px; color: var(--text-muted); overflow: hidden; }
.status > div { display: flex; align-items: center; gap: 6px; padding: 0 12px; border-right: 1px solid var(--border);
                white-space: nowrap; }
.status > div.grow { flex: 1; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.status .clickable { cursor: pointer; }
.status .clickable:hover { background: var(--surface-2); color: var(--text); }
@media (max-width: 760px) { .status .opt { display: none; } }

/* ---------- screens (inside tabs) ---------- */
.screen { display: flex; flex-direction: column; height: 100vh; }
.screen-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--surface);
               border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.screen-head h1 { font-size: 15px; margin: 0 8px 0 0; font-weight: 600; }
.screen-body { flex: 1; overflow: auto; padding: 14px; min-height: 0; }
.screen-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 10px 14px; background: var(--surface);
               border-top: 1px solid var(--border); flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.spacer { flex: 1; }

table.grid { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); }
table.grid th, table.grid td { padding: 0 10px; height: var(--row); border-bottom: 1px solid var(--border);
                               text-align: left; white-space: nowrap; }
table.grid th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); font-weight: 600;
                font-size: .92em; color: var(--text-muted); }
table.grid tbody tr { cursor: default; }
table.grid tbody tr:hover { background: var(--surface-2); }
table.grid tbody tr.sel { background: var(--accent-soft); }

.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; background: var(--surface-3); }
.badge.in { background: color-mix(in srgb, var(--ok) 18%, var(--surface)); color: var(--ok); }
.badge.out { background: color-mix(in srgb, var(--warn) 18%, var(--surface)); color: var(--warn); }
.badge.dc { background: color-mix(in srgb, var(--danger) 15%, var(--surface)); color: var(--danger); }

.msg { padding: 10px 12px; border-radius: 6px; margin-bottom: 10px; }
.msg.error { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); color: var(--danger); }
.msg.ok { background: color-mix(in srgb, var(--ok) 12%, var(--surface)); color: var(--ok); }

.placeholder { max-width: 560px; margin: 8vh auto; text-align: center; padding: 28px; }
.placeholder .big { width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 14px; background: var(--accent-soft);
                    color: var(--accent); display: grid; place-items: center; }

/* dialogs & toasts */
dialog.dlg { border: 1px solid var(--border); border-radius: 10px; padding: 18px; color: var(--text);
             background: var(--surface); box-shadow: var(--shadow); max-width: 94vw; min-width: 320px; }
dialog.dlg::backdrop { background: rgba(10, 15, 25, .35); }
.toast { position: fixed; right: 16px; bottom: 16px; z-index: 2000; padding: 10px 16px; border-radius: 8px;
         background: var(--text); color: var(--surface); box-shadow: var(--shadow); transition: opacity .4s; }
.toast.error { background: var(--danger); color: #fff; }
.toast.out { opacity: 0; }

/* combo with left/right arrows (TADFlatComboLR) */
.combo-lr { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 6px;
            background: var(--surface); height: var(--row); }
.combo-lr select { border: 0; background: none; height: 100%; padding: 0 6px; min-width: 120px; max-width: 280px; }
.combo-lr button { border: 0; background: none; width: 26px; height: 100%; cursor: pointer; color: var(--text-muted); }
.combo-lr button:hover { background: var(--surface-3); color: var(--text); }
.combo-lr button:first-child { border-right: 1px solid var(--border); }
.combo-lr button:last-child { border-left: 1px solid var(--border); }
