:root {
    --bg: #f4f7f4;
    --panel: #ffffff;
    --ink: #16202a;
    --muted: #66737f;
    --line: #dbe4df;
    --sidebar: #14242e;
    --sidebar-soft: #203542;
    --green: #16885f;
    --green-dark: #0f6f4d;
    --amber: #b7791f;
    --red: #b42318;
    --blue: #2563eb;
    --shadow: 0 18px 45px rgba(20, 36, 46, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 15px;
}

a {
    color: inherit;
    text-decoration: none;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
    background: var(--sidebar);
    color: #eef7f1;
    padding: 24px 18px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--green);
    color: #fff;
    font-weight: 800;
    letter-spacing: 0;
}

.brand strong,
.brand small {
    display: block;
}

.brand small {
    color: #a6bac6;
    margin-top: 3px;
}

.nav {
    display: grid;
    gap: 8px;
}

.nav-label {
    margin: 16px 10px 4px;
    color: #a6bac6;
    font-size: 12px;
    text-transform: uppercase;
}

.nav-link {
    min-height: 42px;
    display: flex;
    align-items: center;
    border-radius: 8px;
    padding: 0 12px;
    color: #dce9e2;
}

.nav-link:hover,
.nav-link.is-active {
    background: var(--sidebar-soft);
    color: #fff;
}

.nav-link.is-disabled {
    color: #7f94a1;
    cursor: not-allowed;
}

.main {
    padding: 28px;
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 24px;
}

.topbar h1,
.panel h2,
.login-copy h1,
.login-form h2 {
    margin: 0;
    letter-spacing: 0;
}

.topbar h1 {
    font-size: 28px;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--green-dark);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.userbox {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px 8px 14px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.userbox span,
.userbox small {
    display: block;
}

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

.button {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0 14px;
    background: #fff;
    color: var(--ink);
    font-weight: 700;
    cursor: pointer;
}

.button:hover {
    border-color: #b8c8bf;
}

.button-primary {
    background: var(--green);
    border-color: var(--green);
    color: #fff;
}

.button-primary:hover {
    background: var(--green-dark);
    border-color: var(--green-dark);
}

.button-secondary {
    background: #e8f4ef;
    color: var(--green-dark);
    border-color: #c9e2d6;
}

.button-ghost {
    background: transparent;
}

.button-small {
    min-height: 32px;
    padding: 0 10px;
    font-size: 13px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}

.stat-card,
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.stat-card {
    padding: 20px;
}

.stat-card span,
label span {
    display: block;
    color: var(--muted);
    font-size: 13px;
}

.stat-card strong {
    display: block;
    margin-top: 10px;
    font-size: 32px;
}

.section-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
    gap: 18px;
}

.section-grid-wide {
    grid-template-columns: 420px minmax(0, 1fr);
}

.panel {
    padding: 20px;
}

.panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.panel h2 {
    font-size: 20px;
}

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 13px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

td strong,
td small {
    display: block;
}

.empty {
    color: var(--muted);
    text-align: center;
}

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

.actions form {
    margin: 0;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    border-radius: 8px;
    padding: 0 9px;
    font-size: 12px;
    font-weight: 700;
}

.badge-success {
    background: #e6f7ee;
    color: #0f6f4d;
}

.badge-warning {
    background: #fff3d6;
    color: #8a5a12;
}

.badge-danger {
    background: #fee4e2;
    color: var(--red);
}

.badge-muted {
    background: #eef2f4;
    color: var(--muted);
}

.form-grid {
    display: grid;
    gap: 14px;
}

label {
    display: grid;
    gap: 7px;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #cdd8d1;
    border-radius: 8px;
    padding: 0 12px;
    background: #fff;
    color: var(--ink);
    font: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: 3px solid rgba(22, 136, 95, 0.18);
    border-color: var(--green);
}

input,
select {
    min-height: 42px;
}

