:root {
  --bg: #0d1412;
  --surface: #131d1a;
  --surface-2: #192622;
  --surface-3: #20302b;
  --border: #2a3b35;
  --border-soft: #21312c;
  --text: #eff7f3;
  --muted: #9bb0a8;
  --faint: #71867e;
  --primary: #5ee0b7;
  --primary-strong: #2fc897;
  --primary-dark: #103d31;
  --blue: #73b7ff;
  --warning: #f5bc62;
  --danger: #ff8178;
  --radius: 18px;
  --shadow: 0 22px 70px rgba(0, 0, 0, .26);
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 0%, rgba(51, 173, 137, .08), transparent 28rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 76px;
  padding: 0 max(24px, calc((100vw - 1280px) / 2));
  border-bottom: 1px solid rgba(81, 111, 101, .28);
  background: rgba(13, 20, 18, .9);
  backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark, .login-logo {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  color: #08241b;
  background: linear-gradient(135deg, #85f2cf, #32ca9a);
  font-weight: 900;
  box-shadow: 0 7px 24px rgba(65, 215, 169, .18);
}
.brand strong, .brand small { display: block; line-height: 1.1; }
.brand small { margin-top: 4px; color: var(--faint); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.main-nav { display: flex; align-items: center; gap: 7px; }
.main-nav > a, .nav-button {
  padding: 9px 12px;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 14px;
}
.main-nav > a:hover, .nav-button:hover { color: var(--text); background: var(--surface-2); }
.main-nav form { margin: 0; }

.page-shell { width: min(1280px, calc(100% - 48px)); margin: 0 auto; padding: 52px 0 80px; }
.hero-row, .detail-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; margin-bottom: 30px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(34px, 5vw, 54px); line-height: 1.06; letter-spacing: -.045em; }
h2 { margin-bottom: 0; font-size: 25px; letter-spacing: -.025em; }
h3 { letter-spacing: -.018em; }
.lead { max-width: 720px; margin-bottom: 0; color: var(--muted); font-size: 17px; }
.eyebrow { margin-bottom: 9px; color: var(--primary); font-size: 11px; font-weight: 800; letter-spacing: .14em; }
.muted { color: var(--muted); }
.hero-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.hero-actions form { margin: 0; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 17px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-weight: 750;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
.button:hover { transform: translateY(-1px); }
.button-primary { color: #06271d; background: var(--primary); }
.button-primary:hover { background: #83ebcc; }
.button-secondary { color: var(--text); border-color: var(--border); background: var(--surface-2); }
.button-secondary:hover { border-color: #456257; background: var(--surface-3); }
.button-danger-quiet { color: var(--danger); border-color: rgba(255, 129, 120, .25); background: rgba(255, 129, 120, .07); }
.button-small { min-height: 36px; padding: 0 12px; border-radius: 10px; font-size: 13px; }
.button-full { width: 100%; }
.button:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.search-bar {
  display: flex;
  align-items: center;
  gap: 13px;
  height: 56px;
  padding: 0 18px;
  margin-bottom: 40px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: rgba(20, 31, 27, .82);
}
.search-bar > span { color: var(--primary); font-size: 25px; }
.search-bar input { flex: 1; min-width: 0; border: 0; outline: 0; color: var(--text); background: transparent; }
.search-bar a { color: var(--primary); font-size: 13px; font-weight: 700; }

.alert-banner { display: flex; gap: 10px; padding: 14px 17px; margin: -20px 0 32px; border: 1px solid rgba(245, 188, 98, .25); border-radius: 12px; color: #f4d297; background: rgba(245, 188, 98, .08); }
.alert-banner span { color: var(--warning); }
.content-section { margin-top: 43px; }
.infra-section { padding-top: 42px; border-top: 1px solid var(--border-soft); }
.section-heading, .panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.section-heading .eyebrow, .panel-heading .eyebrow { margin-bottom: 4px; }
.count-pill { display: grid; place-items: center; min-width: 34px; height: 28px; padding: 0 10px; border: 1px solid var(--border); border-radius: 20px; color: var(--muted); background: var(--surface); font-size: 13px; }
.card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.project-card {
  display: flex;
  flex-direction: column;
  min-height: 232px;
  padding: 22px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: linear-gradient(150deg, rgba(27, 42, 37, .92), rgba(18, 28, 25, .92));
  box-shadow: 0 10px 40px rgba(0, 0, 0, .12);
  transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.project-card:hover { transform: translateY(-3px); border-color: #48675c; box-shadow: var(--shadow); }
.card-topline { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 21px; }
.card-icon, .detail-icon {
  display: grid;
  place-items: center;
  width: 43px;
  height: 43px;
  border: 1px solid rgba(94, 224, 183, .18);
  border-radius: 13px;
  color: var(--primary);
  background: var(--primary-dark);
  font-weight: 850;
}
.card-icon.subtle { color: var(--blue); border-color: rgba(115, 183, 255, .15); background: rgba(66, 122, 177, .12); }
.project-card h3 { margin-bottom: 7px; font-size: 20px; }
.project-card > p { flex: 1; margin-bottom: 22px; color: var(--muted); font-size: 14px; }
.card-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 16px; border-top: 1px solid var(--border-soft); color: var(--faint); font-size: 12px; }
.card-footer strong { color: var(--primary); font-size: 13px; }
.compact-card { min-height: 214px; }

.status { display: inline-flex; align-items: center; gap: 7px; width: fit-content; padding: 5px 9px; border: 1px solid var(--border); border-radius: 20px; color: var(--muted); background: rgba(255, 255, 255, .025); font-size: 11px; font-weight: 750; white-space: nowrap; }
.status i { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); box-shadow: 0 0 0 3px rgba(113, 134, 126, .1); }
.status-online { color: #91eacb; border-color: rgba(94, 224, 183, .2); background: rgba(94, 224, 183, .06); }
.status-online i, .status-bg-online { background: var(--primary) !important; }
.status-offline { color: #ff9e97; border-color: rgba(255, 129, 120, .2); background: rgba(255, 129, 120, .06); }
.status-offline i, .status-bg-offline { background: var(--danger) !important; }
.status-instavel, .status-unstable { color: #f3cd89; border-color: rgba(245, 188, 98, .2); background: rgba(245, 188, 98, .06); }
.status-instavel i, .status-unstable i, .status-bg-unstable { background: var(--warning) !important; }
.status-desenvolvimento { color: #9dc9f6; border-color: rgba(115, 183, 255, .2); }
.status-desenvolvimento i { background: var(--blue); }
.status-internal, .status-a_confirmar, .status-unknown { color: #a8b8b2; }

.flash-stack { position: fixed; z-index: 50; top: 90px; right: 24px; display: grid; gap: 8px; width: min(390px, calc(100vw - 48px)); }
.flash { padding: 13px 15px; border: 1px solid var(--border); border-radius: 12px; color: var(--text); background: #1b2925; box-shadow: var(--shadow); transition: opacity .3s, transform .3s; }
.flash-success { border-color: rgba(94, 224, 183, .35); }
.flash-error { border-color: rgba(255, 129, 120, .4); }
.flash-warning { border-color: rgba(245, 188, 98, .4); }
.flash-hide { opacity: 0; transform: translateY(-8px); pointer-events: none; }

.back-link { display: inline-flex; margin-bottom: 28px; color: var(--muted); font-size: 14px; }
.back-link:hover { color: var(--primary); }
.detail-header { align-items: center; padding-bottom: 30px; border-bottom: 1px solid var(--border-soft); }
.detail-title { display: flex; align-items: center; gap: 20px; }
.detail-title h1 { margin-bottom: 6px; font-size: clamp(32px, 4vw, 46px); }
.detail-icon { width: 64px; height: 64px; border-radius: 19px; font-size: 24px; }
.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; align-items: start; }
.detail-main, .detail-side { display: grid; gap: 18px; }
.detail-side { position: sticky; top: 96px; }
.panel-card { padding: 23px; border: 1px solid var(--border-soft); border-radius: var(--radius); background: rgba(19, 29, 26, .86); }
.panel-heading { margin-bottom: 17px; }
.link-list, .relation-list { display: grid; gap: 9px; }
.link-row { display: flex; align-items: center; gap: 13px; min-height: 76px; padding: 11px 13px; border: 1px solid var(--border-soft); border-radius: 13px; background: rgba(29, 43, 38, .55); }
.link-main { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.link-main > span:last-child { min-width: 0; }
.link-main small, .link-main strong, .link-main em { display: block; }
.link-main small { margin-bottom: 1px; color: var(--faint); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.link-main strong { font-size: 14px; }
.link-main em { overflow: hidden; color: var(--muted); font-size: 11px; font-style: normal; text-overflow: ellipsis; white-space: nowrap; }
.link-icon { display: grid; place-items: center; width: 37px; height: 37px; flex-shrink: 0; border-radius: 10px; color: var(--primary); background: var(--primary-dark); font-size: 17px; font-weight: 800; }
.link-status { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.link-status small { color: var(--faint); font-size: 9px; }
.row-actions { display: flex; gap: 3px; }
.row-actions form { margin: 0; }
.icon-button { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 8px; color: var(--muted); background: transparent; cursor: pointer; }
.icon-button:hover { color: var(--text); background: var(--surface-3); }
.icon-button.danger:hover { color: var(--danger); background: rgba(255, 129, 120, .08); }
.missing-link { min-height: 62px; border-style: dashed; color: var(--muted); }
.missing-link:hover { color: var(--text); border-color: #446257; }
.missing-link small, .missing-link strong { display: block; }
.missing-link small { color: var(--faint); font-size: 10px; }
.missing-link .link-icon { width: 34px; height: 34px; color: var(--muted); background: transparent; border: 1px dashed var(--border); }

.relation-row { position: relative; display: grid; grid-template-columns: auto auto 1fr auto; align-items: center; gap: 8px; padding: 13px; border: 1px solid var(--border-soft); border-radius: 12px; font-size: 13px; }
.relation-row > a { color: var(--primary); font-weight: 750; }
.relation-row p { grid-column: 1 / -1; margin: 3px 32px 0 0; color: var(--muted); font-size: 12px; }
.relation-source { font-weight: 750; }
.relation-verb { color: var(--faint); }
.relation-row.incoming { grid-template-columns: auto auto 1fr; opacity: .78; }
.inline-form-wrap { margin-top: 14px; }
.inline-form-wrap summary { color: var(--primary); cursor: pointer; font-size: 13px; font-weight: 750; }
.inline-form { display: grid; grid-template-columns: auto 150px 1fr 1.5fr auto; align-items: center; gap: 8px; padding-top: 13px; }
.inline-form label { color: var(--muted); font-size: 12px; }
.inline-form input, .inline-form select { height: 38px; }

.facts-card dl { margin: 0; }
.facts-card dl > div { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border-soft); }
.facts-card dl > div:last-child { border-bottom: 0; }
.facts-card dt { color: var(--muted); font-size: 12px; }
.facts-card dd { margin: 0; font-size: 13px; font-weight: 700; }
.notes-card > p:last-child { margin-bottom: 0; color: var(--muted); font-size: 13px; white-space: pre-line; }
.mini-checks { display: grid; gap: 12px; margin-top: 16px; }
.mini-checks > div { display: flex; align-items: center; gap: 10px; }
.mini-checks strong, .mini-checks small { display: block; }
.mini-checks strong { font-size: 12px; }
.mini-checks small { color: var(--faint); font-size: 10px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }

.form-page { display: grid; grid-template-columns: minmax(260px, .65fr) minmax(460px, 1fr); gap: 54px; align-items: start; }
.form-page h1 { font-size: clamp(32px, 4vw, 46px); }
.editor-card { display: grid; gap: 18px; padding: 27px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.field { display: grid; gap: 7px; }
.field label { color: #cfddd8; font-size: 12px; font-weight: 750; }
.field small { color: var(--faint); font-size: 11px; }
.two-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
input, select, textarea { width: 100%; border: 1px solid var(--border); border-radius: 11px; outline: 0; color: var(--text); background: #0f1815; }
input, select { height: 46px; padding: 0 13px; }
textarea { padding: 12px 13px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary-strong); box-shadow: 0 0 0 3px rgba(94, 224, 183, .08); }
input::placeholder, textarea::placeholder { color: #53665f; }
.check-field { display: flex; gap: 11px; padding: 14px; border: 1px solid var(--border-soft); border-radius: 12px; cursor: pointer; }
.check-field input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--primary); }
.check-field strong, .check-field small { display: block; }
.check-field strong { font-size: 13px; }
.check-field small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.advanced-fields summary { color: var(--muted); cursor: pointer; font-size: 12px; }
.advanced-fields .two-fields { padding-top: 13px; }
.form-actions { display: flex; gap: 9px; padding-top: 6px; }

.login-page { display: grid; place-items: center; min-height: 100vh; background: radial-gradient(circle at 50% 20%, rgba(60, 198, 156, .13), transparent 32rem), var(--bg); }
.login-page .page-shell { width: min(450px, calc(100% - 36px)); padding: 40px 0; }
.login-card { padding: 38px; border: 1px solid var(--border); border-radius: 24px; background: rgba(19, 29, 26, .9); box-shadow: var(--shadow); }
.login-logo { width: 52px; height: 52px; margin-bottom: 27px; border-radius: 15px; font-size: 20px; }
.login-card h1 { margin-bottom: 14px; font-size: 38px; }
.form-stack { display: grid; gap: 10px; margin-top: 28px; }
.form-stack label { font-size: 12px; font-weight: 750; }
.form-stack input { height: 54px; text-align: center; font-size: 24px; letter-spacing: .22em; }
.form-stack .button { margin-top: 6px; }
.login-help { margin: 22px 0 0; color: var(--faint); font-size: 11px; text-align: center; }

.alerts-list, .trash-list { padding: 8px 22px; }
.alert-row, .trash-row { display: flex; align-items: center; gap: 15px; padding: 18px 2px; border-bottom: 1px solid var(--border-soft); }
.alert-row:last-child, .trash-row:last-child { border-bottom: 0; }
.alert-symbol { display: grid; place-items: center; width: 38px; height: 38px; flex-shrink: 0; border-radius: 50%; background: var(--surface-3); font-weight: 850; }
.alert-offline .alert-symbol { color: var(--danger); background: rgba(255, 129, 120, .1); }
.alert-recovered .alert-symbol { color: var(--primary); background: rgba(94, 224, 183, .1); }
.alert-row h3 { margin-bottom: 2px; font-size: 15px; }
.alert-row p { margin-bottom: 4px; color: var(--muted); font-size: 13px; }
.alert-row small { color: var(--faint); font-size: 10px; }
.trash-row { justify-content: space-between; }
.trash-row h3 { margin-bottom: 2px; }
.trash-row p { margin-bottom: 0; color: var(--faint); font-size: 12px; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.setting-card { display: flex; gap: 17px; min-height: 178px; }
.setting-icon { display: grid; place-items: center; width: 44px; height: 44px; flex-shrink: 0; border-radius: 12px; color: var(--primary); background: var(--primary-dark); font-size: 21px; }
.setting-card h2 { margin-bottom: 7px; font-size: 18px; }
.setting-card p { margin-bottom: 14px; color: var(--muted); font-size: 13px; }
.copilot-card h2 { margin-bottom: 8px; font-size: 19px; }
.setting-copy, .lead-small { color: var(--muted); font-size: 13px; }
.setting-note { display: block; margin-top: 9px; color: var(--faint); line-height: 1.45; }
.copilot-facts { margin: 16px 0; }
.copilot-facts div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border-soft); font-size: 12px; }
.copilot-facts dd { color: var(--muted); text-align: right; }
.stack-form { display: grid; gap: 12px; margin-top: 15px; }
.stack-form label, .credential-form label { display: grid; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 750; }
.stack-form input, .stack-form select, .credential-form input, .credential-form select { width: 100%; }
.compact-check { padding: 9px 0; }
.credentials-panel { margin-top: 22px; }
.credential-form { display: grid; grid-template-columns: 1.1fr .8fr 1.6fr auto; align-items: end; gap: 12px; margin-top: 20px; }
.credential-list { margin-top: 20px; }
.credential-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 0; border-top: 1px solid var(--border-soft); }
.credential-row span { display: grid; gap: 3px; }
.credential-row small { color: var(--faint); }
@media (max-width: 760px) { .credential-form { grid-template-columns: 1fr; } .credential-row { align-items: flex-start; flex-direction: column; } }
.setting-card form { margin-top: 13px; }
.empty-state { grid-column: 1 / -1; padding: 54px 24px; border: 1px dashed var(--border); border-radius: var(--radius); color: var(--muted); text-align: center; }
.empty-state h3 { margin-bottom: 5px; color: var(--text); }
.empty-state p { margin-bottom: 0; }
.empty-inline { padding: 20px; border: 1px dashed var(--border); border-radius: 12px; color: var(--muted); font-size: 13px; text-align: center; }
.launch-card { max-width: 720px; margin: 2rem auto; padding: clamp(1.5rem, 4vw, 3rem); }
.launch-card h1 { margin: .35rem 0 .75rem; }
.launch-button { margin: 1.25rem 0; }
.launch-url { overflow-wrap: anywhere; font-size: .9rem; }

@media (max-width: 980px) {
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-layout { grid-template-columns: 1fr; }
  .detail-side { position: static; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-page { grid-template-columns: 1fr; gap: 28px; }
  .inline-form { grid-template-columns: 1fr 1fr; }
  .inline-form label { grid-column: 1 / -1; }
  .inline-form input { grid-column: 1 / -1; }
}

@media (max-width: 720px) {
  .topbar { position: static; height: auto; padding: 15px 18px; align-items: flex-start; }
  .brand small { display: none; }
  .main-nav { max-width: 70%; flex-wrap: wrap; justify-content: flex-end; gap: 1px; }
  .main-nav > a, .nav-button { padding: 6px 7px; font-size: 11px; }
  .page-shell { width: min(100% - 28px, 1280px); padding: 34px 0 60px; }
  .hero-row, .detail-header { align-items: flex-start; flex-direction: column; }
  .hero-actions { width: 100%; flex-wrap: wrap; }
  .hero-actions .button { flex: 1; }
  .card-grid, .settings-grid { grid-template-columns: 1fr; }
  .project-card { min-height: 205px; }
  .detail-title { align-items: flex-start; }
  .detail-icon { width: 50px; height: 50px; }
  .detail-side { grid-template-columns: 1fr; }
  .link-row { align-items: flex-start; flex-wrap: wrap; }
  .link-main { flex-basis: calc(100% - 45px); }
  .link-status { align-items: flex-start; margin-left: 49px; }
  .row-actions { margin-left: auto; }
  .relation-row, .relation-row.incoming { grid-template-columns: 1fr; }
  .relation-row p { grid-column: 1; }
  .two-fields { grid-template-columns: 1fr; }
  .editor-card, .panel-card { padding: 19px; }
  .login-card { padding: 28px 23px; }
  .login-card h1 { font-size: 32px; }
  .flash-stack { top: 16px; right: 14px; width: calc(100vw - 28px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
