:root {
  --primary: #073eae;
  --primary-600: #062f85;
  --primary-050: #eaf0fb;
  --secondary: #00ddff;
  --secondary-ink: #063b57;
  --ink: #0d1b2a;
  --muted: #5b6b7d;
  --line: #e2e8f0;
  --bg: #f4f7fb;
  --white: #ffffff;
  --ok: #16a34a;
  --err: #dc2626;
  --warn: #b45309;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(7, 62, 174, 0.10);
  font-family: "Sora", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

* { box-sizing: border-box; }
/* Garante que o atributo `hidden` sempre esconda, mesmo em elementos com
   display definido por classe (.login-view, .app-view, .modal-backdrop). */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Sora", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; }
code {
  background: #eef2f7;
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 0.85em;
}

/* ---------- Buttons ---------- */
.btn {
  border: 0;
  border-radius: 10px;
  padding: 11px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform .05s ease, background .15s ease, box-shadow .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); }
.btn-primary:disabled { background: #9db4dd; cursor: not-allowed; }
.btn-ghost {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--line);
}
.btn-ghost:hover { border-color: var(--primary); }
.icon-btn {
  background: rgba(255,255,255,.14);
  border: 0;
  color: #fff;
  width: 38px; height: 38px;
  border-radius: 10px;
  font-size: 1.1rem;
  cursor: pointer;
}
.icon-btn:hover { background: rgba(255,255,255,.26); }
.link {
  background: none; border: 0; color: var(--primary);
  font-weight: 600; cursor: pointer; text-decoration: underline; padding: 0;
}

/* ---------- Login (split-screen) ---------- */
.login-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

/* painel esquerdo (marca) */
.login-left {
  position: relative;
  overflow: hidden;
  padding: 48px 56px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  color: #fff;
  background:
    radial-gradient(900px 500px at 15% 20%, rgba(0, 221, 255, 0.22), transparent 55%),
    linear-gradient(150deg, var(--primary) 0%, var(--primary-600) 100%);
}
.login-brand-logo {
  position: absolute;
  top: 40px;
  left: 56px;
  height: 34px;
}
.login-left-content { max-width: 460px; }
.login-left-content h1 {
  font-size: 2.6rem;
  line-height: 1.12;
  font-weight: 800;
  margin: 0 0 18px;
  letter-spacing: -0.5px;
}
.login-left-content p {
  font-size: 1.02rem;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.82);
  margin: 0;
  max-width: 420px;
}
.login-left-footer {
  position: absolute;
  bottom: 34px;
  left: 56px;
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.6);
}
.deco {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.02));
  pointer-events: none;
}
.deco-1 { width: 420px; height: 420px; right: -120px; bottom: -120px; }
.deco-2 { width: 260px; height: 260px; right: 60px; top: -80px; opacity: 0.6; }

/* painel direito (formulario) */
.login-right {
  display: grid;
  place-items: center;
  padding: 40px 24px;
  background: var(--white);
}
.login-form-wrap { width: 100%; max-width: 380px; }
.login-form-wrap h2 { font-size: 1.7rem; margin: 0 0 4px; color: var(--ink); }
.login-sub { color: var(--muted); margin: 0 0 28px; font-size: 0.95rem; }
#login-form { display: grid; gap: 16px; text-align: left; }
#login-form label { display: grid; gap: 7px; font-size: 0.82rem; font-weight: 600; color: var(--ink); }
#login-form input {
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 13px 14px;
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  width: 100%;
}
#login-form input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-050); }
.input-with-icon { position: relative; }
.input-with-icon input { padding-right: 44px; }
.eye-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: 0;
  cursor: pointer;
  font-size: 1.05rem;
  opacity: 0.6;
  padding: 6px 8px;
}
.eye-btn:hover { opacity: 1; }
.btn-block { width: 100%; margin-top: 6px; padding: 13px; }
.login-error { color: var(--err); font-size: 0.85rem; margin: 4px 0 0; }
.login-config-warning {
  color: var(--warn);
  font-size: 0.82rem;
  margin-top: 18px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  padding: 10px 12px;
  border-radius: 8px;
}
.login-version { text-align: center; color: var(--muted); font-size: 0.78rem; margin-top: 28px; }

@media (max-width: 820px) {
  .login-view { grid-template-columns: 1fr; }
  .login-left { display: none; }
}

