* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
}
body {
    background: var(--color-bg-page);
    color: var(--color-text-heading);
    min-height: 100vh;
    height: auto;
    display: flex;
    flex-direction: column;
    overflow: auto;
}

.link-reset-flex {
    text-decoration: none;
    color: inherit;
    display: flex;
    align-items: center;
    gap: 14px;
}
.width-zero {
    width: 0%;
}

/* #main-content and #auth-error start hidden via .hidden class */

/* ── Header ── */
.profile-header {
    background: linear-gradient(135deg, var(--color-sidebar-bg-from) 0%, var(--color-sidebar-bg-to) 100%);
    padding: 0 32px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 12px var(--color-shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}
.profile-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}
.profile-logo {
    width: 38px;
    height: 38px;
    background: var(--color-accent-gradient);
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 10px var(--color-sidebar-shadow);
}
.profile-logo svg {
    width: 20px;
    height: 20px;
    fill: var(--color-sidebar-text-active);
}
.profile-title-text {
    font-size: 17px;
    font-weight: 700;
    color: var(--color-sidebar-text-active);
    letter-spacing: 0.3px;
}
.profile-title-separator {
    font-size: 17px;
    color: var(--color-sidebar-storage-faint);
    font-weight: 400;
    margin-left: 6px;
}
.profile-header-right a {
    color: var(--color-sidebar-text);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color 0.2s;
}
.profile-header-right a:hover {
    color: var(--color-sidebar-text-active);
}

/* ── Container ── */
.profile-container {
    max-width: 720px;
    margin: 0 auto;
    padding: 32px 24px 60px;
    width: 100%;
}

/* ── Card ── */
.profile-card {
    background: var(--color-bg-surface);
    border-radius: 16px;
    box-shadow:
        0 1px 4px var(--color-shadow-xs),
        0 0 0 1px var(--color-shadow-xs);
    padding: 32px;
    margin-bottom: 22px;
}
.profile-card h2 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--color-text-heading);
    display: flex;
    align-items: center;
    gap: 10px;
}
.profile-card h2 i {
    color: var(--color-accent);
    font-size: 17px;
}

/* ── Avatar Section ── */
.avatar-section {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-bottom: 8px;
}
.avatar-large {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: var(--color-accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-sidebar-text-active);
    font-size: 32px;
    font-weight: 700;
    letter-spacing: 1px;
    box-shadow: 0 6px 20px var(--color-accent-shadow);
    flex-shrink: 0;
}
.avatar-info h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--color-text-heading);
    margin-bottom: 4px;
}
.avatar-info .email {
    font-size: 14px;
    color: var(--color-text-subtle);
    margin-bottom: 8px;
}
.avatar-info .role-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 20px;
}
.role-badge-admin {
    background: var(--color-role-admin-bg);
    color: var(--color-role-admin-text);
}
.role-badge-user {
    background: var(--color-border-light);
    color: var(--color-text-subtle);
}

/* ── Info Grid ── */
.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
@media (max-width: 560px) {
    .info-grid {
        grid-template-columns: 1fr;
    }
}
.info-item {
    padding: 16px;
    background: var(--color-bg-alt);
    border-radius: 12px;
    border: 1px solid var(--color-border);
}
.info-item .info-label {
    font-size: 11.5px;
    color: var(--color-text-faint);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.info-item .info-label i {
    font-size: 12px;
    color: var(--color-text-dark);
}
.info-item .info-value {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text-heading);
}

/* ── Storage ── */
.storage-section {
    margin-top: 4px;
}
.storage-stats {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 14px;
    margin-bottom: 16px;
}
@media (max-width: 560px) {
    .storage-stats {
        grid-template-columns: 1fr;
    }
}
.storage-stat {
    text-align: center;
    padding: 16px;
    background: var(--color-bg-hover);
    border-radius: 12px;
    border: 1px solid var(--color-border);
}
.storage-stat .stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--color-text-heading);
}
.storage-stat .stat-label {
    font-size: 11px;
    color: var(--color-text-faint);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    margin-top: 2px;
}
.storage-bar-wrap {
    margin-top: 4px;
}
.storage-bar {
    height: 10px;
    background: var(--color-border);
    border-radius: 5px;
    overflow: hidden;
}
.storage-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 0.6s ease;
}
.storage-fill.green {
    background: var(--color-storage-fill-green);
}
.storage-fill.orange {
    background: var(--color-storage-fill-orange);
}
.storage-fill.red {
    background: var(--color-storage-fill-red);
}
.storage-text {
    font-size: 12px;
    color: var(--color-text-faint);
    text-align: right;
    margin-top: 6px;
}

