/* -------------------------------------------------------------
   ESTUDIO AGATHO - SISTEMA DE DISEÑO MINIMALISTA GRIS/NEGRO
   ------------------------------------------------------------- */

:root {
    --bg-main: #F8F9FA;
    --bg-card: #FFFFFF;
    --text-dark: #121212;
    --text-medium: #4A4A4A;
    --text-muted: #8E8E93;
    --border-color: #E5E5EA;
    --border-dark: #2C2C2E;
    --accent-dark: #1C1C1E;
    --accent-success: #242426;
    --accent-info: #E5E5EA;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.05);
    --radius: 6px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* GENERAL STYLES */
body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-dark);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.5;
}

/* APP SPA LAYOUT STYLES */
.app-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* SIDEBAR STYLING */
.sidebar-nav {
    background-color: var(--accent-dark);
    color: white;
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    border-right: 1px solid var(--border-dark);
    overflow-y: auto;
    z-index: 100;
}

.sidebar-nav .logo-area {
    padding: 8px 12px 24px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 24px;
}

.logo-image {
    height: 34px;
    width: auto;
    display: block;
    object-fit: contain;
    filter: brightness(0) invert(1);
    opacity: 0.95;
    transition: var(--transition);
}

.logo-image:hover {
    opacity: 1;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.nav-item {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.65);
    padding: 12px 16px;
    text-align: left;
    font-size: 13.5px;
    font-weight: 500;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: inherit;
    transition: var(--transition);
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.06);
    color: white;
}

.nav-item.active {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    font-weight: 600;
}

.nav-icon {
    font-size: 16px;
}

.sidebar-footer {
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-settings-nav {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-settings-nav:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-color: rgba(255, 255, 255, 0.2);
}

/* MAIN CONTENT AREA */
.main-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    background-color: var(--bg-main);
    padding: 0 32px 32px 32px;
    box-sizing: border-box;
}

/* HEADER AND LOGO BRANDING */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 32px;
    background-color: var(--bg-main);
    position: sticky;
    top: 0;
    z-index: 50;
}

.app-header h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.6px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

/* LED CONNECTION INDICATOR */
.connection-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #EFEFF4;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-medium);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.connection-indicator .led {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.connection-indicator .led.green {
    background-color: #34C759;
    box-shadow: 0 0 6px #30d158;
    animation: ledPulse 2s infinite;
}

.connection-indicator .led.orange {
    background-color: #FF9500;
    box-shadow: 0 0 6px #ff9f0a;
}

.connection-indicator .led.red {
    background-color: #FF3B30;
    box-shadow: 0 0 6px #ff453a;
}

@keyframes ledPulse {
    0% { opacity: 0.7; }
    50% { opacity: 1; }
    100% { opacity: 0.7; }
}

.conn-text {
    font-family: monospace;
}

/* USER PROFILE */
.user-profile {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 20px;
    transition: var(--transition);
    border: 1px solid transparent;
}

.user-profile:hover {
    background-color: #EFEFF4;
    border-color: var(--border-color);
}

.profile-avatar {
    width: 28px;
    height: 28px;
    background-color: var(--text-dark);
    color: white;
    font-size: 11px;
    font-weight: 600;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-dark);
}

/* SPA VIEWS ROUTING SYSTEM */
.spa-view {
    display: none;
    opacity: 0;
    transform: translateY(12px);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.spa-view.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
    animation: viewFadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

/* DASHBOARD METRIC CARDS */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.metric-card h3 {
    margin: 0 0 8px 0;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    font-weight: 600;
}

.metric-card .metric-value {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin: 0 0 6px 0;
    color: var(--text-dark);
}

.metric-card .metric-sub {
    font-size: 12px;
    color: var(--text-muted);
}

.metric-card.highlight {
    background-color: var(--text-dark);
    border-color: var(--text-dark);
}

.metric-card.highlight * {
    color: white;
}

.metric-card.highlight h3 {
    color: rgba(255,255,255,0.6);
}

/* DASHBOARD LAYOUT DETAILS */
.dashboard-details {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 24px;
    margin-top: 12px;
}

@media (max-width: 992px) {
    .dashboard-details {
        grid-template-columns: 1fr;
    }
}

.summary-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 16px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    font-size: 13.5px;
    color: var(--text-medium);
}

.summary-row.divider {
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
    margin-top: 8px;
    font-weight: 600;
    color: var(--text-dark);
}

.summary-row strong {
    font-size: 14.5px;
    color: var(--text-dark);
}

