@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

:root {
    --bg: #F5F5F5;
    --panel: #ffffff;
    --panel-soft: #f9fafb;
    --sidebar: #000000;
    --text: #111827;
    --muted: #6b7280;
    --line: #e5e7eb;
    --green: #198C19;
    --green-dark: #146b14;
    --danger-bg: #fee2e2;
    --danger-text: #991b1b;
    --danger-line: #fecaca;
    --success-bg: #dcfce7;
    --success-text: #166534;
    --success-line: #bbf7d0;
    --warning-bg: #fef3c7;
    --warning-text: #92400e;
    --warning-line: #fde68a;
    --shadow: 0 12px 35px rgba(0, 0, 0, 0.08);
    --radius: 18px;
    --radius-lg: 24px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    font-family: 'Poppins', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

body { min-height: 100vh; overflow-x: hidden; }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

/* LOGIN */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--bg);
}

.login-wrapper {
    width: 100%;
    max-width: 1120px;
    min-height: 520px;
    display: grid;
    grid-template-columns: 1.08fr 0.92fr;
    background: var(--panel);
    border-radius: 28px;
    overflow: hidden;
    box-shadow: 0 22px 60px rgba(0,0,0,.10);
}

.login-left {
    background: #000000;
    color: #ffffff;
    padding: 32px 40px 36px;
    display: grid;
    grid-template-rows: auto 1fr auto;
}

.login-left-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 18px;
}

.login-left-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin-top: 0;
}

.login-left-logo img {
    max-width: 140px;
    width: 100%;
    height: auto;
    filter: brightness(0) invert(1);
}

.login-left h1 {
    margin: 0 0 10px;
    font-size: 26px;
    line-height: 1.2;
    font-weight: 700;
    color: #ffffff;
}

.login-left p {
    margin: 0;
    max-width: 420px;
    font-size: 14px;
    line-height: 1.75;
    color: #f3f4f6;
}

.login-social {
    margin-top: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

.login-social-mobile { display: none; }

.login-social-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.social-link {
    width: 42px;
    height: 42px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    border: none;
    background: transparent;
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.social-link svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.social-link:hover {
    transform: translateY(-1px);
    background: transparent;
    border-color: transparent;
    color: var(--green);
}

.whatsapp-float {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 56px;
    height: 56px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #25D366;
    color: #ffffff;
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.2);
    z-index: 999;
    transition: transform 0.2s ease, background 0.2s ease;
}

.whatsapp-float:hover {
    transform: translateY(-2px);
    background: #1fb95a;
}

.whatsapp-float svg {
    width: 26px;
    height: 26px;
    fill: currentColor;
}

.login-right {
    background: #ffffff;
    padding: 34px 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    width: 100%;
    max-width: 380px;
}

.login-subtitle {
    margin: 0 0 22px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--muted);
}

.alert {
    margin-bottom: 18px;
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 14px;
}

.alert-error,
.alert-danger {
    background: var(--danger-bg);
    color: var(--danger-text);
    border: 1px solid var(--danger-line);
}

.alert-success {
    background: var(--success-bg);
    color: var(--success-text);
    border: 1px solid var(--success-line);
}

.alert-warning {
    background: var(--warning-bg);
    color: var(--warning-text);
    border: 1px solid var(--warning-line);
}

.field { margin-bottom: 16px; }

.label,
.field label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.input,
.field input,
.field select,
.field textarea {
    width: 100%;
    min-height: 50px;
    padding: 12px 14px;
    border: 1px solid #cfd5df;
    border-radius: 14px;
    background: #eef3fb;
    color: var(--text);
    outline: none;
    transition: .18s ease;
    font-size: 14px;
}

.field textarea { min-height: 120px; resize: vertical; }

.input:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: var(--green);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(25, 140, 25, 0.10);
}

.form-row,
.login-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.remember {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #444;
}

.forgot-link,
.link {
    color: var(--green);
    font-size: 14px;
    font-weight: 600;
}

.forgot-link:hover,
.link:hover { color: var(--green-dark); text-decoration: underline; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 44px;
    padding: 0 16px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: .18s ease;
}

.btn-primary {
    background: var(--green);
    color: #ffffff;
}

.btn-primary:hover { background: var(--green-dark); }

.login-page .field { margin-bottom: 12px; }

.login-page .input,
.login-page .field input,
.login-page .field select,
.login-page .field textarea {
    min-height: 46px;
    padding: 10px 12px;
}

.login-page .form-row { margin-bottom: 16px; }
.login-page .btn { min-height: 42px; }

.btn-light,
.btn-secondary {
    background: #ffffff;
    color: var(--text);
    border: 1px solid var(--line);
    width: auto;
    min-height: 42px;
    font-size: 14px;
    padding: 0 14px;
}