/* ── Change Password ── */
.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--color-text-dark);
}
.form-group input {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--color-border);
    border-radius: 10px;
    font-size: 14px;
    background: var(--color-bg-input);
    transition: all 0.2s;
    font-family: inherit;
    color: var(--color-text-heading);
}
.form-group input:hover {
    background: var(--color-bg-surface);
}
.form-group input:focus {
    outline: none;
    border-color: var(--color-accent);
    background: var(--color-bg-surface);
    box-shadow: 0 0 0 3px var(--color-accent-ring);
}
.form-group small {
    color: var(--color-text-faint);
    font-size: 12px;
    display: block;
    margin-top: 3px;
}

.btn {
    padding: 10px 22px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-primary {
    background: var(--color-accent-gradient);
    color: var(--color-sidebar-text-active);
    box-shadow: 0 2px 8px var(--color-accent-shadow-sm);
}
.btn-primary:hover {
    box-shadow: 0 4px 14px var(--color-sidebar-shadow);
    transform: translateY(-1px);
}
.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
}

.alert {
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 13px;
    margin-top: 14px;
    font-weight: 500;
}
.alert-success {
    background: var(--color-badge-success-bg);
    color: var(--color-badge-success-text);
    border: 1px solid var(--color-badge-success-border);
}
.alert-error {
    background: var(--color-danger-light-bg);
    color: var(--color-error-text-dark);
    border: 1px solid var(--color-badge-error-border);
}

/* ── App Passwords ── */
.section-desc {
    font-size: 13px;
    color: var(--color-text-subtle);
    margin-bottom: 16px;
    line-height: 1.5;
}
.scope-checkboxes {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-dark);
    cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
    accent-color: var(--color-accent);
    width: 16px;
    height: 16px;
}
.form-select {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--color-border);
    border-radius: 10px;
    font-size: 14px;
    background: var(--color-bg-hover);
    color: var(--color-text-heading);
    font-family: inherit;
    transition: all 0.2s;
    appearance: auto;
}
.form-select:focus {
    outline: none;
    border-color: var(--color-accent);
    background: var(--color-bg-surface);
    box-shadow: 0 0 0 3px var(--color-accent-ring);
}
.btn-secondary {
    background: var(--color-border-light);
    color: var(--color-text-dark);
    border: 2px solid var(--color-border);
}
.btn-secondary:hover {
    background: var(--color-border);
}
.btn-danger {
    background: var(--color-danger-gradient);
    color: var(--color-danger-text);
    box-shadow: 0 2px 8px var(--color-danger-shadow);
}
.btn-danger:hover {
    box-shadow: 0 4px 14px var(--color-danger-shadow-lg);
    transform: translateY(-1px);
}
.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 8px;
}

.app-pw-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.app-pw-table th {
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-faint);
    font-weight: 700;
    padding: 8px 10px;
    border-bottom: 2px solid var(--color-border);
}
.app-pw-table td {
    padding: 10px;
    border-bottom: 1px solid var(--color-border-light);
    vertical-align: middle;
}
.app-pw-table tr:last-child td {
    border-bottom: none;
}
.app-pw-label-cell {
    font-weight: 600;
    color: var(--color-text-heading);
}
.app-pw-prefix code {
    font-size: 12px;
    background: var(--color-border-light);
    padding: 2px 8px;
    border-radius: 6px;
    color: var(--color-text-subtle);
}

.badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 12px;
}
.badge-active {
    background: var(--color-badge-success-bg);
    color: var(--color-badge-success-text);
}
.badge-expired {
    background: var(--color-danger-light-bg);
    color: var(--color-error-text-dark);
}

