/* =====================================================
   TOKENS
===================================================== */
:root{
  --bg: #090C10;
  --surface: #0F141A;
  --surface-2: #141B22;
  --surface-3: #1B232C;
  --border: #1D262E;
  --border-strong: #2C3843;
  --text: #EEF3F6;
  --text-muted: #8E9CA8;
  --text-faint: #556069;

  --accent: #4C9FE0;
  --accent-strong: #82C6F5;
  --accent-soft: rgba(76,159,224,0.10);

  --gold: #C9A227;
  --gold-strong: #E7C765;
  --gold-soft: rgba(201,162,39,0.10);

  --good: #4CAF7D;
  --good-soft: rgba(76,175,125,0.12);
  --warn: #E0A64C;
  --warn-soft: rgba(224,166,76,0.12);
  --bad: #E2685A;
  --bad-soft: rgba(226,104,90,0.12);

  --font-ui: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;

  --radius: 7px;
  --radius-sm: 4px;
  --sidebar-w: 256px;
}

*{ box-sizing: border-box; }

html, body{
  margin:0; padding:0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body{
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse 900px 480px at 14% -8%, rgba(76,159,224,0.07), transparent 60%),
    radial-gradient(ellipse 700px 420px at 100% 0%, rgba(201,162,39,0.045), transparent 55%),
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: auto, auto, 46px 46px, 46px 46px;
  background-position: 0 0, 0 0, -1px -1px, -1px -1px;
  background-attachment: fixed;
  background-color: var(--bg);
}

a{ color: var(--accent-strong); }

::selection{ background: var(--accent-soft); color: var(--accent-strong); }