/* DATA TABLE STYLES (GENERAL) */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    text-align: left;
}

.data-table th {
    padding: 12px 16px;
    border-bottom: 1.5px solid var(--border-color);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-dark);
    vertical-align: middle;
}

.data-table tbody tr:hover td {
    background-color: #F8F9FA;
}

/* STATUS BADGES */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge.cobrada, .badge.pagado, .badge.si {
    background-color: #E8F5E9;
    color: #2E7D32;
}

.badge.pendiente, .badge.no {
    background-color: #FFF3E0;
    color: #EF6C00;
}

.badge.vencida {
    background-color: #FFEBEE;
    color: #C62828;
}

/* LIST HEADER AND FILTERS */
.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 16px;
    flex-wrap: wrap;
    gap: 16px;
}

.list-header h2 {
    margin: 0;
    border-bottom: none !important;
    padding-bottom: 0 !important;
}

.filters-container {
    display: flex;
    gap: 16px;
    align-items: center;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-group label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
}

.filter-group select {
    padding: 6px 12px;
    font-size: 12.5px;
    border-radius: 4px;
}

/* WORKSPACE LAYOUT (SIDEBAR + FORM) */
.workspace {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 24px;
    align-items: start;
}

@media (max-width: 992px) {
    .workspace {
        grid-template-columns: 1fr;
    }
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 28px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.card h2 {
    margin: 0 0 20px 0;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.3px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

/* EMISOR DETAILS SIDEBAR CARD */
.emisor-details-card h3 {
    margin: 0 0 16px 0;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.emisor-info-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-value {
    font-size: 13px;
    font-weight: 400;
    color: var(--text-dark);
    line-height: 1.4;
    word-break: break-word;
}

#emisor-iban {
    font-family: monospace;
    background: #F2F2F7;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
    font-size: 11px;
}

/* FORM FIELDS */
.form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

@media (max-width: 600px) {
    .form-row {
        flex-direction: column;
        gap: 12px;
    }
}

.form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-medium);
    letter-spacing: 0.5px;
}

input, select, textarea {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    background-color: #FFFFFF;
    font-size: 14px;
    border-radius: 4px;
    outline: none;
    font-family: inherit;
    transition: var(--transition);
    color: var(--text-dark);
}

input:focus, select:focus, textarea:focus {
    border-color: var(--text-dark);
}

input[readonly] {
    background-color: #F2F2F7;
    color: var(--text-muted);
    cursor: not-allowed;
}

/* TABLE STYLING */
.items-section {
    margin-top: 32px;
    margin-bottom: 24px;
}

.items-section h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-dark);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.table-responsive {
    overflow-x: auto;
    margin-bottom: 16px;
    border-radius: 4px;
}

.items-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

.items-table th {
    background-color: var(--accent-dark);
    color: white;
    text-align: left;
    padding: 10px 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.items-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.items-table input {
    padding: 6px 8px;
    font-size: 13px;
    border-radius: 3px;
}

.items-table .btn-delete-line {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 4px;
    color: var(--text-muted);
    transition: var(--transition);
}

.items-table .btn-delete-line:hover {
    color: #FF3B30;
}

/* BUTTONS */
.btn {
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-decoration: none;
}

.btn.primary {
    background-color: var(--text-dark);
    color: white;
}

.btn.primary:hover {
    background-color: #2c2c2e;
}

.btn.secondary {
    background-color: transparent;
    color: var(--text-dark);
    border: 1px solid var(--text-dark);
}

.btn.secondary:hover {
    background-color: #F2F2F7;
}

.btn.success {
    background-color: white;
    color: var(--text-dark);
    border: 1px solid var(--border-color);
}

.btn.success:hover {
    background-color: #F2F2F7;
    border-color: var(--text-dark);
}

.btn.info {
    background-color: #EFEFF4;
    color: var(--text-medium);
    border: 1px solid var(--border-color);
}

.btn.info:hover {
    background-color: #E5E5EA;
    color: var(--text-dark);
}

.btn.mini {
    padding: 6px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 3px;
}

/* FORM TOTALS */
.form-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 24px;
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}

.totals-box {
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.total-line {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-medium);
}

.total-line.final {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-dark);
    border-top: 1px solid var(--text-dark);
    padding-top: 10px;
    margin-top: 4px;
}

.actions-box {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}

@media (max-width: 600px) {
    .actions-box {
        flex-direction: column;
        gap: 8px;
    }
    .btn {
        width: 100%;
    }
}

/* MODALS LAYOUT */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(18, 18, 18, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease-out;
}

