:root {
    --bg: #0c0f14;
    --surface: #141820;
    --surface-2: #1a2030;
    --border: #252d3d;
    --text: #e8ecf4;
    --text-muted: #8b95a8;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --radius: 10px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --font: 'DM Sans', system-ui, sans-serif;
    --mono: 'JetBrains Mono', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
}

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

/* Sidebar */
.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    min-height: 100vh;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    margin-bottom: 2rem;
}

.brand-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary), #6366f1);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.brand-icon svg { width: 22px; height: 22px; color: #fff; }

.sidebar-brand h1 {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.sidebar-brand p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
    width: 100%;
}

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.nav-item:hover { background: var(--surface-2); color: var(--text); }

.nav-item.active {
    background: rgba(59, 130, 246, 0.12);
    color: var(--primary);
}

.sidebar-footer { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--border); }

.connection-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
}

.connection-status.connected .status-dot { background: var(--success); box-shadow: 0 0 8px var(--success); }
.connection-status.error .status-dot { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.connection-status.loading .status-dot { background: var(--warning); animation: pulse 1.2s infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Main */
.main {
    padding: 2rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.page-content {
    flex: 1;
}

.main-footer {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.75rem;
}

a.nav-item {
    text-decoration: none;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 2rem;
    gap: 1rem;
}

.page-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.page-header p {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.125rem;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.btn svg { width: 16px; height: 16px; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn-success { background: rgba(34, 197, 94, 0.15); color: var(--success); border: 1px solid rgba(34, 197, 94, 0.3); }
.btn-success:hover:not(:disabled) { background: rgba(34, 197, 94, 0.25); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }

.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }

.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }
.btn-sm svg { width: 14px; height: 14px; }

.btn-icon {
    padding: 0.375rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    transition: all 0.15s;
}

.btn-icon svg { width: 15px; height: 15px; }
.btn-icon:hover { background: var(--surface-2); color: var(--text); }
.btn-icon.danger:hover { background: rgba(239, 68, 68, 0.1); color: var(--danger); border-color: rgba(239, 68, 68, 0.3); }

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.5rem;
    margin-bottom: 1.25rem;
}

.create-card { border-color: rgba(59, 130, 246, 0.25); background: linear-gradient(135deg, var(--surface) 0%, rgba(59, 130, 246, 0.04) 100%); }

.card h3 {
    font-size: 0.9375rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.card-header h3 { margin-bottom: 0; }

.table-search {
    position: relative;
    margin-bottom: 1rem;
    max-width: 360px;
}

.table-search-icon {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
}

.table-search input {
    width: 100%;
    padding: 0.625rem 0.875rem 0.625rem 2.625rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--mono);
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.15s;
}

.table-search input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.table-search input::placeholder {
    color: var(--text-muted);
    font-family: var(--font);
}

.badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.625rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-muted);
}

/* Form */
.create-form {
    display: flex;
    gap: 0.75rem;
}

.create-form input {
    flex: 1;
    max-width: 360px;
    padding: 0.625rem 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--mono);
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.15s;
}

.create-form input:focus { border-color: var(--primary); }
.create-form input::placeholder { color: var(--text-muted); opacity: 0.6; }

.create-form-stacked {
    flex-direction: column;
    align-items: stretch;
}

.create-form-stacked .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.875rem;
}

.create-form-stacked label {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.create-form-stacked label span {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
}

.create-form-stacked input,
.create-form-stacked select {
    max-width: none;
    width: 100%;
    font-family: var(--font);
}

.create-form-stacked select {
    padding: 0.625rem 0.875rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.875rem;
    outline: none;
}

.create-form-stacked select:focus { border-color: var(--primary); }

.db-code {
    font-family: var(--mono);
    font-size: 0.8125rem;
    color: #93c5fd;
    background: rgba(59, 130, 246, 0.1);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.cliente-name {
    font-weight: 500;
    color: var(--text);
}

.cliente-link {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
    text-align: left;
    text-decoration: underline;
    text-decoration-color: rgba(59, 130, 246, 0.35);
    text-underline-offset: 3px;
}

.cliente-link:hover {
    color: #93c5fd;
}

.info-link {
    color: var(--primary);
    text-decoration: none;
    word-break: break-all;
}

.info-link:hover {
    text-decoration: underline;
}

.info-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem 1.25rem;
    margin-bottom: 1.25rem;
}

.info-detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.info-detail-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.info-detail-value {
    font-size: 0.9375rem;
    line-height: 1.45;
    color: var(--text);
}

.info-detail-value a {
    color: var(--primary);
    text-decoration: none;
    word-break: break-all;
}

.info-detail-value a:hover {
    text-decoration: underline;
}

.hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.625rem;
}

