:root {
  --green: #20a53a;
  --green-600: #1a8f31;
  --green-50: #e9f7ec;
  --amber: #f0a020;
  --amber-50: #fdf4e3;
  --red: #e5484d;
  --red-50: #fdecec;
  --blue: #2f7ae5;
  --blue-50: #eaf2fd;
  --ink: #1f2329;
  --ink-2: #4e5662;
  --ink-3: #8a919c;
  --line: #e8ebef;
  --line-2: #f1f3f6;
  --bg: #f3f5f8;
  --card: #ffffff;
  --side: #1f2329;
  --side-ink: #aeb4bd;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased;
}
a { color: var(--green-600); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; font-weight: 600; font-size: 15px; }
.brand-mark { width: 28px; height: 28px; border-radius: 7px; background: var(--green); display: grid; place-items: center; }
.nav { padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 7px; color: var(--side-ink); }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: var(--green); color: #fff; }
.nav svg { width: 17px; height: 17px; flex: none; }
.side-foot { margin-top: auto; padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; }
.side-foot .who { color: #fff; font-weight: 500; }
.side-foot button { background: none; border: 0; color: var(--side-ink); padding: 0; cursor: pointer; font-size: 12.5px; }
.side-foot button:hover { color: #fff; }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 28px 6px; }
.topbar h1 { font-size: 19px; }
.content { padding: 14px 28px 40px; }
.btn.menu-btn { display: none; }

/* ---------- cards ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.card-h h2 { font-size: 15px; }
.card-b { padding: 16px 18px; }
.grid-top { display: grid; grid-template-columns: 1.45fr 1fr; gap: 16px; }

/* ---------- gauges (estilo aaPanel) ---------- */
.gauges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 18px 10px 20px; }
.gauge { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; }
.gauge svg { width: 118px; height: 118px; }
.gauge .val { font-size: 21px; font-weight: 600; fill: var(--ink); }
.gauge .lbl { font-weight: 600; margin-top: 6px; }
.gauge .sub { color: var(--ink-2); font-size: 12.5px; }
.ring-bg { stroke: var(--line-2); }
.ok { stroke: var(--green); color: var(--green); }
.warn { stroke: var(--amber); color: var(--amber); }
.crit { stroke: var(--red); color: var(--red); }
.disk-wrap { display: flex; gap: 18px; padding: 18px; align-items: center; }
.disk-list { display: flex; gap: 16px; flex-wrap: wrap; flex: 1; }
.disk-item { min-width: 120px; }
.disk-item .mp { background: var(--line-2); border-radius: 4px; padding: 3px 8px; font-size: 12px; color: var(--ink-2); text-align: center; margin-bottom: 10px; }
.disk-item .pct { font-size: 20px; font-weight: 600; }
.disk-item .det { font-size: 12px; color: var(--ink-2); }
.disk-rings svg { width: 132px; height: 132px; }

/* ---------- tabelas ---------- */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .02em; background: #fafbfc; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fbfcfd; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.bar { height: 6px; border-radius: 3px; background: var(--line-2); overflow: hidden; min-width: 80px; }
.bar > i { display: block; height: 100%; background: var(--green); border-radius: 3px; }
.bar.warn > i { background: var(--amber); }
.bar.crit > i { background: var(--red); }
.metric { display: flex; flex-direction: column; gap: 4px; min-width: 110px; }
.metric b { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--line-2); color: var(--ink-2); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.green { background: var(--green-50); color: var(--green-600); }
.badge.red { background: var(--red-50); color: var(--red); }
.badge.amber { background: var(--amber-50); color: #b46d00; }
.badge.blue { background: var(--blue-50); color: var(--blue); }
.badge.plain::before { display: none; }

/* ---------- botões / forms ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; padding: 7px 14px; border-radius: 7px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: #cfd4da; background: #fafbfc; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-600); }
.btn.danger { color: var(--red); }
.btn.danger.solid { background: var(--red); border-color: var(--red); color: #fff; }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn svg { width: 15px; height: 15px; }
label.f { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 500; color: var(--ink-2); }
label.f .hint { font-weight: 400; color: var(--ink-3); font-size: 12px; }
input[type=text], input[type=password], input[type=search], input[type=datetime-local], select, textarea {
  border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; background: #fff; outline: none; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(32, 165, 58, .12); }
textarea { font-family: var(--mono); font-size: 12.5px; resize: vertical; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13.5px; }
.check input { accent-color: var(--green); width: 16px; height: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px; }
.c3 { grid-column: span 3; } .c4 { grid-column: span 4; } .c6 { grid-column: span 6; } .c8 { grid-column: span 8; } .c12 { grid-column: span 12; }
.section-t { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-3); margin: 4px 0 -2px; display: flex; align-items: center; gap: 10px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.toolbar label.f { min-width: 160px; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, #1f2329 0%, #25303a 55%, #1d3a28 100%); }
.login .card { width: 100%; max-width: 380px; padding: 30px 28px; }
.login h1 { font-size: 20px; margin: 14px 0 4px; }
.login form { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }
.err-msg { color: var(--red); font-size: 13px; min-height: 18px; }

/* ---------- modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 20, 25, .5); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 560px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.xl { max-width: 1280px; height: calc(100vh - 32px); }
.modal-h { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.modal-h h2 { font-size: 16px; flex: 1; }
.modal-b { padding: 18px 20px; overflow: auto; }
.modal-f { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; align-items: center; }

/* ---------- toasts ---------- */
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 8px; font-size: 13.5px; max-width: 380px; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.toast.err { background: var(--red); }
.toast.ok { background: var(--green-600); }

/* ---------- job / log ---------- */
.job-head { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.steps { display: flex; gap: 0; align-items: center; flex-wrap: wrap; padding: 14px 18px; }
.step { display: flex; align-items: center; gap: 8px; color: var(--ink-3); font-weight: 500; font-size: 13.5px; }
.step .dot { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: 12px; background: #fff; }
.step.done { color: var(--ink); } .step.done .dot { background: var(--green); border-color: var(--green); color: #fff; }
.step.cur { color: var(--ink); } .step.cur .dot { border-color: var(--green); color: var(--green); animation: pulse 1.4s infinite; }
.step.fail .dot { background: var(--red); border-color: var(--red); color: #fff; }
.step.wait .dot { background: var(--amber); border-color: var(--amber); color: #fff; }
.step-sep { width: 34px; height: 2px; background: var(--line); margin: 0 10px; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px rgba(32,165,58,.15); } }
.term { background: #14181d; color: #d6dbe1; font-family: var(--mono); font-size: 12.5px; line-height: 1.55; padding: 14px 16px; height: calc(100vh - 330px); min-height: 320px; overflow: auto; border-radius: 0 0 var(--radius) var(--radius); white-space: pre-wrap; word-break: break-word; }
.term .l { display: flex; gap: 12px; }
.term .ts { color: #5d6672; flex: none; user-select: none; }
.term .err { color: #ff8a80; }
.term .stderr { color: #aab3bd; }
.term .sys { color: #7ee2a0; font-weight: 600; }
.term .cmd { color: #8ab4f8; }
.banner { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-radius: var(--radius); font-size: 17px; font-weight: 600; }
.banner.ok { background: var(--green); color: #fff; }
.banner.fail { background: var(--red); color: #fff; }
.banner.wait { background: var(--amber-50); color: #8a5300; border: 1px solid #f3d699; font-size: 14.5px; }
.banner svg { width: 26px; height: 26px; flex: none; }

/* ---------- merge editor ---------- */
.merge { display: grid; grid-template-columns: 250px 1fr; height: 100%; min-height: 0; }
.merge-files { border-right: 1px solid var(--line); overflow: auto; padding: 8px; }
.merge-file { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 7px; cursor: pointer; font-size: 13px; word-break: break-all; }
.merge-file:hover { background: var(--line-2); }
.merge-file.active { background: var(--green-50); }
.merge-file .n { margin-left: auto; flex: none; }
.merge-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.merge-bar { display: flex; gap: 8px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.merge-main .CodeMirror { flex: 1; height: auto; min-height: 0; font-family: var(--mono); font-size: 13px; }
.merge-legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-2); }
.merge-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.cm-conf-marker { background: #e6e9ee !important; color: #5a6270; font-weight: 600; }
.cm-conf-ours { background: #e3f1ff !important; }
.cm-conf-base { background: #f3eefe !important; }
.cm-conf-theirs { background: #e6f6ea !important; }
.merge-empty { display: grid; place-items: center; flex: 1; color: var(--ink-3); padding: 40px; text-align: center; }

/* ---------- monitoramento ---------- */
.sys-head { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.sys-head .kpi { display: flex; flex-direction: column; font-size: 12px; color: var(--ink-3); }
.sys-head .kpi b { color: var(--ink); font-size: 14px; font-variant-numeric: tabular-nums; }
.collapse-btn { background: none; border: 0; cursor: pointer; padding: 0; display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; }
.collapse-btn svg { width: 16px; height: 16px; transition: transform .15s; }
.collapsed .collapse-btn svg { transform: rotate(-90deg); }
.collapsed .tbl-wrap { display: none; }
.log-text { font-family: var(--mono); font-size: 12px; white-space: pre-wrap; word-break: break-word; }
mark { background: #fff1a8; padding: 0 1px; border-radius: 2px; }
.empty { padding: 40px 18px; text-align: center; color: var(--ink-3); }
.alert { padding: 10px 14px; border-radius: 8px; background: var(--amber-50); color: #8a5300; border: 1px solid #f3d699; font-size: 13px; }
.alert.red { background: var(--red-50); color: var(--red); border-color: #f6c5c6; }
.chart svg { width: 100%; height: 150px; display: block; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: 3px; }
.perm-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 16px; padding: 12px; background: #fafbfc; border: 1px solid var(--line); border-radius: 8px; }
.check-list { display: flex; flex-direction: column; gap: 6px; }
.check-item { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; }
.check-item .ic { flex: none; width: 18px; text-align: center; font-weight: 700; }

@media (max-width: 1100px) {
  .grid-top { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 40; width: 240px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .btn.menu-btn { display: inline-flex; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .gauges { grid-template-columns: 1fr 1fr 1fr; }
  .gauge svg { width: 90px; height: 90px; }
  .form-grid > * { grid-column: span 12; }
  .merge { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .merge-files { border-right: 0; border-bottom: 1px solid var(--line); max-height: 140px; }
  .disk-wrap { flex-direction: column; align-items: stretch; }
  .disk-rings { display: none; }
}