@media (max-width: 640px) {
    .app-pw-table {
        font-size: 12px;
    }
    .app-pw-table th:nth-child(3),
    .app-pw-table td:nth-child(3),
    .app-pw-table th:nth-child(5),
    .app-pw-table td:nth-child(5) {
        display: none;
    }
}
.app-pw-empty {
    text-align: center;
    padding: 24px;
    color: var(--color-text-faint);
    font-size: 13px;
}
.app-pw-empty i {
    margin-right: 6px;
}

.hidden {
    display: none;
}
.app-pw-warn {
    margin-bottom: 8px;
}
.app-pw-dismiss {
    margin-top: 10px;
}
.app-pw-actions {
    display: flex;
    gap: 8px;
}
.app-pw-new-btn {
    margin-top: 14px;
}
.app-pw-created-box {
    position: relative;
}
.app-pw-token-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}
.app-pw-token-input {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid var(--color-badge-success-border);
    border-radius: 10px;
    font-size: 14px;
    font-family: "Courier New", Courier, monospace;
    background: var(--color-badge-success-fill-faint);
    color: var(--color-badge-success-text);
}
.app-pw-instr-list {
    font-size: 12px;
    line-height: 1.8;
    margin-top: 8px;
}
.app-pw-instr-list code {
    background: var(--color-badge-success-fill-faint);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 12px;
}

/* ── Loading / Error ── */
#loading {
    text-align: center;
    padding: 80px;
    color: var(--color-text-faint);
    font-size: 15px;
}
#loading i {
    font-size: 32px;
    color: var(--color-accent);
    display: block;
    margin-bottom: 12px;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
#auth-error {
    text-align: center;
    padding: 80px 20px;
}
#auth-error .err-icon {
    width: 80px;
    height: 80px;
    background: var(--color-danger-light-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}
#auth-error .err-icon i {
    font-size: 32px;
    color: var(--color-danger-alt);
}
#auth-error h2 {
    color: var(--color-error-text-dark);
    margin-bottom: 8px;
    font-size: 20px;
}
#auth-error p {
    color: var(--color-text-subtle);
    margin-bottom: 20px;
    font-size: 14px;
}
#auth-error a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 24px;
    background: var(--color-accent-gradient);
    color: var(--color-sidebar-text-active);
    text-decoration: none;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    box-shadow: 0 3px 12px var(--color-accent-shadow);
    transition: all 0.2s;
}
#auth-error a:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 18px var(--color-accent-shadow-lg);
}

/* ── App Passwords ── */
.app-pw-desc {
    font-size: 13px;
    color: var(--color-text-subtle);
    margin-bottom: 16px;
    line-height: 1.5;
}
.app-pw-create {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}
.app-pw-create input {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid var(--color-border);
    border-radius: 10px;
    font-size: 14px;
    background: var(--color-bg-input);
    transition: all 0.2s;
    font-family: inherit;
    color: var(--color-text-heading);
}

.app-pw-create input:hover {
    background: var(--color-bg-surface);
}

.app-pw-create input:focus {
    outline: none;
    border-color: var(--color-accent);
    background: var(--color-bg-surface);
    box-shadow: 0 0 0 3px var(--color-accent-ring);
}
.app-pw-created {
    background: var(--color-badge-success-bg);
    border: 1px solid var(--color-badge-success-border);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}
