/* ============================================
   pibiCo Auth — App-specific styles
   ============================================ */

/* ── Auth Container (centered card layout) ── */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100%;
    padding: 20px;
}

.auth-card {
    padding: 32px;
    max-width: 400px;
    width: 100%;
}

/* Mobile: minimal padding (3px vertical / 6px horizontal) for full-width cards */
@media (max-width: 768px) {
    .auth-container {
        padding: 3px 6px !important;
        align-items: flex-start !important;
        min-height: 100vh;
    }
    .auth-card {
        padding: 12px 10px !important;
        max-width: none !important;
        width: 100% !important;
        border-radius: 10px !important;
        margin: 0 !important;
        box-sizing: border-box;
    }
    .auth-logo { margin-bottom: 12px !important; }
    .auth-title { font-size: 1.25rem !important; margin: 0 0 8px !important; }
    .auth-subtitle { font-size: 13px !important; margin: 0 0 12px !important; }
    .form-group { margin-bottom: 10px !important; }
    .auth-btn-primary, .auth-btn-secondary {
        width: 100% !important;
        padding: 12px 16px !important;
        font-size: 15px !important;
    }
    /* Anti-zoom: iOS Safari requires >=16px on inputs to prevent focus zoom */
    input, textarea, select {
        font-size: 16px !important;
        width: 100% !important;
        box-sizing: border-box;
    }
    /* Account page sections compact */
    .account-section {
        padding: 10px !important;
        margin-bottom: 10px !important;
    }
    .account-section-title {
        font-size: 0.85rem !important;
        margin-bottom: 8px !important;
    }
    .pibico-card {
        padding: 12px !important;
        border-radius: 10px !important;
    }
}

.auth-logo {
    text-align: center;
    margin-bottom: 24px;
}

.auth-logo img {
    width: 48px;
    height: 48px;
}

.auth-title {
    text-align: center;
    color: var(--accent-color);
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 20px;
}

.auth-subtitle {
    text-align: center;
    color: var(--text-light);
    font-size: 0.8rem;
    margin-top: -12px;
    margin-bottom: 20px;
}

/* ── Auth Form ── */
.auth-form .form-group {
    margin-bottom: 14px;
}

.auth-form .pibico-input {
    padding: 8px 12px;
    font-size: 0.875rem;
}

.auth-form .pibico-label {
    margin-bottom: 4px;
}

/* ── Primary Auth Button ── */
.auth-btn-primary {
    width: 100%;
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--accent-color), var(--primary-color));
    color: white;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 8px;
}

.auth-btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(70, 130, 180, 0.35);
}

.auth-btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ── Separator ── */
.auth-separator {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    color: var(--text-light);
    font-size: 0.75rem;
}

.auth-separator::before,
.auth-separator::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(44, 81, 113, 0.15);
}

/* ── Social Login Buttons ── */
.social-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.social-btn {
    width: 100%;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: white;
    border: 1.5px solid rgba(44, 81, 113, 0.18);
    color: var(--text-color);
}

.social-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.social-btn svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.social-btn-google:hover {
    border-color: #4285f4;
    color: #4285f4;
}

.social-btn-github:hover {
    border-color: #333;
    color: #333;
}

.social-btn-microsoft:hover {
    border-color: #00a4ef;
    color: #00a4ef;
}

/* ── Auth Links ── */
.auth-links {
    display: flex;
    justify-content: space-between;
    margin-top: 16px;
    font-size: 0.8rem;
}

.auth-links a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s;
}

.auth-links a:hover {
    color: var(--accent-color);
    text-decoration: underline;
}

.auth-link-center {
    text-align: center;
    margin-top: 16px;
    font-size: 0.8rem;
}

.auth-link-center a {
    color: var(--primary-color);
    text-decoration: none;
}

.auth-link-center a:hover {
    color: var(--accent-color);
    text-decoration: underline;
}

/* ── Error Display ── */
.auth-error {
    display: none;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
    font-size: 0.8rem;
    margin-bottom: 14px;
    text-align: center;
}

.auth-error.visible {
    display: block;
}