textarea {
    min-height: 92px;
    padding-top: 10px;
    resize: vertical;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding-top: 4px;
}

.alert {
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 16px;
    border: 1px solid var(--line);
    background: #fff;
}

.alert-success {
    border-color: #adddc5;
    background: #edf9f2;
    color: #0f6f4d;
}

.alert-danger {
    border-color: #fecaca;
    background: #fff1f1;
    color: var(--red);
}

.alert-warning {
    border-color: #f8d889;
    background: #fff8e6;
    color: #8a5a12;
}

.roadmap {
    display: grid;
    gap: 14px;
    margin: 0;
    padding-left: 22px;
}

.roadmap li strong,
.roadmap li span {
    display: block;
}

.roadmap li span {
    color: var(--muted);
    margin-top: 3px;
}

.login-page {
    min-height: 100vh;
    background:
        linear-gradient(135deg, rgba(20, 36, 46, 0.96), rgba(15, 111, 77, 0.88)),
        #14242e;
}

.login-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-panel {
    width: min(980px, 100%);
    display: grid;
    grid-template-columns: minmax(0, 1fr) 410px;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.22);
}

.login-copy {
    min-height: 460px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 42px;
    background: #edf7f2;
}

.login-copy .brand-mark {
    margin-bottom: 28px;
}

.login-copy h1 {
    font-size: 44px;
    margin-bottom: 12px;
}

.login-copy p:last-child {
    max-width: 470px;
    color: #43515d;
    line-height: 1.6;
}

.login-form {
    display: grid;
    align-content: center;
    gap: 16px;
    padding: 42px;
}

.login-form h2 {
    font-size: 24px;
}

.login-form .button {
    width: 100%;
    margin-top: 4px;
}

.login-help {
    margin: 2px 0 0;
    color: var(--muted);
    text-align: center;
}

.login-help a {
    color: var(--green-dark);
    font-weight: 700;
}

.signup-panel {
    width: min(1040px, 100%);
    display: grid;
    gap: 22px;
    background: #fff;
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.22);
}

.signup-heading {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 28px;
    align-items: center;
    padding: 8px 8px 20px;
    border-bottom: 1px solid var(--line);
}

.signup-heading .brand {
    margin-bottom: 0;
    color: var(--ink);
}

.signup-heading h1 {
    margin: 0 0 8px;
    font-size: 30px;
    letter-spacing: 0;
}

.signup-heading p:last-child {
    margin: 0;
    color: var(--muted);
}

.signup-form {
    display: grid;
    gap: 16px;
}

