/* ============================================================
   USER PANEL
   Builds on the tokens defined in app.css (colours, radii, fonts).
   ============================================================ */

.panel-body {
    background: var(--bg-light);
    min-height: 100vh;
}

.hidden { display: none !important; }

/* ── Loading / signed-out states ── */
.panel-loading,
.panel-guest {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    color: var(--text-muted);
}

.panel-guest-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem;
    text-align: center;
    box-shadow: var(--shadow-lg);
    max-width: 420px;
}
.panel-guest-card h1 { font-size: 1.4rem; margin-bottom: 0.5rem; }
.panel-guest-card p { color: var(--text-muted); margin-bottom: 1.5rem; }
.panel-guest-card .btn-next { display: inline-flex; text-decoration: none; }

/* ── Shell ── */
.panel-shell {
    display: grid;
    grid-template-columns: 1fr;
    min-height: 100vh;
}

@media (min-width: 900px) {
    .panel-shell { grid-template-columns: 260px 1fr; }
}

/* ── Sidebar ── */
.panel-sidebar {
    background: var(--gradient-hero);
    color: #fff;
    padding: 1.75rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.panel-logo {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    line-height: 1.15;
}
.panel-logo-name {
    font-size: 1.25rem;
    font-weight: 900;
    letter-spacing: -0.03em;
    color: #fff;
}
.panel-logo-sub {
    font-size: 0.65rem;
    font-weight: 500;
    color: rgba(255,255,255,0.7);
}

.panel-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
}

.panel-nav-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    padding: 0.7rem 0.9rem;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: rgba(255,255,255,0.8);
    font-family: var(--font-main);
    font-size: 0.9rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.panel-nav-item:hover { background: rgba(255,255,255,0.12); color: #fff; }
.panel-nav-item.active { background: rgba(255,255,255,0.18); color: #fff; }
.panel-nav-item .material-symbols-outlined { font-size: 1.15rem; }

.panel-sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.panel-new-audit,
.panel-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.65rem 1rem;
    border-radius: 10px;
    font-family: var(--font-main);
    font-size: 0.875rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    transition: opacity 0.2s, background 0.2s;
}
.panel-new-audit {
    background: #fff;
    color: var(--brand-purple);
    border: none;
}
.panel-new-audit:hover { opacity: 0.92; }
.panel-logout {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.35);
    color: rgba(255,255,255,0.9);
}
.panel-logout:hover { background: rgba(255,255,255,0.14); }
.panel-new-audit .material-symbols-outlined,
.panel-logout .material-symbols-outlined { font-size: 1.05rem; }

/* ── Main area ── */
.panel-main {
    padding: 2rem 1.5rem 3rem;
    max-width: 900px;
    width: 100%;
}
@media (min-width: 900px) {
    .panel-main { padding: 2.5rem 2.5rem 3rem; }
}

.panel-header { margin-bottom: 1.75rem; }
.panel-header h1 {
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 900;
    letter-spacing: -0.03em;
    color: var(--text-main);
    margin-bottom: 0.35rem;
}
.panel-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.6;
    max-width: 620px;
}

/* ── Stat cards ── */
.panel-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 1.75rem;
}
@media (min-width: 640px) {
    .panel-cards { grid-template-columns: repeat(3, 1fr); }
}

.panel-card {
    background: var(--white);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}
.panel-card-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}
.panel-card-value {
    font-size: 1.6rem;
    font-weight: 900;
    letter-spacing: -0.02em;
    color: var(--text-main);
    line-height: 1.1;
}
.panel-card-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
}

.panel-cta-card {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: var(--gradient-hero);
    border-radius: var(--radius);
    padding: 1.75rem;
    color: #fff;
}
.panel-cta-card h3 { font-size: 1.1rem; font-weight: 800; margin-bottom: 0.25rem; }
.panel-cta-card p { font-size: 0.9rem; color: rgba(255,255,255,0.85); }
.panel-cta-card .btn-next {
    background: #fff;
    color: var(--brand-purple);
    text-decoration: none;
    display: inline-flex;
}

/* ── Connections ── */
.connections-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.connection-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--white);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.4rem;
    flex-wrap: wrap;
}
.connection-card.is-connected { border-color: hsl(142 76% 36% / 0.4); }

