:root {
  --blue: #1746c8;
  --blue-dark: #0e2d7d;
  --blue-soft: #eaf0ff;
  --green: #087f5b;
  --red: #c92a2a;
  --amber: #a75f00;
  --ink: #172033;
  --muted: #687387;
  --line: #dfe4ed;
  --surface: #ffffff;
  --background: #f4f6fa;
  --radius: 14px;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body { margin: 0; font-family: Inter, "Segoe UI", Arial, sans-serif; color: var(--ink); background: var(--background); }
a { color: var(--blue); text-decoration: none; }
button, input { font: inherit; }

.sidebar { position: fixed; inset: 0 auto 0 0; width: 250px; padding: 24px 18px; background: #0e1a35; color: white; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--blue); font-weight: 800; font-size: 22px; }
.brand strong, .brand small { display: block; }
.brand small { color: #aebbd7; margin-top: 3px; font-size: 12px; }
.sidebar nav { margin-top: 34px; display: grid; gap: 7px; }
.sidebar nav a { color: #c8d2e8; padding: 12px 14px; border-radius: 10px; font-weight: 600; }
.sidebar nav a:hover, .sidebar nav a.active { color: white; background: rgba(255,255,255,.1); }
.logout { margin-top: auto; }
.link-button { border: 0; color: #c8d2e8; background: transparent; cursor: pointer; padding: 10px 14px; }

.content { margin-left: 250px; padding: 30px 36px 60px; min-height: 100vh; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.topbar h1 { margin: 0; font-size: 28px; }
.topbar p { margin: 6px 0 0; color: var(--muted); }
.badge { padding: 8px 12px; border-radius: 999px; font-weight: 700; font-size: 13px; }
.badge.warning { background: #fff3bf; color: #7c4a03; }

.status-strip { display: flex; align-items: center; justify-content: space-between; gap: 15px; background: var(--surface); border: 1px solid var(--line); border-left: 5px solid var(--muted); padding: 16px 18px; border-radius: var(--radius); margin-bottom: 18px; }
.status-strip > div { display: flex; align-items: center; gap: 9px; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.status-strip.sucesso { border-left-color: var(--green); }
.status-strip.sucesso .status-dot { background: var(--green); }
.status-strip.executando { border-left-color: var(--blue); }
.status-strip.executando .status-dot { background: var(--blue); animation: pulse 1s infinite alternate; }
.status-strip.erro { border-left-color: var(--red); }
.status-strip.erro .status-dot { background: var(--red); }
@keyframes pulse { to { opacity: .35; } }

.cards { display: grid; gap: 16px; margin-bottom: 18px; }
.cards.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 4px 14px rgba(24,42,77,.04); }
.metric { padding: 20px; min-height: 122px; }
.metric span { color: var(--muted); font-size: 13px; font-weight: 600; }
.metric strong { display: block; margin-top: 18px; font-size: 31px; }
.metric .small-value { font-size: 16px; line-height: 1.35; }
.panel { padding: 22px; margin-bottom: 18px; }
.panel h2 { margin: 0 0 12px; font-size: 18px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-heading h2 { margin: 0; }
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 18px 0; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 10px 16px; border-radius: 9px; border: 1px solid transparent; cursor: pointer; font-weight: 700; }
.button.primary { background: var(--blue); color: white; }
.button.primary:hover { background: var(--blue-dark); }
.button.secondary { border-color: #b9c6e8; background: white; color: var(--blue); }
.button.compact { min-height: 34px; padding: 7px 12px; }
.button:disabled { opacity: .5; cursor: wait; }
.inline-error { color: var(--red); font-weight: 600; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { color: var(--muted); background: #f8f9fc; text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
th, td { padding: 12px 13px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.empty, .muted { color: var(--muted); }
.capture-link { display: inline-block; margin: 8px 0; font-weight: 700; }

.file-list { list-style: none; margin: 0; padding: 0; }
.file-list li { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.file-list li:last-child { border-bottom: 0; }
.file-list strong, .file-list small { display: block; overflow-wrap: anywhere; }
.file-list small { color: var(--muted); margin-top: 4px; }

.flash, .notice { padding: 14px 16px; border-radius: 10px; margin-bottom: 16px; border: 1px solid; }
.flash.sucesso { background: #e6fcf5; color: #065f46; border-color: #96f2d7; }
.flash.erro { background: #fff0f0; color: #a61e1e; border-color: #ffc9c9; }
.flash.aviso, .notice { background: #fff9db; color: #704800; border-color: #ffe066; }
.log-view { margin: 0; min-height: 480px; max-height: 70vh; overflow: auto; border-radius: 10px; padding: 18px; background: #101827; color: #dce7ff; font: 13px/1.55 Consolas, monospace; white-space: pre-wrap; }

.search-form, .upload-form { display: flex; gap: 10px; align-items: center; }
.search-form input { flex: 1; }
.stack-form, .settings-form { display: grid; gap: 18px; }
label { display: grid; gap: 7px; font-size: 14px; font-weight: 650; }
label small { color: var(--muted); font-weight: 400; }
input[type="email"], input[type="password"], input[type="text"], input[type="search"], input[type="number"], .settings-form input:not([type="checkbox"]) { width: 100%; min-height: 43px; border: 1px solid #c9d1df; border-radius: 8px; padding: 9px 11px; background: white; }
input:focus { outline: 3px solid rgba(23,70,200,.15); border-color: var(--blue); }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.form-grid .wide { grid-column: span 3; }
.switches { display: flex; flex-wrap: wrap; gap: 24px; padding: 15px; background: #f7f9fd; border-radius: 10px; }
.switches label { display: flex; align-items: center; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 0%, #e9efff, #f6f8fc 48%); }
.login-card { width: min(430px, 100%); background: white; padding: 34px; border-radius: 18px; border: 1px solid var(--line); box-shadow: 0 18px 60px rgba(20,39,84,.14); }
.login-brand { color: var(--ink); margin-bottom: 30px; }
.login-brand small { color: var(--muted); }
.login-card h1 { margin: 0; font-size: 25px; }
.login-card > p { color: var(--muted); margin-bottom: 24px; }

@media (max-width: 1050px) {
  .cards.four { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid .wide { grid-column: span 2; }
}
@media (max-width: 760px) {
  .sidebar { position: static; width: auto; min-height: auto; }
  .sidebar nav { grid-template-columns: repeat(2, 1fr); margin-top: 20px; }
  .logout { margin-top: 16px; }
  .content { margin-left: 0; padding: 22px 16px 45px; }
  .grid.two, .cards.four, .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: span 1; }
  .status-strip, .topbar { align-items: flex-start; flex-direction: column; }
}