.modal-box {
    background: white;
    padding: 36px;
    width: 90%;
    max-width: 520px;
    border-radius: var(--radius);
    box-shadow: 0 20px 40px rgba(0,0,0,0.15);
    border: 1px solid var(--border-color);
    animation: scaleUp 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.settings-modal-box {
    max-width: 680px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-box h2 {
    margin: 0 0 16px 0;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.5px;
    color: var(--text-dark);
}

.modal-box p, .modal-box ol {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-medium);
}

.modal-box ol {
    padding-left: 20px;
    margin-bottom: 16px;
}

.modal-box li {
    margin-bottom: 8px;
}

.modal-footer-text {
    font-style: italic;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 16px;
    display: block;
}

/* STEP GUIDE AND CODE BOX FOR SETTINGS */
.step-guide {
    background: #F8F9FA;
    border: 1px solid var(--border-color);
    padding: 16px;
    border-radius: 4px;
    margin-bottom: 16px;
}

.step-guide strong {
    color: var(--text-dark);
    font-size: 12px;
}

.settings-input-group {
    margin-bottom: 20px;
}

.settings-input-group label {
    margin-bottom: 6px;
    display: block;
}

.help-text {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    display: block;
}

.apps-script-code-box {
    margin-top: 16px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.code-header {
    background: #F2F2F7;
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-medium);
}

.btn-copy {
    background: white;
    border: 1px solid var(--border-color);
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 10px;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.btn-copy:hover {
    background: var(--text-dark);
    color: white;
    border-color: var(--text-dark);
}

#apps-script-code {
    width: 100%;
    height: 140px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 11px;
    background: #1C1C1E;
    color: #F8F9FA;
    padding: 12px;
    box-sizing: border-box;
    border: none;
    resize: none;
    outline: none;
}

.modal-settings-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleUp {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* FLOATING TOAST SYSTEM */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--accent-dark);
    color: white;
    padding: 12px 20px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 260px;
    max-width: 380px;
    transform: translateY(20px);
    opacity: 0;
    animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    border-left: 4px solid var(--text-muted);
}

.toast.success {
    border-left-color: #30d158;
}

.toast.error {
    border-left-color: #ff453a;
}

.toast.info {
    border-left-color: #0a84ff;
}

@keyframes toastIn {
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* CUSTOM SCROLLBARS FOR A CLEAN LOOK */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #C7C7CC;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* RESPONSIVE DESIGN - COLLAPSING SIDEBAR TO PREMIUM VERTICAL DRAWER */
.mobile-menu-toggle {
    display: none;
    background: transparent;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-dark);
    padding: 4px;
    line-height: 1;
    font-family: inherit;
    transition: var(--transition);
}

.mobile-menu-toggle:hover {
    opacity: 0.7;
}

.mobile-menu-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 998;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.mobile-menu-backdrop.show {
    display: block;
    opacity: 1;
    pointer-events: auto;
}

@media (max-width: 868px) {
    .mobile-menu-toggle {
        display: block;
    }

    .app-layout {
        grid-template-columns: 1fr;
        height: 100vh;
        width: 100vw;
        overflow: hidden;
    }
    
    .sidebar-nav {
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        height: 100%;
        background-color: var(--accent-dark);
        border-right: 1px solid var(--border-dark);
        padding: 24px 20px;
        display: flex;
        flex-direction: column;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        z-index: 1000;
        box-shadow: 20px 0 40px rgba(0,0,0,0.15);
    }

    .sidebar-nav.show-mobile-menu {
        transform: translateX(0);
    }
    
    .sidebar-nav .logo-area {
        padding: 8px 12px 24px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        margin-bottom: 24px;
        display: block;
    }
    
    .nav-menu {
        display: flex;
        flex-direction: column;
        gap: 8px;
        flex-grow: 1;
    }
    
    .nav-item {
        padding: 12px 16px;
        font-size: 13.5px;
        white-space: normal;
    }
    
    .sidebar-footer {
        padding-top: 16px;
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        display: flex;
        flex-direction: column;
        gap: 8px;
    }
    
    .btn-settings-nav {
        padding: 10px 14px;
        font-size: 12px;
    }
    
    .main-content {
        padding: 0 20px 20px 20px;
        height: 100%;
        overflow-y: auto;
        box-sizing: border-box;
    }
    
    .app-header {
        position: sticky;
        top: 0;
        padding: 16px 0;
        margin-bottom: 24px;
        background-color: var(--bg-main);
        z-index: 50;
    }

    /* ERGONOMIC TOUCH SCREEN FORMS (Stack at 768px for portrait tablets & mobile) */
    .form-row {
        flex-direction: column;
        gap: 12px;
    }

    /* SMOOTH NATIVE KINETIC SCROLL FOR ALL MOBILE TABLES */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }
}