.btn-light:hover,
.btn-secondary:hover { background: var(--panel-soft); }

/* APP */
.app-body { min-height: 100vh; }

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
}

.sidebar {
    background: var(--sidebar);
    color: #ffffff;
    padding: 22px 14px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.brand {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 6px 10px 12px;
}

.brand-logo {
    width: 118px;
    max-width: 100%;
    height: auto;
    filter: brightness(0) invert(1);
}

.menu {
    display: grid;
    gap: 8px;
}

.menu-link {
    color: #f3f4f6;
    padding: 12px 14px;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 600;
    transition: background .18s ease, color .18s ease;
}

.menu-link:hover,
.menu-link.active {
    background: rgba(255,255,255,.08);
    color: #ffffff;
}

.menu-link.menu-exit {
    margin-top: 8px;
    background: transparent;
    color: #ffffff;
}

.menu-link.menu-exit:hover,
.menu-link.menu-exit.active {
    background: rgba(255,255,255,.08);
    color: #ffffff;
}

.content {
    min-width: 0;
    padding: 28px;
}

.topbar {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.page-title {
    margin: 0;
    font-size: 30px;
    line-height: 1.2;
    font-weight: 600;
}

.page-subtitle {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.logout-link { display: none; }

.mobile-nav {
    display: none;
    gap: 10px;
    margin-bottom: 16px;
}

.mobile-nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 12px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: #ffffff;
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    transition: 0.2s ease;
}

.mobile-nav-link.active {
    background: var(--green);
    border-color: var(--green);
    color: #ffffff;
}

.user-chip {
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 500;
}

.grid { display: grid; gap: 18px; }
.grid-cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-dashboard { grid-template-columns: 1.2fr 0.8fr; margin-top: 18px; }
.grid-invoice-summary { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 18px; }

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
}

.metric-label {
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 8px;
}

.metric-value {
    font-size: 30px;
    font-weight: 700;
    line-height: 1.1;
}

.metric-help {
    margin-top: 8px;
    color: var(--muted);
    font-size: 14px;
}

.section-title {
    margin: 0 0 16px;
    font-size: 20px;
    font-weight: 600;
}

.section-subtitle {
    margin: -4px 0 16px;
    color: var(--muted);
    font-size: 14px;
}

.table-wrap { overflow: auto; }
.table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    font-size: 14px;
    vertical-align: middle;
}

.table th {
    color: var(--muted);
    font-weight: 600;
    background: var(--panel-soft);
}

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

.badge {
    display: inline-flex;
    align-items: center;
    padding: 7px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.badge.success { background: #dcfce7; color: #166534; }
.badge.warning { background: #fef3c7; color: #92400e; }
.badge.danger { background: #fee2e2; color: #991b1b; }
.badge.muted { background: #e5e7eb; color: #374151; }

.stat-list {
    display: grid;
    gap: 12px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #eceff3;
    font-size: 14px;
}

.stat-item:last-child { border-bottom: none; }

.empty {
    padding: 18px;
    border: 1px dashed #d1d5db;
    border-radius: 14px;
    color: var(--muted);
    background: #fafafa;
    font-size: 14px;
}

.footer-note {
    margin-top: 20px;
    color: var(--muted);
    font-size: 14px;
    text-align: center;
}

.service-name {
    font-weight: 600;
    color: var(--text);
}

.service-meta {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
}

.service-cycle {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
}

.service-action-link {
    color: var(--green);
    font-weight: 700;
}

.service-action-link:hover {
    color: var(--green-dark);
}

.service-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.45);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 9999;
}

.service-modal-overlay.is-open { display: flex; }

.service-modal-content {
    width: 100%;
    max-width: 420px;
    background: #ffffff;
    border-radius: 22px;
    padding: 22px 22px 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,.18);
    position: relative;
}

.service-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 999px;
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    color: #111827;
}

.service-modal-title {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: #111827;
    text-align: center;
    padding: 0 40px;
}

.service-modal-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.service-detail-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 10px;
}

.service-detail-text {
    min-width: 0;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    overflow-wrap: anywhere;
    word-break: break-word;
}

.service-detail-text-copy {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.service-detail-text-copy .service-detail-value {
    word-break: break-word;
    overflow-wrap: anywhere;
}

.service-detail-text strong { font-weight: 700; }

.service-detail-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    justify-content: flex-end;
    min-width: auto;
}

.service-copy-btn {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    width: 22px !important;
    height: 22px !important;
    min-width: 22px !important;
    min-height: 22px !important;
    border-radius: 0 !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #6b7280;
}

