
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;450;500;550;600;650;700;750;800&display=swap');

:root {
    --bg: #f5f7f9;
    --card: #ffffff;
    --ink: #17252b;
    --muted: #71808b;
    --green: #177b65;
    --green-dark: #10624f;
    --line: #e5ebee;
    --red: #dc4651;
    --amber: #be801f;
    --blue: #48718b;

    --sidebar-bg: #111e23;
    --sidebar-hover: #1c3036;
    --sidebar-active: #203b39;
    --sidebar-text: #a9bac0;

    --radius: 14px;
    --shadow: 0 3px 18px rgba(17, 35, 43, .035);
    --sidebar-width: 252px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, -apple-system, BlinkMacSystemFont,
        "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
a,
input,
select,
textarea {
    -webkit-tap-highlight-color: transparent;
}

a {
    color: var(--green);
}

a:hover {
    color: var(--green-dark);
}

::selection {
    color: #113a2e;
    background: #d9eee5;
}

/* ======================================================
   ESTRUTURA PRINCIPAL
====================================================== */

.app-shell {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

.app-main {
    flex: 1;
    min-width: 0;
    min-height: 100vh;
    margin-left: var(--sidebar-width);
}

.wrap {
    width: 100%;
    max-width: 1650px;
    margin: 0 auto;
    padding: 30px 34px 65px;
}

.app-main > .wrap > h1:first-child {
    margin-bottom: 23px;
}

.app-main > .wrap > h1:first-child + .muted,
.app-main > .wrap > h1:first-child + p {
    margin-top: -13px;
    margin-bottom: 25px;
}

/* ======================================================
   MENU LATERAL
====================================================== */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 27px 14px 17px;
    z-index: 100;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #364a50 transparent;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 11px 35px;
    color: #fff;
    text-decoration: none;
}

.sidebar-brand:hover {
    color: #fff;
}

.brand-symbol {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    color: #fff;
    background: linear-gradient(145deg, #209b78, #0f6654);
    font-size: 22px;
    font-weight: 800;
    box-shadow: 0 6px 20px rgba(26, 146, 110, .2);
}

.brand-copy {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
}

.brand-copy strong {
    font-size: 16px;
    line-height: 1.35;
    letter-spacing: -.45px;
    font-weight: 750;
}

.brand-copy small {
    color: #879ba1;
    font-size: 10px;
    font-weight: 500;
}

.sidebar-section-label {
    padding: 0 16px;
    margin-bottom: 13px;
    color: #72878e;
    font-size: 10px;
    font-weight: 750;
    letter-spacing: 1.35px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 44px;
    padding: 10px 14px;
    text-decoration: none;
    color: var(--sidebar-text);
    font-size: 12.5px;
    font-weight: 550;
    line-height: 1.4;
    border-radius: 10px;
    border: 1px solid transparent;
    transition:
        background .15s ease,
        color .15s ease,
        border-color .15s ease;
}

.sidebar-link svg {
    display: block;
    flex: 0 0 19px;
    opacity: .85;
}

.sidebar-link:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.sidebar-link.is-active {
    background: var(--sidebar-active);
    color: #fff;
    border-color: rgba(78, 180, 139, .13);
}

.sidebar-link.is-active svg {
    color: #5bd0a7;
    opacity: 1;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 25px;
    border-top: 1px solid #26383e;
}

.sidebar-footer-label {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 0 14px 16px;
    color: #91a5ac;
    font-size: 11px;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    flex: 0 0 8px;
    border-radius: 50%;
    background: #36bb87;
    box-shadow: 0 0 0 3px rgba(54, 187, 135, .1);
}

.logout-link {
    color: #aab6bc;
}

/* ======================================================
   BARRA SUPERIOR
====================================================== */

.topbar {
    position: relative;
    min-height: 87px;
    padding: 18px 34px;
    background: #fff;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.topbar-heading {
    min-width: 0;
}

.topbar-eyebrow {
    color: #94a0a8;
    font-size: 10px;
    font-weight: 750;
    letter-spacing: 1.1px;
    margin-bottom: 2px;
}

.topbar-title {
    color: #1d2a30;
    font-size: 19px;
    font-weight: 750;
    letter-spacing: -.6px;
    line-height: 1.4;
}

.topbar-right {
    display: flex;
    align-items: center;
}

.topbar-indicator {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    background: #f5f8f7;
    border: 1px solid #e6eeeb;
    border-radius: 999px;
    padding: 9px 13px;
    color: #5b6b70;
    font-size: 11px;
    font-weight: 650;
    white-space: nowrap;
}

/* ======================================================
   TIPOGRAFIA
====================================================== */

h1,
h2,
h3,
h4 {
    color: #19272d;
    letter-spacing: -.55px;
    line-height: 1.3;
}

h1 {
    font-size: 25px;
    font-weight: 750;
    margin: 0 0 22px;
}

h2 {
    font-size: 18px;
    font-weight: 750;
    margin: 0 0 17px;
}

h3 {
    font-size: 15px;
    font-weight: 700;
    margin: 0 0 13px;
}

p {
    margin: 0 0 14px;
}

p:last-child {
    margin-bottom: 0;
}

.muted,
small {
    color: var(--muted);
}

small {
    font-size: 12px;
}

strong {
    font-weight: 700;
}

/* ======================================================
   CARDS E PAINÉIS
====================================================== */

.card {
    position: relative;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 21px;
    box-shadow: var(--shadow);
    min-width: 0;
}

.card > h2:first-child,
.card > h3:first-child {
    padding-bottom: 15px;
    margin-bottom: 20px;
    border-bottom: 1px solid #edf0f2;
}

.card > h2:first-child:last-child,
.card > h3:first-child:last-child {
    border-bottom: none;
}

.grid {
    display: grid;
    grid-template-columns: repeat(
        auto-fit,
        minmax(min(100%, 190px), 1fr)
    );
    gap: 17px;
    align-items: stretch;
}

.grid > .card {
    margin-bottom: 0;
}

.metric {
    position: relative;
}

.metric b {
    display: block;
    color: #192c33;
    font-size: clamp(23px, 2.2vw, 32px);
    font-weight: 800;
    letter-spacing: -1.3px;
    line-height: 1.25;
    margin-top: 8px;
    overflow-wrap: anywhere;
}

.metric small,
.metric .muted {
    font-size: 12px;
}

.grid + .card,
.grid + h2,
.grid + h3 {
    margin-top: 23px;
}

/* ======================================================
   FORMULÁRIOS
====================================================== */

label {
    display: block;
    margin: 14px 0 6px;
    color: #44565e;
    font-size: 12px;
    font-weight: 650;
}

input,
select,
textarea {
    display: block;
    width: 100%;
    max-width: 100%;
    min-height: 43px;
    padding: 10px 12px;
    color: #24333a;
    background: #fff;
    border: 1px solid #dce5e8;
    border-radius: 9px;
    outline: none;
    transition:
        border-color .16s ease,
        box-shadow .16s ease,
        background .16s ease;
}

input::placeholder,
textarea::placeholder {
    color: #a0abb1;
}

input:hover,
select:hover,
textarea:hover {
    border-color: #bfced1;
}

input:focus,
select:focus,
textarea:focus {
    border-color: #44a489;
    box-shadow: 0 0 0 3px rgba(36, 154, 116, .12);
}

input:disabled,
select:disabled,
textarea:disabled,
button:disabled {
    opacity: .6;
    cursor: not-allowed;
}

input[type="checkbox"],
input[type="radio"] {
    display: inline-block;
    width: 16px;
    height: 16px;
    min-height: 0;
    padding: 0;
    margin: 0 6px 0 0;
    vertical-align: middle;
    accent-color: var(--green);
    cursor: pointer;
}

input[type="color"] {
    padding: 4px;
    min-height: 38px;
    width: 65px;
}

input[type="hidden"] {
    display: none;
}

input[type="file"] {
    padding: 8px;
}

textarea {
    min-height: 105px;
    line-height: 1.65;
    resize: vertical;
}

select {
    cursor: pointer;
}

form {
    min-width: 0;
}

.card form + form {
    margin-top: 16px;
}

/* ======================================================
   BOTÕES
====================================================== */

button,
.button,
input[type="submit"],
input[type="button"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    max-width: 100%;
    min-height: 40px;
    padding: 10px 16px;
    border: 1px solid transparent;
    border-radius: 9px;
    background: var(--green);
    color: #fff;
    text-decoration: none;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.45;
    cursor: pointer;
    transition:
        background .15s ease,
        border-color .15s ease,
        box-shadow .15s ease,
        transform .15s ease;
}

button:hover,
.button:hover,
input[type="submit"]:hover,
input[type="button"]:hover {
    background: var(--green-dark);
    color: #fff;
    box-shadow: 0 3px 10px rgba(23, 123, 101, .12);
}

button:active,
.button:active {
    transform: translateY(1px);
}

.secondary,
button.secondary,
.button.secondary {
    background: #edf2f3;
    color: #36505a;
    border-color: #e4ebed;
}

.secondary:hover,
button.secondary:hover,
.button.secondary:hover {
    background: #e0e9eb;
    color: #263f47;
}

.danger,
button.danger,
.button.danger {
    background: #d94a54;
    color: #fff;
}

.danger:hover,
button.danger:hover,
.button.danger:hover {
    background: #bc343f;
    color: #fff;
}

.actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 9px;
}

.actions form,
.inline-form {
    margin: 0;
}

/* ======================================================
   FILTROS
====================================================== */

.filters {
    display: grid;
    grid-template-columns: repeat(
        auto-fit,
        minmax(min(100%, 160px), 1fr)
    );
    align-items: end;
    gap: 14px;
}

.filters label {
    margin-top: 0;
}

.filters button,
.filters .button {
    width: 100%;
}

/* ======================================================
   TABELAS
====================================================== */

.table {
    width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    border: 1px solid #e9eef0;
    border-radius: 11px;
    background: #fff;
    scrollbar-width: thin;
}

table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    font-size: 12.5px;
    line-height: 1.5;
}

