:root {
    --bg: #f8fafc;
    --card: #ffffff;
    --primary: #10b981; /* Emerald 500 */
    --primary-dark: #059669;
    --primary-light: rgba(16, 185, 129, 0.1);
    --secondary: #0ea5e9; /* Sky 500 */
    --accent: #f59e0b; /* Amber 500 */
    --danger: #ef4444; /* Rose 500 */
    --t1: #0f172a; /* Slate 900 */
    --t2: #334155; /* Slate 700 */
    --t3: #64748b; /* Slate 500 */
    --line: #e2e8f0; /* Slate 200 */
    --line-light: #f1f5f9; /* Slate 100 */
    --shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.05), 0 2px 10px -2px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --mono: 'JetBrains Mono', 'Fira Code', monospace;
}

.pg-wrap {
    padding: 30px;
    max-width: 1400px;
    margin: 0 auto;
    animation: fadeIn 0.5s ease-out;
}

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

/* ── FORM CARD ── */
.pg-form-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.pg-form-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 4px; height: 100%;
    background: var(--primary);
}

.pg-form-title {
    font-size: 14px;
    font-weight: 800;
    color: var(--t1);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.pg-form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
}

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

.pg-form-group label {
    font-size: 11px;
    font-weight: 700;
    color: var(--t3);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.pg-select, .pg-date-input {
    background: #fdfdfd;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    color: var(--t1);
    font-size: 14px;
    padding: 10px 14px;
    height: 44px;
    outline: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.pg-select:focus, .pg-date-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-light);
    background: #fff;
}

.pg-btn-calc {
    height: 44px;
    padding: 0 24px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
    transition: all 0.2s;
}

.pg-btn-calc:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(16, 185, 129, 0.3);
}

.pg-btn-reset {
    height: 44px;
    padding: 0 20px;
    background: #fff;
    color: var(--t2);
    border: 1.5px solid var(--line);
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.pg-btn-reset:hover {
    background: var(--line-light);
    border-color: var(--t3);
}

/* ── SUMMARY GRID ── */
.pg-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.pg-summary-item {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
    transition: transform 0.2s;
}

.pg-summary-item:hover {
    transform: translateY(-4px);
}

.pg-summary-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.pg-summary-icon.green { background: #ecfdf5; color: #10b981; }
.pg-summary-icon.cyan { background: #f0f9ff; color: #0ea5e9; }
.pg-summary-icon.amber { background: #fffbeb; color: #f59e0b; }
.pg-summary-icon.violet { background: #f5f3ff; color: #8b5cf6; }

.pg-summary-val {
    font-size: 20px;
    font-weight: 800;
    color: var(--t1);
    letter-spacing: -0.02em;
}

.pg-summary-lbl {
    font-size: 12px;
    font-weight: 600;
    color: var(--t3);
    margin-top: 2px;
}

/* ── TABLE CARD ── */
.pg-table-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.pg-table-head {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    border-bottom: 1px solid var(--line);
}

.pg-table-head-title {
    font-size: 16px;
    font-weight: 800;
    color: var(--t1);
    display: flex;
    align-items: center;
    gap: 12px;
}

.pg-btn-pay-all {
    padding: 10px 20px;
    background: var(--primary-light);
    color: var(--primary-dark);
    border: 1.5px solid transparent;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.pg-btn-pay-all:hover {
    background: var(--primary);
    color: #fff;
}

.pg-table {
    width: 100%;
    border-collapse: collapse;
}

.pg-table th {
    background: #f8fafc;
    padding: 14px 20px;
    text-align: left;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--t3);
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--line);
}

.pg-table td {
    padding: 16px 20px;
    font-size: 14px;
    color: var(--t1);
    border-bottom: 1px solid var(--line-light);
    vertical-align: middle;
}

.pg-table tbody tr:hover {
    background: #f9fafb;
}

.pg-av {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: linear-gradient(135deg, #10b981, #3b82f6);
    color: #fff;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
}

.pg-name { font-weight: 700; color: var(--t1); margin-bottom: 2px; }
.pg-sub { font-size: 12px; color: var(--t3); }

.pg-money-pos { color: var(--primary-dark); font-weight: 800; font-family: var(--mono); }
.pg-money-neg { color: var(--danger); font-weight: 800; font-family: var(--mono); }
.pg-money-neu { color: var(--t2); font-weight: 600; font-family: var(--mono); }

.pg-badge {
    padding: 6px 12px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.pg-badge-ok { background: #dcfce7; color: #15803d; }
.pg-badge-warn { background: #fef3c7; color: #b45309; }

.pg-action-wrap {
    position: relative;
    display: flex;
    justify-content: center;
}

.pg-action-btn {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1.5px solid var(--line);
    background: #fff;
    color: var(--t2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.pg-action-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.pg-dropdown {
    position: absolute;
    right: 0; top: calc(100% + 8px);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    min-width: 180px;
    box-shadow: var(--shadow-lg);
    z-index: 100;
    display: none;
    overflow: hidden;
}

.pg-dropdown.show { display: block; animation: scaleUp 0.15s ease-out; }

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

.pg-dropdown-item {
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--t2);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.15s;
}

.pg-dropdown-item:hover {
    background: #f8fafc;
    color: var(--primary-dark);
}

/* ── MODAL ── */
.pg-modal-overlay {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.pg-modal-overlay.show { display: flex; }

.pg-modal-box {
    background: #fff;
    border-radius: 24px;
    width: 100%;
    max-width: 700px;
    max-height: 90vh;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    animation: modalSlide 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalSlide {
    from { opacity: 0; transform: translateY(30px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.pg-modal-hd {
    padding: 24px;
    border-bottom: 1px solid var(--line-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.pg-modal-hd-title { font-size: 18px; font-weight: 800; color: var(--t1); display: flex; align-items: center; gap: 12px; }

.pg-modal-body {
    padding: 24px;
    overflow-y: auto;
}

.pg-modal-footer {
    padding: 20px 24px;
    border-top: 1px solid var(--line-light);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.pg-btn-print {
    background: var(--t1);
    color: #fff;
    border: none;
    padding: 10px 24px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pg-alert {
    position: fixed;
    top: 24px; left: 50%;
    transform: translateX(-50%);
    padding: 14px 24px;
    border-radius: 14px;
    z-index: 9999;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 14px;
}

.pg-alert-ok { background: #10b981; color: #fff; }
.pg-alert-err { background: #ef4444; color: #fff; }

/* ── STATES ── */
.pg-loading {
    display: none;
    text-align: center;
    padding: 60px 20px;
    background: #fff;
}

.pg-empty {
    text-align: center;
    padding: 80px 20px;
    background: #fff;
}

.pg-empty-icon {
    font-size: 54px;
    margin-bottom: 20px;
    filter: drop-shadow(0 10px 15px rgba(0,0,0,0.1));
}

.pg-empty-title {
    font-size: 18px;
    font-weight: 800;
    color: var(--t1);
    margin-bottom: 8px;
}

.pg-empty-sub {
    font-size: 14px;
    color: var(--t3);
    max-width: 400px;
    margin: 0 auto;
}

.pg-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--line-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

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

@media (max-width: 992px) {
    .pg-summary { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
    .pg-summary { grid-template-columns: 1fr; }
    .pg-wrap { padding: 16px; }
}
