/*
 * Sistema 1026578 — Identidade ECCO Service
 * Padrão claro, sombras discretas, leitura pericial e acessibilidade visual.
 */

:root {
    --bg: #eef3f8;
    --bg2: #f8fbff;
    --card: rgba(255,255,255,.94);
    --card-solid: #ffffff;
    --text: #172033;
    --muted: #667085;
    --line: #d8e0ea;
    --line2: #cbd5e1;
    --accent: #0b2d5c;
    --accent-2: #00854a;
    --accent-soft: #eef6ff;
    --success-soft: #ecfdf3;
    --danger: #b42318;
    --success: #067647;
    --warning: #b54708;
    --shadow: 0 22px 70px rgba(15,23,42,.10);
    --shadow-soft: 0 14px 34px rgba(15,23,42,.08);
    --radius-xl: 24px;
    --radius-lg: 18px;
    --radius-md: 13px;
    --font-scale: 1;
}

html[data-theme="dark"] {
    --bg: #111827;
    --bg2: #0b1220;
    --card: rgba(17,24,39,.94);
    --card-solid: #111827;
    --text: #f8fafc;
    --muted: #cbd5e1;
    --line: #334155;
    --line2: #475569;
    --accent: #8fb7ff;
    --accent-2: #56d696;
    --accent-soft: rgba(143,183,255,.12);
    --success-soft: rgba(86,214,150,.10);
    --shadow: 0 22px 70px rgba(0,0,0,.32);
    --shadow-soft: 0 14px 34px rgba(0,0,0,.22);
}

html[data-theme="green"] {
    --bg: #eef6f1;
    --bg2: #f8fbff;
    --accent: #0b3b2e;
    --accent-2: #00854a;
    --accent-soft: #edf7f1;
}

html[data-font="sm"] { --font-scale: .92; }
html[data-font="md"] { --font-scale: 1; }
html[data-font="lg"] { --font-scale: 1.12; }
html[data-font="xl"] { --font-scale: 1.25; }

* { box-sizing: border-box; }

html {
    min-height: 100%;
    background: var(--bg);
    font-size: calc(14px * var(--font-scale));
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 18% 18%, rgba(0,133,74,.09), transparent 26%),
        radial-gradient(circle at 82% 16%, rgba(11,45,92,.10), transparent 28%),
        linear-gradient(180deg, var(--bg2), var(--bg));
}

a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

a:hover { color: var(--accent-2); text-decoration: underline; }

img { max-width: 100%; height: auto; }

.app-shell {
    width: min(1240px, calc(100% - 44px));
    margin: 0 auto;
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: color-mix(in srgb, var(--card-solid) 86%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}

.app-topbar-inner {
    width: min(1240px, calc(100% - 44px));
    margin: 0 auto;
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.brand-mini {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.brand-mini img {
    width: 54px;
    height: 54px;
    object-fit: contain;
    background: #fff;
    border-radius: 14px;
    border: 1px solid var(--line);
    padding: 4px;
}

.brand-title {
    font-size: .95rem;
    font-weight: 650;
    letter-spacing: -.01em;
    color: var(--text);
}

.brand-subtitle {
    font-size: .78rem;
    color: var(--muted);
    margin-top: 2px;
}

.app-nav {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.app-nav a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 10px;
    border-radius: 999px;
    color: var(--text);
    font-size: .86rem;
    font-weight: 500;
}

.app-nav a:hover,
.app-nav a.active {
    background: var(--accent-soft);
    color: var(--accent);
    text-decoration: none;
}

.user-tools {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.select-control {
    width: auto;
    min-width: 116px;
    border: 1px solid var(--line2);
    background: var(--card-solid);
    color: var(--text);
    border-radius: 12px;
    padding: 8px 10px;
    font-size: .85rem;
}

.page-hero {
    margin: 26px auto 18px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
    padding: 28px 34px;
}

.hero-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--accent);
    font-size: .76rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.hero-dot {
    width: 9px;
    height: 9px;
    border-radius: 99px;
    background: var(--accent-2);
}

.page-hero h1 {
    margin: 0 0 8px;
    font-size: 1.65rem;
    line-height: 1.18;
    letter-spacing: -.03em;
    font-weight: 650;
}

.page-hero p {
    margin: 0;
    color: var(--muted);
    line-height: 1.65;
    max-width: 860px;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-soft);
    padding: 22px;
}

.card h2, .card h3 {
    margin: 0 0 10px;
    letter-spacing: -.02em;
    color: var(--text);
}

.muted {
    color: var(--muted);
    line-height: 1.65;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(260px, 1fr));
    gap: 18px;
}

.module-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-soft);
    padding: 22px;
    display: flex;
    flex-direction: column;
    min-height: 260px;
    color: var(--text);
    text-decoration: none;
    transition: transform .16s ease, box-shadow .16s ease;
}