/* NARROW PHONE OPTIMIZATIONS (iPhone, Android) */
@media (max-width: 600px) {
    /* 1. Header Optimization (Hide long text to save space) */
    .profile-name {
        display: none !important;
    }
    
    .user-profile {
        padding: 4px !important;
        gap: 0 !important;
        background: transparent !important;
        border-color: transparent !important;
    }

    .conn-text {
        display: none !important;
    }
    
    .connection-indicator {
        gap: 0 !important;
        padding: 6px !important;
        border-radius: 50% !important;
        background: rgba(0,0,0,0.03) !important;
    }

    /* 2. Modals Padding Optimization */
    .modal-box {
        padding: 24px 20px !important;
    }
    
    /* 3. Action Buttons stack ergonomically */
    .actions-box {
        flex-direction: column !important;
        gap: 8px !important;
    }
    
    .actions-box .btn {
        width: 100% !important;
    }

    /* 4. Dashboard Metric cards look tighter and clean */
    .metric-card {
        padding: 20px !important;
    }

    /* 5. Invoicing Concept rows input padding tighter */
    .items-table th, .items-table td {
        padding: 6px 8px !important;
    }

    .items-table input {
        padding: 4px 6px !important;
        font-size: 12px !important;
    }
}


/* =============================================================
   PRINT MEDIA STYLES - PIXEL-PERFECT A4 CORRESPONDENCE
   ============================================================= */

/* Hide print layout by default on screen */
.print-only {
    display: none;
}

@media print {
    /* Hide everything on screen */
    body {
        background-color: #FFFFFF !important;
        color: #000000 !important;
        font-size: 11pt !important;
        line-height: 1.3 !important;
    }
    
    .app-layout,
    .sidebar-nav,
    .main-content,
    .modal-overlay,
    .toast-container,
    #toast-container,
    button,
    .btn,
    .app-header,
    .dashboard-grid,
    .workspace,
    .sidebar-box,
    .form-card,
    #doc-form,
    .spa-view {
        display: none !important;
    }
    
    /* Make printable area full page */
    .print-only {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    /* Document Setup */
    @page {
        size: A4 portrait;
        margin: 1.5cm;
    }
    
    /* Print Header */
    .print-header {
        display: flex !important;
        justify-content: space-between !important;
        align-items: flex-start !important;
        margin-bottom: 25px !important;
    }
    
    .print-logo-area {
        width: 160px !important;
    }
    
    .print-logo-image {
        width: 100% !important;
        height: auto !important;
        display: block !important;
        object-fit: contain !important;
        filter: grayscale(100%) !important;
    }
    
    .print-emisor-box {
        text-align: right !important;
        font-size: 9pt !important;
        color: #1c1c1e !important;
        line-height: 1.4 !important;
    }
    
    .print-emisor-box h2 {
        font-size: 13pt !important;
        font-weight: 700 !important;
        margin: 0 0 6px 0 !important;
        letter-spacing: -0.3px !important;
        color: #000000 !important;
    }
    
    .print-emisor-box p {
        margin: 2px 0 !important;
    }
    
    .print-divider {
        border-bottom: 1px solid #1c1c1e !important;
        margin-bottom: 20px !important;
        width: 100% !important;
    }
    
    /* Grid Meta */
    .print-meta-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 30px !important;
        margin-bottom: 30px !important;
        font-size: 9.5pt !important;
    }
    
    .print-meta-col {
        line-height: 1.5 !important;
    }
    
    .print-meta-col p {
        margin: 3px 0 !important;
    }
    
    .print-sub-title {
        font-size: 8pt !important;
        font-weight: 700 !important;
        letter-spacing: 1px !important;
        text-transform: uppercase !important;
        color: #48484a !important;
        border-bottom: 1px solid #e5e5ea !important;
        padding-bottom: 4px !important;
        margin: 0 0 10px 0 !important;
    }
    
    /* Print Table */
    .print-table {
        width: 100% !important;
        border-collapse: collapse !important;
        margin-bottom: 30px !important;
        font-size: 9pt !important;
    }
    
    .print-table th {
        border-bottom: 1px solid #1c1c1e !important;
        padding: 8px 6px !important;
        font-size: 8pt !important;
        font-weight: 700 !important;
        text-transform: uppercase !important;
        color: #000000 !important;
        text-align: left !important;
    }
    
    .print-table td {
        border-bottom: 1px solid #e5e5ea !important;
        padding: 10px 6px !important;
        vertical-align: top !important;
    }
    
    .print-table tr {
        page-break-inside: avoid !important;
    }
    
    /* Bottom Layout */
    .print-footer-section {
        display: flex !important;
        justify-content: space-between !important;
        align-items: flex-start !important;
        margin-top: 20px !important;
        page-break-inside: avoid !important;
    }
    
    .print-bank-info {
        width: 50% !important;
        font-size: 8.5pt !important;
        color: #2c2c2e !important;
        line-height: 1.4 !important;
    }
    
    .print-bank-info p {
        margin: 4px 0 !important;
    }
    
    .print-thankyou {
        margin-top: 15px !important;
        font-style: italic !important;
        color: #48484a !important;
    }
    
    .print-totals-box {
        width: 40% !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
    }
    
    .print-total-line {
        display: flex !important;
        justify-content: space-between !important;
        font-size: 9pt !important;
        color: #1c1c1e !important;
    }
    
    .print-total-line.print-total-final {
        font-size: 13pt !important;
        font-weight: 700 !important;
        color: #000000 !important;
        border-top: 1.5px solid #000000 !important;
        padding-top: 8px !important;
        margin-top: 4px !important;
    }
    
    .print-legal-footer {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        text-align: center !important;
        font-size: 7.5pt !important;
        color: #8e8e93 !important;
        border-top: 1px solid #e5e5ea !important;
        padding-top: 6px !important;
    }
}

