/* Agente Ops · panel */
:root {
  --ground: #F3F4F1;
  --surface: #FFFFFF;
  --surface-2: #FAFAF8;
  --line: #DEE0DA;
  --line-soft: #ECEDE9;
  --ink: #15171C;
  --muted: #5B6068;
  --side: #15171C;
  --side-2: #262A31;
  --side-line: #343941;
  --side-ink: #E8E9E4;
  --side-muted: #A2A6AD;
  --ok: #1D6B47; --ok-ink: #134A31; --ok-bg: #E3F1E9;
  --warn: #E9772F; --warn-ink: #8A3409; --warn-bg: #FBEBDD;
  --bad: #A3241B; --bad-bg: #FBE4E1;
  --info-ink: #1E4E8C; --info-bg: #E3ECF8;
  --off-ink: #4A4F57; --off-bg: #ECEDE9;
  --bar-in: #1D6B47; --bar-out: #F2B48A;
  --r: 14px;
  --sans: 'IBM Plex Sans', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ground); color: var(--ink); font: 15px/1.45 var(--sans); }
a { color: var(--ok); }
a:hover { color: var(--ok-ink); }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 18px; font-weight: 600; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* Layout */
.app { min-height: 100vh; display: flex; flex-wrap: wrap; }
.side { flex: 1 1 248px; max-width: 280px; background: var(--side); color: var(--side-ink); padding: 28px 20px; display: flex; flex-direction: column; gap: 28px; }
.brand { display: flex; flex-direction: column; gap: 4px; }
.brand b { font-size: 20px; letter-spacing: -0.01em; }
.brand span { font-size: 13px; color: var(--side-muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; justify-content: space-between; align-items: center; padding: 11px 12px; border-radius: 8px; color: var(--side-ink); text-decoration: none; }
.nav a:hover { background: #1F2228; color: #fff; }
.nav a.on { background: var(--side-2); color: #fff; font-weight: 500; }
.count { background: var(--warn); color: var(--ink); font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 999px; }
.status { margin-top: auto; display: flex; flex-direction: column; gap: 12px; padding: 16px; border: 1px solid var(--side-line); border-radius: 12px; }
.status-row { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #3FB27F; flex: none; }
.dot.off { background: #E5534B; }
.status p { margin: 0; font-size: 13px; color: var(--side-muted); }
.btn-pause { width: 100%; min-height: 44px; border-radius: 8px; border: 1px solid #F0A39B; background: transparent; color: #F6C5BF; font: inherit; font-weight: 600; cursor: pointer; }
.btn-pause:hover { background: #2A1D1C; }
.btn-pause.resume { background: var(--side-ink); color: var(--ink); border-color: var(--side-ink); }
.side-foot { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: var(--side-muted); }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-decoration: underline; cursor: pointer; }

.main { flex: 999 1 560px; min-width: 0; padding: 32px 40px 56px; display: flex; flex-direction: column; gap: 24px; }
.head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; }
.head-text { display: flex; flex-direction: column; gap: 4px; }
.eyebrow { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.cols { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.col-main { flex: 2 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 24px; }
.col-side { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 24px; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 24px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; display: flex; flex-direction: column; gap: 8px; }
.kpi-label { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi-value { font-family: var(--mono); font-size: 30px; font-weight: 500; letter-spacing: -0.02em; line-height: 1.15; }
.kpi-value small { font-size: 16px; color: var(--muted); }
.up { color: var(--ok); font-weight: 600; }
.down { color: var(--bad); font-weight: 600; }
.meter { height: 8px; background: var(--line-soft); border-radius: 999px; overflow: hidden; }
.meter i { display: block; height: 8px; background: var(--warn); border-radius: 999px; }
.meter i.full { background: var(--bad); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 8px; border: 1px solid #C9CCC4; background: var(--surface); color: var(--ink); font: inherit; font-weight: 500; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #9EA29A; color: var(--ink); }
.btn-dark { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 600; }
.btn-dark:hover { background: #2B2E35; color: #fff; }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; font-weight: 600; padding: 0 22px; }
.btn-ok:hover { background: var(--ok-ink); color: #fff; }
.btn-bad { color: var(--bad); border-color: #E3B3AE; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
form.inline { display: inline; margin: 0; }

/* Badges */
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.b-ok { background: var(--ok-bg); color: var(--ok-ink); }
.b-warn { background: var(--warn-bg); color: var(--warn-ink); }
.b-info { background: var(--info-bg); color: var(--info-ink); }
.b-off { background: var(--off-bg); color: var(--off-ink); }
.b-bad { background: var(--bad-bg); color: #8C1F17; }
.tag { padding: 4px 10px; border-radius: 999px; background: var(--ground); font-size: 13px; }
.tag-dash { font-size: 12px; color: var(--muted); border: 1px dashed #B9BCB4; padding: 4px 10px; border-radius: 999px; }

/* Approvals */
.appr { display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; align-items: center; padding: 16px; border: 1px solid var(--line-soft); border-radius: 12px; background: var(--surface-2); }
.appr-body { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.appr-body .badge { align-self: flex-start; }
.appr-title { font-weight: 600; font-size: 16px; }
.appr-detail { font-size: 14px; color: var(--muted); }
.appr-btns { display: flex; gap: 8px; }
.empty { padding: 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 12px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table-wrap table { min-width: 640px; }
th { text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; padding: 8px 10px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
td.num, th.num { text-align: right; font-family: var(--mono); white-space: nowrap; }
th.num { font-family: var(--sans); }
tr.row-link td a { color: var(--ink); text-decoration: none; font-weight: 500; }
tr.row-link td a:hover { text-decoration: underline; }

/* Chart */
.chart { display: flex; align-items: flex-end; gap: 10px; height: 170px; padding-top: 10px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.chart-day { flex: 1 0 22px; display: flex; align-items: flex-end; justify-content: center; gap: 3px; height: 150px; }
.chart-day i { width: 10px; border-radius: 3px 3px 0 0; display: block; min-height: 1px; }
.chart-day i.in { background: var(--bar-in); }
.chart-day i.out { background: var(--bar-out); }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: block; }
.axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }

/* Log */
.log-item { display: flex; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.log-item:last-child { border-bottom: 0; }
.log-time { flex: 0 0 64px; font-family: var(--mono); font-size: 13px; color: var(--muted); padding-top: 1px; }
.log-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.log-what { font-weight: 500; font-size: 14px; }
.log-why { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.log-item.alerta .log-what { color: var(--warn-ink); }
.log-item.error .log-what { color: var(--bad); }

/* Rules list */
.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--line-soft); }
.kv span:first-child { color: var(--muted); }
.kv span:last-child { font-weight: 500; text-align: right; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px 20px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
label { font-size: 14px; font-weight: 500; }
.hint { font-size: 13px; color: var(--muted); }
.input-wrap { display: flex; align-items: center; border: 1px solid #C9CCC4; border-radius: 8px; background: var(--surface); overflow: hidden; }
.input-wrap:focus-within { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(21, 23, 28, .08); }
.input-wrap .unit { padding: 0 12px; color: var(--muted); font-size: 14px; background: var(--surface-2); align-self: stretch; display: flex; align-items: center; border-right: 1px solid var(--line-soft); }
.input-wrap .unit.after { border-right: 0; border-left: 1px solid var(--line-soft); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], select, textarea {
  font: inherit; color: inherit; border: 1px solid #C9CCC4; border-radius: 8px; padding: 10px 12px; min-height: 44px; background: var(--surface); width: 100%;
}
.input-wrap input { border: 0; border-radius: 0; box-shadow: none; min-width: 0; }
.input-wrap input:focus { outline: none; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(21, 23, 28, .08); }
textarea { min-height: 96px; resize: vertical; }
.check { display: flex; gap: 10px; align-items: flex-start; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--ok); }
.form-foot { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

/* Flash */
.flash { padding: 14px 16px; border-radius: 10px; font-size: 14px; font-weight: 500; border: 1px solid; }
.flash.ok { background: var(--ok-bg); color: var(--ok-ink); border-color: #BFDDCB; }
.flash.error { background: var(--bad-bg); color: #8C1F17; border-color: #EDC0BA; }
.flash.warn { background: var(--warn-bg); color: var(--warn-ink); border-color: #F1CFB4; }
.banner-pause { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 14px 16px; border-radius: 10px; background: var(--bad-bg); color: #8C1F17; font-weight: 500; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs a { padding: 8px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); text-decoration: none; font-size: 14px; }
.tabs a.on { background: var(--ink); border-color: var(--ink); color: #fff; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
.stat-row div { display: flex; flex-direction: column; gap: 2px; }
.stat-row b { font-family: var(--mono); font-weight: 500; font-size: 18px; }

/* Bottom nav (phone) */
.bottom-nav { display: none; }

/* Login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 32px 28px; display: flex; flex-direction: column; gap: 18px; }

@media (max-width: 860px) {
  .side { max-width: none; flex-basis: 100%; padding: 16px; gap: 0; flex-direction: row; align-items: center; justify-content: space-between; }
  .side .nav, .side .side-foot, .side .brand span { display: none; }
  .side .status { margin: 0; padding: 0; border: 0; flex-direction: row; align-items: center; gap: 10px; }
  .side .status p { display: none; }
  .btn-pause { width: auto; padding: 0 14px; min-height: 40px; }
  .main { padding: 20px 16px 104px; gap: 18px; }
  h1 { font-size: 24px; }
  .card { padding: 18px; }
  .kpi { padding: 16px; }
  .kpi-value { font-size: 24px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .appr-btns { width: 100%; }
  .appr-btns form { flex: 1; }
  .appr-btns .btn { width: 100%; }
  .bottom-nav { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(10px + env(safe-area-inset-bottom)); z-index: 10; }
  .bottom-nav a { min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; color: var(--muted); text-decoration: none; position: relative; }
  .bottom-nav a.on { color: var(--ink); font-weight: 600; }
  .bottom-nav svg { width: 22px; height: 22px; }
  .bottom-nav .count { position: absolute; top: 2px; right: calc(50% - 22px); font-size: 10px; padding: 0 6px; }
}
@media (max-width: 420px) {
  .kpis { grid-template-columns: minmax(0, 1fr); }
}