th,
td {
    padding: 13px 15px;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid #edf1f3;
}

th {
    color: #77868e;
    background: #f9fbfc;
    font-size: 10.5px;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: .45px;
    white-space: nowrap;
}

td {
    color: #35464e;
    overflow-wrap: anywhere;
}

tbody tr {
    transition: background .12s ease;
}

tbody tr:hover {
    background: #fafcfb;
}

tbody tr:last-child td {
    border-bottom: 0;
}

td a {
    font-weight: 650;
    text-decoration: none;
}

td a:hover {
    text-decoration: underline;
}

td button,
td .button {
    min-height: 32px;
    padding: 7px 10px;
    font-size: 11px;
}

td input:not([type="checkbox"]):not([type="radio"]),
td select {
    min-width: 115px;
    min-height: 35px;
    padding: 7px 9px;
}

td form {
    margin: 0;
}

.table td {
    vertical-align: middle;
}

/* ======================================================
   INDICADORES E ALERTAS
====================================================== */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    max-width: 100%;
    padding: 5px 10px;
    border-radius: 999px;
    background: #eaf1f5;
    color: var(--blue);
    font-size: 10.5px;
    font-weight: 750;
    line-height: 1.4;
    white-space: normal;
}

.success,
.badge.success {
    background: #e5f5ee;
    color: #16805d;
}

