/* Nordic Minimalist Aesthetic */
:root {
    --bg-color: #faf9f6;
    --text-primary: #333333;
    --text-secondary: #666666;
    --accent-color: #9caf88;
    --accent-hover: #869b6f;
    --card-bg: #ffffff;
    --border-color: #e5e5e5;
    --error-color: #d9534f;
    --success-color: #5cb85c;
    --font-family: 'Inter', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    padding: 1rem 2rem;
}

.container {
    width: 100%;
    max-width: 500px;
    transition: max-width 0.3s ease;
}

.container.wide {
    max-width: 1200px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 2rem;
}

.logo {
    font-size: 2.5rem;
    font-weight: 600;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

.subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* Views */
.view {
    display: none;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.view.active {
    display: block;
    opacity: 1;
}

/* Forms & Cards */
#login-view, #profile-setup-view {
    max-width: 450px;
    margin: 0 auto;
    background: var(--card-bg);
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--border-color);
}

#login-view h2, #profile-setup-view h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    text-align: center;
}

#login-view > p, #profile-setup-view > p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 2rem;
    text-align: center;
}

/* Auth Tabs */
.auth-tabs {
    display: flex;
    margin-bottom: 2rem;
    border-bottom: 2px solid #e5e5e5;
}

.auth-tab {
    flex: 1;
    background: none;
    border: none;
    padding: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    position: relative;
    transition: color 0.3s ease;
}

.auth-tab.active {
    color: var(--text-primary);
}

.auth-tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--accent-color);
}

.auth-section {
    display: none;
    animation: fadeIn 0.3s ease;
}

.auth-section.active {
    display: block;
}

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

.login-methods {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.google-login-container {
    display: flex;
    justify-content: center;
}

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-color);
}

.divider span {
    padding: 0 10px;
}

.input-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 1.25rem;
}

.input-group label {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.input-group input {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.2s ease;
    background-color: #fff;
}

.input-group input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.input-group input:disabled {
    background-color: #f5f5f5;
    color: var(--text-secondary);
    cursor: not-allowed;
}

.input-group select {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: inherit;
    font-size: 1rem;
    background-color: #fff;
    color: var(--text-primary);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.input-group select:focus {
    outline: none;
    border-color: var(--accent-color);
}

.btn {
    width: 100%;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

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

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

.btn.primary:not(:disabled):hover {
    background-color: var(--accent-hover);
}

.btn.secondary {
    background-color: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn.secondary:not(:disabled):hover {
    background-color: #f0f0f0;
}

.btn.small {
    width: auto;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

.error-msg {
    color: var(--error-color) !important;
    font-size: 0.85rem !important;
    margin-top: 0.5rem;
    margin-bottom: 0 !important;
    min-height: 1.2rem;
}

.status-msg {
    font-size: 0.85rem !important;
    margin-top: 0.5rem;
    margin-bottom: 0 !important;
    min-height: 1.2rem;
}

.status-msg.success {
    color: var(--success-color) !important;
}

.status-msg.error {
    color: var(--error-color) !important;
}

/* Dashboard */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-top: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-branding-text {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 1.1rem;
    letter-spacing: 0.5px;
}

@media (max-width: 768px) {
    .header-branding-text {
        display: none; /* Hide on small screens to save space */
    }
}

.header-profile-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: var(--card-bg);
    color: var(--text-primary);
    font-size: 1.25rem;
    border: 1px solid var(--border-color);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.header-profile-btn:hover {
    background-color: #f9f9f9;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.dashboard-header h2 {
    font-weight: 400;
    margin: 0;
}

/* Search and Filter Bar */
.search-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    align-items: center;
}

.search-input {
    flex: 1;
    min-width: 200px;
    padding: 0.6rem 1rem; /* Sleeker padding */
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-color);
    font-family: inherit;
    font-size: 0.9rem; /* Sleeker text */
    color: var(--text-primary);
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(156, 175, 136, 0.2);
}

.sort-select {
    padding: 0.6rem 1rem; /* Sleeker padding */
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-color);
    font-family: inherit;
    font-size: 0.9rem; /* Sleeker text */
    color: var(--text-primary);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem; /* space for arrow */
}

.sort-select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(156, 175, 136, 0.2);
}

.sort-wrapper {
    position: relative;
    display: inline-block;
}

@media (max-width: 768px) {
    .sort-wrapper {
        width: 44px; /* Icon size */
        height: 42px;
        border: 1px solid var(--border-color);
        border-radius: 8px;
        background-color: var(--bg-color);
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23333333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolygon points='22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3'%3E%3C/polygon%3E%3C/svg%3E");
        background-position: center;
        background-repeat: no-repeat;
        overflow: hidden; /* Clips the oversized invisible select */
    }
    .sort-wrapper:focus-within {
        border-color: var(--accent-color);
        box-shadow: 0 0 0 3px rgba(156, 175, 136, 0.2);
    }
    .sort-select {
        opacity: 0; 
        width: 200px; /* Forces browser to render a proper, wide, padded dropdown menu */
        height: 100%;
        padding: 0;
        margin: 0;
        position: absolute;
        top: 0;
        right: 0; /* Aligns the clickable part with the 44px wrapper */
        cursor: pointer;
    }
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
}

.card h3 {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
}

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

/* Floating Action Button (FAB) */
.fab-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    z-index: 100;
}

