:root {
    --navy: #173f4f;
    --navy-deep: #0d2b36;
    --text: #182631;
    --muted: #667987;
    --line: #d7e3e8;
    --bg: #f3f7f8;
    --blue: #2477a8;
    --blue-dark: #145f86;
    --green: #0f9f78;
    --purple: #6d72c3;
    --cyan: #139fb5;
}

* {
    box-sizing: border-box;
}

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

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

.login-page {
    min-height: 100vh;
    background: radial-gradient(circle at 50% 12%, #2f6f78 0, #174552 42%, #0e2d38 100%);
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-shell {
    width: min(400px, 100%);
}

.login-card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 24px 70px rgba(3, 10, 28, 0.35);
    padding: 32px;
}

.brand-mark {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    margin: 0 auto 16px;
    display: grid;
    place-items: center;
    background: linear-gradient(145deg, #16a085, #2477a8);
    box-shadow: 0 12px 24px rgba(22, 160, 133, 0.28);
}

.brand-mark span {
    width: 24px;
    height: 24px;
    border: 3px solid #fff;
    border-radius: 8px;
    display: block;
    background: linear-gradient(90deg, transparent 45%, rgba(255,255,255,.9) 46% 54%, transparent 55%);
}

.brand-mark-small {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    margin: 0;
}

.brand-mark-small span {
    transform: scale(.75);
}

.login-card h1 {
    margin: 0;
    text-align: center;
    font-size: 26px;
}

.login-subtitle {
    margin: 10px 0 30px;
    text-align: center;
    color: #8ca0bc;
}

.login-form label {
    display: block;
    margin: 18px 0 8px;
    color: #64748b;
    font-weight: 700;
    font-size: 14px;
}

.input-group {
    display: grid;
    grid-template-columns: 40px 1fr;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 6px;
    overflow: hidden;
    background: #f8fafc;
}

.input-group span {
    text-align: center;
    color: #8da2bf;
}

.input-group input {
    width: 100%;
    height: 46px;
    border: 0;
    outline: 0;
    padding: 0 14px;
    font-size: 16px;
    background: #eef4ff;
    color: #111827;
}

.input-group:focus-within {
    border-color: var(--blue);
    box-shadow: 0 0 0 4px rgba(59, 125, 241, 0.12);
}

.primary-button,
.ghost-button {
    height: 56px;
    border: 0;
    border-radius: 8px;
    font-weight: 800;
    cursor: pointer;
}

.primary-button {
    width: 100%;
    margin-top: 24px;
    color: #fff;
    font-size: 16px;
    background: linear-gradient(135deg, #0f9f78, #2477a8);
    box-shadow: 0 10px 24px rgba(15, 159, 120, .24);
}

.primary-button:disabled {
    cursor: wait;
    opacity: .72;
}

.secure-note {
    margin: 28px 0 0;
    padding-top: 24px;
    border-top: 1px solid #eef2f7;
    color: #6b7280;
    text-align: center;
}

.alert {
    border-radius: 6px;
    padding: 12px 14px;
    font-weight: 700;
    font-size: 14px;
}

.alert-danger {
    color: #991b1b;
    background: #fee2e2;
}

.app-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 292px 1fr;
}

.sidebar {
    min-height: 100vh;
    background:
        linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,0) 190px),
        linear-gradient(180deg, #0b2630, #123f4a);
    color: #e3f6f4;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255,255,255,.08);
}

.sidebar-brand {
    min-height: 92px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 22px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-brand > span:last-child {
    display: grid;
    gap: 3px;
}

.sidebar-brand strong {
    font-size: 22px;
    line-height: 1;
}

.sidebar-brand small {
    color: #8fb4bb;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.side-nav {
    display: grid;
    gap: 6px;
    padding: 22px 14px;
}

.side-nav p {
    margin: 18px 12px 8px;
    color: #7fa6ad;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .1em;
}

.side-nav a {
    min-height: 66px;
    display: flex;
    align-items: center;
    gap: 13px;
    color: #c2d8dc;
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 10px 12px;
    font-weight: 700;
    position: relative;
    transition: background .18s ease, border-color .18s ease, color .18s ease, transform .18s ease;
}

.side-nav a:hover {
    color: #fff;
    background: rgba(255,255,255,.07);
    border-color: rgba(255,255,255,.08);
}

.side-nav a.active {
    color: #fff;
    background: linear-gradient(135deg, rgba(15,159,120,.24), rgba(36,119,168,.28));
    border-color: rgba(164, 230, 214, .36);
    box-shadow: inset 3px 0 0 #35d0ae, 0 10px 24px rgba(0, 0, 0, .14);
}

.nav-icon {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    flex: 0 0 38px;
    border-radius: 10px;
    color: #dffaf5;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.08);
    font-weight: 900;
}

.side-nav a.active .nav-icon {
    color: #0d2b36;
    background: #bff7e8;
}

.nav-copy {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.nav-copy strong,
.nav-copy small {
    display: block;
}

.nav-copy strong {
    font-size: 15px;
}

.nav-copy small {
    color: #83aab2;
    font-size: 12px;
    font-weight: 700;
}

.side-nav a.active .nav-copy small,
.side-nav a:hover .nav-copy small {
    color: #b7d5da;
}

.system-status {
    margin-top: auto;
    display: grid;
    gap: 6px;
    margin: auto 14px 16px;
    padding: 14px;
    color: #c2d8dc;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 12px;
    background: rgba(255,255,255,.05);
}

.system-status div {
    display: flex;
    align-items: center;
    font-weight: 800;
}

.system-status small {
    color: #85aab1;
    font-weight: 700;
}

.system-status span {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    margin-right: 8px;
}

.main-area {
    min-width: 0;
}

.topbar {
    min-height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: #fff;
    border-bottom: 1px solid var(--line);
}

.topbar h1 {
    margin: 0;
    font-size: 24px;
}

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

.user-chip {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 178px;
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}

.user-chip span {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    color: #fff;
    border-radius: 50%;
    background: linear-gradient(145deg, #16a085, #2477a8);
    font-weight: 800;
}

.user-chip strong,
.user-chip small {
    display: block;
}

.user-chip small {
    color: #8aa0bc;
}

.ghost-button {
    height: 46px;
    display: inline-grid;
    place-items: center;
    padding: 0 18px;
    border: 1px solid var(--line);
    background: #f8fafc;
    color: #475569;
}

.content {
    padding: 24px;
}

.metric-grid,
.color-grid,
.panel-grid {
    display: grid;
    gap: 24px;
}

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

.metric-card,
.panel,
.table-panel {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, .08);
}

.metric-card {
    min-height: 148px;
    padding: 22px;
    border-top: 4px solid var(--blue);
}

.metric-card small,
.color-card small {
    display: block;
    color: #687992;
    font-weight: 800;
}

.metric-card strong,
.color-card strong {
    display: block;
    margin-top: 4px;
    font-size: 36px;
    line-height: 1;
}

.metric-card span {
    display: inline-block;
    margin-top: 26px;
    border-radius: 999px;
    padding: 7px 12px;
    font-size: 12px;
    font-weight: 800;
    background: #e9f9f1;
    color: #079566;
}

.metric-green { border-top-color: var(--green); }
.metric-purple { border-top-color: var(--purple); }
.metric-cyan { border-top-color: var(--cyan); }

.info-strip {
    margin: 24px 0;
    padding: 16px;
    border-radius: 8px;
    color: #07526a;
    background: #c9f4ff;
    font-weight: 700;
}

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

.color-card {
    min-height: 138px;
    padding: 22px;
    color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, .16);
}

.color-card small,
.color-card span {
    color: rgba(255,255,255,.78);
}

.color-card span {
    display: block;
    margin-top: 18px;
    font-weight: 800;
}

.red { background: linear-gradient(135deg, #f43f5e, #dc2626); }
.orange { background: linear-gradient(135deg, #fb923c, #f97316); }
.emerald { background: linear-gradient(135deg, #22c55e, #16a34a); }
.indigo { background: linear-gradient(135deg, #6366f1, #4f46e5); }

.panel-grid {
    margin-top: 24px;
    grid-template-columns: 1fr 1.4fr;
}

.panel {
    min-height: 344px;
    padding: 22px;
}

.panel h2 {
    margin: 0 0 18px;
    font-size: 18px;
}

.donut {
    width: 260px;
    height: 260px;
    margin: 8px auto 18px;
    border-radius: 50%;
    background: radial-gradient(circle, #fff 0 39%, transparent 40%), conic-gradient(var(--blue) 0 100%);
}

.legend {
    display: flex;
    justify-content: center;
    gap: 16px;
    color: #64748b;
    font-size: 14px;
}

.dot {
    width: 10px;
    height: 10px;
    display: inline-block;
    border-radius: 3px;
    margin-right: 6px;
}

.dot.blue { background: var(--blue); }
.dot.green { background: var(--green); }
.dot.amber { background: #f59e0b; }
.dot.purple { background: var(--purple); }

.empty-chart {
    height: 250px;
    display: grid;
    align-content: stretch;
    gap: 18px;
    padding: 18px 0;
}

.empty-chart span {
    border-top: 1px solid #e6edf5;
}

.simple-page {
    min-height: 100vh;
    padding: 32px;
}

.simple-shell {
    max-width: 1100px;
    margin: 0 auto;
}

.simple-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.back-link {
    color: var(--blue-dark);
    font-weight: 800;
}

.simple-header h1 {
    margin: 8px 0 0;
}

.table-panel {
    overflow: hidden;
}

.query-panel,
.query-results {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, .08);
}

.query-form {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    padding: 22px;
}

.query-form label {
    display: grid;
    gap: 7px;
    color: #475569;
    font-weight: 800;
}

.query-form input,
.query-form select {
    width: 100%;
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0 12px;
    background: #f8fafc;
    color: #111827;
    font-size: 15px;
}

.query-form input:focus,
.query-form select:focus {
    outline: 0;
    border-color: var(--blue);
    box-shadow: 0 0 0 4px rgba(59, 125, 241, 0.12);
}

.query-check {
    grid-template-columns: 18px 1fr;
    align-items: center;
    align-content: center;
}

.query-check input {
    width: 18px;
    height: 18px;
    padding: 0;
}

.query-actions {
    display: grid;
    grid-template-columns: 1fr 110px;
    gap: 10px;
    align-items: end;
}

.query-actions .primary-button,
.query-actions .ghost-button {
    height: 44px;
    margin: 0;
}

.query-results {
    margin-top: 24px;
    overflow: hidden;
}

.result-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    padding: 18px 22px;
    border-bottom: 1px solid #edf2f7;
}

.result-head h2 {
    margin: 0;
    font-size: 18px;
}

.result-head span {
    color: #64748b;
    font-weight: 800;
}

.empty-state {
    padding: 30px 22px;
    color: #64748b;
    font-weight: 800;
}

.consult-table-wrap {
    overflow: auto;
}

.consult-table {
    min-width: 1180px;
}

.consult-table td {
    vertical-align: top;
}

.consult-table td strong,
.consult-table td small {
    display: block;
}

.consult-table td small {
    margin-top: 5px;
    color: #64748b;
    line-height: 1.35;
}

.import-shell {
    display: grid;
    grid-template-columns: minmax(320px, 420px) 1fr;
    gap: 24px;
    align-items: start;
}

.receita-panel {
    grid-column: 1 / -1;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, .08);
    overflow: hidden;
}

.receita-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    padding: 22px;
    border-bottom: 1px solid #edf2f7;
}

.receita-head-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex: 0 0 auto;
}

.receita-head-actions .ghost-button,
.receita-head-actions .primary-button {
    width: auto;
    height: 46px;
    margin: 0;
    padding: 0 18px;
}

.receita-head h2,
.receita-head p {
    margin: 0;
}

.receita-head p {
    margin-top: 8px;
    color: #64748b;
}

.receita-controls {
    display: grid;
    grid-template-columns: 70px minmax(180px, 280px) 1fr;
    gap: 12px;
    align-items: center;
    padding: 18px 22px;
    border-bottom: 1px solid #edf2f7;
}

.receita-controls label,
.receita-controls span {
    color: #64748b;
    font-weight: 800;
}

.month-import-status {
    display: grid;
    gap: 10px;
    padding: 16px 22px;
    border-bottom: 1px solid #edf2f7;
    background: #f8fbff;
}

.month-import-status[hidden] {
    display: none;
}

.month-import-status > div:first-child {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    color: #334155;
}

.month-import-status small {
    color: #64748b;
    font-weight: 800;
}

.month-import-status ol {
    max-height: 150px;
    margin: 0;
    padding: 0;
    overflow: auto;
    color: #475569;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    list-style: none;
}

.month-import-status li {
    padding: 4px 0;
    border-bottom: 1px solid #edf2f7;
}

.receita-controls select {
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0 12px;
    background: #f8fafc;
    color: #1f2937;
    font-weight: 800;
}

.receita-file-list {
    max-height: 520px;
    overflow: auto;
}

.receita-file {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 18px;
    align-items: center;
    padding: 14px 22px;
    border-bottom: 1px solid #edf2f7;
}

.receita-file.downloaded {
    background: #f0fdf4;
}

.receita-file.queued {
    background: #f8fafc;
}

.receita-file.downloading {
    background: #eff6ff;
}

.receita-file.imported {
    background: #ecfeff;
}

.receita-file.failed {
    background: #fff1f2;
}

.receita-file-main {
    display: grid;
    gap: 7px;
    min-width: 0;
}

.receita-file-main strong {
    color: #1e293b;
}

.receita-file-main span {
    color: #64748b;
    overflow-wrap: anywhere;
}

.receita-file-actions {
    display: grid;
    grid-template-columns: 90px 96px 110px;
    gap: 10px;
    align-items: center;
}

.receita-file-actions small {
    color: #64748b;
    font-weight: 800;
    text-align: right;
}

.receita-file-actions .ghost-button {
    width: 100%;
    height: 38px;
    padding: 0 10px;
}

.receita-file-actions .ghost-button:disabled {
    cursor: not-allowed;
    opacity: .55;
}

.mini-progress {
    height: 7px;
    overflow: hidden;
    border-radius: 999px;
    background: #e8eef6;
}

.mini-progress i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #2f80ed, #14b8a6);
}

.import-uploader,
.import-progress-panel {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, .08);
}

.import-uploader {
    padding: 22px;
}

.import-uploader h2,
.import-progress-panel h2,
.import-results h3 {
    margin: 0;
}

.import-uploader p,
.import-panel-head p {
    margin: 8px 0 0;
    color: #64748b;
    line-height: 1.5;
}

.file-drop {
    min-height: 218px;
    margin-top: 22px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 10px;
    padding: 24px;
    border: 2px dashed #b9c8da;
    border-radius: 8px;
    background: #f8fbff;
    cursor: pointer;
    text-align: center;
}

.file-drop:hover {
    border-color: var(--blue);
    background: #eef6ff;
}

.file-drop span {
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    color: #fff;
    border-radius: 14px;
    background: linear-gradient(145deg, #2f80ed, #14b8a6);
    font-size: 30px;
    font-weight: 800;
}

.file-drop strong {
    max-width: 100%;
    color: #1e293b;
    overflow-wrap: anywhere;
}

.file-drop small {
    color: #64748b;
}

.file-drop input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
}

.import-submit {
    margin-top: 18px;
}

.import-progress-panel {
    padding: 0;
    overflow: hidden;
}

.import-panel-head {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    padding: 22px;
    border-bottom: 1px solid #edf2f7;
}

.status-pill {
    height: 34px;
    display: inline-grid;
    place-items: center;
    padding: 0 12px;
    border-radius: 999px;
    color: #075985;
    background: #e0f2fe;
    font-weight: 800;
    white-space: nowrap;
}

.status-pill.running,
.status-pill.queued {
    color: #075985;
    background: #dff5ff;
}

.status-pill.finished {
    color: #047857;
    background: #d1fae5;
}

.status-pill.failed,
.status-pill.danger {
    color: #b91c1c;
    background: #fee2e2;
}

.progress-stack {
    display: grid;
    gap: 16px;
    padding: 22px;
    border-bottom: 1px solid #edf2f7;
}

.progress-row {
    display: grid;
    gap: 10px;
}

.progress-row div:first-child {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    color: #334155;
}

.progress-row small {
    color: #64748b;
    font-weight: 800;
}

.progress-track {
    height: 12px;
    overflow: hidden;
    border-radius: 999px;
    background: #e8eef6;
}

.progress-track span {
    height: 100%;
    display: block;
    border-radius: inherit;
    background: linear-gradient(90deg, #2f80ed, #14b8a6);
    transition: width .25s ease;
}

.import-results {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 22px;
    padding: 22px;
}

.ready-path {
    margin: 10px 0 14px;
    padding: 10px 12px;
    border-radius: 6px;
    background: #f1f5f9;
    color: #475569;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    overflow-wrap: anywhere;
}

.file-list,
.log-list {
    min-height: 220px;
    max-height: 340px;
    overflow: auto;
    border: 1px solid #edf2f7;
    border-radius: 8px;
    background: #fbfdff;
}

.file-list {
    display: grid;
    align-content: start;
}

.file-item {
    display: grid;
    grid-template-columns: 150px 1fr 78px;
    gap: 12px;
    padding: 12px;
    border-bottom: 1px solid #edf2f7;
    align-items: center;
}

.file-item strong {
    color: #2563eb;
    font-size: 13px;
}

.file-item span {
    overflow-wrap: anywhere;
}

.file-item small {
    color: #64748b;
    text-align: right;
}

.log-list {
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
}

.log-list li {
    display: grid;
    grid-template-columns: 68px 1fr;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid #edf2f7;
    color: #334155;
}

.log-list time {
    color: #64748b;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
}

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

th,
td {
    padding: 16px;
    border-bottom: 1px solid #edf2f7;
    text-align: left;
}

th {
    color: #64748b;
    background: #f8fafc;
}

@media (max-width: 1080px) {
    .app-page {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: none;
    }

    .metric-grid,
    .color-grid,
    .panel-grid,
    .import-shell,
    .query-form,
    .import-results {
        grid-template-columns: 1fr 1fr;
    }

    .import-shell,
    .import-results {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .login-card {
        padding: 26px 20px;
    }

    .topbar,
    .simple-header {
        align-items: flex-start;
        flex-direction: column;
        height: auto;
        gap: 14px;
        padding: 18px;
    }

    .content,
    .simple-page {
        padding: 16px;
    }

    .metric-grid,
    .color-grid,
    .panel-grid,
    .import-shell,
    .query-form,
    .import-results {
        grid-template-columns: 1fr;
    }

    .legend {
        flex-wrap: wrap;
    }

    .import-panel-head,
    .receita-head,
    .progress-row div:first-child {
        flex-direction: column;
    }

    .receita-controls,
    .receita-file,
    .receita-file-actions {
        grid-template-columns: 1fr;
    }

    .receita-head-actions {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr;
    }

    .receita-file-actions small {
        text-align: left;
    }

    .file-item {
        grid-template-columns: 1fr;
    }

    .file-item small {
        text-align: left;
    }
}