.error,
.failed,
.badge.error,
.badge.failed {
    background: #feebed;
    color: #b62e40;
}

.retry,
.badge.retry {
    background: #fff3df;
    color: #956316;
}

.notice {
    padding: 13px 17px;
    margin-bottom: 19px;
    border: 1px solid #c9e7d9;
    border-left: 3px solid #239e72;
    border-radius: 10px;
    background: #edf9f2;
    color: #216c50;
    font-size: 12.5px;
}

.notice.bad {
    background: #fff0f1;
    border-color: #f1c8ce;
    border-left-color: #d94a54;
    color: #aa3440;
}

/* ======================================================
   CÓDIGO E EDITOR DE PROMPTS
====================================================== */

.code {
    display: block;
    background: #f4f7f8;
    border: 1px solid #e9eef0;
    border-radius: 10px;
    color: #40525c;
    padding: 15px 17px;
    font-family: ui-monospace, SFMono-Regular,
        Menlo, Consolas, monospace;
    font-size: 11.5px;
    line-height: 1.8;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
    max-width: 100%;
    overflow-x: auto;
}

code,
pre {
    font-family: ui-monospace, SFMono-Regular,
        Menlo, Consolas, monospace;
}

pre {
    max-width: 100%;
    overflow-x: auto;
}

.prompt-editor {
    min-height: 440px;
    padding: 18px;
    background: #fcfdfd;
    border-color: #dce6e9;
    border-radius: 11px;
    font-family: ui-monospace, SFMono-Regular,
        Menlo, Consolas, monospace;
    font-size: 12.5px;
    line-height: 1.8;
    resize: vertical;
    tab-size: 4;
}

/* ======================================================
   EXECUÇÕES: LINHA DO TEMPO
====================================================== */

.trace-timeline {
    list-style: none;
    position: relative;
    margin: 0;
    padding: 0;
}

.trace-step {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 15px;
    margin: 0;
    padding: 15px 0;
    border-bottom: 1px solid #edf1f2;
    min-width: 0;
}

.trace-step:first-child {
    padding-top: 5px;
}

.trace-step:last-child {
    border-bottom: 0;
    padding-bottom: 5px;
}

.trace-step > *:last-child {
    flex: 1;
    min-width: 0;
}

.trace-step p {
    margin: 5px 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    color: #45565e;
    font-size: 12px;
}

.trace-step small {
    color: #7e8e94;
    font-size: 11px;
}

.trace-marker {
    display: grid;
    place-items: center;
    align-self: flex-start;
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    border-radius: 11px;
    background: #edf3f2;
    border: 1px solid #e1eae8;
    color: #3b7264;
    font-size: 12px;
    font-weight: 800;
}

.inline-form {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 9px;
}

.inline-form select {
    min-width: 160px;
    width: auto;
}

.inline-form input:not([type="checkbox"]) {
    width: auto;
    min-width: 130px;
}

/* ======================================================
   LOGIN
====================================================== */