/* ── Success Display ── */
.auth-success {
    display: none;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
    font-size: 0.8rem;
    margin-bottom: 14px;
    text-align: center;
}

.auth-success.visible {
    display: block;
}

/* ── OTP / 2FA Input ── */
.otp-input {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--glass-border);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 600;
    text-align: center;
    letter-spacing: 0.5em;
    background: white;
    color: var(--text-color);
    transition: all 0.2s;
}

.otp-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(70, 130, 180, 0.1);
}

/* ── QR Code ── */
.qr-container {
    text-align: center;
    margin: 16px 0;
}

.qr-container img {
    border-radius: var(--radius-sm);
    border: 1px solid var(--glass-border);
}

.secret-key {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    background: rgba(70, 130, 180, 0.08);
    padding: 8px 12px;
    border-radius: 6px;
    text-align: center;
    word-break: break-all;
    margin: 12px 0;
    color: var(--accent-color);
    font-weight: 600;
    letter-spacing: 0.05em;
}

/* ── Consent Page ── */
.consent-app-name {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-color);
    text-align: center;
    margin-bottom: 8px;
}

.consent-description {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 16px;
}

.consent-scopes {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    margin-bottom: 20px;
}

.scope-badge {
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
    background: rgba(70, 130, 180, 0.12);
    color: var(--accent-color);
}

.consent-user {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-light);
    margin-bottom: 16px;
}

.consent-actions {
    display: flex;
    gap: 10px;
}

.consent-actions button {
    flex: 1;
}

/* ── Account Page ── */
.account-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px;
    width: 100%;
    overflow-y: auto;
    flex: 1;
}

.account-section {
    padding: 16px;
    margin-bottom: 8px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.3);
}

.account-section-title {
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 14px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(44, 81, 113, 0.12);
}

.identity-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 3px 0;
}

.identity-provider {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
}

.identity-provider svg {
    width: 18px;
    height: 18px;
}

.avatar-wrapper {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 14px;
}

.avatar-circle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-color), var(--primary-color));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.3rem;
    font-weight: 700;
    font-family: var(--font-heading);
    flex-shrink: 0;
}

/* ── Admin Page (three-layer tab architecture) ── */

/* Legacy admin-panel fallback (still referenced by admin.js) */
.admin-panel {
    display: none;
    flex: 1;
    overflow: hidden;
    flex-direction: column;
}

.admin-panel.active {
    display: flex;
}

#adminContent {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pibico-tab-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.admin-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.admin-search {
    padding: 5px 10px;
    border: 1.5px solid var(--glass-border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-family: var(--font-body);
    background: white;
    min-width: 200px;
    transition: all 0.2s;
}

.admin-search:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(70, 130, 180, 0.1);
}

.admin-table-wrap {
    flex: 1;
    overflow: auto;
    border-radius: var(--radius-sm);
    background: var(--glass-bg);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.admin-table th {
    background: var(--accent-color);
    color: white;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 6px 10px;
    text-align: left;
    position: sticky;
    top: 0;
    z-index: 1;
}

.admin-table td {
    padding: 3px 10px;
    border-bottom: 1px solid rgba(44, 81, 113, 0.08);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.admin-table tr:hover td {
    background: rgba(70, 130, 180, 0.06);
}

/* ── Service Badges ── */
.svc-badges-cell {
    white-space: normal;
    max-width: 220px;
}
.svc-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 600;
    line-height: 1;
    margin: 1px 2px;
    letter-spacing: 0.02em;
    text-transform: lowercase;
}

/* ── Stats Cards ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    padding: 4px;
}

.stat-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    text-align: center;
}

.stat-value {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent-color);
    line-height: 1;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-top: 4px;
}

/* ── Service Registry Cards ── */
.svc-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    padding: 4px 14px 4px 4px;
    margin-right: -18px;
    flex: 1;
    overflow-y: auto;
    align-content: start;
    min-height: 0;
    scrollbar-gutter: stable;
}