.app-pw-created-label {
    font-size: 13px;
    color: var(--color-badge-success-text);
    margin-bottom: 8px;
    font-weight: 500;
}
.app-pw-created-value {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}
.app-pw-created-value code {
    font-family: "SF Mono", SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 16px;
    font-weight: 700;
    color: var(--color-badge-success-text);
    letter-spacing: 1px;
    background: var(--color-badge-success-bg-medium);
    padding: 8px 14px;
    border-radius: 8px;
    flex: 1;
    word-break: break-all;
}
.btn-copy {
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    background: var(--color-secret-green);
    color: var(--color-sidebar-text-active);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.15s;
    flex-shrink: 0;
}
.btn-copy:hover {
    background: var(--color-badge-success-fill);
}
.app-pw-created small {
    font-size: 12px;
    color: var(--color-badge-success-fill);
}
.app-pw-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.app-pw-table thead th {
    text-align: left;
    font-size: 11.5px;
    color: var(--color-text-faint);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
    padding: 8px 12px;
    border-bottom: 1px solid var(--color-border);
}
.app-pw-table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--color-border-light);
    color: var(--color-text-dark);
}
.app-pw-table tbody tr:last-child td {
    border-bottom: none;
}
.btn-danger-sm {
    padding: 6px 10px;
    border: none;
    border-radius: 8px;
    background: var(--color-danger-light-bg);
    color: var(--color-error-text-dark);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.15s;
}
.btn-danger-sm:hover {
    background: var(--color-error-bg);
    color: var(--color-error-text);
}
.app-pw-empty {
    text-align: center;
    color: var(--color-text-faint);
    font-size: 14px;
    padding: 24px 0;
}
.app-pw-auto-section {
    margin-top: 20px;
    border-top: 1px solid var(--color-border);
    padding-top: 16px;
}
.app-pw-auto-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-subtle);
    padding: 0;
    transition: color 0.15s;
    width: 100%;
}
.app-pw-auto-toggle:hover {
    color: var(--color-text-dark);
}
.app-pw-auto-toggle i {
    font-size: 11px;
    transition: transform 0.15s;
    width: 12px;
}
.app-pw-auto-count {
    font-size: 11px;
    font-weight: 700;
    background: var(--color-border);
    color: var(--color-text-subtle);
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: auto;
}
.app-pw-auto-desc {
    font-size: 12px;
    color: var(--color-text-faint);
    margin: 12px 0 8px;
    line-height: 1.4;
}

/* ── Avatar photo ──────────────────────────────────────────────────────────── */

.avatar-large-wrap {
    position: relative;
    flex-shrink: 0;
}

/* Fill circle with photo when JS injects an <img> */
.avatar-large img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

/* Pencil button that appears on hover (visible only for local accounts) */
.avatar-edit-btn {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid var(--color-bg-surface);
    background: var(--color-accent);
    color: var(--color-sidebar-text-active);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    cursor: pointer;
    transition:
        opacity 0.15s,
        transform 0.15s;
}

.avatar-edit-btn:hover {
    transform: scale(1.1);
}

/* OIDC note shown instead of edit button */
.avatar-oidc-note {
    font-size: 12px;
    color: var(--color-text-faint);
    margin-top: 6px;
    font-style: italic;
}

/* ── Photo edit panel ──────────────────────────────────────────────────────── */

.avatar-edit-panel {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--color-border);
}

.avatar-edit-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
}

.avatar-tab {
    padding: 6px 16px;
    border: 1px solid var(--color-border);
    border-radius: 20px;
    background: none;
    color: var(--color-text-subtle);
    font-size: 13px;
    cursor: pointer;
    transition:
        background 0.15s,
        color 0.15s,
        border-color 0.15s;
}

.avatar-tab.active {
    background: var(--color-accent);
    color: var(--color-sidebar-text-active);
    border-color: var(--color-accent);
}

.avatar-tab-pane {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.avatar-url-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    background: var(--color-bg-alt);
    color: var(--color-text-dark);
    font-size: 14px;
    box-sizing: border-box;
}

.avatar-url-input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-accent-ring);
}

.avatar-hint {
    font-size: 12px;
    color: var(--color-text-faint);
}

/* Hidden file input — triggered via the label */
.avatar-file-input {
    display: none;
}

.avatar-file-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: 1px dashed var(--color-border);
    border-radius: 10px;
    background: var(--color-bg-alt);
    color: var(--color-text-subtle);
    font-size: 13px;
    cursor: pointer;
    transition:
        border-color 0.15s,
        color 0.15s;
}

.avatar-file-label:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

/* Live preview thumbnail (square, small) */
.avatar-preview {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--color-border);
}

.avatar-edit-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 16px;
}

#p-avatar-status {
    margin-top: 12px;
}
