/* Components: cards, number tiles, tables, status pills, charger tiles, pop-ups, setup sheet, charts, message log. */
/* panels */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 14px; }
.kpi .v { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; }
.kpi .l { color: var(--muted); font-size: 13px; }
.two { grid-template-columns: 1.4fr 1fr; }
.stack > * + * { margin-top: 14px; }
.alert { border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.info { background: var(--info-soft); color: var(--info); }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; white-space: nowrap; }
tbody tr:hover { background: color-mix(in srgb, var(--bg) 60%, transparent); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.click { cursor: pointer; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* pills */
.pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 99px; padding: 1px 9px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--idle-soft); color: var(--idle); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.plugs { display: flex; gap: 6px; flex-wrap: wrap; }

/* charger tiles */
.tiles { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.tile { cursor: pointer; transition: border-color .15s; }
.tile:hover { border-color: var(--brand); }
.tile-mini { cursor: pointer; padding: 6px 0; border-top: 1px solid var(--line); }
.tile-mini:first-child { border-top: 0; }
.tile .id { font-weight: 700; }
.tile .sub { color: var(--muted); font-size: 13px; margin: 2px 0 10px; }
.plug { display: flex; justify-content: space-between; gap: 8px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 13px; }


/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(5, 12, 10, .45); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal { background: var(--panel); border-radius: 14px; width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow: auto; padding: 22px; border: 1px solid var(--line); }
.modal.wide { max-width: 860px; }
.modal h2 { font-size: 18px; }

/* setup sheet */
.secret { display: grid; grid-template-columns: 150px 1fr auto; gap: 8px 12px; align-items: center; background: var(--bg); border-radius: 10px; padding: 12px 14px; }
.secret .k { color: var(--muted); font-size: 13px; }
.secret .v { font-family: var(--mono); font-size: 14px; word-break: break-all; }

/* chart */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 150px; padding-top: 10px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bar .b { width: 100%; max-width: 46px; background: var(--brand); border-radius: 6px 6px 2px 2px; min-height: 2px; }
.bar .t { font-size: 11px; color: var(--muted); white-space: nowrap; }
.bar .n { font-size: 11px; font-weight: 600; }
svg.line { width: 100%; height: 180px; display: block; }
svg.line .grid { stroke: var(--line); }
svg.line .e { fill: none; stroke: var(--brand); stroke-width: 2.2; }
svg.line .p { fill: none; stroke: var(--info); stroke-width: 1.6; stroke-dasharray: 4 3; }
svg.line text { fill: var(--muted); font-size: 11px; }

/* log */
.log { font-family: var(--mono); font-size: 12px; max-height: 420px; overflow: auto; background: var(--bg); border-radius: 10px; padding: 8px 10px; }
.log .l { display: grid; grid-template-columns: 64px 30px 170px minmax(0, 1fr); gap: 8px; padding: 3px 0; border-bottom: 1px dashed var(--line); }
.log .in { color: var(--ok); } .log .out { color: var(--info); } .log .sys { color: var(--warn); }
.log .l { cursor: pointer; }
.log .msg { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.log .l.open .msg { white-space: pre-wrap; word-break: break-all; }
table.nowrap td { white-space: nowrap; }

dl.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; margin: 0; font-size: 14px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; word-break: break-word; }

#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 30; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; }
#toast.bad { background: var(--bad); color: #fff; }