.svc-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    position: relative;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.svc-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.svc-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.svc-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.svc-status-dot.healthy { background: #34a853; }
.svc-status-dot.unhealthy { background: #ea4335; }
.svc-status-dot.unknown { background: #999; }
.svc-status-dot.checking {
    background: #fbbc04;
    animation: pulse-dot 1s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.svc-card-name {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--accent-color);
    flex: 1;
    line-height: 1;
}

.svc-card-port {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-light);
    background: rgba(70, 130, 180, 0.08);
    padding: 1px 6px;
    border-radius: 4px;
}

.svc-card-desc {
    font-size: 0.75rem;
    color: var(--text-light);
    line-height: 1.3;
    margin-bottom: 6px;
}

.svc-card-url {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--primary-color);
    text-decoration: none;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.svc-card-url:hover {
    text-decoration: underline;
}

.svc-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.svc-card-orgs {
    font-size: 0.7rem;
    color: var(--text-light);
}

.svc-card-badge-inactive {
    font-size: 0.65rem;
    background: rgba(234, 67, 53, 0.12);
    color: #ea4335;
    padding: 1px 6px;
    border-radius: 4px;
}

.svc-card-time {
    font-size: 0.65rem;
    color: var(--text-light);
}

/* ── Loading Spinner ── */
.spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(70, 130, 180, 0.2);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.spinner-lg {
    width: 40px;
    height: 40px;
    border-width: 4px;
}

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

.loading-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 40px;
    color: var(--text-light);
    font-size: 0.85rem;
}

/* Language dropdown styles moved to pibico.css */

/* ── Resend Link ── */
.resend-link {
    text-align: center;
    margin-top: 10px;
    font-size: 0.8rem;
}

.resend-link a {
    color: var(--primary-color);
    text-decoration: none;
    cursor: pointer;
}

.resend-link a:hover {
    text-decoration: underline;
}

.resend-link a.disabled {
    color: var(--text-light);
    pointer-events: none;
}

/* ── Step containers ── */
.step-container {
    display: none;
}

.step-container.active {
    display: block;
}

/* ── Skip link ── */
.skip-link {
    text-align: center;
    margin-top: 12px;
}

.skip-link a {
    color: var(--text-light);
    font-size: 0.8rem;
    text-decoration: none;
}

.skip-link a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

/* ── Error Pages ── */
.error-page {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

#error-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.error-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.error-card {
    padding: 40px;
    text-align: center;
    max-width: 480px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.error-code {
    font-size: 5rem;
    font-weight: 800;
    color: var(--accent-color);
    line-height: 1;
    margin-bottom: 8px;
    font-family: var(--font-heading);
}

.error-title {
    font-size: 1.4rem;
    color: var(--accent-color);
    margin-bottom: 12px;
    font-weight: 600;
}

.error-desc {
    color: var(--text-light);
    font-size: 0.95rem;
    margin-bottom: 24px;
    line-height: 1.5;
}

.error-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.btn-back,
.btn-login {
    padding: 10px 24px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    font-family: var(--font-body);
}

.btn-back {
    background: linear-gradient(135deg, var(--accent-color), var(--primary-color));
    color: white;
    border: none;
}

.btn-back:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(44, 81, 113, 0.3);
}

.btn-login {
    background: transparent;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-login:hover {
    background: var(--primary-color);
    color: white;
}

/* Mobile fallback: hide canvas, add CSS animation */
@media (max-width: 600px) {
    #error-canvas {
        display: none;
    }

    .error-page::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: var(--bg-gradient);
        animation: errorBgShift 8s ease-in-out infinite alternate;
        z-index: 0;
    }

    .error-card {
        padding: 28px 20px;
    }

    .error-code {
        font-size: 3.5rem;
    }

    .error-title {
        font-size: 1.1rem;
    }

    .error-desc {
        font-size: 0.85rem;
    }

    .error-actions {
        flex-direction: column;
        gap: 8px;
    }
}

@keyframes errorBgShift {
    0% { background-position: 0% 50%; }
    100% { background-position: 100% 50%; }
}

/* ── Clickable table rows ── */
.admin-table tbody tr {
    cursor: pointer;
    transition: background 0.15s;
}
.admin-table tbody tr:hover td {
    background: rgba(70, 130, 180, 0.08);
}

