.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    min-width: 300px;
    max-width: 400px;
    padding: 15px 20px;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideInRight 0.3s ease-out;
    font-size: 14px;
    font-weight: 500;
    word-wrap: break-word;
}

.toast.success {
    background: #d4edda;
    color: #155724;
    border-left: 4px solid #28a745;
}

.toast.error {
    background: #f8d7da;
    color: #721c24;
    border-left: 4px solid #dc3545;
}

.toast.info {
    background: #d1ecf1;
    color: #0c5460;
    border-left: 4px solid #17a2b8;
}

.toast.warning {
    background: #fff3cd;
    color: #856404;
    border-left: 4px solid #ffc107;
}

.toast-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.toast-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    opacity: 0.7;
    margin-left: auto;
}

.toast-close:hover {
    opacity: 1;
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }

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

@keyframes dropdownIn {
    from {
        transform: translateY(-6px);
        opacity: 0;
    }

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

/* Utilities */
.text-center {
    text-align: center;
}

/* Responsive */
@media (max-width: 768px) {
    .header h1 {
        font-size: 20px;
    }

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

    .controls {
        flex-direction: column;
        align-items: stretch;
    }

    .controls-right {
        flex-direction: column;
    }

    .header-action-buttons {
        position: static;
        width: auto;
        flex: 0 0 auto;
        align-self: center;
        justify-content: flex-end;
        padding: 0;
        background: transparent;
    }

    .header-content {
        align-items: flex-start;
    }

    .user-info {
        flex-wrap: wrap;
        align-items: center;
    }

    .main-content {
        padding-top: 120px;
    }

    .search-input {
        min-width: 100%;
    }

    .table-container {
        overflow-x: scroll;
        /* Always show horizontal scrollbar on mobile */
    }

    .data-table {
        font-size: 12px;
    }

    .data-table th,
    .data-table td {
        padding: 8px 6px;
        white-space: nowrap;
    }

    /* Make status badges more compact */
    .status-badge {
        padding: 3px 8px;
        font-size: 10px;
    }

    .status-expired {
        font-size: 9px;
        padding: 2px 6px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .modal-content {
        width: 95%;
    }

    .logs-container {
        padding: 14px;
    }

    .modal-actions {
        flex-wrap: wrap;
    }

    .stat-card-usage-avg {
        align-items: flex-start;
    }

    .stat-extra-actions {
        width: 100%;
        min-width: 0;
        align-items: stretch;
    }

    .stat-inline-select {
        min-width: 0;
        width: 100%;
    }
}

@media (max-width: 640px) {
    .password-changes-header {
        align-items: stretch !important;
    }

    .password-changes-header .toggle-stack {
        flex-direction: column;
        width: 100%;
    }

    .password-changes-header .toggle-item {
        width: 100%;
        justify-content: flex-start;
        gap: 12px;
        min-width: 0;
    }

    .password-changes-header label {
        width: 100%;
        justify-content: flex-start;
    }

    .password-changes-header button {
        width: 100%;
    }

    .password-changes-header span {
        white-space: normal;
    }

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

    .modal-actions .btn {
        width: 100%;
    }

    .tab-button {
        width: 100%;
        justify-content: center;
    }
}

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

    .stat-card {
        padding: 20px;
    }

    .stat-value {
        font-size: 24px;
    }

    .login-box {
        padding: 30px 20px;
    }

    /* Extra compact for very small screens */
    .data-table {
        font-size: 11px;
    }

    .data-table th,
    .data-table td {
        padding: 6px 4px;
    }

    /* Hide duration column on very small screens */
    .data-table th[data-column="durasi"],
    .data-table td[data-column="durasi"],
    .data-table th[data-column="waktuBeli"],
    .data-table td[data-column="waktuBeli"] {
        display: none;
    }

    .data-table th[data-column="avgUsagePerDay"],
    .data-table td[data-column="avgUsagePerDay"] {
        display: none;
    }

    .btn-icon {
        font-size: 16px;
        padding: 6px;
    }

    .controls-left {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .controls-left .btn {
        flex: 1 1 calc(50% - 4px);
        font-size: 12px;
        padding: 8px;
    }

    .modal-header h2 {
        font-size: 14px;
    }

    .logs-container {
        padding: 10px;
    }
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
}

.toast {
    background: var(--card-bg);
    color: var(--text-color);
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-left: 4px solid var(--primary-color);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    animation: slideInRight 0.3s ease-out;
    position: relative;
}

.toast.success {
    border-left-color: var(--success-color);
}

.toast.error {
    border-left-color: var(--danger-color);
}

.toast.warning {
    border-left-color: var(--warning-color);
}

.toast.info {
    border-left-color: var(--primary-color);
}

.toast-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.toast-message {
    font-size: 14px;
    opacity: 0.9;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.toast-close:hover {
    opacity: 1;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.toast.removing {
    animation: slideOutRight 0.3s ease-out forwards;
}

/* ─── Password Readiness Dropdown ─── */
.pwd-btn {
    background: #6c5ce7;
    color: #fff;
    padding: 2px 8px;
    font-size: 10px;
    width: auto;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}
.pwd-btn:hover { background: #5a4bd1; }

/* .pwd-btn inside popup/dropdown menus — full-width, left-aligned */
.row-action-popup .pwd-btn,
.action-dropdown .pwd-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    font-size: 13px;
    text-align: left;
    background: var(--card-bg, #fff);
    color: var(--text-color, #333);
    border-radius: 4px;
}
.row-action-popup .pwd-btn:hover,
.action-dropdown .pwd-btn:hover {
    background: #e8e4ff;
}

.pwd-dropdown {
    display: none;
    position: fixed;
    z-index: 100001;
    min-width: 200px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.18);
    padding: 0;
    overflow: hidden;
}

.pwd-dropdown-header {
    padding: 8px 14px;
    font-size: 11px;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #eee;
    background: #fafafa;
}

.pwd-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 14px;
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
    border: none;
    background: none;
    text-align: left;
    transition: background 0.15s;
}
.pwd-dropdown-item:hover { background: #f5f5f5; }

/* Confirm Dialog Modal */
.confirm-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.confirm-dialog {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    max-width: 500px;
    width: 90%;
    text-align: center;
}

.confirm-dialog-icon {
    font-size: 48px;
    margin-bottom: 20px;
}

.confirm-dialog-title {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-color);
}

.confirm-dialog-message {
    font-size: 16px;
    margin-bottom: 30px;
    color: var(--text-color);
    opacity: 0.8;
}

.confirm-dialog-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}


/* Endpoint usage chart (grouped bars) */
.endpoint-usage-chart {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 14px 16px;
    box-shadow: var(--shadow);
}

.endpoint-usage-chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.endpoint-usage-chart-header h4 {
    font-size: 14px;
}

.endpoint-usage-chart-legend {
    font-size: 12px;
    color: var(--secondary-color);
}

.endpoint-chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 14px;
    margin-bottom: 12px;
}

.endpoint-chart-legend .legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}

.endpoint-chart-legend .legend-color {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.endpoint-bar-groups {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    overflow-x: auto;
    padding-bottom: 6px;
}

.endpoint-bar-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-width: 60px;
}

.endpoint-bar-stack {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 180px;
}

.endpoint-bar {
    width: 10px;
    height: 100%;
    display: flex;
    align-items: flex-end;
}

.endpoint-bar-fill {
    width: 100%;
    border-radius: 6px 6px 2px 2px;
    min-height: 4px;
    transition: height 0.2s ease;
}

.endpoint-bar-date {
    font-size: 11px;
    color: var(--secondary-color);
    text-align: center;
}

/* API Key & Stats Styles */
.api-key-modal-content {
    max-width: 760px;
}

.api-key-modal-body {
    padding: 16px 18px 10px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.api-key-modal-body .api-key-info-alert {
    margin-bottom: 0;
    padding: 8px 12px;
    font-size: 13px;
    border-radius: 8px;
    color: var(--secondary-color);
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--table-hover);
    border: 1px solid var(--border-color);
}

.api-key-modal-body .api-key-info-alert i {
    font-size: 16px;
    color: var(--icon-blue);
}

.api-key-card-text {
    flex: 1;
    margin: 0;
    font-size: 13px;
    color: var(--secondary-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* keep previous list rules (if used elsewhere) but reduce spacing */
.api-key-info-list li {
    margin: 2px 0;
    font-size: 12px;
    color: var(--secondary-color);
}

/* Ensure user-provided solver inputs look identical to other form inputs */
.api-key-user-keys-grid .form-input {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 14px;
    width: 100%;
    min-width: 0; /* allow input to shrink within grid cell */
}

.api-key-info-text {
    margin: 8px 0 6px;
    padding: 0;
}

.api-key-info-text-last {
    margin-bottom: 0;
}

.api-key-info-list {
    margin: 6px 0 0 18px;
    padding: 0;
}

.api-key-main-card,