.fab {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background-color: var(--text-primary);
    color: white;
    font-size: 1.8rem;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(51, 51, 51, 0.35);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.fab:hover {
    background-color: #1a1a1a;
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(51, 51, 51, 0.45);
}

/* Footer */
.dashboard-footer {
    text-align: center;
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding-bottom: 2rem;
}

.dashboard-footer a {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
}

.dashboard-footer a:hover {
    text-decoration: underline;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: var(--card-bg);
    border-radius: 12px;
    width: 100%;
    max-width: 800px;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}

.modal-content h2 {
    margin: 2rem 2.5rem 1.25rem 2.5rem;
    font-weight: 600;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.modal-scroll-area {
    padding: 0 2.5rem 2rem 2.5rem;
    overflow-y: auto;
}

/* Grid Layout for Form */
.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

@media (min-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr 1fr;
        gap: 3rem;
    }
}

.col-title {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.close-btn {
    position: absolute;
    top: 1.25rem;
    right: 1.5rem;
    font-size: 1.5rem;
    font-weight: 300;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s ease;
}

.close-btn:hover {
    color: var(--text-primary);
}

/* Toggle Switch */
.toggle-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.toggle-row label {
    font-size: 0.85rem;
    font-weight: 600;
}

.toggle {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: var(--border-color);
    border-radius: 24px;
    transition: background-color 0.25s ease;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.25s ease;
}

.toggle input:checked + .toggle-slider {
    background-color: var(--accent-color);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

/* Conditional Field */
.conditional-field {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 0;
}

.conditional-field.visible {
    max-height: 120px;
    opacity: 1;
}

/* File Upload */
.file-upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s ease;
    margin-bottom: 1.25rem;
}

.file-upload-area:hover {
    border-color: var(--accent-color);
}

.file-upload-area input[type="file"] {
    display: none;
}

.file-upload-area p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0;
}

.file-upload-area .file-name {
    font-size: 0.85rem;
    color: var(--accent-color);
    font-weight: 600;
    margin-top: 0.5rem;
}

/* Item Cards (List View) */
.item-card {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: stretch; /* crucial for left/right column balance */
    gap: 1.5rem;
    padding: 1.25rem 1.5rem;
}

.item-card-left {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex: 1;
    gap: 1rem;
}

.item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.item-header-text h3 {
    border-bottom: none;
    margin-bottom: 0.15rem;
    padding-bottom: 0;
    font-size: 1.15rem;
    font-weight: 600;
}

.mobile-expand-icon {
    display: none;
}

.item-spec {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0;
}

.item-details-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    font-size: 0.85rem;
}

.detail-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #f8f9fa; /* very subtle background */
    padding: 4px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
}

.detail-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.detail-value {
    font-weight: 600;
}

.item-card-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: space-between;
    min-width: fit-content;
    gap: 1rem;
}

.item-card-actions-top {
    display: flex;
    flex-direction: column;
    align-items: center; /* Perfectly centers File Claim under the pill's text */
    gap: 4px; 
}

.item-card-actions-bottom {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: flex-end;
}

@media (max-width: 768px) {
    .item-card {
        flex-direction: column; 
        padding: 1rem;
        gap: 1.25rem;
    }
    
    .item-card-right {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center; /* Fixes bottom alignment issues between text and buttons */
        justify-content: flex-start; /* Stops it from feeling pushed to the far edges */
        gap: 1rem 2rem;
    }

    .item-card-actions-top {
        align-items: center; 
    }

    .item-card-actions-bottom {
        align-items: center;
    }

    .warranty-counter {
        font-size: 0.95rem !important;
    }

    .item-header {
        cursor: pointer;
    }

    .mobile-expand-icon {
        display: block;
        color: var(--text-secondary);
        transition: transform 0.3s ease;
    }

    .item-details-row {
        display: none; /* Hide details by default on mobile */
    }

    .item-card-left.expanded .item-details-row {
        display: flex; /* Show details when expanded */
        margin-top: 0.5rem;
    }

    .item-card-left.expanded .mobile-expand-icon {
        transform: rotate(180deg);
    }
}