/* Databases page */
.databases-page {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.875rem;
    margin-bottom: 1.25rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.125rem;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.stat-value {
    font-size: 1.375rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text);
    line-height: 1.2;
}

.stat-value-size {
    display: flex;
    align-items: baseline;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.stat-amount {
    font-size: 1.375rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.stat-unit {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

.card-intro {
    margin-bottom: 1.25rem;
}

.card-intro h3 {
    margin-bottom: 0.375rem;
}

.card-intro p,
.card-subtitle,
.modal-subtitle {
    font-size: 0.8125rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0;
}

.card-header > div {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.card-toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.table-search-wide {
    max-width: 100%;
    flex: 1;
    min-width: 220px;
}

.form-section {
    border: none;
    margin: 0 0 1.25rem;
    padding: 0;
}

.form-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    width: 100%;
}

.form-field-full {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.field-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.form-actions {
    display: flex;
    justify-content: flex-start;
    padding-top: 0.25rem;
}

.db-table .col-numeric {
    text-align: right;
    width: 1%;
    white-space: nowrap;
}

.db-table .col-actions {
    width: 1%;
    white-space: nowrap;
}

.cell-stack {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    align-items: flex-start;
}

.cell-meta {
    font-size: 0.8125rem;
    color: var(--text-muted);
    line-height: 1.35;
}

.cell-meta-muted {
    font-style: italic;
}

.metric-pill {
    display: inline-block;
    font-size: 0.8125rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    padding: 0.2rem 0.55rem;
    border-radius: 6px;
    background: rgba(59, 130, 246, 0.12);
    color: #93c5fd;
}

.metric-pill-muted {
    background: var(--surface-2);
    color: var(--text-muted);
    font-weight: 500;
}

.info-sections {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

.info-section-title {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.backup-filename {
    font-family: var(--mono);
    font-size: 0.8125rem;
    color: var(--text-muted);
    word-break: break-all;
}

.backups-table .col-numeric {
    text-align: right;
    width: 1%;
    white-space: nowrap;
}

.backups-table .col-actions {
    width: 1%;
    white-space: nowrap;
}

/* Table */
.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

thead th {
    text-align: left;
    padding: 0.625rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

tbody td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid rgba(37, 45, 61, 0.5);
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255, 255, 255, 0.02); }

.db-name {
    font-family: var(--mono);
    font-weight: 500;
    color: var(--primary);
}

.actions { display: flex; gap: 0.375rem; align-items: center; }

.loading, .empty {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem !important;
}

.backup-date { font-size: 0.8125rem; color: var(--text-muted); }
.backup-none { color: var(--text-muted); font-size: 0.8125rem; font-style: italic; }

/* Tabs */
/* Toast */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    z-index: 1000;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    box-shadow: var(--shadow);
    animation: slideIn 0.25s ease;
    max-width: 380px;
    border: 1px solid transparent;
    pointer-events: auto;
}

.toast.toast-out {
    animation: slideOut 0.25s ease forwards;
}

.toast-icon {
    flex-shrink: 0;
    width: 1.375rem;
    height: 1.375rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8125rem;
    border-radius: 50%;
    margin-top: 0.0625rem;
}

.toast-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.toast-title {
    font-weight: 600;
    font-size: 0.8125rem;
    line-height: 1.3;
}

.toast-message {
    font-size: 0.8125rem;
    line-height: 1.45;
    opacity: 0.92;
}

.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: inherit;
    opacity: 0.6;
    cursor: pointer;
    font-size: 1.125rem;
    line-height: 1;
    padding: 0;
    margin: -0.125rem -0.125rem 0 0;
}

.toast-close:hover { opacity: 1; }

.toast-spinner {
    width: 0.875rem;
    height: 0.875rem;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.toast.success { background: #14532d; border-color: #166534; color: #bbf7d0; }
.toast.success .toast-icon { background: rgba(187, 247, 208, 0.15); color: #86efac; }

.toast.error { background: #450a0a; border-color: #7f1d1d; color: #fecaca; }
.toast.error .toast-icon { background: rgba(254, 202, 202, 0.12); color: #fca5a5; }

.toast.info { background: #1e3a5f; border-color: #1d4ed8; color: #bfdbfe; }
.toast.info .toast-icon { background: rgba(191, 219, 254, 0.12); color: #93c5fd; }

.toast.warning { background: #422006; border-color: #854d0e; color: #fde68a; }
.toast.warning .toast-icon { background: rgba(253, 230, 138, 0.12); color: #fcd34d; }

.toast.loading { background: #1e293b; border-color: #334155; color: #cbd5e1; }
.toast.loading .toast-icon { background: rgba(203, 213, 225, 0.1); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 900;
    backdrop-filter: blur(4px);
}

.modal-overlay.hidden { display: none; }

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.75rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow);
}

.modal h3 { font-size: 1.0625rem; margin-bottom: 0.625rem; }
.modal p { color: var(--text-muted); font-size: 0.875rem; margin-bottom: 1.5rem; }

.modal-actions { display: flex; gap: 0.75rem; justify-content: flex-end; }

/* Spinner */
.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.2);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Login */
.login-page {
    min-height: 100vh;
    background: var(--bg);
}

.login-shell {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 100vh;
}

.login-hero {
    position: relative;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    padding: 2.75rem 3rem;
    overflow: hidden;
    background: linear-gradient(145deg, #0a1628 0%, #0c0f14 45%, #111827 100%);
    border-right: 1px solid var(--border);
}

.login-hero-glow {
    position: absolute;
    top: -20%;
    left: -10%;
    width: 60%;
    height: 60%;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.18) 0%, transparent 70%);
    pointer-events: none;
}

.login-hero-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.6), transparent 90%);
    pointer-events: none;
}

.login-hero-content {
    position: relative;
    z-index: 1;
    max-width: 420px;
}

.login-hero-brand {
    display: flex;
    gap: 1.25rem;
    align-items: center;
    margin-bottom: 2rem;
}

.brand-icon-lg {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    flex-shrink: 0;
}

.brand-icon-lg svg { width: 28px; height: 28px; }

.brand-icon-sm {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    flex-shrink: 0;
}

.brand-icon-sm svg { width: 20px; height: 20px; }

.login-hero-eyebrow {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.login-hero-brand h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.2;
    margin-bottom: 0.625rem;
}

.login-hero-tagline {
    color: var(--text-muted);
    font-size: 0.9375rem;
    line-height: 1.6;
}

.login-features {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.login-features li {
    display: flex;
    align-items: flex-start;
    gap: 0.875rem;
    padding: 0.875rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius);
    transition: border-color 0.2s, background 0.2s;
}

.login-features li:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(59, 130, 246, 0.2);
}

.login-feature-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(59, 130, 246, 0.12);
    border-radius: 8px;
    color: var(--primary);
}

.login-feature-icon svg { width: 18px; height: 18px; }

.login-features strong {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.125rem;
}

.login-features span {
    font-size: 0.8125rem;
    color: var(--text-muted);
    line-height: 1.45;
}

.login-main {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 2.75rem 2rem;
    background: var(--bg);
}

.login-card {
    width: 100%;
    max-width: 420px;
    animation: loginFadeIn 0.5s ease;
}

@keyframes loginFadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-card-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.login-card-header h2 {
    font-size: 1.375rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.25rem;
}

.login-card-header p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.login-card-logo { display: none; }

.login-error {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #fecaca;
    padding: 0.875rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
    line-height: 1.45;
}

.login-error svg {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    margin-top: 0.0625rem;
    color: #f87171;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.login-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.login-field > span {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-muted);
}

.login-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.login-input-icon {
    position: absolute;
    left: 0.875rem;
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    pointer-events: none;
    transition: color 0.2s;
}

.login-input-wrap:focus-within .login-input-icon {
    color: var(--primary);
}

.login-form input {
    width: 100%;
    padding: 0.75rem 0.875rem 0.75rem 2.625rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.9375rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.login-form input::placeholder {
    color: #5c6578;
}

.login-form input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.login-input-wrap input[type="password"],
.login-input-wrap input[type="text"]#loginPassword {
    padding-right: 2.75rem;
}

.login-toggle-pass {
    position: absolute;
    right: 0.625rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
}

.login-toggle-pass:hover {
    color: var(--text);
    background: var(--surface-2);
}

.login-toggle-pass svg {
    width: 18px;
    height: 18px;
}

.btn-login {
    margin-top: 0.25rem;
    padding: 0.8125rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 600;
    gap: 0.5rem;
}

.btn-login svg {
    width: 18px;
    height: 18px;
    transition: transform 0.2s;
}

.btn-login:hover:not(:disabled) svg {
    transform: translateX(3px);
}

.btn-login .spinner {
    width: 18px;
    height: 18px;
    border-width: 2px;
}

.login-footer-note {
    margin-top: 1.5rem;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.btn-block { width: 100%; justify-content: center; }

@media (max-width: 900px) {
    .login-shell {
        grid-template-columns: 1fr;
    }

    .login-hero {
        display: none;
    }

    .login-main {
        min-height: 100vh;
        padding: 1.5rem;
    }

    .login-card-logo {
        display: flex;
    }

    .login-card-header {
        flex-direction: column;
        text-align: center;
        gap: 0.875rem;
    }
}

/* Sidebar user */
.sidebar-user {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
    margin-bottom: 0.5rem;
    border-top: 1px solid var(--border);
    font-size: 0.8125rem;
    color: var(--text-muted);
}

/* Settings */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
}

.card-wide { grid-column: 1 / -1; }

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.settings-form label {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.settings-form label span {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
}

.settings-form input {
    padding: 0.625rem 0.875rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--mono);
    font-size: 0.875rem;
    outline: none;
}

.settings-form input:focus { border-color: var(--primary); }

.settings-form select,
.settings-form textarea {
    padding: 0.625rem 0.875rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.875rem;
    outline: none;
    resize: vertical;
}

.settings-form select:focus,
.settings-form textarea:focus { border-color: var(--primary); }

.form-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 0.25rem;
}

.test-result {
    font-size: 0.8125rem;
    padding: 0.75rem 0.875rem;
    border-radius: var(--radius);
    margin-top: 0.25rem;
    line-height: 1.5;
}

.test-result-line {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

.test-result-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.75rem;
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
}

.test-result-details {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.375rem;
    margin-top: 0.375rem;
    font-size: 0.75rem;
    opacity: 0.9;
    font-family: var(--mono);
}

.test-result-sep {
    opacity: 0.5;
    font-family: inherit;
}

.test-result.success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: var(--success);
}

.test-result.error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fecaca;
}

.test-result.hidden { display: none; }

.conn-help {
    font-size: 0.8125rem;
    line-height: 1.6;
    padding: 0.875rem 1rem;
    border-radius: var(--radius);
    margin-top: 0.75rem;
    background: #422006;
    border: 1px solid #854d0e;
    color: #fde68a;
    white-space: pre-line;
}

.conn-help p { margin: 0.375rem 0; color: #fde68a; }
.conn-help strong { color: #fef3c7; }

.conn-help code,
#mariadbHelpBox code {
    display: block;
    margin-top: 0.5rem;
    padding: 0.625rem 0.875rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: var(--mono);
    font-size: 0.8125rem;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-all;
}

#mariadbHelpBox {
    background: rgba(59, 130, 246, 0.08);
    border-color: rgba(59, 130, 246, 0.25);
    color: var(--text-muted);
    margin-bottom: 1rem;
}

#mariadbHelpBox strong { color: var(--text); }

.conn-help.hidden { display: none; }

.conn-summary {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.conn-field {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.625rem 0.875rem;
}

.conn-label {
    display: block;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.conn-value {
    font-family: var(--mono);
    font-size: 0.875rem;
    color: var(--primary);
    word-break: break-all;
}

/* Settings layout */
.settings-layout {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
}

.settings-info-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.5rem;
}

.settings-info-card.card-wide {
    grid-column: 1 / -1;
}

.settings-info-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.settings-info-title {
    display: flex;
    align-items: center;
    gap: 0.875rem;
}

.settings-info-title h3 {
    font-size: 0.9375rem;
    font-weight: 600;
    margin: 0 0 0.25rem;
}

.settings-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.settings-icon svg { width: 20px; height: 20px; }

.settings-icon.mariadb { background: rgba(59, 130, 246, 0.15); color: var(--primary); }
.settings-icon.user { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.settings-icon.users { background: rgba(168, 85, 247, 0.15); color: #a855f7; }

.status-badge {
    display: inline-block;
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 20px;
    background: var(--surface-2);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.status-badge.ok { background: rgba(34, 197, 94, 0.12); color: var(--success); border-color: rgba(34, 197, 94, 0.3); }
.status-badge.warn { background: rgba(245, 158, 11, 0.12); color: #fbbf24; border-color: rgba(245, 158, 11, 0.3); }

.info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.info-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
}

.info-item-wide { grid-column: 1 / -1; }

.info-label {
    display: block;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
}

.info-value {
    font-family: var(--mono);
    font-size: 0.875rem;
    color: var(--primary);
    word-break: break-all;
}

.info-value.muted { color: var(--text-muted); font-family: var(--font); font-size: 0.8125rem; }

.settings-card-actions {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* Modal improvements */
.modal-lg { max-width: 520px; }

/* Gestão de mesas — página inteira */

.mesas-toolbar {
    margin-bottom: 1rem;
}

.mesas-back {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.mesas-stats {
    margin-bottom: 1rem;
}

.mesas-section {
    margin-bottom: 1.25rem;
}

.mesas-section-header {
    align-items: flex-start;
}

.db-code-inline {
    font-family: var(--mono);
    font-size: 0.8125em;
    background: var(--surface-2);
    padding: 0.05em 0.35em;
    border-radius: 4px;
}

.mesa-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
    gap: 0.875rem;
    padding: 0.25rem 0 0.5rem;
}

.mesa-card {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.875rem 1rem;
    background: var(--surface-1);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-height: 7.75rem;
}

.mesa-card-aberta {
    border-color: rgba(34, 197, 94, 0.45);
    box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.08) inset;
}

.mesa-card-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.mesa-card-ticket {
    font-size: 1.45rem;
    font-weight: 700;
    font-family: var(--mono);
    color: var(--text);
    line-height: 1.15;
    word-break: break-all;
}

.mesa-card-meta {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.mesa-card-total {
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--primary);
    margin-top: auto;
}

.mesa-card-id {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: var(--mono);
}

.mesa-loading,
.mesa-empty {
    padding: 1rem 0;
    color: var(--text-muted);
    font-size: 0.875rem;
}

    padding: 0.4rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-mesa img {
    display: block;
    object-fit: contain;
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.modal-header > div:first-child {
    flex: 1;
    min-width: 0;
}

.modal-header h3 { margin: 0 0 0.25rem; }

.modal-close {
    font-size: 1.25rem;
    line-height: 1;
    padding: 0.25rem 0.5rem;
}

.modal-tip {
    margin-bottom: 1rem;
    background: rgba(59, 130, 246, 0.08) !important;
    border-color: rgba(59, 130, 246, 0.25) !important;
    color: var(--text-muted) !important;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.875rem;
}

.hidden { display: none !important; }

/* Responsive — empilha só em telas bem estreitas */
@media (max-width: 640px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { padding: 1rem; }
    .sidebar-nav { flex-direction: row; overflow-x: auto; }
    .sidebar-footer { display: none; }
    .main { padding: 1rem; }
    .create-form { flex-direction: column; }
    .create-form input { max-width: 100%; }
    .create-form-stacked .form-row { grid-template-columns: 1fr; }
    .info-detail-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }

    .db-table thead { display: none; }

    .db-table tbody tr {
        display: block;
        border-bottom: 1px solid var(--border);
        padding: 0.75rem 0;
    }

    .db-table tbody tr:last-child { border-bottom: none; }

    .db-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 1rem;
        padding: 0.5rem 0;
        border-bottom: none;
    }

    .db-table tbody td::before {
        content: attr(data-label);
        font-size: 0.75rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: var(--text-muted);
        flex-shrink: 0;
    }

    .db-table tbody td.col-numeric {
        text-align: right;
    }

    .db-table tbody td.col-actions .actions {
        margin-left: auto;
    }

    .backups-table thead { display: none; }

    .backups-table tbody tr {
        display: block;
        border-bottom: 1px solid var(--border);
        padding: 0.75rem 0;
    }

    .backups-table tbody tr:last-child { border-bottom: none; }

    .backups-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 1rem;
        padding: 0.5rem 0;
        border-bottom: none;
    }

    .backups-table tbody td::before {
        content: attr(data-label);
        font-size: 0.75rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: var(--text-muted);
        flex-shrink: 0;
    }

    .backups-table tbody td.col-numeric {
        text-align: right;
    }

    .backups-table tbody td.col-actions .actions {
        margin-left: auto;
    }
    .page-header { flex-direction: column; }
    .settings-layout { grid-template-columns: 1fr; }
    .info-grid { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .conn-summary { grid-template-columns: 1fr; }
}