.two-cols {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.full-field {
    width: 100%;
}

.success-box {
    display: grid;
    gap: 12px;
    padding: 24px;
    border: 1px solid #adddc5;
    border-radius: 8px;
    background: #edf9f2;
}

.success-box h2,
.success-box p {
    margin: 0;
}

.success-box .button {
    justify-self: flex-start;
    margin-top: 8px;
}

.filter-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.pill {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0 11px;
    color: var(--muted);
    font-weight: 700;
}

.pill.is-active {
    background: #e8f4ef;
    border-color: #c9e2d6;
    color: var(--green-dark);
}

.actions-stacked {
    align-items: flex-start;
    flex-direction: column;
}

.inline-details {
    width: 100%;
}

.inline-details summary {
    color: var(--muted);
    cursor: pointer;
    font-weight: 700;
}

.inline-details form {
    display: grid;
    gap: 8px;
    margin-top: 8px;
}

.note-row td {
    background: #fbfdfb;
    color: #43515d;
    font-size: 13px;
}

@media (max-width: 980px) {
    .app-shell,
    .section-grid,
    .section-grid-wide,
    .login-panel,
    .signup-heading,
    .two-cols {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
    }

    .nav {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .main {
        padding: 18px;
    }

    .topbar,
    .userbox,
    .panel-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .stats-grid,
    .nav {
        grid-template-columns: 1fr;
    }

    .login-copy,
    .login-form {
        padding: 26px;
    }

    .login-copy {
        min-height: auto;
    }

    .login-copy h1 {
        font-size: 34px;
    }
}

@media (max-width: 760px) {
    .table-wrap {
        overflow-x: visible;
    }

    table,
    thead,
    tbody,
    tr,
    th,
    td {
        display: block;
    }

    thead {
        display: none;
    }

    tbody tr {
        margin-bottom: 12px;
        border: 1px solid var(--line);
        border-radius: 8px;
        padding: 10px 12px;
        background: #fff;
    }

    tbody tr.note-row {
        margin-top: -12px;
        border-top: 0;
        background: #fbfdfb;
    }

    th,
    td {
        border-bottom: 0;
    }

    td {
        display: grid;
        grid-template-columns: minmax(98px, 34%) minmax(0, 1fr);
        gap: 10px;
        padding: 9px 0;
    }

    td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 12px;
        font-weight: 700;
        text-transform: uppercase;
    }

    td.empty {
        display: block;
        text-align: left;
    }

    td.empty::before {
        content: '';
    }

    td.actions,
    .actions {
        align-items: stretch;
        flex-direction: column;
    }

    td.actions::before {
        align-self: flex-start;
    }

    .actions .button,
    .actions form,
    .actions button,
    .inline-details,
    .inline-details form {
        width: 100%;
    }

    .filter-pills,
    .form-actions {
        width: 100%;
    }

    .filter-pills .pill,
    .form-actions .button {
        flex: 1 1 160px;
    }
}

.signup-page {
    min-height: 100vh;
    background:
        linear-gradient(135deg, #0d2f33 0%, #135642 48%, #f4f7f4 48%, #f4f7f4 100%);
    color: var(--ink);
}

.signup-shell {
    width: min(1180px, calc(100% - 32px));
    min-height: calc(100vh - 32px);
    display: grid;
    grid-template-columns: minmax(320px, 0.92fr) minmax(0, 1.08fr);
    gap: 18px;
    margin: 16px auto;
}

.signup-hero,
.signup-card {
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(13, 47, 51, 0.18);
}

.signup-hero {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 28px;
    min-height: 680px;
    padding: 34px;
    background:
        linear-gradient(160deg, rgba(13, 47, 51, 0.98), rgba(18, 86, 66, 0.95)),
        #0d2f33;
    color: #f5fbf7;
}

.signup-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px);
    background-size: 28px 28px;
    opacity: 0.35;
    pointer-events: none;
}

.signup-hero > * {
    position: relative;
    z-index: 1;
}

.signup-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
}

.signup-brand strong,
.signup-brand small {
    display: block;
}

.signup-brand small {
    color: #b9d3ca;
    margin-top: 3px;
}

.signup-hero-copy {
    display: grid;
    gap: 14px;
}

.signup-kicker {
    width: fit-content;
    margin: 0;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 8px;
    padding: 8px 10px;
    color: #c8f3e2;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.signup-hero h1 {
    max-width: 540px;
    margin: 0;
    font-size: 42px;
    line-height: 1.08;
    letter-spacing: 0;
}

.signup-hero-copy p:last-child {
    max-width: 520px;
    margin: 0;
    color: #cfe2da;
    line-height: 1.65;
}

.signup-flow {
    display: grid;
    gap: 10px;
}

.signup-flow div {
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    min-height: 58px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 8px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.06);
}

.signup-flow strong {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: rgba(22, 136, 95, 0.9);
    color: #fff;
    font-size: 13px;
}

.signup-flow span {
    color: #eef7f1;
    font-weight: 700;
}

.tech-panel {
    display: grid;
    gap: 12px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 8px;
    padding: 18px;
    background: rgba(8, 25, 29, 0.42);
}