/* ── Slide Panel Form Fields ── */
.sp-field {
    margin-bottom: 10px;
}

.sp-field-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 3px;
}

.sp-field-input {
    font-size: 0.85rem;
    padding: 5px 10px;
}

.sp-field-value {
    font-size: 0.85rem;
    color: var(--text-color);
    padding: 3px 0;
    min-height: 1.4em;
}

.sp-field-toggle {
    padding: 3px 0;
}

.sp-toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-color);
}

.sp-toggle-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

.sp-toggle-text {
    user-select: none;
}

.sp-section-title {
    font-family: var(--font-heading);
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--accent-color);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-top: 14px;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(44, 81, 113, 0.1);
}

.sp-badges-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.sp-member-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
    font-size: 0.85rem;
}

.sp-member-row .pibico-badge {
    font-size: 0.65rem;
}

.sp-member-row .pibico-btn {
    margin-left: auto;
    flex-shrink: 0;
}

/* Custom select dropdown styling — SVG chevron-down */
select.pibico-input,
select.pibico-input-sm,
select.sp-field-input,
.slide-panel select,
.sp-org-ctrl-row select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    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='%234682b4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 14px;
    padding-right: 28px;
    cursor: pointer;
}
select.pibico-input-sm,
.sp-org-ctrl-row select {
    padding: 3px 26px 3px 8px;
    font-size: 0.78rem;
    border: 1px solid var(--glass-border, rgba(200,200,200,0.5));
    border-radius: var(--radius-sm, 8px);
    background-color: white;
    color: var(--text-color, #333);
}
select.pibico-input-sm:focus,
.sp-org-ctrl-row select:focus {
    outline: none;
    border-color: var(--primary-color, #4682b4);
    box-shadow: 0 0 0 2px rgba(70,130,180,0.1);
}

/* Button size variants — consistent height */
.pibico-btn-sm {
    padding: 4px 10px;
    font-size: 0.78rem;
    border-radius: 6px;
    gap: 4px;
    min-height: 28px;
}
.pibico-btn-xs {
    padding: 4px 8px;
    font-size: 0.72rem;
    border-radius: 6px !important;
    gap: 3px;
    min-height: 28px;
}
/* Icon-only small buttons (square) */
.pibico-btn-xs:has(svg:only-child),
.pibico-btn-sm:has(svg:only-child) {
    padding: 5px;
    border-radius: 6px !important;
    min-width: 28px; min-height: 28px;
    aspect-ratio: 1;
    justify-content: center;
}
.pibico-btn-xs:has(svg:only-child) svg,
.pibico-btn-sm:has(svg:only-child) svg {
    width: 14px; height: 14px;
}
/* All small ghost/remove buttons — square hover */
.pibico-btn-ghost.pibico-btn-xs {
    width: 24px; height: 24px;
    padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 6px !important;
}
.sp-member-row .pibico-btn-ghost {
    width: 24px; height: 24px;
    padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 6px !important;
    flex-shrink: 0;
}

/* Checkbox styling — rounded */
input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--glass-border, rgba(200,200,200,0.6));
    border-radius: 4px;
    background: white;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: all 0.15s;
}
input[type="checkbox"]:checked {
    background: var(--primary-color, #4682b4);
    border-color: var(--primary-color, #4682b4);
}
input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 5px;
    height: 9px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
input[type="checkbox"]:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(70,130,180,0.2);
}

/* Header icon buttons — ensure square */
.pibico-btn-icon {
    aspect-ratio: 1;
    padding: 6px !important;
    border-radius: 6px !important;
    border: none !important;
}

/* SMTP 2-col grid in slide panel */
.smtp-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 12px;
}
@media (max-width: 768px) {
    .smtp-grid { grid-template-columns: 1fr; }
}

/* Datalist input with chevron (autocomplete dropdown) */
input[list] {
    appearance: none;
    -webkit-appearance: none;
    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='%234682b4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 14px;
    padding-right: 28px;
}
/* Hide native datalist arrow in webkit */
input[list]::-webkit-calendar-picker-indicator {
    opacity: 0;
    width: 20px;
    cursor: pointer;
}