.module-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: var(--text);
}

.module-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.module-icon {
    width: 46px;
    height: 46px;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, var(--accent-soft), var(--card-solid));
    border: 1px solid var(--line);
    font-size: 1.25rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid color-mix(in srgb, var(--accent-2) 25%, var(--line));
    background: var(--success-soft);
    color: var(--success);
    border-radius: 999px;
    padding: 6px 10px;
    font-size: .70rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.module-card h2 {
    margin: 0 0 9px;
    font-size: 1.15rem;
    font-weight: 650;
    letter-spacing: -.02em;
}

.module-card p {
    margin: 0 0 16px;
    color: var(--muted);
    line-height: 1.62;
    font-size: .94rem;
}

.meta-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: auto;
}

.meta-box {
    background: color-mix(in srgb, var(--card-solid) 88%, var(--accent-soft));
    border: 1px solid var(--line);
    border-radius: 15px;
    padding: 11px;
}

.meta-label {
    color: var(--muted);
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    font-weight: 650;
    margin-bottom: 4px;
}

.meta-value {
    font-weight: 650;
    color: var(--text);
    line-height: 1.3;
    word-break: break-word;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 0;
    border-radius: 13px;
    background: linear-gradient(135deg, #0b2d5c, #174d8f);
    color: #fff !important;
    -webkit-text-fill-color: #fff !important;
    padding: 11px 15px;
    font-weight: 650;
    font-size: .92rem;
    cursor: pointer;
    box-shadow: 0 12px 28px rgba(11,45,92,.18);
}

.btn:hover {
    filter: brightness(1.04);
    text-decoration: none;
    color: #fff !important;
}

.btn-light {
    background: var(--card-solid);
    color: var(--accent) !important;
    -webkit-text-fill-color: var(--accent) !important;
    border: 1px solid var(--line);
    box-shadow: none;
}

.alert {
    border-radius: 14px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    background: var(--accent-soft);
    color: var(--text);
    line-height: 1.55;
}

.alert-error {
    background: #fef3f2;
    border-color: #fecdca;
    color: var(--danger);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-solid);
    font-size: .90rem;
}

th, td {
    padding: 9px 10px;
    border-bottom: 1px solid var(--line);
    text-align: center;
    vertical-align: middle;
}

th {
    background: color-mix(in srgb, var(--accent-soft) 52%, var(--card-solid));
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    font-weight: 650;
    color: var(--text);
}

td.text-left, th.text-left { text-align: left; }

.table-wrap {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--card-solid);
}

input, select, textarea {
    width: 100%;
    border: 1px solid var(--line2);
    border-radius: 13px;
    background: var(--card-solid);
    color: var(--text);
    padding: 10px 12px;
    font-size: 1rem;
    outline: none;
}

textarea {
    min-height: 150px;
    font-family: Consolas, Monaco, "Courier New", monospace;
    line-height: 1.5;
}

label {
    display: block;
    font-size: .82rem;
    font-weight: 600;
    color: var(--text);
    margin: 12px 0 6px;
}

/* Login */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px;
}

.login-shell {
    width: min(1040px, 100%);
    display: grid;
    grid-template-columns: 1fr 1.1fr;
    gap: 22px;
    align-items: stretch;
}

.login-brand, .login-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
}