::-webkit-scrollbar{ width: 10px; height: 10px; }
::-webkit-scrollbar-track{ background: transparent; }
::-webkit-scrollbar-thumb{ background: var(--border-strong); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover{ background: var(--text-faint); }

:focus-visible{
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
  border-radius: 2px;
}

@media (prefers-reduced-motion: reduce){
  *{ animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* =====================================================
   LAYOUT
===================================================== */
.app{
  display:flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar{
  display:flex;
  align-items:center;
  gap: 18px;
  padding: 15px 28px;
  background: rgba(15,20,26,0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top:0;
  z-index: 20;
}

.signature-line{
  height: 2px;
  background: linear-gradient(90deg, transparent 2%, var(--accent) 30%, var(--gold) 68%, transparent 98%);
  opacity: 0.55;
}

.nav-toggle{
  display:none;
  flex-direction:column;
  justify-content:center;
  gap:4px;
  width:32px; height:32px;
  background:none;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor:pointer;
  padding: 8px;
}
.nav-toggle span{
  display:block;
  height:1px;
  background: var(--text-muted);
}

.brand-mark{
  width: 34px; height: 34px;
  flex-shrink: 0;
  display:flex; align-items:center; justify-content:center;
}
.brand-mark svg{ width: 100%; height:100%; fill:none; }
.brand-mark path{
  stroke: var(--accent-strong);
  stroke-width: 1.3;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.brand-mark circle{ fill: var(--gold); stroke: none; }

.org{ display:flex; flex-direction:column; gap:1px; margin-right: auto; }
.org input{
  background: none;
  border: none;
  border-bottom: 1px solid transparent;
  color: var(--text);
  font-family: var(--font-ui);
  padding: 2px 0;
}
.org-nome{ font-size: 17.5px; font-weight: 700; letter-spacing: -0.015em; }
.org-setor{ font-size: 12.5px; color: var(--text-muted); font-weight: 500; }
.org input:focus{ outline: none; border-bottom-color: var(--accent); }

.topbar-stats{ display:flex; align-items:center; gap: 26px; }
.stat{ display:flex; flex-direction:column; align-items:flex-end; gap: 3px; }
.stat-value{
  font-family: var(--font-mono);
  font-size: 19px;
  font-weight: 600;
  color: var(--accent-strong);
  letter-spacing: -0.01em;
}
.stat-label{ font-size: 10.5px; color: var(--text-faint); letter-spacing: 0.01em; }
.stat-input input{
  width: 62px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-mono);
  padding: 5px 8px;
  text-align: right;
}
.stat-input input:focus{ border-color: var(--accent); outline:none; }

.shell{
  display:flex;
  flex: 1;
  align-items: stretch;
}

/* ---------- Sidebar ---------- */
.sidebar{
  width: var(--sidebar-w);
  flex-shrink:0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display:flex;
  flex-direction:column;
  padding: 20px 14px;
  gap: 2px;
  position: sticky;
  top: 62px;
  height: calc(100vh - 62px);
}

.nav-item{
  display:flex;
  align-items:center;
  gap: 12px;
  background:none;
  border:none;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor:pointer;
  text-align:left;
  transition: background-color .15s ease, color .15s ease;
}
.nav-item svg{
  width:17px; height:17px;
  flex-shrink:0;
  fill:none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.85;
}
.nav-item:hover{ color: var(--text); background: var(--surface-2); }
.nav-item.is-active{
  color: var(--accent-strong);
  background: var(--accent-soft);
  box-shadow: inset 2px 0 0 var(--accent);
}

.sidebar-foot{
  margin-top: auto;
  display:flex;
  flex-direction:column;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.sidebar-credit{
  margin: 10px 2px 0;
  font-size: 10.5px;
  color: var(--text-faint);
  letter-spacing: 0.02em;
}

.ghost-btn{
  display:flex;
  align-items:center;
  justify-content:center;
  background: none;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 12.5px;
  font-weight: 600;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor:pointer;
  text-align:center;
  transition: border-color .15s ease, color .15s ease, background-color .15s ease;
}
.ghost-btn:hover{ color: var(--text); border-color: var(--accent); background: var(--surface-2); }
.file-btn{ position:relative; }

.ghost-btn-accent{ color: var(--gold-strong); border-color: rgba(201,162,39,0.4); }
.ghost-btn-accent:hover{ background: var(--gold-soft); border-color: var(--gold); color: var(--gold-strong); }

/* ---------- Content ---------- */
.content{
  flex:1;
  padding: 36px 44px 72px;
  max-width: 1100px;
  animation: rise .5s cubic-bezier(.2,.7,.3,1);
}

@keyframes rise{
  from{ opacity: 0; transform: translateY(8px); }
  to{ opacity: 1; transform: translateY(0); }
}

.panel{ display:none; }
.panel.is-active{ display:block; }

.panel-head{ margin-bottom: 26px; }
.panel-head h1{
  margin:0 0 7px;
  font-size: 28px;
  font-weight: 300;
  letter-spacing: -0.02em;
  color: var(--text);
}
.panel-head p{
  margin:0;
  color: var(--text-muted);
  font-size: 14.5px;
  max-width: 62ch;
  line-height: 1.55;
}

/* ---------- Cards / forms ---------- */
.card{
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.form-grid{
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px 20px;
}

.field{ display:flex; flex-direction:column; gap:7px; }
.field label{
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.field input, .field select{
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13.5px;
  padding: 10px 11px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus, .field select:focus{
  border-color: var(--accent);
  outline:none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field input::placeholder{ color: var(--text-faint); }

.field-submit{ align-self:flex-end; }

.primary-btn{
  background: linear-gradient(180deg, var(--accent-strong), var(--accent));
  border: 1px solid var(--accent);
  color: #071119;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 13.5px;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  cursor:pointer;
  width: 100%;
  transition: filter .15s ease, transform .1s ease;
}
.primary-btn:hover{ filter: brightness(1.08); }
.primary-btn:active{ transform: translateY(1px); }

/* ---------- Tables ---------- */
.table-wrap{ overflow-x:auto; }
table{
  width:100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
thead th{
  text-align:left;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-faint);
  padding: 0 12px 11px;
  border-bottom: 1px solid var(--border);
  white-space:nowrap;
}
tbody td{
  padding: 13px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: top;
}
tbody tr{ transition: background-color .12s ease; }
tbody tr:hover{ background: rgba(255,255,255,0.015); }
tbody tr:last-child td{ border-bottom:none; }
td.mono, .mono{ font-family: var(--font-mono); }
td.muted{ color: var(--text-muted); }

.row-delete{
  background:none;
  border: 1px solid var(--border-strong);
  color: var(--text-faint);
  border-radius: var(--radius-sm);
  width:26px; height:26px;
  line-height:1;
  cursor:pointer;
  font-size: 14px;
  transition: color .15s ease, border-color .15s ease;
}
.row-delete:hover{ color: var(--bad); border-color: var(--bad); background: var(--bad-soft); }

.empty-state{
  color: var(--text-faint);
  font-size: 13.5px;
  padding: 26px 4px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  text-align:center;
  display:none;
}
.empty-state.is-visible{ display:block; }
table.is-empty{ display:none; }

.tag{
  display:inline-block;
  padding: 3px 9px;
  border-radius: 3px;
  font-size: 11.5px;
  font-weight: 600;
  font-family: var(--font-mono);
}
.tag-servidor{ background: var(--accent-soft); color: var(--accent-strong); }
.tag-firewall{ background: var(--bad-soft); color: var(--bad); }
.tag-default{ background: var(--surface-3); color: var(--text-muted); border:1px solid var(--border-strong); }

/* ---------- Relatório ---------- */
.report-grid{
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 20px;
}
.report-metric{ margin-bottom:0; position:relative; overflow:hidden; }
.report-label{
  display:block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.report-value{
  display:block;
  font-family: var(--font-mono);
  font-size: 27px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  margin-bottom: 16px;
}
.gauge{
  height: 5px;
  background: var(--surface-3);
  border-radius: 3px;
  overflow:hidden;
}
.gauge-fill{
  height:100%;
  width:0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  transition: width .5s cubic-bezier(.2,.7,.3,1);
}
.gauge-fill.is-warn{ background: linear-gradient(90deg, var(--warn), #F0C27E); }
.gauge-fill.is-bad{ background: linear-gradient(90deg, var(--bad), #F09088); }

.parecer{
  border-left: 2px solid var(--gold);
  background: linear-gradient(180deg, var(--gold-soft), var(--surface));
}
.parecer .report-label{ color: var(--gold-strong); }
.parecer p{ margin: 0; font-size: 15px; line-height: 1.65; color: var(--text); }
.parecer.is-good{ border-left-color: var(--good); background: linear-gradient(180deg, var(--good-soft), var(--surface)); }
.parecer.is-good .report-label{ color: var(--good); }
.parecer.is-warn{ border-left-color: var(--warn); background: linear-gradient(180deg, var(--warn-soft), var(--surface)); }
.parecer.is-warn .report-label{ color: var(--warn); }

.summary-list{ display:flex; flex-direction:column; gap: 0; margin-top: 14px; }
.summary-row{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.summary-row:last-child{ border-bottom:none; }
.summary-row .count{ font-family: var(--font-mono); color: var(--accent-strong); font-weight:600; }

/* =====================================================
   RESPONSIVE
===================================================== */
@media (max-width: 900px){
  .content{ padding: 26px 22px 60px; }
  .form-grid{ grid-template-columns: repeat(2, 1fr); }
  .report-grid{ grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 720px){
  .nav-toggle{ display:flex; }
  .topbar{ padding: 12px 16px; gap: 12px; }
  .topbar-stats{ gap: 14px; }
  .brand-mark{ width: 28px; height: 28px; }

  .sidebar{
    position: fixed;
    top: 58px;
    left: 0;
    height: calc(100vh - 58px);
    transform: translateX(-100%);
    transition: transform .22s ease;
    z-index: 30;
    box-shadow: 24px 0 48px rgba(0,0,0,.45);
  }
  .sidebar.is-open{ transform: translateX(0); }

  .form-grid{ grid-template-columns: 1fr; }
  .report-grid{ grid-template-columns: 1fr; }
  .org-nome{ font-size: 15px; }
}

@media (max-width: 480px){
  .panel-head h1{ font-size: 22px; }
  .stat-label{ display:none; }
  thead th, tbody td{ padding: 9px 8px; }
}