/* Org list → detail in service panel */
.svc-org-list { display: flex; flex-direction: column; gap: 4px; }

.svc-org-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm, 8px);
    background: rgba(70,130,180,0.04);
    cursor: pointer;
    transition: background 0.15s;
}
.svc-org-card:hover { background: rgba(70,130,180,0.1); }
.svc-org-card-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent-color, #2c5171);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.svc-org-card-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

/* Org detail view */
.svc-org-detail { }
.svc-org-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--primary-color, #4682b4);
    padding: 0;
    margin-bottom: 12px;
}
.svc-org-back:hover { text-decoration: underline; }
.svc-org-detail-header {
    margin-bottom: 10px;
}
.svc-org-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 12px;
}

/* Legacy collapsible (keep for toggleSvcOrg if still used) */
.sp-org-ctrl-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    flex-wrap: wrap;
}
.sp-org-ctrl-label {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 0.78rem;
    color: var(--text-color);
}
.sp-org-member-list {
    padding: 2px 0;
}
.sp-member-name {
    cursor: pointer;
    color: var(--primary-color, #4682b4);
}
.sp-member-name:hover {
    text-decoration: underline;
}

.sp-members-list {
    max-height: 160px;
    overflow-y: auto;
    margin-bottom: 8px;
}

.sp-add-member {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-bottom: 10px;
}

.sp-svc-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
}

.sp-svc-check {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    margin-bottom: 2px;
}

.sp-svc-check input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

/* ── Danger Zone (inline confirm for slide panel) ── */
.sp-danger-zone {
    margin-top: 20px;
    padding-top: 14px;
    border-top: 1px solid rgba(229, 62, 62, 0.15);
}

.sp-danger-confirm {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.sp-danger-msg {
    font-size: 0.8rem;
    color: #e53e3e;
}

/* ── Responsive ── */
@media (max-width: 480px) {
    .auth-card {
        padding: 24px 20px;
    }

    .consent-actions {
        flex-direction: column;
    }

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

/* ── Responsive Tables (mobile) ── */
@media (max-width: 768px) {
    /* Card-based table layout */
    .admin-table thead {
        display: none;
    }
    .admin-table,
    .admin-table tbody,
    .admin-table tr,
    .admin-table td {
        display: block;
        width: 100%;
    }
    .admin-table tbody tr {
        background: rgba(255, 255, 255, 0.92);
        border-radius: var(--radius-sm);
        margin-bottom: 6px;
        padding: 6px 10px;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    }
    .admin-table td {
        padding: 2px 0;
        border-bottom: none;
        white-space: normal;
        max-width: none;
        overflow: visible;
        text-overflow: unset;
        display: flex;
        align-items: center;
        gap: 6px;
    }
    .admin-table td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.7rem;
        color: var(--text-light);
        text-transform: uppercase;
        letter-spacing: 0.3px;
        min-width: 80px;
        flex-shrink: 0;
    }
    .admin-table-wrap {
        background: transparent;
        box-shadow: none;
    }
    .admin-table td.svc-badges-cell {
        flex-wrap: wrap;
    }

    /* Slide panel full width on mobile */
    .sp-add-member {
        flex-wrap: wrap;
    }
}

/* ── Account 2-column grid ── */
.account-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    max-width: 900px;
    margin: 0 auto;
}
@media (max-width: 768px) {
    .account-grid { grid-template-columns: 1fr; }
}

/* ── OTP step visibility ── */
.step-container { display: none; }
.step-container.active { display: block; }

/* ── Slide Panel ──────────────────────────────────────────────────────────── */
.panel-backdrop {
  position: fixed; inset: 0; z-index: 999;
  background: rgba(0,0,0,0.3);
  display: none;
}
.panel-backdrop.open { display: block; }

.slide-panel {
  position: fixed; top: 0; right: -100%; width: 45%; height: 100vh;
  z-index: 1000;
  background: #fff;
  border-left: none;
  border-radius: 16px 0 0 16px;
  box-shadow: -4px 0 24px rgba(0,0,0,0.15);
  display: flex; flex-direction: column;
  overflow: hidden;
  transition: right 0.3s ease;
}
.slide-panel.open { right: 0; }

