:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #edf3fc;
  background: #0b1018;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --surface: #111a27;
  --surface-raised: #172233;
  --border: #263449;
  --muted: #91a0b5;
  --blue: #78aefe;
  --blue-soft: #1c3656;
  --green: #64d5a5;
  /* Category colors */
  --cat-infra: #78aefe;
  --cat-ia: #c084fc; /* Inteligencia Artificial */
  --cat-intel: #f472b6; /* Inteligencia */
  --cat-docs: #34d399; /* Documentacao */
  --cat-mon: #fb923c; /* Monitoramento */
  --cat-media: #f87171; /* Media */
  --cat-prod: #60a5fa; /* Produtividade */
  --cat-home: #a3e635; /* Automacao Residencial */
  --cat-public: #fbbf24; /* Servicos Publicos */
  --cat-net: #22d3ee; /* Rede & Busca */
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(ellipse at 75% -18%, #1a2e47 0, transparent 38rem),
    #0b1018;
}

button, input, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}

.app-shell { width: min(1120px, calc(100% - 48px)); margin: 0 auto; padding-bottom: 5rem; }
.site-header { min-height: 86px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-bottom: 1px solid #ffffff0f; }
.brand { display: flex; align-items: center; gap: .75rem; color: inherit; text-decoration: none; }
.brand-mark { width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid #42628b; border-radius: 12px; color: #a7ccff; background: #1a2d45; font-size: 1.65rem; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: .96rem; letter-spacing: -.02em; }
.brand small { margin-top: .18rem; color: var(--muted); font-size: .76rem; }
.header-actions { display: flex; align-items: center; gap: .5rem; }
.header-actions form { margin: 0; }
.button { min-height: 38px; padding: .55rem .85rem; border: 1px solid var(--border); border-radius: 8px; background: transparent; color: #cfdaea; cursor: pointer; font-size: .82rem; font-weight: 600; }
.button:hover, .icon-button:hover { border-color: #476080; background: #ffffff09; }
.button-primary { border-color: var(--blue); background: var(--blue); color: #071321; }
.button-primary:hover { background: #9ac3ff; }
.dashboard-content[hidden], .login-screen[hidden] { display: none; }
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.login-card { width: min(100%, 390px); padding: 2rem; border: 1px solid #263449; border-radius: 16px; background: linear-gradient(145deg, #141e2c, #101722); box-shadow: 0 1.5rem 5rem #0008; }
.login-mark { margin-bottom: 1.5rem; }
.login-card .eyebrow { margin-bottom: .45rem; }
.login-card h1 { margin-bottom: .5rem; font-size: 1.65rem; }
.login-copy { margin-bottom: 1.5rem; color: var(--muted); font-size: .86rem; }
.login-card label { display: block; margin: 1rem 0 .4rem; color: #cbd6e5; font-size: .8rem; }
.login-card input { width: 100%; padding: .75rem; border: 1px solid #34455d; border-radius: 8px; background: #0b121d; color: inherit; }
.login-submit { width: 100%; margin-top: 1.35rem; }
.login-error { margin: 1.1rem 0 0; color: #ff9a9a; font-size: .78rem; line-height: 1.5; }

.tabs { display: flex; align-items: center; gap: .35rem; min-height: 58px; overflow-x: auto; border-bottom: 1px solid #ffffff0f; }
.tab { position: relative; flex: 0 0 auto; min-height: 58px; padding: 0 .95rem; border: 0; background: transparent; color: #93a2b7; cursor: pointer; font-size: .86rem; }
.tab:hover { color: #e6eefb; }
.tab.is-active { color: #eaf2ff; }
.tab.is-active::after { position: absolute; right: .85rem; bottom: -1px; left: .85rem; height: 2px; background: var(--blue); content: ""; }

.tab-panel { padding-top: 2.3rem; }
.tab-panel[hidden] { display: none; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.65rem; }
.eyebrow { margin: 0 0 .4rem; color: #83aee6; font-size: .67rem; font-weight: 750; letter-spacing: .14em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.7rem, 3vw, 2.25rem); letter-spacing: -.045em; }
.status-chip { display: inline-flex; align-items: center; gap: .48rem; margin-bottom: .15rem; padding: .42rem .68rem; border: 1px solid #27443f; border-radius: 99px; background: #10251f; color: #a7d8c6; font-size: .72rem; white-space: nowrap; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px #64d5a577; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 1.4rem 0 1.2rem; }
.search-box { display: flex; align-items: center; gap: .6rem; width: min(100%, 340px); min-height: 42px; padding: 0 .75rem; border: 1px solid var(--border); border-radius: 9px; background: #101824; color: var(--muted); }
.search-icon { font-size: 1.35rem; line-height: 1; }
.search-box input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: #edf3fc; font-size: .83rem; }
.search-box input::placeholder { color: #75849a; }
kbd { padding: .12rem .38rem; border: 1px solid #344256; border-radius: 4px; color: #8190a4; font: .67rem ui-monospace, monospace; }
.filter-pills { display: flex; flex-wrap: wrap; justify-content: end; gap: .4rem; }
.filter-pill { padding: .42rem .72rem; border: 1px solid transparent; border-radius: 99px; background: transparent; color: #98a7bb; cursor: pointer; font-size: .76rem; white-space: nowrap; }
.filter-pill:hover { color: #e4ecf7; background: #ffffff08; }
.filter-pill.is-selected { border-color: #345477; background: #172a41; color: #b7d5ff; }

.shortcut-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .8rem; }
.service-card { position: relative; display: flex; align-items: flex-start; gap: .9rem; min-height: 126px; padding: 1rem; overflow: hidden; border: 1px solid var(--border); border-radius: 11px; background: linear-gradient(145deg, #141e2c, #101722); color: inherit; text-decoration: none; transition: border-color .16s ease, transform .16s ease, background .16s ease; }
.service-card:hover { transform: translateY(-2px); border-color: var(--card-border-color, #466383); background: var(--card-hover-bg, #172333); }
.service-card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--card-accent, var(--blue)); border-radius: 11px 11px 0 0; }
.service-icon { flex: 0 0 42px; width: 42px; height: 42px; display: grid; place-items: center; overflow: hidden; border: 1px solid #32445c; border-radius: 10px; background: #1a293b; color: #c4dcff; font-size: 1.23rem; }
.service-icon img { width: 100%; height: 100%; object-fit: cover; }
.service-card-content { min-width: 0; padding-top: .12rem; }
.service-name { display: block; overflow: hidden; color: #e7eef9; font-size: .89rem; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.service-description { display: block; margin-top: .35rem; color: #91a0b5; font-size: .75rem; line-height: 1.4; }
.service-group { display: inline-flex; align-items: center; gap: .35rem; margin-top: .65rem; color: #86abd7; font-size: .66rem; }
.service-group::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--group-color, var(--blue)); flex-shrink: 0; }
.service-status { position: absolute; top: .9rem; right: 2.5rem; width: 8px; height: 8px; border-radius: 50%; background: var(--status-color, var(--muted)); box-shadow: 0 0 6px var(--status-glow, transparent); }
.service-status.up { --status-color: #64d5a5; --status-glow: #64d5a588; }
.service-status.down { --status-color: #f87171; --status-glow: #f8717188; }
.service-status.unknown { --status-color: #fbbf24; --status-glow: #fbbf2488; }
.external-mark { position: absolute; top: .9rem; right: .9rem; color: #73859c; font-size: .78rem; }
.empty-state { padding: 2rem 0; color: var(--muted); text-align: center; }
.notice { margin-top: 1rem; padding: .8rem 1rem; border: 1px solid #584b32; border-radius: 8px; background: #241e13; color: #f0d7a2; font-size: .82rem; line-height: 1.5; }
.notice[hidden] { display: none; }

.iframe-panel { min-height: 72vh; padding-top: 1.3rem; }
.iframe-panel[hidden] { display: none; }
.iframe-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .8rem; }
.iframe-heading h1 { font-size: 1.3rem; }
.iframe-link { color: #9ac3ff; font-size: .8rem; }
.iframe-help { margin-bottom: .8rem; color: #aab8ca; font-size: .78rem; line-height: 1.5; }
.iframe-frame { display: block; width: 100%; height: min(72vh, 780px); min-height: 480px; border: 1px solid var(--border); border-radius: 10px; background: #090e15; }
.iframe-placeholder { display: grid; min-height: 480px; place-items: center; border: 1px dashed #34445a; border-radius: 10px; color: var(--muted); text-align: center; }

.chat-toggle { position: fixed; z-index: 20; right: max(24px, calc((100vw - 1120px) / 2)); bottom: 22px; display: flex; align-items: center; gap: .55rem; min-height: 48px; padding: 0 1rem; border: 1px solid #86b8ff; border-radius: 99px; background: #78aefe; box-shadow: 0 8px 30px #0008; color: #081321; cursor: pointer; font-size: .82rem; font-weight: 750; }
.chat-toggle:hover { background: #a0c8ff; }
.chat-toggle-icon { font-size: 1rem; }
.chat-panel { position: fixed; z-index: 21; right: max(24px, calc((100vw - 1120px) / 2)); bottom: 82px; display: flex; width: min(390px, calc(100vw - 32px)); height: min(570px, calc(100vh - 112px)); flex-direction: column; overflow: hidden; border: 1px solid #33465e; border-radius: 15px; background: #101824; box-shadow: 0 18px 70px #000b; }
.chat-panel[hidden] { display: none; }
.chat-header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1rem .75rem; border-bottom: 1px solid #ffffff10; }
.chat-header .eyebrow { margin-bottom: .2rem; }
.chat-header h2 { margin: 0; font-size: .98rem; letter-spacing: -.02em; }
.chat-header-actions { display: flex; gap: .25rem; }
.icon-button { width: 34px; height: 34px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: #a9b7c9; cursor: pointer; font-size: 1.25rem; }
.chat-messages { display: flex; flex: 1; flex-direction: column; gap: .8rem; padding: 1rem; overflow-y: auto; }
.chat-welcome { max-width: 90%; margin: auto; color: #91a0b5; font-size: .82rem; line-height: 1.55; text-align: center; }
.chat-message { max-width: 90%; padding: .68rem .78rem; border: 1px solid #29384b; border-radius: 10px; color: #d8e2f0; font-size: .81rem; line-height: 1.5; overflow-wrap: anywhere; white-space: pre-wrap; }
.chat-message.user { align-self: flex-end; border-color: #31527a; background: #1b3049; }
.chat-message.assistant { align-self: flex-start; background: #151f2c; }
.chat-message.pending { color: #93a3b8; }
.chat-error { margin: 0 1rem .6rem; color: #ff9a9a; font-size: .76rem; line-height: 1.45; }
.chat-error[hidden] { display: none; }
.chat-form { display: flex; align-items: end; gap: .5rem; margin: 0 .8rem; padding: .45rem; border: 1px solid #33445b; border-radius: 10px; background: #0c131d; }
.chat-form textarea { flex: 1; max-height: 120px; min-height: 36px; resize: vertical; padding: .55rem .45rem; border: 0; outline: 0; background: transparent; color: #edf3fc; font-size: .8rem; }
.chat-form textarea::placeholder { color: #77869a; }
.send-button { flex: 0 0 34px; width: 34px; height: 34px; border: 0; border-radius: 8px; background: var(--blue); color: #071321; cursor: pointer; font-size: 1.2rem; font-weight: 700; }
.send-button:disabled { cursor: wait; opacity: .55; }
.chat-footnote { margin: .55rem 1rem .8rem; color: #77869a; font-size: .65rem; }

.config-dialog { width: min(780px, calc(100% - 28px)); max-height: min(88vh, 900px); padding: 1.4rem; border: 1px solid #34465d; border-radius: 14px; background: #111a27; color: #edf3fc; box-shadow: 0 20px 80px #000b; }
.config-dialog::backdrop { background: #05080dcc; backdrop-filter: blur(4px); }
.dialog-close-form { position: absolute; top: .75rem; right: .75rem; }
.dialog-heading { padding-right: 2.8rem; }
.dialog-heading h2 { margin: 0 0 .3rem; font-size: 1.3rem; }
.dialog-heading > p:last-child { color: var(--muted); font-size: .8rem; }
.config-editor { width: 100%; min-height: min(55vh, 500px); padding: .9rem; border: 1px solid #2c3d53; border-radius: 8px; background: #0a111a; color: #d3e2f4; font: .78rem/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; tab-size: 2; }
.config-message { min-height: 1.3rem; margin: .5rem 0; color: #a8c9f5; font-size: .78rem; }
.config-message.is-error { color: #ff9a9a; }
.dialog-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: end; gap: .5rem; }
.config-warning { margin: .9rem 0 0; color: #d9b986; font-size: .72rem; line-height: 1.5; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 760px) {
  .shortcut-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar { align-items: flex-start; flex-direction: column; }
  .search-box { width: 100%; }
  .filter-pills { justify-content: flex-start; }
}

@media (max-width: 520px) {
  .app-shell { width: min(100% - 28px, 1120px); }
  .site-header { min-height: 72px; }
  .brand-mark { width: 36px; height: 36px; }
  .brand strong { font-size: .84rem; }
  .brand small { font-size: .68rem; }
  .header-actions { gap: .2rem; }
  .button { min-height: 35px; padding: .45rem .58rem; font-size: .72rem; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .shortcut-grid { grid-template-columns: 1fr; }
  .service-card { min-height: 110px; }
  .chat-toggle { right: 14px; bottom: 14px; }
  .chat-panel { right: 10px; bottom: 72px; width: calc(100vw - 20px); }
  .iframe-frame { min-height: 55vh; }
  .dialog-actions { justify-content: flex-start; }
}