.guest-body {
    min-height: 100vh;
    background:
        radial-gradient(
            circle at 12% 15%,
            rgba(29, 143, 108, .075),
            transparent 35%
        ),
        #f5f7f9;
}

.guest-body .app-main {
    margin-left: 0;
}

.guest-body .wrap {
    max-width: 1100px;
}

.login {
    width: min(100%, 440px);
    max-width: 440px;
    margin: max(35px, 9vh) auto;
    padding: 31px;
    border: 1px solid #e8edef;
    border-radius: 17px;
    background: #fff;
    box-shadow: 0 14px 50px rgba(21, 43, 49, .055);
}

.login h1,
.login h2 {
    text-align: center;
}

.login button[type="submit"],
.login input[type="submit"] {
    width: 100%;
    margin-top: 13px;
}

/* ======================================================
   COMPATIBILIDADE COM ELEMENTOS EXISTENTES
====================================================== */

hr {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 22px 0;
}

details {
    margin: 8px 0;
}

summary {
    cursor: pointer;
    color: #324b55;
    font-weight: 650;
}

blockquote {
    margin: 15px 0;
    padding: 12px 16px;
    border-left: 3px solid var(--green);
    background: #f6faf8;
    color: #42565d;
}

fieldset {
    min-width: 0;
    padding: 17px;
    border: 1px solid var(--line);
    border-radius: 11px;
}

legend {
    padding: 0 7px;
    color: #52646d;
    font-size: 12px;
    font-weight: 700;
}

img {
    max-width: 100%;
}

a:focus-visible,
button:focus-visible,
.button:focus-visible {
    outline: 3px solid rgba(41, 153, 117, .35);
    outline-offset: 2px;
}

/* ======================================================
   TELAS MENORES
====================================================== */

@media (max-width: 1200px) {
    :root {
        --sidebar-width: 225px;
    }

    .wrap {
        padding: 25px 23px 50px;
    }

    .topbar {
        padding: 17px 23px;
    }

    .card {
        padding: 20px;
    }

    th,
    td {
        padding: 12px;
    }
}

@media (max-width: 850px) {
    :root {
        --sidebar-width: 0px;
    }

    .app-shell {
        display: block;
    }

    .sidebar {
        position: relative;
        top: auto;
        left: auto;
        bottom: auto;
        width: 100%;
        padding: 13px 15px 12px;
        overflow: visible;
    }

    .sidebar-brand {
        padding: 3px 4px 14px;
    }

    .brand-symbol {
        width: 35px;
        height: 35px;
        flex-basis: 35px;
        border-radius: 10px;
        font-size: 19px;
    }

    .brand-copy strong {
        font-size: 14px;
    }

    .sidebar-section-label,
    .sidebar-footer {
        display: none;
    }

    .sidebar-nav {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 5px;
        scrollbar-width: none;
        padding-bottom: 3px;
    }

    .sidebar-nav::-webkit-scrollbar {
        display: none;
    }

    .sidebar-link {
        width: auto;
        min-height: 37px;
        padding: 8px 12px;
        white-space: nowrap;
        flex: 0 0 auto;
        font-size: 11.5px;
    }

    .sidebar-link svg {
        width: 16px;
        height: 16px;
        flex-basis: 16px;
    }

    .app-main {
        min-height: 0;
        margin-left: 0;
    }

    .topbar {
        min-height: 69px;
    }

    .topbar-title {
        font-size: 17px;
    }
}

@media (max-width: 600px) {
    body {
        font-size: 13px;
    }

    .wrap {
        padding: 19px 13px 38px;
    }

    .topbar {
        padding: 14px 16px;
        min-height: 65px;
    }

    .topbar-eyebrow {
        font-size: 9px;
    }

    .topbar-title {
        font-size: 16px;
    }

    .topbar-indicator {
        display: none;
    }

    .card {
        padding: 17px 15px;
        border-radius: 12px;
        margin-bottom: 15px;
    }

    .card > h2:first-child {
        margin-bottom: 16px;
    }

    .grid {
        gap: 11px;
    }

    .grid > .card {
        padding: 16px;
    }

    h1 {
        font-size: 21px;
    }

    h2 {
        font-size: 17px;
    }

    h3 {
        font-size: 14px;
    }

    .metric b {
        font-size: 25px;
    }

    th,
    td {
        padding: 10px 11px;
        font-size: 11.5px;
    }

    th {
        font-size: 10px;
    }

    .filters {
        gap: 11px;
    }

    .actions {
        gap: 7px;
    }

    .hide-mobile {
        display: none;
    }

    .prompt-editor {
        min-height: 340px;
        font-size: 12px;
    }

    .trace-step {
        gap: 10px;
    }

    .trace-marker {
        width: 29px;
        height: 29px;
        flex-basis: 29px;
    }

    .login {
        padding: 24px 18px;
        margin: 5vh auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
    }
}
