/* Ele Cloud console. Layout and interaction model follow the Firebase console (sidebar, project picker, tabs,
   three-column data panel, dialogs); the visual identity is Ele Cloud's own. Light and dark follow the system. */
:root {
  --bg: #f8fafd; --side: #f0f4f9; --surface: #ffffff; --surface-2: #f3f6fb; --hover: #e9eef6; --selected: #d3e3fd;
  --ink: #1f1f1f; --ink-2: #444746; --muted: #5f6368; --line: #dadce0; --line-2: #e8eaed;
  --accent: #0b57d0; --accent-ink: #ffffff; --accent-soft: #d3e3fd; --link: #0b57d0;
  --ok: #146c2e; --ok-soft: #c4eed0; --warn: #8a5300; --bad: #b3261e; --bad-soft: #f9dedc;
  --str: #188038; --num: #1967d2; --bool: #a142f4; --nul: #80868b; --ts: #b06000;
  --chart-1: #1a73e8; --chart-2: #9aa0a6; --badge-ink: #9f5d00; --badge-line: #f9ab00;
  --shadow: 0 1px 2px rgba(60,64,67,.3), 0 2px 6px 2px rgba(60,64,67,.15);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131314; --side: #1b1b1c; --surface: #1e1f20; --surface-2: #232425; --hover: #2a2b2d; --selected: #004a77;
    --ink: #e3e3e3; --ink-2: #c4c7c5; --muted: #9aa0a6; --line: #3c4043; --line-2: #303134;
    --accent: #a8c7fa; --accent-ink: #062e6f; --accent-soft: #0842a0; --link: #a8c7fa;
    --ok: #6dd58c; --ok-soft: #0f5223; --warn: #fdd663; --bad: #f2b8b5; --bad-soft: #601410;
    --str: #81c995; --num: #8ab4f8; --bool: #d7aefb; --nul: #9aa0a6; --ts: #fdd663;
    --chart-1: #8ab4f8; --chart-2: #9aa0a6; --badge-ink: #fdd663; --badge-line: #fdd663;
    --shadow: 0 1px 3px rgba(0,0,0,.5), 0 4px 8px 3px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.43 "Google Sans Text", "Google Sans", Roboto, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: "Roboto Mono", ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
svg.i { width: 20px; height: 20px; fill: currentColor; flex: none; }
svg.i.s { width: 18px; height: 18px; }
svg.i.xs { width: 16px; height: 16px; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ── shell ── */
.shell { display: grid; grid-template-columns: 280px 1fr; min-height: 100vh; }
.shell.collapsed { grid-template-columns: 72px 1fr; }
.side { background: var(--side); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; border-right: 1px solid var(--line-2); }
.side .brand { display: flex; align-items: center; gap: 10px; padding: 18px 22px 14px; font-size: 22px; font-weight: 500; color: var(--ink); }
.side .brand svg { width: 28px; height: 28px; }
.side nav { padding: 0 8px; }
.side .item { display: flex; align-items: center; gap: 16px; height: 44px; padding: 0 16px; border-radius: 22px; color: var(--ink); font-weight: 500; white-space: nowrap; }
.side .item:hover { background: var(--hover); text-decoration: none; }
.side .item.on { background: var(--selected); }
.side .item .grow { flex: 1; }
.side .item .pin { opacity: 0; color: var(--muted); }
.side .item:hover .pin, .side .item.on .pin { opacity: 1; }
.side hr { border: 0; border-top: 1px solid var(--line); margin: 10px 16px; }
.side .label { color: var(--muted); font-size: 13px; padding: 12px 24px 6px; }
.side details > summary { list-style: none; cursor: pointer; }
.side details > summary::-webkit-details-marker { display: none; }
.side details[open] > summary .chev { transform: rotate(90deg); }
.side details .sub { padding-left: 36px; }
.side .sub .item { height: 36px; font-weight: 400; }
.side .plan { margin-top: auto; border-top: 1px solid var(--line); padding: 16px 24px; display: flex; justify-content: space-between; align-items: center; }
.side .plan b { display: block; font-weight: 500; }
.side .plan small { color: var(--muted); }
.side .collapse { border-top: 1px solid var(--line); padding: 10px 24px; display: flex; justify-content: flex-end; }
.shell.collapsed .side .txt, .shell.collapsed .side .label, .shell.collapsed .side .plan, .shell.collapsed .side .pin, .shell.collapsed .side .chev { display: none; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 12px; height: 64px; padding: 0 24px; }
.top .grow { flex: 1; }
.picker > summary { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 8px; cursor: pointer; list-style: none; font-size: 16px; font-weight: 500; }
.picker > summary::-webkit-details-marker { display: none; }
.picker > summary:hover { background: var(--hover); }
.who { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 500; }
.content { padding: 8px 40px 64px; max-width: 1600px; width: 100%; }
.content.wide { max-width: none; }

/* ── headers, tabs ── */
.crumb { color: var(--muted); font-size: 14px; display: flex; gap: 6px; align-items: center; margin-bottom: 2px; }
.crumb a { color: var(--muted); }
h1 { font-size: 36px; line-height: 44px; font-weight: 400; margin: 4px 0 18px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
h2 { font-size: 22px; font-weight: 400; margin: 32px 0 14px; }
h3 { font-size: 16px; font-weight: 500; margin: 0 0 8px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 0 0 24px; overflow-x: auto; }
.tabs a { padding: 12px 16px 10px; color: var(--ink-2); font-weight: 500; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a:hover { background: var(--hover); text-decoration: none; }
.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); }
.badge { font-size: 14px; font-weight: 500; padding: 2px 12px; border: 1px solid var(--badge-line); color: var(--badge-ink); border-radius: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 20px; background: var(--surface-2); font-weight: 500; }
.chips { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 700; }
.muted { color: var(--muted); }
.ok { color: var(--ok); } .bad { color: var(--bad); }

/* ── buttons, forms ── */
.btn { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 20px; border-radius: 20px; border: 1px solid var(--line); background: transparent; color: var(--accent); font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--hover); text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: var(--bad); color: var(--surface); border-color: var(--bad); }
.btn.text { border-color: transparent; padding: 0 12px; }
.btn.sm { height: 32px; padding: 0 14px; }
.btn:disabled { opacity: .45; cursor: default; }
.icon-btn { width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 50%; border: 0; background: transparent; color: var(--ink-2); cursor: pointer; }
.icon-btn:hover { background: var(--hover); }
.icon-btn.sm { width: 32px; height: 32px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > span { font-size: 12px; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=datetime-local], select, textarea {
  height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); min-width: 0; }
textarea { height: auto; min-height: 96px; padding: 10px 14px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.search { display: flex; align-items: center; gap: 10px; flex: 1; height: 48px; padding: 0 16px; border-radius: 24px; background: var(--surface-2); color: var(--muted); }
.search input { flex: 1; border: 0; background: transparent; height: 46px; padding: 0; outline: none; color: var(--ink); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row .grow { flex: 1; }
.notice { display: flex; gap: 14px; align-items: flex-start; padding: 14px 18px; border: 1px solid var(--line); border-radius: 12px; margin: 0 0 20px; background: var(--surface); }
.notice.ok { border-color: var(--ok); }
.notice.bad { border-color: var(--bad); color: var(--bad); }

/* ── cards and tables ── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 24px; margin-bottom: 24px; }
.card.flush { padding: 0; }
/* No overflow clipping on flush cards: row menus must be able to open past the card's bottom edge. */
.card.flush > :first-child { border-top-left-radius: 16px; border-top-right-radius: 16px; }
.card.flush table.t tr:first-child th:first-child { border-top-left-radius: 16px; }
.card.flush table.t tr:first-child th:last-child { border-top-right-radius: 16px; }
.card .card-title { display: flex; align-items: center; gap: 10px; font-size: 18px; margin-bottom: 18px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 24px; }
.metric small { color: var(--muted); font-size: 16px; }
.metric b { display: block; font-size: 34px; font-weight: 400; line-height: 1.3; }
.metric .delta { font-size: 16px; color: var(--muted); margin-left: 6px; }
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-weight: 500; color: var(--ink-2); padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
table.t td { padding: 12px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.t tr:hover td { background: var(--hover); }
table.t tr.off td { color: var(--muted); }
table.t td.actions { width: 56px; text-align: right; }
table.t tr .reveal { visibility: hidden; }
table.t tr:hover .reveal { visibility: visible; }
.toolbar { display: flex; gap: 12px; align-items: center; padding: 16px; border-bottom: 1px solid var(--line); }
.pager { display: flex; justify-content: flex-end; align-items: center; gap: 20px; padding: 10px 16px; color: var(--muted); }
.pager select { height: 32px; }
.empty { padding: 48px; text-align: center; color: var(--muted); }
.trunc { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: bottom; }
.prov { display: inline-flex; gap: 6px; }

/* ── menus (details) ── */
details.menu { position: relative; display: inline-block; }
details.menu > summary { list-style: none; }
details.menu > summary::-webkit-details-marker { display: none; }
details.menu .pop { position: absolute; right: 0; top: 100%; z-index: 40; min-width: 220px; background: var(--surface); border-radius: 8px; box-shadow: var(--shadow); padding: 8px 0; }
details.menu.left .pop { right: auto; left: 0; }
details.menu .pop a, details.menu .pop button { display: flex; width: 100%; gap: 12px; align-items: center; padding: 10px 18px; border: 0; background: transparent; text-align: left; color: var(--ink); cursor: pointer; }
details.menu .pop a:hover, details.menu .pop button:hover { background: var(--hover); text-decoration: none; }
details.menu .pop .danger { color: var(--bad); }
details.menu .pop hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
details.menu .pop .head { padding: 6px 18px; color: var(--muted); font-size: 12px; }

/* ── dialogs ── */
dialog { border: 0; border-radius: 28px; padding: 24px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); }
dialog.wide { width: min(760px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog h2 { margin: 0 0 20px; font-size: 24px; }
dialog .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
dialog .steps { display: flex; gap: 8px; color: var(--muted); margin-bottom: 18px; font-size: 13px; }
dialog .fieldrow { display: grid; grid-template-columns: 1.2fr .9fr 1.4fr 40px; gap: 8px; align-items: center; margin-bottom: 8px; }

/* ── Firestore data panel ── */
.dbhead { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 20px; overflow: hidden; }
.seg a { padding: 9px 18px; color: var(--ink-2); font-weight: 500; }
.seg a.on { background: var(--selected); color: var(--ink); }
.seg a:hover { text-decoration: none; background: var(--hover); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.panel .path { display: flex; align-items: center; gap: 6px; padding: 14px 20px; border-bottom: 1px solid var(--line); font-size: 15px; overflow-x: auto; white-space: nowrap; }
.panel .path a { color: var(--ink-2); }
.cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); min-height: 620px; }
.col { border-right: 1px solid var(--line); min-width: 0; display: flex; flex-direction: column; }
.col:last-child { border-right: 0; }
.col .colhead { display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 8px 0 20px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.col .colhead .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: "Roboto Mono", ui-monospace, monospace; }
.col .add { display: flex; align-items: center; gap: 12px; padding: 12px 20px; color: var(--accent); font-weight: 500; background: none; border: 0; width: 100%; text-align: left; cursor: pointer; }
.col .add:hover { background: var(--hover); }
.col .list { overflow-y: auto; max-height: 72vh; }
.col .list a.it { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 20px; color: var(--ink); font-family: "Roboto Mono", ui-monospace, monospace; font-size: 13.5px; }
.col .list a.it span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col .list a.it:hover { background: var(--hover); text-decoration: none; }
.col .list a.it.on { background: var(--selected); }
.col .list a.it .chev { visibility: hidden; }
.col .list a.it.on .chev { visibility: visible; }
.col .more { padding: 12px 20px; }
.col .sep { border-top: 1px solid var(--line); }
.fields { padding: 8px 0 24px; font-family: "Roboto Mono", ui-monospace, monospace; font-size: 13.5px; }
.f { display: flex; align-items: flex-start; gap: 4px; padding: 6px 12px 6px 20px; min-height: 34px; }
.f:hover { background: var(--hover); }
.f .k { color: var(--ink-2); }
.f .v { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.f .acts { visibility: hidden; display: flex; gap: 0; margin-top: -6px; }
.f:hover .acts { visibility: visible; }
.f .ty { color: var(--muted); font-size: 12px; margin-left: 8px; font-family: inherit; }
.v.string { color: var(--str); } .v.number { color: var(--num); } .v.boolean { color: var(--bool); }
.v.null { color: var(--nul); } .v.timestamp { color: var(--ts); } .v.map, .v.array { color: var(--muted); }
details.node > summary { list-style: none; cursor: pointer; }
details.node > summary::-webkit-details-marker { display: none; }
details.node > summary .tw { display: inline-block; width: 14px; transition: transform .1s; }
details.node[open] > summary .tw { transform: rotate(90deg); }
details.node .kids { padding-left: 22px; }
.editor { width: 100%; min-height: 420px; font-family: "Roboto Mono", ui-monospace, monospace; font-size: 13px; }
pre.code { margin: 0; padding: 16px 0; overflow: auto; font-family: "Roboto Mono", ui-monospace, monospace; font-size: 13px; line-height: 1.6; counter-reset: ln; }
pre.code span.l { display: block; padding: 0 20px 0 0; }
pre.code span.l::before { counter-increment: ln; content: counter(ln); display: inline-block; width: 52px; padding-right: 16px; text-align: right; color: var(--muted); }

/* ── charts ── */
svg.chart { width: 100%; height: auto; display: block; }
svg.chart .grid { stroke: var(--line); stroke-width: 1; }
svg.chart .axis { fill: var(--muted); font-size: 12px; }
svg.chart .s1 { stroke: var(--chart-1); fill: none; stroke-width: 2; }
svg.chart .s2 { stroke: var(--chart-1); fill: none; stroke-width: 2; stroke-dasharray: 5 4; opacity: .8; }
svg.chart .s3 { stroke: var(--chart-2); fill: none; stroke-width: 2; }
svg.chart .p1 { fill: var(--chart-1); }
.legend { display: flex; gap: 18px; justify-content: flex-end; color: var(--muted); margin-top: 6px; font-size: 13px; }
.legend i { display: inline-block; width: 18px; border-top: 2px solid var(--chart-1); vertical-align: middle; margin-right: 6px; }
.legend i.d { border-top-style: dashed; }
.legend i.g { border-top-color: var(--chart-2); }

/* ── storage ── */
.bucket { display: flex; align-items: center; gap: 8px; font-family: "Roboto Mono", ui-monospace, monospace; }
.split { display: grid; grid-template-columns: 1fr 360px; gap: 0; }
.split .aside { border-left: 1px solid var(--line); padding: 20px; }
.split .aside dl { display: grid; grid-template-columns: 1fr; gap: 2px; margin: 0; }
.split .aside dt { color: var(--muted); font-size: 12px; margin-top: 12px; }
.split .aside dd { margin: 0; overflow-wrap: anywhere; }

/* ── product search ── */
.side .search-item { width: 100%; border: 0; background: transparent; cursor: pointer; text-align: left; font: inherit; color: var(--ink); }
.plist { margin-top: 12px; max-height: 60vh; overflow-y: auto; }
.plist a { display: flex; gap: 14px; align-items: center; padding: 12px 16px; border-radius: 12px; color: var(--ink); }
.plist a:hover, .plist a.hit { background: var(--hover); text-decoration: none; }

/* ── login ── */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login .card { width: min(420px, 100%); padding: 40px; }
.login .brand { display: flex; align-items: center; gap: 10px; font-size: 24px; margin-bottom: 8px; }
.login .brand svg { width: 32px; height: 32px; }

@media (max-width: 1100px) { .cols { grid-template-columns: 1fr; } .col { border-right: 0; border-bottom: 1px solid var(--line); } .split { grid-template-columns: 1fr; } }
@media (max-width: 800px) { .shell { grid-template-columns: 1fr; } .side { position: static; height: auto; } .content { padding: 8px 16px 48px; } h1 { font-size: 28px; } }
