:root {
    color-scheme: dark;
    --bg: #07101f;
    --surface: #0f1a2e;
    --surface-2: #15223a;
    --surface-3: #1b2b48;
    --line: #293a59;
    --text: #f5f7ff;
    --muted: #9dabc3;
    --primary: #6754f4;
    --primary-2: #4d3bd8;
    --green: #1fd1a0;
    --red: #ff5d68;
    --yellow: #ffbf4b;
    --blue: #4ea7ff;
    --radius: 16px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 17px;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.55; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: #a99cff; text-decoration: none; }
a:hover { color: #c9c1ff; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 4px; font-size: 1.75rem; line-height: 1.2; }
h2 { margin-bottom: 4px; font-size: 1.3rem; }
h3 { margin-bottom: 5px; font-size: 1.2rem; }
small { display: block; color: var(--muted); font-size: .88rem; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 270px minmax(0, 1fr); }
.sidebar {
    position: sticky; top: 0; height: 100vh; padding: 24px 18px;
    background: #091425; border-right: 1px solid var(--line);
    display: flex; flex-direction: column; gap: 28px; z-index: 20;
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand strong { font-size: 1.08rem; display: block; }
.brand-mark {
    width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center;
    background: linear-gradient(145deg, #7665ff, #4932d2); color: white; font-weight: 800;
    box-shadow: 0 10px 28px rgba(103,84,244,.3);
}
.nav-label { color: #64728b; font-size: .8rem; font-weight: 800; letter-spacing: .13em; margin: 0 10px 10px; }
.nav-link {
    display: flex; align-items: center; gap: 14px; min-height: 52px;
    padding: 0 14px; margin: 4px 0; border-radius: 12px; color: #b6c0d2; font-weight: 650;
}
.nav-link span { font-size: 1.3rem; width: 24px; text-align: center; }
.nav-link:hover, .nav-link.active { background: rgba(103,84,244,.18); color: white; }
.nav-link.active { box-shadow: inset 3px 0 0 var(--primary); }
.system-status {
    display: flex; gap: 10px; align-items: flex-start; padding: 14px;
    border: 1px solid var(--line); border-radius: 12px; margin-top: auto; background: rgba(31,209,160,.05);
}
.system-status strong { font-size: .9rem; display: block; }
.status-dot { width: 10px; height: 10px; margin-top: 6px; border-radius: 99px; background: var(--green); box-shadow: 0 0 0 5px rgba(31,209,160,.12); }
.user-box { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 10px; }
.user-box strong { font-size: .92rem; }
.avatar { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-3); color: #c9c1ff; font-weight: 800; }
.icon-button { color: var(--muted); background: transparent; border: 0; cursor: pointer; padding: 10px; font-size: 1.2rem; }

.main-content { min-width: 0; padding: 0 30px 50px; }
.topbar {
    min-height: 96px; display: flex; align-items: center; justify-content: space-between;
    gap: 24px; margin-bottom: 24px; border-bottom: 1px solid var(--line);
}
.topbar p { margin: 0; color: var(--muted); font-size: .92rem; }
.top-actions { display: flex; gap: 12px; align-items: center; }
.menu-button { display: none; border: 1px solid var(--line); background: var(--surface); color: white; border-radius: 10px; padding: 10px 13px; }
.search {
    display: flex; align-items: center; gap: 9px; min-width: 280px; min-height: 48px;
    padding: 0 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
}
.search input { width: 100%; border: 0; outline: 0; color: white; background: transparent; }
.search input::placeholder { color: #71809a; }
.inner-search { min-width: 320px; }

.btn {
    min-height: 48px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    border: 1px solid transparent; border-radius: 11px; padding: 0 18px;
    font-weight: 750; cursor: pointer; transition: .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--primary); color: white; box-shadow: 0 10px 25px rgba(103,84,244,.2); }
.btn-primary:hover { background: #7564ff; color: white; }
.btn-secondary { background: var(--surface-3); border-color: var(--line); color: white; }
.btn-danger { background: rgba(255,93,104,.14); border-color: rgba(255,93,104,.45); color: #ff8a92; }
.btn-danger:hover { background: rgba(255,93,104,.24); }
.btn-small { min-height: 38px; padding: 8px 12px; font-size: .88rem; }
.row-actions { display: flex; align-items: center; gap: 8px; }
.row-actions form { margin: 0; }

.alert { padding: 15px 18px; margin-bottom: 20px; border-radius: 12px; border: 1px solid; font-weight: 650; }
.alert-success { color: #a4f3da; background: rgba(31,209,160,.10); border-color: rgba(31,209,160,.3); }
.alert-error { color: #ffadb4; background: rgba(255,93,104,.10); border-color: rgba(255,93,104,.3); }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.metric-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metric-card {
    min-height: 155px; padding: 22px; border: 1px solid var(--line); border-radius: var(--radius);
    background: linear-gradient(145deg, var(--surface-2), var(--surface));
    display: flex; flex-direction: column; justify-content: center;
}
.metric-card span { color: var(--muted); font-weight: 650; }
.metric-card strong { display: block; margin: 8px 0; font-size: 1.8rem; line-height: 1.2; }
.metric-highlight { background: linear-gradient(135deg, #604bec, #3c2fba); border-color: transparent; }
.metric-highlight span, .metric-highlight small { color: rgba(255,255,255,.78); }
.positive { color: var(--green) !important; }
.negative { color: var(--red) !important; }

.panel {
    margin-bottom: 20px; padding: 24px; border: 1px solid var(--line);
    border-radius: var(--radius); background: var(--surface);
}
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 22px; }
.panel-heading p, .config-heading p { margin: 0; color: var(--muted); }
.flow-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.flow-grid > div { min-height: 145px; padding: 17px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-2); }
.flow-grid span { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: rgba(103,84,244,.2); color: #bfb7ff; font-weight: 800; }
.flow-grid strong { display: block; margin: 15px 0 5px; }

.badge { display: inline-flex; align-items: center; min-height: 30px; padding: 4px 11px; border-radius: 99px; background: #26334e; color: #c9d2e4; font-size: .82rem; font-weight: 800; white-space: nowrap; }
.badge-success, .badge-paid, .badge-delivered { color: #69e9c1; background: rgba(31,209,160,.13); }
.badge-awaiting_payment { color: #ffd37a; background: rgba(255,191,75,.13); }
.badge-preparing { color: #b5aaff; background: rgba(103,84,244,.18); }
.badge-ready, .badge-out_for_delivery { color: #8ecaff; background: rgba(78,167,255,.15); }
.badge-cancelled { color: #ff9da5; background: rgba(255,93,104,.13); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 13px; }
.data-table { width: 100%; border-collapse: collapse; min-width: 860px; }
.data-table th { padding: 15px 17px; color: #8190aa; background: #0c172a; text-align: left; font-size: .82rem; letter-spacing: .04em; text-transform: uppercase; }
.data-table td { padding: 17px; border-top: 1px solid var(--line); vertical-align: middle; }
.data-table tbody tr:hover { background: rgba(103,84,244,.05); }
.data-table td small { margin-top: 2px; }
.empty { padding: 30px !important; text-align: center; color: var(--muted); }
.filter-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.filter-tabs button {
    min-height: 42px; padding: 0 14px; color: #aeb9cb; border: 1px solid transparent;
    border-radius: 10px; background: transparent; cursor: pointer; font-weight: 650;
}
.filter-tabs button:hover, .filter-tabs button.active { color: white; background: rgba(103,84,244,.16); border-color: rgba(103,84,244,.3); }

.two-columns { display: grid; grid-template-columns: minmax(360px, .8fr) minmax(480px, 1.2fr); gap: 20px; align-items: start; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px; }
.form-stack { display: grid; gap: 17px; }
.form-grid label, .form-stack label { display: grid; gap: 7px; }
.form-grid label > span, .form-stack label > span { font-weight: 700; color: #dfe4ef; }
.form-grid .full { grid-column: 1 / -1; }
input, select, textarea {
    width: 100%; color: white; background: #091322; border: 1px solid #344561;
    border-radius: 10px; padding: 13px 14px; outline: none;
}
input, select { min-height: 51px; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(103,84,244,.15); }
.money-input { display: flex; align-items: center; min-height: 51px; overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-2); }
.money-input:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(103,84,244,.15); }
.money-input > span { padding-left: 16px; color: #9aabd0; font-weight: 700; }
.money-input input { min-height: 49px; border: 0; box-shadow: none; background: transparent; }
.money-input input:focus { border: 0; box-shadow: none; }
.pix-layout { display: grid; grid-template-columns: minmax(220px, 320px) 1fr; gap: 28px; align-items: start; }
.pix-qr { display: block; width: 100%; max-width: 320px; padding: 14px; border-radius: 18px; background: white; }
.pix-details { display: grid; gap: 18px; }
.pix-details > strong { font-size: 2rem; color: var(--success); }
.pix-details label { display: grid; gap: 7px; }
.pix-details label > span { font-weight: 700; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.transaction-list { display: grid; gap: 10px; }
.transaction-list article { display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 13px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; }
.transaction-icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 12px; font-weight: 900; }
.positive-bg { color: var(--green); background: rgba(31,209,160,.12); }
.negative-bg { color: var(--red); background: rgba(255,93,104,.12); }
.report-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.report-grid article { padding: 22px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-2); }
.report-grid span { color: var(--muted); }
.report-grid strong { display: block; margin-top: 8px; font-size: 1.5rem; }
.report-note { margin-top: 18px; padding: 18px; border-left: 4px solid var(--primary); background: rgba(103,84,244,.08); }
.report-note p { margin: 5px 0 0; color: var(--muted); }

.integration-tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 24px; padding-bottom: 1px; border-bottom: 1px solid var(--line); }
.integration-tabs a { padding: 13px 18px; border-bottom: 3px solid transparent; color: #9ba8bd; font-weight: 750; white-space: nowrap; }
.integration-tabs a.active { color: white; border-bottom-color: var(--primary); }
.integration-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.integration-cards article { min-height: 210px; padding: 20px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); }
.integration-cards article > strong { display: block; margin: 14px 0 10px; font-size: 1.05rem; }
.integration-cards article p { color: var(--muted); min-height: 52px; }
.integration-logo { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 12px; background: rgba(103,84,244,.2); color: #c1b9ff; font-weight: 900; }
.config-heading { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin: 6px 0 20px; }
.credential-alert { margin-bottom: 20px; padding: 18px; border: 1px solid rgba(255,191,75,.3); border-radius: 12px; background: rgba(255,191,75,.07); }
.credential-alert strong { color: #ffd27a; }
.credential-alert p { margin: 5px 0 0; color: #c9bd9e; }
.integration-form { max-width: 980px; }
.inline-form { margin-top: -48px; width: fit-content; }
.workflow-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 24px; }
.workflow-summary article { padding: 17px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.workflow-summary span { color: #a99cff; font-weight: 900; }
.workflow-summary strong { display: block; margin: 8px 0 4px; }
.workflow-summary p { margin: 0; color: var(--muted); }

.login-body { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at top, #17254c, var(--bg) 52%); }
.login-card { width: min(460px, 100%); padding: 36px; border: 1px solid var(--line); border-radius: 20px; background: rgba(15,26,46,.96); box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.login-card .brand-mark { margin-bottom: 24px; }
.login-card > p { color: var(--muted); margin-bottom: 25px; }
.empty-state { text-align: center; padding: 70px 25px; }
.empty-icon { font-size: 3rem; font-weight: 900; color: #7465d7; }

@media (max-width: 1180px) {
    .metric-grid { grid-template-columns: repeat(2, 1fr); }
    .flow-grid { grid-template-columns: repeat(3, 1fr); }
    .integration-cards { grid-template-columns: repeat(2, 1fr); }
    .two-columns { grid-template-columns: 1fr; }
    .report-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 850px) {
    .pix-layout { grid-template-columns: 1fr; }
    :root { font-size: 16px; }
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: fixed; left: -290px; width: 270px; transition: left .2s ease; box-shadow: 12px 0 45px rgba(0,0,0,.4); }
    .sidebar.open { left: 0; }
    .main-content { padding: 0 18px 35px; }
    .topbar { min-height: 84px; }
    .menu-button { display: block; }
    .topbar > div:first-of-type { flex: 1; }
    .top-actions .search { display: none; }
    .flow-grid, .workflow-summary { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
    .main-content { padding-inline: 13px; }
    .topbar { gap: 10px; }
    .topbar h1 { font-size: 1.35rem; }
    .topbar .btn { font-size: 0; width: 48px; padding: 0; }
    .topbar .btn::first-letter { font-size: 1.2rem; }
    .metric-grid, .metric-grid.three, .flow-grid, .integration-cards, .workflow-summary, .report-grid, .form-grid { grid-template-columns: 1fr; }
    .metric-card { min-height: 130px; }
    .panel { padding: 18px; }
    .panel-heading, .config-heading { align-items: flex-start; flex-direction: column; }
    .inner-search { min-width: 100%; width: 100%; }
    .form-grid .full { grid-column: auto; }
    .inline-form { margin-top: 10px; }
    .transaction-list article { grid-template-columns: 44px 1fr; }
    .transaction-list article > strong:last-child { grid-column: 2; }
}

@media print {
    .sidebar, .topbar, .btn, .integration-tabs { display: none !important; }
    .app-shell { display: block; }
    .main-content { padding: 0; }
    body, .panel, .metric-card { background: white; color: black; border-color: #ccc; }
}