.connection-icon {
    width: 44px; height: 44px;
    border-radius: 12px;
    background: var(--bg-light);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.connection-icon svg { width: 24px; height: 24px; }

.connection-info { flex: 1; min-width: 160px; }
.connection-name {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.connection-status {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 2px;
}
.connection-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 9px;
    border-radius: 50px;
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.connection-badge.connected {
    background: hsl(142 76% 36% / 0.12);
    color: var(--success);
}
.connection-badge.disconnected {
    background: var(--bg-light);
    color: var(--text-muted);
}

.connection-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.btn-connect,
.btn-disconnect {
    padding: 0.55rem 1.1rem;
    border-radius: 10px;
    font-family: var(--font-main);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: opacity 0.2s, background 0.2s, border-color 0.2s;
}
.btn-connect {
    background: var(--gradient-btn);
    color: #fff;
    border: none;
}
.btn-connect:hover { opacity: 0.92; }
.btn-disconnect {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--text-muted);
}
.btn-disconnect:hover { border-color: var(--error); color: var(--error); }

.connection-revoke {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-decoration: underline;
}
.connection-revoke:hover { color: var(--brand-purple); }

.panel-note {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-top: 1.5rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.55;
}
.panel-note .material-symbols-outlined { font-size: 1.05rem; color: var(--brand-purple); }

/* ── Profile ── */
.panel-form-card {
    background: var(--white);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    max-width: 560px;
}
.panel-card-title {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 1rem;
}

.panel-field {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--border);
}
.panel-field:last-child { border-bottom: none; }
.panel-field-label { font-size: 0.85rem; color: var(--text-muted); }
.panel-field-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
    text-align: right;
    word-break: break-word;
}

.panel-field-stack { margin-bottom: 1rem; }
.panel-field-stack .form-label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-main);
}

#pwSubmit { margin-top: 0.5rem; }

/* ── Saved accounts ── */
.panel-section-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text-main);
    margin: 2.5rem 0 0.35rem;
}

.panel-empty {
    color: var(--text-muted);
    font-size: 0.9rem;
    background: var(--white);
    border: 1.5px dashed var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    line-height: 1.6;
}

.saved-groups {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-top: 1rem;
}

.saved-group {
    background: var(--white);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
}

.saved-group-title {
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.6rem;
}

.saved-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--border);
}
.saved-row:last-child { border-bottom: none; }
.saved-row.is-disabled { opacity: 0.5; }

.saved-row input[type="checkbox"] {
    width: 17px; height: 17px;
    accent-color: var(--brand-purple);
    cursor: pointer;
    flex-shrink: 0;
}

.saved-row-info { flex: 1; min-width: 0; }
.saved-row-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.saved-row-id {
    font-size: 0.75rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.saved-row-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    flex-shrink: 0;
    transition: background 0.2s, color 0.2s;
}
.saved-row-remove:hover { background: hsl(0 72% 51% / 0.1); color: var(--error); }

/* ── Audit history ── */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.history-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--white);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
    flex-wrap: wrap;
}

.history-score {
    width: 52px; height: 52px;
    border-radius: 14px;
    background: var(--gradient-hero);
    color: #fff;
    font-size: 1.15rem;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.history-info { flex: 1; min-width: 180px; }
.history-title {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--text-main);
}
.history-meta { font-size: 0.8rem; color: var(--text-muted); margin-top: 1px; }
.history-url {
    font-size: 0.78rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 340px;
}
.history-nopdf { font-size: 0.78rem; color: var(--text-muted); }

.history-pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
}
.history-pager button[disabled] { opacity: 0.45; cursor: not-allowed; }
.history-range { font-size: 0.85rem; color: var(--text-muted); }

/* ── Profile: inline name form ── */
.panel-inline-form .form-label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-main);
}
.panel-inline-row {
    display: flex;
    gap: 0.6rem;
    align-items: center;
}
.panel-inline-row .email-modal-input { flex: 1; }

/* ── Danger zone ── */
.danger-zone { border-color: hsl(0 72% 51% / 0.35); }
.danger-title { color: var(--error); }
.danger-text {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 1rem;
}

.btn-danger {
    padding: 0.7rem 1.3rem;
    border-radius: 10px;
    background: var(--error);
    color: #fff;
    border: none;
    font-family: var(--font-main);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.2s;
}
.btn-danger:hover { opacity: 0.9; }
.btn-danger[disabled] { opacity: 0.6; cursor: not-allowed; }

/* Toast reused from app.css if present; minimal fallback here */
.panel-toast {
    position: fixed;
    right: 1.5rem;
    bottom: 1.5rem;
    background: var(--text-main);
    color: #fff;
    padding: 0.85rem 1.25rem;
    border-radius: 10px;
    font-size: 0.875rem;
    box-shadow: var(--shadow-xl);
    z-index: 2000;
    animation: fadeIn 0.25s ease-out;
}
.panel-toast.error { background: var(--error); }
.panel-toast.success { background: var(--success); }