.service-copy-btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.service-copy-btn:hover {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    opacity: 0.85;
    color: var(--green);
}

.service-panel-link {
    color: var(--green);
    font-weight: 700;
}

.service-panel-link:hover { color: var(--green-dark); }

.service-modal-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 18px;
}

.service-modal-footer .btn { width: auto; }

@media (max-width: 1200px) {
    .login-wrapper {
        max-width: 1120px;
        grid-template-columns: 1fr 0.95fr;
    }

    .grid-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

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

    .login-left {
        padding: 18px 24px 2px;
        background: #ffffff;
        color: var(--text);
        text-align: center;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 6px;
    }

    .login-left-logo img { filter: none; }

    .login-left h1 { color: var(--text); }
    .login-left-content {
        display: block;
        margin-top: 2px;
        margin-bottom: 4px;
    }
    .login-left-content .feature { color: var(--text); }

    .login-left .login-social { display: none; }
    .login-social-mobile {
        display: flex;
        margin-top: 18px;
    }

    .login-social-mobile .social-link {
        color: #111827;
        border: none;
        background: transparent;
        border-radius: 0;
    }

    .login-left-logo { margin-bottom: 4px; }

    .login-left h1,
    .login-left p { text-align: center; }
    .login-left p { max-width: 100%; }
    .login-social { align-items: center; }
    .login-social-links { justify-content: center; }

    .login-right { padding: 6px 22px 28px; }
    .login-card { max-width: 100%; }

    .topbar-actions { width: 100%; justify-content: flex-start; }
    .mobile-nav { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .logout-link { display: inline-flex; }

    .sidebar { display: none; }

    .content { padding: 18px; min-width: 0; }
    .topbar { flex-direction: column; align-items: flex-start; }
    .grid-cards { grid-template-columns: 1fr; }
    .grid-dashboard { grid-template-columns: 1fr; }
    .grid-invoice-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }

    .service-modal-content { max-width: 100%; width: 100%; }
    .service-detail-row { grid-template-columns: 1fr; align-items: flex-start; }

    .filter-chips {
        justify-content: flex-start;
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 4px;
        margin-bottom: 12px;
        gap: 8px;
        -webkit-overflow-scrolling: touch;
    }
    .filter-chip {
        white-space: nowrap;
        flex: 0 0 auto;
        min-height: 34px;
        padding: 0 12px;
        font-size: 12px;
        border-radius: 12px;
    }

    .table-wrap { overflow: visible; }
    .table {
        display: block;
        width: 100%;
        min-width: 0;
        border: none;
    }

    .table thead { display: none; }

    .table tbody {
        display: grid;
        gap: 12px;
    }

    .table tr {
        display: grid;
        gap: 8px;
        padding: 12px;
        border: 1px solid var(--line);
        border-radius: 14px;
        background: #ffffff;
        box-shadow: var(--shadow);
    }

    .table td {
        display: grid;
        grid-template-columns: minmax(110px, 40%) 1fr;
        gap: 10px;
        padding: 6px 0;
        border-bottom: 1px dashed #e5e7eb;
        font-size: 14px;
    }

    .table td:last-child { border-bottom: none; }

    .table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-weight: 600;
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: 0.06em;
    }

    .actions-row.inline-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .actions-row.inline-actions .btn { width: 100%; }
}

@media (max-width: 640px) {
    .login-page { padding: 16px; }
    .login-left-logo img { max-width: 120px; }
    .page-title { font-size: 24px; }
    .metric-value { font-size: 26px; }
    .service-modal-content { padding: 22px 20px 20px; }
    .service-detail-row { grid-template-columns: 1fr; align-items: flex-start; }
    .service-detail-actions { gap: 12px; }
    .whatsapp-float { right: 18px; bottom: 18px; width: 52px; height: 52px; }

    .menu { grid-template-columns: 1fr; }
    .grid-invoice-summary { grid-template-columns: 1fr; }
}


.filter-chips {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 16px;
    border-radius: 14px;
    border: 1px solid #d1d5db;
    background: #ffffff;
    color: #111827;
    font-size: 14px;
    font-weight: 600;
    transition: 0.2s ease;
}

.filter-chip:hover,
.filter-chip.active {
    background: var(--panel-soft);
    border-color: #cfd5df;
}

.actions-row.inline-actions {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 0;
    align-items: center;
}

.btn-inline-small {
    width: auto;
    min-width: 132px;
    min-height: 38px;
    padding: 0 14px;
    font-size: 13px;
}

.invoice-actions-right {
    display: flex;
    justify-content: flex-end;
    margin-top: 12px;
}

.invoice-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.invoice-header .btn { white-space: nowrap; }
