:root {
  --ink: #14221f;
  --ink-soft: #243633;
  --paper: #f3efe6;
  --card: #fffdf8;
  --line: #e4d9c8;
  --accent: #0f6e6b;
  --accent-ink: #083f3d;
  --ok: #1f7a4d;
  --warn: #8a5a12;
  --danger: #8d2b2b;
  --muted: #66716d;
  --shadow: 0 12px 30px rgba(20, 34, 31, 0.08);
  --side-w: 250px;
  font-family: "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(15, 110, 107, 0.16), transparent 32%),
    linear-gradient(160deg, #efe7d8, var(--paper) 42%);
}

.login-card, .card, .table-wrap, .panel, .filters {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.login-card { width: min(440px, 100%); padding: 32px; }
.eyebrow { margin: 0 0 8px; color: var(--accent); font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase; }
h1, h2, h3 { margin: 0; font-weight: 650; }
h1 { font-size: 1.8rem; line-height: 1.15; }
.lede { color: var(--muted); margin: 12px 0 24px; }

.shell { min-height: 100vh; display: grid; grid-template-columns: var(--side-w) 1fr; }
.side {
  background: var(--ink);
  color: #f6f1e8;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}
.brand small { display: block; color: #b7c7c3; margin-top: 4px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav button, .ghost, .primary, .danger, .icon-btn {
  border: 0;
  border-radius: 10px;
}
.nav button {
  text-align: left;
  background: transparent;
  color: #f6f1e8;
  padding: 10px 12px;
}
.nav button.active, .nav button:hover { background: rgba(255, 255, 255, 0.08); }
.side .ghost { margin-top: auto; background: transparent; color: #f6f1e8; border: 1px solid rgba(255,255,255,0.2); padding: 10px 12px; }
.main { padding: 28px; min-width: 0; }
.topbar-mobile {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -8px 0 16px;
}
.icon-btn {
  background: var(--ink);
  color: #fff;
  padding: 10px 12px;
  min-width: 44px;
}
.scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20, 34, 31, 0.45);
  z-index: 20;
}
.scrim.open { display: block; }

.top { display: flex; justify-content: space-between; gap: 16px; align-items: end; margin-bottom: 18px; flex-wrap: wrap; }
.who { color: var(--muted); font-size: 0.92rem; margin: 6px 0 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 12px; }
.stat { padding: 16px; }
.stat span { display: block; color: var(--muted); font-size: 0.85rem; }
.stat strong { font-size: 1.7rem; }
.stack { display: grid; gap: 14px; }
.card, .panel, .filters { padding: 16px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
label { display: grid; gap: 6px; font-size: 0.86rem; color: var(--ink-soft); min-width: 0; }
input, select, textarea {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
  min-width: 0;
}
.row > label { flex: 1 1 160px; }
.filters .row > label { flex: 1 1 140px; }
textarea { min-height: 72px; resize: vertical; }
.primary { background: var(--accent); color: white; padding: 10px 14px; }
.primary:hover { background: var(--accent-ink); }
.danger { background: transparent; color: var(--danger); border: 1px solid #eccfcf; padding: 8px 10px; }
.ghost { background: transparent; border: 1px solid var(--line); padding: 8px 10px; }
.table-wrap { overflow: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; min-width: 520px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.78rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.badge { display: inline-flex; border-radius: 999px; padding: 3px 8px; font-size: 0.75rem; background: #eee7dc; white-space: nowrap; }
.badge.ok { background: #e5f4ec; color: var(--ok); }
.badge.warn { background: #fff1d6; color: var(--warn); }
.badge.danger { background: #fde8e8; color: var(--danger); }
.error, .flash { padding: 10px 12px; border-radius: 10px; }
.error { background: #fde8e8; color: var(--danger); }
.flash { background: #e7f5f4; color: var(--accent-ink); margin-bottom: 14px; }
.checks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: 8px;
}
.check-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-size: 0.9rem;
  line-height: 1.35;
}
.check-item input {
  width: 18px;
  height: 18px;
  min-width: 18px;
  margin-top: 2px;
  flex: 0 0 auto;
  accent-color: var(--accent);
}
.check-item span { min-width: 0; word-break: break-word; }
.muted { color: var(--muted); }
.linkish { background: none; border: 0; color: var(--accent); padding: 0; text-decoration: underline; }
.click-row { cursor: pointer; }
.click-row:hover { background: rgba(15, 110, 107, 0.05); }
.drawer {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: end center;
  background: rgba(20, 34, 31, 0.45);
  padding: 16px;
}
.drawer-card {
  width: min(560px, 100%);
  max-height: min(92vh, 900px);
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 18px;
}
.drawer-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 14px;
}
.list-cards { display: grid; gap: 10px; }
.item-card {
  display: grid;
  gap: 10px;
  padding: 14px;
}
.item-card .meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #efe7dc;
  font-size: 0.82rem;
}
.section-title { font-size: 1rem; margin-bottom: 4px; }
.integracao-erp, .instrucoes-erp { margin-top: 16px; }
.chave-selecionada { outline: 2px solid var(--accent); }
.chave-revogada { background: #f4f1eb; color: var(--muted); }
.badge.revogada { background: #e4e0d8; color: #5c6562; }
.mono { font-family: Consolas, "Cascadia Mono", ui-monospace, monospace; word-break: break-all; }
.secret-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.secret-row .mono { flex: 1 1 180px; }
.back-link { margin-bottom: 8px; }
.empty { color: var(--muted); padding: 18px; text-align: center; }
.split-2 { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 12px; align-items: start; }
.resource-list { display: grid; gap: 8px; }
.resource-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.resource-row input { width: 18px; height: 18px; min-width: 18px; margin-top: 2px; }
.resource-row .copy { min-width: 0; }
.resource-row small { display: block; color: var(--muted); margin-top: 2px; word-break: break-all; }

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .topbar-mobile { display: flex; }
  .side {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(280px, 86vw);
    z-index: 30;
    transform: translateX(-105%);
    transition: transform .2s ease;
    height: 100vh;
  }
  .side.open { transform: translateX(0); }
  .main { padding: 16px; }
  .split-2 { grid-template-columns: 1fr; }
  table { min-width: 480px; }
  .drawer { place-items: end stretch; padding: 0; }
  .drawer-card {
    width: 100%;
    max-height: 92vh;
    border-radius: 18px 18px 0 0;
  }
}

@media (max-width: 560px) {
  .row { align-items: stretch; }
  .row > label { flex: 1 1 100%; }
  .actions, .top .actions { width: 100%; }
  .actions > * { flex: 1 1 auto; }
  .primary, .ghost, .danger { width: 100%; }
  .nav { display: flex; flex-direction: column; }
}