/* ---------- App shell ---------- */
.app-header {
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-logo { height: 30px; }
.brand-title { font-weight: 700; font-size: 1.05rem; letter-spacing: .2px; }
.brand-tv { color: var(--secondary); font-weight: 600; }
.header-right { display: flex; align-items: center; gap: 12px; }
.user-email { font-size: .85rem; opacity: .9; }
.btn-ghost#btn-logout { color: #fff; border-color: rgba(255,255,255,.35); }
.btn-ghost#btn-logout:hover { border-color: #fff; background: rgba(255,255,255,.1); }

.tabs {
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 4px;
  padding: 0 18px;
  position: sticky; top: 0; z-index: 5;
}
.tab {
  background: none;
  border: 0;
  border-bottom: 3px solid transparent;
  padding: 15px 18px;
  font-size: .95rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.tab:hover { color: var(--primary); }
.tab.is-active { color: var(--primary); border-bottom-color: var(--secondary); }

.app-main { max-width: 1000px; margin: 0 auto; padding: 26px 20px 60px; }
.panel { display: none; }
.panel.is-active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.panel-head h2 { margin: 0 0 4px; font-size: 1.3rem; }
.panel-desc { color: var(--muted); margin: 0 0 20px; font-size: .92rem; line-height: 1.5; }

/* ---------- Dropzone ---------- */
.dropzone {
  border: 2px dashed #b9c7e0;
  border-radius: var(--radius);
  background: #fff;
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: var(--primary-050); }
.dropzone-icon { font-size: 2.4rem; }
.dropzone-inner p { margin: 8px 0 0; color: var(--ink); }
.dropzone-hint { color: var(--muted); font-size: .82rem; }

/* ---------- Tables ---------- */
.result-meta {
  display: flex; flex-wrap: wrap; gap: 10px 22px;
  margin: 4px 0 16px; font-size: .88rem; color: var(--muted);
}
.result-meta strong { color: var(--ink); }
.table-wrap { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow); background: #fff; }
.data-table { width: 100%; border-collapse: collapse; font-size: .92rem; min-width: 560px; }
.data-table th, .data-table td { padding: 13px 16px; text-align: left; }
.data-table thead th {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.data-table tbody tr { border-top: 1px solid var(--line); }
.data-table tbody tr:nth-child(odd) { background: #fafcff; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table tfoot th {
  border-top: 2px solid var(--line);
  background: #f2f6fd;
  font-size: .9rem;
}
.data-table input.cell-input {
  width: 130px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: .92rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.data-table input.cell-input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px var(--primary-050); }
.data-table input.cell-input.edited { border-color: var(--secondary); background: #ecfdff; }
.row-detail-btn { background: none; border: 0; color: var(--primary); cursor: pointer; font-size: .8rem; }
.detail-row td { background: #f7faff; padding: 0; }
.detail-inner { padding: 10px 16px; }
.detail-inner table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.detail-inner td { padding: 5px 8px; border-top: 1px dashed var(--line); }
.badge { display: inline-block; background: var(--primary-050); color: var(--primary); border-radius: 999px; padding: 2px 10px; font-size: .78rem; font-weight: 600; }

/* ---------- State boxes (loading / erro) ---------- */
.state-box {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 44px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.state-box p { margin: 0; color: var(--ink); }
.state-icon { font-size: 2rem; }
.state-msg { max-width: 480px; line-height: 1.5; }
.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--primary-050);
  border-top-color: var(--secondary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Actions / misc ---------- */
.actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 20px; }
.actions-start { justify-content: flex-start; align-items: center; }
.actions-center { justify-content: center; }
.muted { color: var(--muted); font-size: .88rem; }
.warn {
  margin-top: 14px; padding: 12px 16px; border-radius: 10px;
  background: #fff7ed; color: var(--warn); border: 1px solid #fed7aa; font-size: .86rem;
}

/* ---------- Histórico ---------- */
.hist-filters { display: flex; align-items: flex-end; gap: 14px; margin-bottom: 18px; }
.hist-filters label { display: grid; gap: 6px; font-size: .8rem; font-weight: 600; color: var(--muted); }
.hist-filters select { padding: 9px 12px; border: 1.5px solid var(--line); border-radius: 9px; font-family: inherit; }
.hist-list { display: grid; gap: 12px; }
.hist-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.hist-card summary {
  list-style: none; cursor: pointer; padding: 16px 18px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.hist-card summary::-webkit-details-marker { display: none; }
.hist-tipo { text-transform: capitalize; font-weight: 700; color: var(--primary); }
.hist-when { color: var(--muted); font-size: .84rem; }
.hist-user { margin-left: auto; font-size: .82rem; color: var(--muted); }
.hist-body { padding: 0 18px 18px; }
.hist-changes { margin-top: 10px; font-size: .84rem; }
.hist-changes .chg { color: var(--warn); }
.empty { color: var(--muted); text-align: center; padding: 40px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(7,20,50,.55);
  display: grid; place-items: center; z-index: 50; padding: 20px;
}
.modal { background: #fff; border-radius: 16px; padding: 26px; width: 100%; max-width: 460px; box-shadow: var(--shadow); }
.modal h3 { margin: 0 0 4px; }
.modal label { display: grid; gap: 6px; margin-top: 14px; font-size: .82rem; font-weight: 600; color: var(--muted); }
.modal input { border: 1.5px solid var(--line); border-radius: 10px; padding: 11px 13px; font-family: inherit; font-size: .92rem; }
.modal input:focus { border-color: var(--primary); outline: none; }

/* ---------- Toasts ---------- */
.toast-container { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 10px; z-index: 100; }
.toast {
  background: #fff; border-left: 5px solid var(--primary);
  border-radius: 10px; padding: 13px 18px; box-shadow: 0 12px 30px rgba(0,0,0,.15);
  font-size: .9rem; max-width: 360px; animation: slidein .2s ease;
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); }
.toast.warn { border-left-color: var(--warn); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (max-width: 640px) {
  .app-main { padding: 18px 12px 50px; }
  .user-email { display: none; }
  .brand-title { font-size: .95rem; }
}
