:root {
    --ui-font: "Heebo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --ui-bg: #f5f7fb;
    --ui-surface: #ffffff;
    --ui-text: #0f172a;
    --ui-muted: #64748b;
    --ui-border: #dbe4ef;
    --ui-primary: #2563eb;
    --ui-primary-strong: #1d4ed8;
    --ui-radius-sm: 10px;
    --ui-radius-md: 14px;
    --ui-shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.05);
    --ui-shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
}

html, body {
    font-family: var(--ui-font) !important;
    background: var(--ui-bg);
    color: var(--ui-text);
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    letter-spacing: -0.01em;
    color: var(--ui-text);
}

input, select, textarea, button {
    font-family: var(--ui-font) !important;
}

input, select, textarea {
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius-sm);
    background: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

button {
    border-radius: var(--ui-radius-sm);
}

.card, .widget, .form-card, .search-card, .result-panel, .supplier-card, .news-card {
    border-radius: var(--ui-radius-md) !important;
    box-shadow: var(--ui-shadow-sm);
}

.header, .hero-section, .top-bar {
    box-shadow: var(--ui-shadow-sm);
}

.btn, .btn-submit, .btn-generate, .btn-send, .btn-top, .btn-action, .action-btn {
    border-radius: var(--ui-radius-sm) !important;
}

.btn-submit, .btn-generate, .btn-send {
    background: linear-gradient(90deg, var(--ui-primary), var(--ui-primary-strong));
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Main shell responsive layout */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.shell-topbar {
    height: 60px;
    background: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 20px;
}

.shell-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-dark);
}

.shell-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.shell-menu-btn {
    display: none;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #0f172a;
    border-radius: 10px;
    width: 38px;
    height: 38px;
    cursor: pointer;
}

.app-frame {
    width: 100%;
    flex: 1;
    border: none;
    background: var(--bg-light);
    min-height: calc(100vh - 60px);
}

.app-sidebar-overlay {
    display: none;
}

@media (max-width: 1024px) {
    .shell-topbar {
        padding: 0 12px;
    }
    .shell-title {
        font-size: 16px;
    }
    .shell-menu-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .sidebar {
        position: fixed !important;
        top: 0;
        bottom: 0;
        z-index: 1200;
        width: min(86vw, 320px) !important;
        min-height: 100vh !important;
        overflow-y: auto;
        transition: transform 0.22s ease;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
    }
    html[dir="rtl"] .sidebar {
        right: 0;
        transform: translateX(110%);
    }
    html[dir="ltr"] .sidebar {
        left: 0;
        transform: translateX(-110%);
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .app-sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1100;
        background: rgba(15, 23, 42, 0.45);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
    }
    body.sidebar-open .app-sidebar-overlay {
        opacity: 1;
        pointer-events: auto;
    }

    .app-frame {
        min-height: calc(100dvh - 60px);
    }
}

/* Generic responsive helpers for inner pages */
@media (max-width: 768px) {
    .form-grid,
    .grid,
    .cards,
    .inputs-grid,
    .doc-grid,
    .info-grid,
    .preview-panel,
    .action-buttons {
        grid-template-columns: 1fr !important;
    }

    .main-wrapper {
        flex-direction: column !important;
        height: auto !important;
    }

    .form-panel,
    .document-wrapper,
    .generator-card,
    .widget,
    .card {
        padding: 14px !important;
    }

    table {
        display: block;
        overflow-x: auto;
        width: 100%;
        -webkit-overflow-scrolling: touch;
    }

    input,
    select,
    textarea,
    button {
        max-width: 100%;
    }
}