.scan-line {
    display: block;
    height: 5px;
    border-radius: 8px;
    background: linear-gradient(90deg, #2dd4bf, #f59e0b, #38bdf8);
}

.tech-panel div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    padding-bottom: 10px;
}

.tech-panel div:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.tech-panel small {
    color: #a9c5bc;
}

.tech-panel strong {
    text-align: right;
}

.signup-card {
    display: grid;
    align-content: start;
    gap: 18px;
    padding: 30px;
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid #dbe4df;
}

.form-title {
    display: grid;
    gap: 6px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line);
}

.form-title h2 {
    margin: 0;
    font-size: 28px;
    letter-spacing: 0;
}

.form-title p:last-child {
    margin: 0;
    color: var(--muted);
}

.enhanced-signup {
    gap: 18px;
}

.form-section {
    min-width: 0;
    display: grid;
    gap: 14px;
    margin: 0;
    border: 1px solid #dbe4df;
    border-radius: 8px;
    padding: 18px;
    background: #fbfdfb;
}

.form-section legend {
    padding: 0 8px;
    color: var(--green-dark);
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
}

.cnpj-lookup {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 150px;
    gap: 10px;
    align-items: end;
}

.cnpj-lookup .button {
    min-height: 46px;
}

.lookup-status {
    min-height: 42px;
    display: flex;
    align-items: center;
    border: 1px solid #c9e2d6;
    border-radius: 8px;
    padding: 10px 12px;
    background: #edf9f2;
    color: #0f6f4d;
    font-size: 13px;
    line-height: 1.35;
}

.lookup-status.is-loading {
    border-color: #bfdbfe;
    background: #eff6ff;
    color: #1d4ed8;
}

.lookup-status.is-success {
    border-color: #adddc5;
    background: #edf9f2;
    color: #0f6f4d;
}

.lookup-status.is-error {
    border-color: #fecaca;
    background: #fff1f1;
    color: var(--red);
}

.autofill-summary {
    display: grid;
    gap: 4px;
    border-left: 4px solid var(--green);
    border-radius: 8px;
    padding: 12px 14px;
    background: #ffffff;
    box-shadow: 0 8px 22px rgba(20, 36, 46, 0.06);
}

.autofill-summary[hidden] {
    display: none;
}

.autofill-summary span {
    color: var(--muted);
    font-size: 13px;
}

.signup-submit {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    align-items: center;
    border-radius: 8px;
    padding: 16px;
    background: #eef6ff;
    border: 1px solid #bfdbfe;
}

.signup-submit strong,
.signup-submit span {
    display: block;
}

.signup-submit span {
    margin-top: 3px;
    color: #43515d;
    font-size: 13px;
}

.button:disabled,
input:disabled {
    cursor: wait;
    opacity: 0.68;
}

.success-box-large {
    align-self: center;
    min-height: 360px;
    align-content: center;
    justify-items: start;
}

.success-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: var(--green);
    color: #fff;
    font-weight: 800;
}

@media (max-width: 1020px) {
    .signup-page {
        background: #f4f7f4;
    }

    .signup-shell {
        grid-template-columns: 1fr;
    }

    .signup-hero {
        min-height: auto;
    }

    .signup-flow {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .signup-shell {
        width: min(100% - 20px, 560px);
        margin: 10px auto;
    }

    .signup-hero,
    .signup-card {
        padding: 22px;
    }

    .signup-hero h1 {
        font-size: 32px;
    }

    .signup-flow,
    .cnpj-lookup,
    .signup-submit {
        grid-template-columns: 1fr;
    }

    .signup-submit .form-actions,
    .signup-submit .button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .signup-hero,
    .signup-card,
    .form-section {
        padding: 16px;
    }

    .form-title h2 {
        font-size: 24px;
    }

    .signup-hero h1 {
        font-size: 28px;
    }

    .tech-panel div {
        align-items: flex-start;
        flex-direction: column;
    }

    .tech-panel strong {
        text-align: left;
    }
}