.sn-copy {
    cursor: pointer;
    color: var(--text-primary);
    position: relative;
    padding-right: 20px;
}
.sn-copy::after {
    content: '📋';
    position: absolute;
    right: 0;
    font-size: 0.8rem;
    opacity: 0.5;
    transition: opacity 0.2s;
}
.sn-copy:hover::after {
    opacity: 1;
}
.sn-copy.copied::after {
    content: '✓';
    color: var(--success-color);
    opacity: 1;
}

.warranty-counter {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent-hover);
    background: #eef5e9;
    padding: 0.25rem 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--accent-color);
}

.warranty-counter.expired {
    color: var(--error-color);
    background: #fdf0ef;
    border-color: #f5c6cb;
}

.ext-warranty-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-style: italic;
}

.invoice-btn {
    text-decoration: none;
    display: inline-block;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.4rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.invoice-btn:hover {
    border-color: var(--accent-color);
    color: var(--accent-hover);
}

.delete-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0.4rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--error-color);
}

.delete-btn:hover {
    background: #fdf0ef;
    transform: scale(1.1);
}

/* ============================
   Profile Panel
   ============================ */
.profile-panel {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.04);
    max-width: 520px;
    margin: 0 auto;
    overflow: hidden;
}

.profile-panel-header {
    text-align: center;
    padding: 2rem 2rem 1.25rem;
    background: linear-gradient(135deg, #f8f9f5 0%, #f0f3eb 100%);
    border-bottom: 1px solid var(--border-color);
}

.profile-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--card-bg);
    border: 2px solid var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    margin: 0 auto 0.75rem;
    box-shadow: 0 2px 8px rgba(156, 175, 136, 0.2);
}

.profile-panel-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    border-bottom: none;
    padding-bottom: 0;
}

.profile-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0;
}

.profile-details {
    padding: 1.5rem 2rem 0.5rem;
}

.profile-field {
    margin-bottom: 1.25rem;
}

.profile-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.label-hint {
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
    opacity: 0.7;
}

.profile-field-row {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.profile-input {
    flex: 1;
    min-width: 0;
    padding: 0.7rem 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-primary);
    background-color: #fff;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.profile-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.profile-input:disabled {
    background-color: #f7f7f5;
    color: var(--text-primary);
    cursor: default;
}

.field-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.3rem 0.6rem;
    border-radius: 20px;
    white-space: nowrap;
    flex-shrink: 0;
}

.badge-locked {
    background: #f0f0ed;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.profile-btn-group {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* Password row wraps on narrow screens */
.profile-field-row--password {
    flex-wrap: wrap;
}

.profile-signout-area {
    padding: 0.75rem 2rem 2rem;
    display: flex;
    justify-content: center;
}

.profile-signout-btn {
    padding: 0.7rem 2.5rem;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 8px;
    border: 1px solid #f5c6cb;
    background: #fdf0ef;
    color: var(--error-color);
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.profile-signout-btn:hover {
    background: #fbe3e1;
}

.profile-signout-btn:active {
    transform: scale(0.97);
}

/* === Mobile Responsive Tweaks === */
@media (max-width: 600px) {
    .profile-panel {
        border-radius: 12px;
        margin: 0 -0.5rem;
    }

    .profile-panel-header {
        padding: 1.5rem 1.25rem 1rem;
    }

    .profile-avatar {
        width: 52px;
        height: 52px;
        font-size: 1.4rem;
    }

    .profile-panel-header h3 {
        font-size: 1.1rem;
    }

    .profile-details {
        padding: 1.25rem 1.25rem 0.25rem;
    }

    .profile-field {
        margin-bottom: 1rem;
    }

    .profile-label {
        font-size: 0.75rem;
    }

    .profile-input {
        padding: 0.6rem 0.75rem;
        font-size: 0.9rem;
    }

    .profile-field-row {
        gap: 0.5rem;
    }

    /* Stack password buttons below input on very small screens */
    .profile-field-row--password {
        flex-direction: column;
        align-items: stretch;
    }

    .profile-field-row--password .profile-input {
        width: 100%;
    }

    .profile-field-row--password .profile-btn-group {
        display: flex;
        gap: 0.5rem;
    }

    .profile-field-row--password .profile-btn-group .btn.small {
        flex: 1;
        text-align: center;
    }

    .field-badge {
        font-size: 0.65rem;
        padding: 0.25rem 0.5rem;
    }

    .profile-signout-area {
        padding: 0.5rem 1.25rem 1.5rem;
    }

    .profile-signout-btn {
        width: 100%;
        padding: 0.7rem 1rem;
    }
}

/* ============================
   UI/UX Refinements (Modals)
   ============================ */

/* Textareas in Modals */
.kuzto-textarea {
    width: 100%;
    min-height: 120px;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    resize: vertical;
    word-wrap: break-word; /* Ensure long links or text don't overflow */
    background-color: var(--bg-color);
    color: var(--text-primary);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.kuzto-textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(156, 175, 136, 0.2);
}

/* Modal Action Buttons */
.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 1.5rem;
    flex-wrap: wrap; /* Helps on small screens */
}

/* Ensure modal action buttons don't stretch forever on desktop */
.modal-actions .btn {
    width: auto;
    flex: 1 1 auto;
}

@media (min-width: 600px) {
    .modal-actions .btn {
        flex: 0 0 auto; /* Natural width on desktop */
        min-width: 120px; /* Minimum width for touch targets */
    }
}

/* Prevent unwanted thick browser borders and add premium focus rings */
.btn.primary {
    border: 2px solid transparent !important;
}

.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(156, 175, 136, 0.4);
}