.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px 8px;
  flex-shrink: 0;
  background: #4682b4;
  border-radius: 16px 0 0 0;
}
.panel-header h2 {
  font-family: var(--font-heading, 'Montserrat', sans-serif);
  font-size: 1rem; font-weight: 700; color: #fff;
  margin: 0;
}
.panel-close {
  background: none; border: none; font-size: 1.3rem; cursor: pointer;
  color: rgba(255,255,255,0.7); padding: 0; line-height: 1;
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px;
  transition: all 0.15s;
}
.panel-close:hover { color: white; background: rgba(255,255,255,0.15); }

.panel-body {
  flex: 1; overflow-y: auto;
  padding: 16px 20px;
  background: #fff;
}
/* When panel has tabbed card area — class-based for broad compat */
.panel-body.panel-body-tabbed,
.panel-body:has(.panel-card-area) {
  padding: 0;
  background: linear-gradient(135deg, #2c5171 0%, #4682b4 50%, #6a9bc3 100%);
  overflow: hidden;
  display: flex; flex-direction: column;
}

/* Nested pibico-card-area inside slide panel */
.panel-card-area {
  flex: 1; display: flex; flex-direction: column; overflow: hidden;
}
.panel-card-area .pibico-tab-row {
  justify-content: flex-start;
  padding: 0 8px;
}
.panel-card-area .pibico-tab {
  min-width: 44px;
  padding: 5px 8px 4px;
}
.panel-card-area .pibico-content {
  flex: 1; overflow-y: auto;
  padding: 12px 16px;
}
.panel-card-area .pibico-tab-content {
  flex: none;
}

@media (max-width: 768px) {
  .slide-panel { width: 100%; }
}

/* ── Slide Panel Form Fields ──────────────────────────────────────────────── */
.sp-field { margin-bottom: 12px; }
.sp-field-label {
  display: block; font-size: 0.7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-light, #666); margin-bottom: 3px;
}
.sp-field-input {
  width: 100%; padding: 6px 10px;
  border: 1px solid #94a3b8 !important;
  border-radius: var(--radius-sm, 8px); font-size: 0.875rem;
  font-family: var(--font-body, 'Inter', sans-serif);
  background: rgba(255,255,255,0.95);
}
.sp-field-input:focus { outline: none; border-color: var(--primary-color, #4682b4) !important; }

/* Any form control inside a slide panel — make the 1px border unambiguous
 * regardless of which input class (pibico-input / sp-field-input / raw) is used.
 * Solves UX bug where inputs faded into the panel background. */
.slide-panel input[type="text"],
.slide-panel input[type="email"],
.slide-panel input[type="password"],
.slide-panel input[type="number"],
.slide-panel input[type="tel"],
.slide-panel input[type="url"],
.slide-panel input[type="date"],
.slide-panel input[type="datetime-local"],
.slide-panel input[type="search"],
.slide-panel textarea,
.slide-panel select {
  border: 1px solid #94a3b8 !important;
  background: #fff;
}
.slide-panel input[type="text"]:focus,
.slide-panel input[type="email"]:focus,
.slide-panel input[type="password"]:focus,
.slide-panel input[type="number"]:focus,
.slide-panel input[type="tel"]:focus,
.slide-panel input[type="url"]:focus,
.slide-panel input[type="date"]:focus,
.slide-panel input[type="datetime-local"]:focus,
.slide-panel input[type="search"]:focus,
.slide-panel textarea:focus,
.slide-panel select:focus {
  outline: none;
  border-color: #4682b4 !important;
  box-shadow: 0 0 0 2px rgba(70,130,180,0.15);
}
.slide-panel input[disabled],
.slide-panel textarea[disabled],
.slide-panel select[disabled],
.slide-panel input[readonly] {
  background: #f1f5f9 !important;
  color: #64748b;
}
.sp-field-input[readonly] { background: rgba(0,0,0,0.03); color: var(--text-light, #666); cursor: default; }
.sp-field-value { font-size: 0.875rem; color: var(--text-color, #333); padding: 4px 0; }

.sp-toggle-label {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  font-size: 0.875rem; margin-bottom: 8px;
}
.sp-toggle-label input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary-color, #4682b4); }

.sp-section-title {
  font-size: 0.75rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--primary-color, #4682b4);
  margin: 16px 0 8px; padding-bottom: 4px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}

.sp-badges-wrap { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px 0; }

.sp-danger-zone {
  margin-top: 24px; padding-top: 16px;
  border-top: 1px solid rgba(0,0,0,0.06);
}
.sp-danger-btn {
  background: none; border: 1px solid #e53e3e; color: #e53e3e;
  padding: 4px 16px; border-radius: var(--radius-sm, 8px);
  cursor: pointer; font-size: 0.8rem; font-weight: 500;
}
.sp-danger-btn:hover { background: #e53e3e; color: white; }
.sp-danger-msg { color: #e53e3e; font-size: 0.8rem; margin-top: 4px; }

.sp-actions {
  display: flex; gap: 8px; margin-top: 20px; padding-top: 12px;
  border-top: 1px solid rgba(0,0,0,0.06);
}

/* ── Members list in org panel ────────────────────────────────────────────── */
.sp-members-list { margin: 8px 0; }
.sp-member-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 0; font-size: 0.85rem; border-bottom: 1px solid rgba(0,0,0,0.04);
}

/* ── Service checkboxes in org panel ──────────────────────────────────────── */
.sp-svc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 4px; }
.sp-svc-check { display: flex; align-items: center; gap: 4px; font-size: 0.8rem; }
.sp-svc-check input { accent-color: var(--primary-color, #4682b4); }

/* Consent history table on /account */
.consent-group { margin-bottom: 14px; }
.consent-group-title { font-size: 0.82rem; color: #2c5171; margin-bottom: 4px; }
.consent-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.consent-table th { text-align: left; font-weight: 600; color: #475569; border-bottom: 1px solid #e5e7eb; padding: 4px 6px; }
.consent-table td { padding: 4px 6px; border-bottom: 1px solid #f1f5f9; color: #2c3e50; }
.consent-table .pill { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 0.66rem; font-weight: 600; }
.consent-table .pill-ok { background: rgba(40,167,69,0.12); color: #166534; }
.consent-table .pill-no { background: rgba(231,76,60,0.12); color: #991b1b; }

/* Legal consent acceptance page */
.legal-consent-docs { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.legal-consent-row {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  align-items: start;
  padding: 8px 10px;
  background: rgba(70,130,180,0.05);
  border: 1px solid rgba(70,130,180,0.18);
  border-radius: 6px;
  cursor: pointer;
}
.legal-consent-row:hover { background: rgba(70,130,180,0.10); }
.legal-consent-row input[type="checkbox"] {
  width: 18px !important;
  height: 18px !important;
  min-width: 18px;
  min-height: 18px;
  aspect-ratio: 1 / 1;
  margin: 2px 0 0 0;
  border-radius: 3px;
  flex: 0 0 18px;
  box-sizing: border-box;
}
.legal-consent-row input[type="checkbox"]:checked::after {
  left: 5px;
  top: 2px;
  width: 5px;
  height: 10px;
}
.legal-consent-title { font-weight: 600; font-size: 0.85rem; color: #2c5171; }
.legal-consent-link { font-size: 0.74rem; color: #4682b4; text-decoration: underline; }
.warn-pill { display: inline-block; margin-top: 3px; padding: 1px 7px; border-radius: 999px; font-size: 0.66rem; background: #fef3c7; color: #92400e; }
.success-msg { padding: 10px; background: rgba(40,167,69,0.10); color: #166534; border-radius: 6px; margin-bottom: 10px; font-size: 0.85rem; }
.consent-doc-link { color: #2c5171; text-decoration: none; font-weight: 600; }
.consent-doc-link:hover { text-decoration: underline; }
.consent-doc-open { display: inline-block; padding: 0 6px; color: #4682b4; text-decoration: none; font-size: 0.95rem; }
.consent-doc-open:hover { color: #2c5171; background: rgba(70,130,180,0.12); border-radius: 4px; }
