/* Shared screen design. Document and report print styles live in gestion.css. */
@media screen {
    :root {
        --ink: #1d2e3e;
        --muted: #657786;
        --line: #e2e9eb;
        --canvas: #f4f7f7;
        --blue: #087f78;
        --blue-dark: #05635e;
        --blue-pale: #e6f4f1;
        --radius: 14px;
        --shadow: 0 3px 12px rgba(22, 44, 53, .025);
    }
    body { font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
    ::selection { background: #c9e9e3; color: #173d38; }
    :focus-visible { outline: 3px solid #36a89b; outline-offset: 4px; }
    .ui-icon { width: 20px; height: 20px; flex: 0 0 auto; vertical-align: middle; }
    .skip-link { position: fixed; top: -100px; left: 20px; z-index: 100; background: white; padding: 12px 20px; border-radius: 8px; }
    .skip-link:focus { top: 12px; }
    .sidebar { width: 248px; flex-basis: 248px; background: #142c36; padding: 26px 14px 16px; }
    .brand { gap: 12px; padding: 0 12px 24px; border-color: #2b414a; }
    .brand img { width: 43px; height: 43px; border-radius: 12px; }
    .brand strong { font-size: 14px; letter-spacing: .055em; }
    .brand small { color: #a5b7bc; font-size: 10px; letter-spacing: .015em; margin-top: 6px; }
    .nav-menu { flex: 1; min-height: 0; overflow-y: auto; padding: 19px 0; scrollbar-width: thin; scrollbar-color: #41565e transparent; }
    .nav-heading { font-size: 9px; letter-spacing: .13em; color: #92a9b0; margin-top: 22px; }
    .nav-link { padding: 9px 12px; gap: 12px; font-size: 12px; font-weight: 500; color: #b9cbd0; border: 1px solid transparent; border-radius: 9px; }
    .nav-link:hover { background: #203d47; }
    .nav-link.active { background: #224c53; border-color: #31636a; box-shadow: none; color: #e9fffa; }
    .nav-link.active .nav-icon { color: #73d3c1; }
    .nav-icon { width: 19px; display: inline-flex; }
    .nav-icon .ui-icon { width: 18px; height: 18px; }
    .sidebar-company { margin-top: 12px; flex-shrink: 0; background: #1b3640; border: 1px solid #2b4650; border-radius: 10px; padding: 13px; line-height: 1.6; color: #9db3ba; }
    .sidebar-company strong { color: #d9e7ea; }
    .sidebar .sidebar-close, .sidebar-overlay { display: none; }
    .main-panel { margin-left: 248px; }
    .topbar { height: 76px; padding: 0 36px; background: rgba(255,255,255,.95); }
    .topbar-title { gap: 6px; font-size: 12px; }
    .topbar-breadcrumb { color: var(--muted); font-weight: 400; display: flex; gap: 12px; align-items: center; }
    .topbar-breadcrumb > span { color: #b9c7cc; }
    .topbar-breadcrumb strong { color: var(--ink); font-weight: 600; }
    .topbar-title small { font-size: 11px; margin: 0; }
    .user-menu { gap: 11px; }
    .avatar { width: 37px; height: 37px; border: 1px solid #cee7df; border-radius: 12px; background: #eaf4f0; color: #277b68; }
    .icon-button { display: inline-grid; place-items: center; min-height: 38px; min-width: 38px; border: 1px solid var(--line); border-radius: 9px; margin-left: 8px; }
    .icon-button:hover { background: #eef6f3; }
    .content { padding: 34px 36px 38px; max-width: 1560px; }
    .page-heading { margin-bottom: 28px; gap: 24px; }
    .page-heading h1 { font-size: 30px; font-weight: 650; letter-spacing: -.045em; line-height: 1.2; margin: 8px 0; }
    .page-heading p { font-size: 13px; line-height: 1.6; }
    .eyebrow { font-size: 10px; letter-spacing: .12em; font-weight: 700; }
    .button { min-height: 42px; padding: 10px 16px; border-radius: 9px; font-size: 13px; font-weight: 600; box-sizing: border-box; }
    .button-primary { box-shadow: 0 2px 4px rgba(5, 99, 94, .12); }
    .button-secondary { border-color: #d8e2e5; color: #3b515e; }
    .button-secondary:hover { border-color: #a6cac1; background: #f5fbf8; }
    .dashboard-heading { padding: 27px 28px; border: 1px solid #d8e9e5; border-radius: 16px; background: linear-gradient(110deg, #eaf4f0, #f5f9f6); align-items: center; }
    .dashboard-heading h1 { font-size: 33px; }
    .dashboard-heading .page-actions { justify-content: flex-end; }
    .section-caption { display: flex; align-items: center; justify-content: space-between; margin: 0 0 14px; gap: 12px; }
    .section-caption h2 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -.02em; }
    .section-caption > span { font-size: 11px; color: var(--muted); }
    .stats-grid { gap: 16px; }
    .stat-card { padding: 22px; position: relative; min-width: 0; gap: 12px; }
    .primary-stats .stat-card { flex-direction: column; gap: 18px; }
    .stat-icon { width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0; }
    .stat-icon.violet { background: #edf0fa; color: #5869a0; }
    .stat-icon.blue { background: #eaf1f8; color: #4e729a; }
    .stat-icon.green { background: #e6f4ee; color: #2c8766; }
    .stat-icon.amber { background: #fbf1e0; color: #a3762e; }
    .stat-label { color: #536a76; font-size: 12px; font-weight: 500; }
    .stat-card strong { font-size: clamp(19px, 1.75vw, 28px); font-weight: 650; line-height: 1.35; margin: 5px 0; white-space: normal; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
    .stat-card strong em { font-size: 11px; font-weight: 500; }
    .stat-card small { color: var(--muted); font-size: 11px; line-height: 1.5; }
    .secondary-stats { margin-bottom: 28px; }
    .secondary-stats .stat-card { padding: 18px; background: #fafcfc; box-shadow: none; align-items: center; }
    .secondary-stats .stat-card strong { font-size: 20px; margin: 3px 0; }
    .secondary-stats .stat-icon { background: transparent; width: 25px; }
    .dashboard-grid { gap: 22px; grid-template-columns: minmax(0, 1.8fr) minmax(280px, 1fr); }
    .dashboard-purchases { margin-top: 22px; }
    .panel { padding: 24px; min-width: 0; }
    .panel-heading { margin-bottom: 22px; align-items: center; }
    .panel-heading h2 { font-size: 16px; font-weight: 650; }
    .panel-heading p { font-size: 12px; margin-top: 5px; line-height: 1.5; }
    .panel-heading > a { font-size: 11px; font-weight: 600; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; }
    .responsive-table table { font-variant-numeric: tabular-nums; }
    .responsive-table th { font-size: 10px; color: #677e89; background: #f4f7f7; padding: 12px; font-weight: 600; letter-spacing: .035em; }
    .responsive-table td { padding: 16px 12px; border-color: #edf1f1; font-size: 12px; }
    .responsive-table th:first-child, .responsive-table td:first-child { padding-left: 12px; }
    .responsive-table th:last-child, .responsive-table td:last-child { padding-right: 12px; }
    .responsive-table tbody tr { transition: background .15s; }
    .responsive-table tbody tr:hover { background: #f8fbfa; }
    .responsive-table td strong { font-weight: 600; }
    .responsive-table td small { font-size: 11px; margin-top: 4px; }
    .document-number { font-weight: 650; }
    .responsive-table .catalog-table { min-width: 930px; }
    .catalog-table :is(th, td):nth-child(n+4) { white-space: nowrap; }
    .catalog-table td:nth-child(2) { min-width: 220px; }
    .status { font-size: 10px; font-weight: 600; padding: 5px 9px; gap: 5px; }
    .status::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
    .status.neutral { background: #eef1f3; color: #647682; }
    .status.warning { background: #fcf1dd; color: #956312; }
    .stock-row { padding: 17px 0; }
    .stock-row strong { font-weight: 600; font-size: 12px; line-height: 1.5; }
    .stock-row small { font-size: 11px; }
    .stock-pill { font-weight: 600; border-radius: 6px; }

    /* ==========================================================================
       Harmonized Inputs & Controls (Consistent 42px height, 13.5px font-size)
       ========================================================================== */
    input:not([type=checkbox]):not([type=radio]):not([type=hidden]):not([type=button]):not([type=submit]):not([type=reset]):not(.line-table input):not([data-searchable-select-filter]),
    select:not(.line-table select):not(.native-searchable-select),
    textarea,
    .searchable-select-control:not(.line-table .searchable-select-control) {
        border: 1px solid #d8e2e5;
        background-color: #fcfdfd;
        border-radius: 9px;
        font-size: 13.5px;
        font-family: inherit;
        color: var(--ink);
        box-sizing: border-box;
        transition: border-color .15s, box-shadow .15s, background-color .15s;
    }

    input:not([type=checkbox]):not([type=radio]):not([type=hidden]):not([type=button]):not([type=submit]):not([type=reset]):not(.line-table input):not(textarea):not([data-searchable-select-filter]) {
        height: 42px;
        min-height: 42px;
        padding: 0 12px;
        line-height: 40px;
    }

    textarea {
        padding: 10px 12px;
        min-height: 70px;
        line-height: 1.5;
        resize: vertical;
    }

    /* All non-line-table dropdown selects */
    select:not(.line-table select):not(.native-searchable-select) {
        height: 42px;
        min-height: 42px;
        line-height: 40px;
        font-size: 13.5px;
        font-family: inherit;
        font-weight: 500;
        color: var(--ink);
        padding: 0 36px 0 12px;
        background-color: #fcfdfd;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 12px center;
        background-size: 16px 16px;
        appearance: none;
        -webkit-appearance: none;
        -moz-appearance: none;
        cursor: pointer;
    }

    /* Searchable select container and sub-elements */
    .searchable-select-control:not(.line-table .searchable-select-control) {
        height: 42px;
        min-height: 42px;
        display: flex;
        align-items: stretch;
        overflow: hidden;
    }
    .searchable-select-control:not(.line-table *) .searchable-select-input {
        height: 40px !important;
        min-height: 40px !important;
        line-height: 40px !important;
        font-size: 13.5px !important;
        font-family: inherit !important;
        padding: 0 12px !important;
        color: var(--ink) !important;
        background: transparent !important;
        box-sizing: border-box !important;
    }
    .searchable-select-control:not(.line-table *) .searchable-select-toggle {
        flex: 0 0 38px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        border: 0;
        border-left: 1px solid #e2e8f0;
        background: transparent;
        color: #64748b;
        font-size: 15px;
        cursor: pointer;
    }

    /* Table tools & toolbar filters */
    .table-tools {
        gap: 12px;
        margin-bottom: 24px;
        align-items: center;
    }
    .table-tools select {
        width: auto;
        min-width: 170px;
        max-width: 270px;
        flex: 0 1 auto;
    }
    .search-box {
        position: relative;
    }
    .search-box input {
        height: 42px;
        min-height: 42px;
        padding: 0 14px 0 38px;
        font-size: 13.5px;
        border-radius: 9px;
    }
    .search-box span {
        position: absolute;
        left: 13px;
        top: 50%;
        transform: translateY(-50%);
        font-size: 17px;
        line-height: 1;
        pointer-events: none;
        color: #8c97a8;
    }

    /* Report filter containers */
    .report-filter .field { max-width: none; min-width: 0; }
    .report-filter form { flex-wrap: wrap; align-items: flex-end; gap: 12px; }

    /* Focus states across all inputs */
    input:focus:not([type=checkbox]):not([type=radio]),
    select:focus:not(.native-searchable-select),
    textarea:focus,
    .searchable-select-control:focus-within,
    .searchable-select.is-open .searchable-select-control {
        border-color: #58a99e !important;
        box-shadow: 0 0 0 3px rgba(8,127,120,.1) !important;
        background-color: #ffffff !important;
        outline: none;
    }

    /* Cross-browser calendar date inputs */
    input[type=date] {
        display: inline-flex;
        align-items: center;
    }

    /* Compact document line item inputs */
    .line-table input:not([type=checkbox]):not([type=radio]),
    .line-table select:not(.native-searchable-select) {
        height: 38px;
        min-height: 38px;
        font-size: 13px;
        font-family: inherit;
        border-radius: 7px;
        border: 1px solid #d8e2e5;
        padding: 0 8px;
        box-sizing: border-box;
    }
    .line-table select:not(.native-searchable-select) {
        padding: 0 28px 0 8px;
        appearance: none;
        -webkit-appearance: none;
        -moz-appearance: none;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 8px center;
        background-size: 14px 14px;
        cursor: pointer;
    }
    .line-table select[data-unit] {
        min-width: 82px !important;
        max-width: 105px !important;
        font-weight: 600;
        color: #1e293b;
        background-color: #f8fafc;
    }
    .line-table .searchable-select-control {
        min-height: 38px;
        height: 38px;
        border-radius: 7px;
        border: 1px solid #d8e2e5;
    }
    .line-table .searchable-select-input {
        height: 36px !important;
        min-height: 36px !important;
        line-height: 36px !important;
        padding: 0 8px !important;
        font-size: 13px !important;
    }
    .line-table .searchable-select-toggle {
        flex: 0 0 30px;
        height: 36px;
        font-size: 14px;
    }

    .field label { font-weight: 600; }
    .field-hint { font-size: 11px; }
    .form-grid { gap: 20px; }
    .form-panel { padding: 28px; }
    .table-action { display: inline-flex; align-items: center; padding: 6px 8px; border-radius: 6px; }
    .table-action:hover { background: var(--blue-pale); }
    .table-action.danger:hover { background: var(--red-pale); }
    .empty-state { padding: 48px 20px; }
    .empty-state p { max-width: 360px; line-height: 1.6; }
    .pagination { padding-top: 20px; font-size: 12px; }
    .report-kpis article > strong { white-space: normal; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
    .report-tabs a { border-radius: 8px; padding: 9px 12px; }
    .bar-value { background: var(--blue); }
    .app-footer { padding: 18px 36px; background: transparent; color: #72858e; }
    .login-page { background: #edf3f1; padding: 36px; }
    .login-shell { width: min(100%, 1040px); display: grid; grid-template-columns: 1.05fr 1fr; border-radius: 24px; overflow: hidden; border: 1px solid #dce8e3; box-shadow: 0 24px 80px rgba(20,44,54,.09); }
    .login-story { padding: 40px; background: #142f39; color: white; display: flex; flex-direction: column; justify-content: space-between; min-height: 640px; }
    .login-story-brand { display: flex; align-items: center; gap: 13px; font-weight: 650; letter-spacing: .06em; }
    .login-story-brand img { width: 46px; height: 46px; object-fit: contain; padding: 5px; background: white; border-radius: 12px; }
    .login-story-brand small { display: block; font-size: 10px; color: #b3c9cb; margin-top: 6px; letter-spacing: .025em; font-weight: 400; }
    .login-story-copy { padding: 52px 0; }
    .login-story .eyebrow { color: #88d3bf; }
    .login-story h2 { font-size: 38px; font-weight: 550; line-height: 1.2; letter-spacing: -.045em; margin: 18px 0; }
    .login-story-copy p { color: #b7ced2; line-height: 1.8; font-size: 14px; max-width: 350px; }
    .login-features { display: grid; gap: 17px; margin-top: 32px; }
    .login-features span { display: flex; align-items: center; gap: 12px; color: #e4f1ef; font-size: 12px; }
    .login-features .ui-icon { color: #88d3bf; width: 18px; }
    .login-story-footer { font-size: 11px; color: #9fb9bf; }
    .login-card { width: 100%; padding: 46px; border-radius: 0; box-shadow: none; align-content: center; }
    .login-brand { display: none; }
    .login-intro { padding: 0 0 24px; }
    .login-intro h1 { font-size: 28px; font-weight: 650; line-height: 1.25; margin: 12px 0; }
    .login-intro p { line-height: 1.7; font-size: 13px; }
    .login-form { gap: 9px; }
    .login-form label:not(.check-label) { font-weight: 600; }
    .login-form input:not([type=checkbox]) { min-height: 46px; }
    .login-form .button { min-height: 46px; justify-content: space-between; }
    .login-legal { font-size: 11px; line-height: 1.6; }
}
@media screen and (max-width: 1200px) {
    .dashboard-grid { grid-template-columns: 1fr; }
    .dashboard-heading { align-items: flex-start; flex-direction: column; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media screen and (max-width: 760px) {
    .sidebar { width: 270px; padding-top: 22px; }
    .sidebar .sidebar-close { display: inline-grid; position: absolute; top: 18px; right: 12px; color: #cee0e2; background: #203d47; border-color: #3b535c; margin: 0; }
    .sidebar .brand { padding-right: 30px; }
    .sidebar .brand span { display: none; }
    .sidebar-overlay:not([hidden]) { display: block; position: fixed; inset: 0; background: rgba(15,34,43,.5); backdrop-filter: blur(2px); border: 0; z-index: 19; }
    .menu-open { overflow: hidden; }
    .main-panel { margin-left: 0; }
    .topbar { height: 66px; padding: 0 18px; }
    .content { padding: 22px 18px 28px; }
    .dashboard-heading { padding: 23px 20px; }
    .dashboard-heading h1 { font-size: 28px; }
    .dashboard-heading .page-actions { flex-direction: column; }
    .page-actions .button { white-space: normal; text-align: center; }
    .page-heading h1 { font-size: 27px; }
    .section-caption { align-items: flex-start; flex-direction: column; gap: 5px; }
    .stats-grid { gap: 11px; }
    .primary-stats .stat-card { padding: 16px; gap: 12px; }
    .stat-card strong { font-size: 21px; }
    .secondary-stats .stat-card { padding: 15px; align-items: flex-start; flex-direction: column; gap: 8px; }
    .secondary-stats .stat-card strong { font-size: 19px; }
    .stat-card small { font-size: 10px; }
    .panel, .form-panel { padding: 18px; }
    .panel-heading { align-items: flex-start; gap: 10px; }
    .panel-heading > a { padding: 5px 7px; }
    .recent-panel .responsive-table table { min-width: 620px; }
    .table-tools { flex-wrap: wrap; }
    .table-tools select { max-width: none; }
    .app-footer { padding: 16px 18px; }
    .login-page { padding: 18px; }
    .login-shell { max-width: 470px; grid-template-columns: 1fr; border-radius: 18px; }
    .login-story { min-height: 0; padding: 22px 26px; }
    .login-story-copy, .login-story-footer { display: none; }
    .login-card { padding: 30px 26px; }
    .login-intro h1 { font-size: 26px; }
}
@media screen and (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media print {
    .skip-link, .sidebar-close, .sidebar-overlay, .section-caption { display: none !important; }
    .login-story { display: none; }
}