.login-brand {
    padding: 34px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-logo {
    max-width: 300px;
    width: 100%;
    display: block;
    margin: 0 auto 24px;
    background: #fff;
}

.login-card {
    padding: 30px;
}

.login-title {
    margin: 0 0 6px;
    font-size: 1.55rem;
    letter-spacing: -.02em;
    font-weight: 650;
}

.login-subtitle {
    margin: 0 0 20px;
    color: var(--muted);
    line-height: 1.6;
    font-size: .95rem;
}

.login-form button {
    width: 100%;
    margin-top: 16px;
}

.login-footer {
    margin-top: 14px;
    font-size: .90rem;
    color: var(--muted);
}

.lgpd-note {
    background: color-mix(in srgb, var(--card-solid) 90%, var(--accent-soft));
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 14px;
    color: var(--muted);
    line-height: 1.58;
    font-size: .88rem;
}

.code {
    font-family: Consolas, Monaco, "Courier New", monospace;
    background: var(--accent-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 2px 6px;
}

.footer {
    width: min(1240px, calc(100% - 44px));
    margin: 30px auto 24px;
    color: var(--muted);
    font-size: .82rem;
    text-align: center;
}

/* SQL module */
.sql-grid {
    display: grid;
    grid-template-columns: minmax(280px, 370px) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.schema-box, .indexes-box {
    max-height: 460px;
    overflow: auto;
    padding-right: 4px;
}

.table-item, .index-table {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px;
    margin-bottom: 10px;
    background: color-mix(in srgb, var(--card-solid) 90%, var(--accent-soft));
}

.table-name, .index-table-title {
    font-weight: 650;
    font-size: .92rem;
    word-break: break-word;
}

.table-meta, .index-meta {
    color: var(--muted);
    font-size: .78rem;
    line-height: 1.45;
    margin-top: 5px;
}

.columns {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
}

.columns code {
    background: var(--card-solid);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 3px 8px;
    font-size: .76rem;
}

.sql-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: end;
    margin: 12px 0;
}

.sql-controls label {
    margin: 0;
    display: grid;
    gap: 5px;
}

.sql-controls select {
    width: auto;
    min-width: 100px;
}

.result-wrap {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--card-solid);
    max-height: 620px;
}

.result-table th, .result-table td {
    white-space: nowrap;
    font-size: .82rem;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.pagination-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.empty-state {
    border: 1px dashed var(--line);
    border-radius: 16px;
    padding: 28px;
    text-align: center;
    color: var(--muted);
    background: color-mix(in srgb, var(--card-solid) 88%, var(--accent-soft));
}

/* Responsive */
@media (max-width: 920px) {
    .login-shell, .grid-2, .sql-grid {
        grid-template-columns: 1fr;
    }
    .app-topbar-inner, .app-shell, .footer {
        width: min(100% - 28px, 1240px);
    }
    .app-topbar-inner {
        align-items: flex-start;
        padding: 12px 0;
        flex-direction: column;
    }
    .user-tools { justify-content: flex-start; }
    .page-hero { padding: 22px; }
}

/* Ajustes de estabilidade visual — patch 1026578 v2 */
.app-topbar-inner { flex-wrap: wrap; }
.app-nav { min-width: 0; }
.app-nav a { white-space: nowrap; }
.card, .module-card, .page-hero, .ata-sql-card, .login-card, .login-brand { overflow-wrap: anywhere; }
.code, code, pre, textarea { overflow-wrap: anywhere; word-break: break-word; }
.table-wrap, .result-wrap, .ata-result-wrap { max-width: 100%; overflow-x: auto; }
.sql-controls > label { min-width: 150px; flex: 1 1 160px; }
.sql-controls .btn { flex: 0 0 auto; }
.alert { overflow-wrap: anywhere; }

@media (max-width: 1100px) {
  .app-topbar-inner { align-items: flex-start; padding: 12px 0; }
  .app-nav { order: 3; width: 100%; }
  .user-tools { margin-left: auto; }
}

@media (max-width: 680px) {
  .app-shell, .app-topbar-inner, .footer, .ata-page, .ata-hero { width: min(100% - 22px, 1240px) !important; }
  .grid-2, .meta-grid, .login-shell, .ata-sql-grid, .sql-grid { grid-template-columns: 1fr !important; }
  .app-nav a { font-size: .82rem; padding: 8px 9px; }
  .user-tools { width: 100%; justify-content: flex-start; }
  .select-control { min-width: 0; flex: 1 1 140px; }
  .page-hero, .card, .module-card, .ata-hero, .ata-sql-card { padding: 18px !important; border-radius: 18px; }
  th, td { padding: 8px; font-size: .80rem; }
}