/* File Claim Text Link */
.file-claim-link {
    font-size: 0.85rem;
    color: var(--accent-color);
    text-decoration: underline;
    cursor: pointer;
    font-weight: 600;
    transition: color 0.2s ease;
}
.file-claim-link:hover {
    color: var(--accent-hover);
}

/* Spinner Animation & Button States */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
}

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

.btn.loading {
    opacity: 0.85;
    cursor: not-allowed;
    display: flex;
    justify-content: center;
    align-items: center;
}

.btn.success-state {
    background-color: var(--success-color) !important;
    color: #fff !important;
    border-color: var(--success-color) !important;
}

/* --- Icon Buttons --- */
.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 44px;
    height: 42px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.icon-btn.spinning svg {
    animation: spin 1s linear infinite;
}

/* --- Skeleton Loading --- */
.skeleton-card {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    display: flex;
    justify-content: space-between;
    gap: 1.5rem;
}

.skeleton-col {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.skeleton-row {
    display: flex;
    gap: 0.5rem;
}

.skeleton-line {
    height: 16px;
    background: #eaedef;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.skeleton-line.title {
    width: 200px;
    height: 24px;
    margin-bottom: 4px;
}

.skeleton-line.spec {
    width: 150px;
}

.skeleton-line.pill {
    width: 120px;
    height: 28px;
    border-radius: 6px;
}

.skeleton-line.btn {
    width: 130px;
    height: 38px;
    border-radius: 8px;
}

.skeleton-line::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.6) 50%, rgba(255,255,255,0) 100%);
    animation: shimmer 1.5s infinite;
    transform: translateX(-100%);
}

@keyframes shimmer {
    100% {
        transform: translateX(100%);
    }
}

/* Optimistic UI Syncing State */
.item-syncing {
    opacity: 0.7;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sync-badge {
    font-size: 0.7rem;
    background: rgba(156, 175, 136, 0.2);
    color: var(--accent-color);
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    margin-left: 0.5rem;
    vertical-align: middle;
    animation: pulse 1.5s infinite alternate;
}

@keyframes pulse {
    from { opacity: 0.6; }
    to { opacity: 1; }
}

/* --- Spinner & Loading States --- */

/* Inline spinner for buttons (used by manual login) */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: btnSpin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

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

.btn.loading {
    pointer-events: none;
    opacity: 0.85;
}

.btn.success-state {
    background-color: var(--success-color) !important;
    pointer-events: none;
}

/* --- Google Auth Full-Screen Loading Overlay --- */
.google-auth-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(250, 249, 246, 0.82);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    animation: overlayFadeIn 0.35s ease forwards;
}

.google-auth-overlay.hiding {
    animation: overlayFadeOut 0.3s ease forwards;
}

@keyframes overlayFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes overlayFadeOut {
    from { opacity: 1; }
    to   { opacity: 0; }
}

.google-auth-overlay-content {
    text-align: center;
    animation: overlayContentSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

.google-auth-spinner {
    width: 48px;
    height: 48px;
    margin: 0 auto 1.5rem;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: googleSpin 0.8s linear infinite;
}

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

.google-auth-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.4rem;
}

.google-auth-subtext {
    font-size: 0.88rem;
    color: var(--text-secondary);
}

/* Syncing State & Lock Styles */
.sync-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.72rem;
    padding: 0.15rem 0.55rem;
    background-color: rgba(217, 131, 36, 0.12);
    color: #c97316;
    border: 1px solid rgba(217, 131, 36, 0.35);
    border-radius: 12px;
    font-weight: 600;
    margin-left: 0.5rem;
    vertical-align: middle;
    letter-spacing: 0.3px;
    animation: pulseSync 1.4s infinite ease-in-out;
}

@keyframes pulseSync {
    0%, 100% { opacity: 0.65; transform: scale(0.98); }
    50% { opacity: 1; transform: scale(1); }
}

.item-card.item-syncing {
    border-left: 3px solid #d98324 !important;
    background: linear-gradient(90deg, rgba(217, 131, 36, 0.04) 0%, #ffffff 15%);
}

.icon-btn.disabled-btn,
.icon-btn[disabled] {
    opacity: 0.35 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
}