/* -------------------------------------------------------------
   LOGIN SCREEN AND LOCK SYSTEM (ESTUDIO AGATHO BRANDING)
   ------------------------------------------------------------- */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-main);
    background-image: linear-gradient(135deg, #f5f5f7 0%, #e5e5ea 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.login-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
    transform: scale(1.04);
}

.login-card {
    background: var(--bg-card);
    padding: 40px;
    border-radius: var(--radius);
    box-shadow: 0 30px 60px rgba(0,0,0,0.1);
    border: 1px solid var(--border-color);
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-sizing: border-box;
}

.login-logo-area {
    margin-bottom: 24px;
}

.login-logo-image {
    height: 38px;
    width: auto;
    object-fit: contain;
    filter: grayscale(100%);
}

.login-card h2 {
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-dark);
    margin: 0 0 6px 0;
}

.login-subtitle {
    font-size: 12.5px;
    color: var(--text-muted);
    margin: 0 0 28px 0;
    line-height: 1.45;
}

.login-card .form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.login-card input[type="text"], 
.login-card input[type="password"] {
    width: 100%;
    box-sizing: border-box;
}

/* ERROR SHAKE ANIMATION */
.login-card.shake {
    animation: loginShake 0.4s cubic-bezier(.36,.07,.19,.97) both;
    border-color: #FF3B30;
    box-shadow: 0 10px 30px rgba(255, 59, 48, 0.15);
}

@keyframes loginShake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

/* LOGOUT BUTTON IN SIDEBAR */
.btn-logout-nav {
    width: 100%;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.4);
    padding: 8px 12px;
    font-size: 11.5px;
    font-weight: 500;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: inherit;
}

.btn-logout-nav:hover {
    background: rgba(255, 59, 48, 0.1);
    color: #ff453a;
    border-color: rgba(255, 59, 48, 0.3);
}

@media (max-width: 868px) {
    .btn-logout-nav {
        width: auto;
        padding: 8px 10px;
        font-size: 11px;
    }
}

/* SLEEK LOGOUT HEADER BUTTON */
.btn-logout-header {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-medium);
    font-size: 14px;
    cursor: pointer;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-logout-header:hover {
    background-color: rgba(255, 59, 48, 0.08);
    border-color: rgba(255, 59, 48, 0.25);
    color: #FF3B30;
    transform: scale(1.05);
}

/* OUTLINE DANGER BUTTON FOR CONFIGURATION FOOTER */
.btn-danger-outline {
    background: transparent;
    border: 1px solid #FF3B30;
    color: #FF3B30;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 4px;
    padding: 10px 18px;
    transition: var(--transition);
}

.btn-danger-outline:hover {
    background-color: #FF3B30;
    color: #FFFFFF;
    box-shadow: 0 4px 12px rgba(255, 59, 48, 0.2);
}

