:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1c2330;
  --muted: #667085;
  --border: #e3e6eb;
  --accent: #2f6fed;
  --accent-text: #ffffff;
  --ok: #157f3b;
  --ok-bg: #e5f5ea;
  --warn: #9a6100;
  --warn-bg: #fff3d6;
  --err: #b42318;
  --err-bg: #fde8e7;
  --info-bg: #e8f0fe;
  --code-bg: #f0f2f5;
  --log-bg: #11161f;
  --log-text: #d6dde8;
  --radius: 8px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f131a;
    --surface: #171c25;
    --text: #e4e8ef;
    --muted: #98a2b3;
    --border: #2a3140;
    --accent: #5b8cf5;
    --ok: #5fd08a;
    --ok-bg: #12321f;
    --warn: #f2c25b;
    --warn-bg: #3a2c0c;
    --err: #ff8a80;
    --err-bg: #3d1513;
    --info-bg: #17284a;
    --code-bg: #222938;
    --log-bg: #0a0d12;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85em; }
code { background: var(--code-bg); padding: .1em .35em; border-radius: 4px; word-break: break-all; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .75rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar nav { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); }
.container { max-width: 1100px; margin: 1.5rem auto; padding: 0 16px; }
.narrow { max-width: 440px; margin: 3rem auto; padding: 0 16px; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 2rem 0; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; margin-bottom: 1rem;
}
.card.empty { text-align: center; color: var(--muted); }
.card.danger { border-color: var(--err); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }
.grid .card { margin-bottom: 0; }
.grid + .card, .grid + section { margin-top: 1rem; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem; }
.row h1, .row h2 { margin: 0; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.crumbs { color: var(--muted); font-size: .9rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
form.inline { display: inline; }
.inline-form { display: flex; gap: .5rem; flex-wrap: wrap; }
.inline-form input { flex: 1; min-width: 200px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1.25rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem 1rem; }
.stat span { display: block; color: var(--muted); font-size: .8rem; }
.stat strong { font-size: 1.05rem; }

.stack { display: flex; flex-direction: column; gap: 1rem; }
fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .9rem; }
legend { font-weight: 600; margin-bottom: .6rem; font-size: 1.05rem; }
fieldset + fieldset { border-top: 1px solid var(--border); padding-top: 1rem; }
label { display: flex; flex-direction: column; gap: .3rem; font-weight: 500; }
label.check { flex-direction: row; align-items: center; gap: .5rem; font-weight: 400; }
small { color: var(--muted); font-weight: 400; font-size: .8rem; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 6px; padding: .5rem .65rem; width: 100%;
}
input[type=checkbox], input[type=radio] { width: auto; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

button, .button {
  font: inherit; font-weight: 500; cursor: pointer; display: inline-block;
  padding: .45rem .9rem; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
}
button:hover, .button:hover { text-decoration: none; filter: brightness(.97); }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.danger { background: var(--err); border-color: var(--err); color: #fff; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 400; }

.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.card .table { border: 0; }
.table th, .table td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.table tr:last-child td { border-bottom: 0; }

.props { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1rem; margin: 0; }
.props dt { color: var(--muted); }
.props dd { margin: 0; min-width: 0; }

.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; vertical-align: middle; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.err { background: var(--err-bg); color: var(--err); }
.badge.muted { background: var(--code-bg); color: var(--muted); }

.flash { padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; }
.flash ul { margin: 0; padding-left: 1.2rem; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.error { background: var(--err-bg); color: var(--err); }
.flash.info { background: var(--info-bg); }
.flash.warn { background: var(--warn-bg); color: var(--warn); }

pre { margin: 0; }
pre.cmd { background: var(--code-bg); padding: .6rem .8rem; border-radius: 6px; overflow-x: auto; margin-bottom: 1rem; }
pre.log {
  background: var(--log-bg); color: var(--log-text); padding: 1rem; border-radius: var(--radius);
  font: 12.5px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  max-height: 65vh; overflow: auto; white-space: pre-wrap; word-break: break-word; margin-top: .5rem;
}
.qr { background: #fff; padding: 8px; border-radius: 6px; }

@media (max-width: 600px) {
  .props { grid-template-columns: 1fr; }
  .props dt { margin-top: .4rem; }
  .table th:nth-child(3), .table td:nth-child(3) { display: none; }
}

/* Consola web (xterm.js) */
.console-term { height: calc(100vh - 260px); min-height: 320px; background: #11161f; border-radius: var(--radius); padding: 8px; overflow: hidden; }
.console-term .xterm { height: 100%; }
.console-term .xterm-viewport { background-color: #11161f !important; }

/* Correo */
.quota { min-width: 160px; }
.quota meter { display: block; width: 100%; height: .6rem; margin-bottom: .2rem; }
.spaced { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); }
label.check span { font-weight: 400; }
label.check:has(span) { align-items: flex-start; }
label.check:has(span) input { margin-top: .3rem; flex: none; }
.table + .card, .card.empty + .card { margin-top: 1rem; }
.secret-box { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 1.2rem; letter-spacing: .04em;
  background: var(--code-bg); padding: .75rem 1rem; border-radius: var(--radius); word-break: break-all; user-select: all; }

/* Monitoreo */
:root { --s1: #2f6fed; --s2: #d9822b; --lim: #b42318; --grid: #e3e6eb; --track: #e9ecf1; }
@media (prefers-color-scheme: dark) { :root { --s1: #6d9bff; --s2: #f0a35e; --lim: #ff8a80; --grid: #2a3140; --track: #232a36; } }
.monitor { margin-bottom: 1.25rem; }
.meters { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .9rem 1.25rem; }
.meter-head { display: flex; justify-content: space-between; gap: .5rem; font-size: .85rem; margin-bottom: .25rem; }
.meter-head span { color: var(--muted); }
.meter-head strong.warn { color: var(--warn); }
.meter-head strong.err { color: var(--err); }
svg.bar { display: block; width: 100%; height: 6px; }
svg.bar .track { fill: var(--track); }
svg.bar .fill.ok { fill: var(--s1); }
svg.bar .fill.warn { fill: var(--warn); }
svg.bar .fill.err { fill: var(--err); }
.services { margin-top: .9rem; display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; }
svg.spark { display: block; width: 120px; max-width: 100%; height: 22px; margin-top: .2rem; }
svg.spark path { fill: none; stroke: var(--s1); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.table.sortable th[data-sort] { cursor: pointer; user-select: none; }
.table.sortable th[aria-sort="ascending"]::after { content: " ▲"; }
.table.sortable th[aria-sort="descending"]::after { content: " ▼"; }
.tabs { display: flex; gap: .25rem; }
.tabs a { padding: .3rem .7rem; border-radius: 999px; font-size: .85rem; color: var(--muted); text-decoration: none; border: 1px solid var(--border); }
.tabs a.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 1.25rem 1.5rem; }
.charts figure { margin: 0; min-width: 0; }
.charts figcaption { font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
svg.chart { display: block; width: 100%; height: auto; }
svg.chart .grid { stroke: var(--grid); stroke-width: 1; }
svg.chart .axis { fill: var(--muted); font-size: 13px; }
svg.chart .line { fill: none; stroke-width: 1.6; stroke-linejoin: round; }
svg.chart .line.s1 { stroke: var(--s1); }
svg.chart .line.s2 { stroke: var(--s2); }
svg.chart .limit { stroke: var(--lim); stroke-width: 1.2; stroke-dasharray: 5 4; }
svg.chart .marker { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 3; opacity: .7; }
.legend { display: flex; flex-wrap: wrap; gap: .2rem 1rem; font-size: .78rem; color: var(--muted); margin: .3rem 0 0; }
.legend span::before { content: ""; display: inline-block; width: 12px; height: 0; border-top: 2px solid; vertical-align: middle; margin-right: .35rem; }
.legend .s1::before { border-color: var(--s1); }
.legend .s2::before { border-color: var(--s2); }
.legend .lim::before { border-top: 2px dashed var(--lim); }
.legend .mk::before { border-top: 2px dotted var(--muted); }
@media (max-width: 600px) {
  .charts { grid-template-columns: 1fr; }
  .table.sites th:nth-child(2), .table.sites td:nth-child(2) { display: none; }
  .table.usage th:nth-child(3), .table.usage td:nth-child(3) { display: table-cell; }
  .table.usage th:nth-child(4), .table.usage td:nth-child(4) { display: none; }
}
