@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:opsz,wght@8..60,500;8..60,600;8..60,700&family=Space+Grotesk:wght@600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
    --ink: #241C3D;
    --plum: #146E66;
    --coral: #00B37A;
    --gold: #FFB627;
    --cream: #FAF3E7;
    --danger: #E4483B;
    --line: rgba(36, 28, 61, 0.1);
}

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

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--cream);
    background-image:
        radial-gradient(circle at 10% 0%, rgba(0, 179, 122, 0.16), transparent 45%),
        radial-gradient(circle at 90% 100%, rgba(20, 110, 102, 0.16), transparent 45%);
    color: var(--ink);
    display: flex;
    justify-content: center;
    padding: 40px 20px;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

.bg-dots {
    position: fixed;
    top: 0;
    width: 420px;
    height: 100vh;
    pointer-events: none;
    z-index: 0;
}

.bg-dots.left {
    left: 0;
    mask-image: linear-gradient(to right, black 15%, transparent 95%);
    -webkit-mask-image: linear-gradient(to right, black 15%, transparent 95%);
}

.bg-dots.right {
    right: 0;
    mask-image: linear-gradient(to left, black 15%, transparent 95%);
    -webkit-mask-image: linear-gradient(to left, black 15%, transparent 95%);
}

.bg-dots span {
    position: absolute;
    border-radius: 50%;
    background: var(--coral);
}

.dashboard-container,
.auth-card {
    position: relative;
    z-index: 1;
}

h1, h2 {
    font-family: 'Source Serif 4', serif;
    letter-spacing: -0.01em;
}

.auth-card {
    background: #fff;
    border-radius: 24px;
    padding: 36px 32px;
    max-width: 380px;
    width: 100%;
    box-shadow: 0 18px 40px -12px rgba(36, 28, 61, 0.18);
    border: 1px solid var(--line);
    align-self: flex-start;
    margin: auto;
}

.auth-card h1 {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 4px;
}

.subtitle {
    color: rgba(36, 28, 61, 0.6);
    font-size: 14px;
    margin-bottom: 24px;
}

.error-message {
    background: #FEECEA;
    color: var(--danger);
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 14px;
    margin-bottom: 16px;
    font-weight: 500;
}

.success-message {
    background: #E4F4F2;
    color: #0B5C52;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 14px;
    margin-bottom: 16px;
    font-weight: 500;
}

form label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: rgba(36, 28, 61, 0.55);
    margin-bottom: 6px;
    margin-top: 16px;
}

form input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    background: var(--cream);
    color: var(--ink);
}

form input:focus {
    outline: none;
    border-color: var(--coral);
    background: #fff;
}

.color-input {
    width: 100%;
    height: 46px;
    padding: 4px;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    cursor: pointer;
    background: var(--cream);
}

.btn-submit {
    width: 100%;
    margin-top: 22px;
    padding: 13px;
    background-color: var(--coral);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease;
}

.btn-submit:hover {
    transform: translateY(-2px);
}

.switch-link {
    text-align: center;
    margin-top: 18px;
    font-size: 13px;
    color: rgba(36, 28, 61, 0.6);
}

.switch-link a {
    color: var(--coral);
    text-decoration: none;
    font-weight: 600;
}

.dashboard-container {
    max-width: 720px;
    width: 100%;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.dashboard-header h1 {
    font-size: 24px;
    font-weight: 700;
}

.header-identity {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-logo {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #fff;
    box-shadow: 0 0 0 3px var(--coral);
    flex-shrink: 0;
}

.header-logo-placeholder {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #fff;
    border: 1.5px dashed var(--line);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: rgba(36, 28, 61, 0.4);
    flex-shrink: 0;
}

.default-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--cream);
    border: 2px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.default-avatar svg {
    width: 60%;
    height: 60%;
    color: rgba(36, 28, 61, 0.35);
}

.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-settings-small,
.btn-logout-small {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.btn-settings-small {
    background-color: var(--plum);
    color: #fff;
    text-decoration: none;
}

.btn-logout-small {
    background-color: transparent;
    color: var(--ink);
    border: 1.5px solid var(--line);
}

.btn-logout-small:hover {
    background-color: #fff;
}

/* ── Carte Wallet — fidèle au vrai rendu Google ───────────────── */

.wallet-card-section {
    margin-bottom: 20px;
}

.wallet-card-preview {
    border-radius: 16px;
    padding: 18px 20px 0;
    color: #fff;
    box-shadow: 0 14px 32px -12px rgba(36, 28, 61, 0.3);
    max-width: 280px;
    transition: background 0.2s ease;
    overflow: hidden;
}

.wallet-card-issuer-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}

.wallet-card-logo {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    background: #fff;
    flex-shrink: 0;
}

.wallet-card-logo-placeholder {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
}

.wallet-card-issuer {
    font-size: 13px;
    font-weight: 600;
    opacity: 0.9;
}

.wallet-card-title {
    font-family: 'Inter', sans-serif;
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 18px;
    line-height: 1.15;
}

.wallet-card-data-row-split {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 18px;
    gap: 16px;
}

.wallet-card-data-col {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.wallet-card-data-col.right {
    text-align: right;
    align-items: flex-end;
}

.wallet-card-label {
    font-size: 12px;
    font-weight: 400;
    opacity: 0.8;
}

.wallet-card-value {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 600;
}

.wallet-card-hero-wrap {
    position: relative;
    width: calc(100% + 40px);
    margin: 0 -20px;
    overflow: hidden;
}

.wallet-card-hero {
    width: 100%;
    display: block;
    object-fit: cover;
    max-height: 130px;
}

.wallet-card-hero-wrap::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 90%;
    background: linear-gradient(
        to bottom,
        var(--wallet-fade-color, #2563eb) 0%,
        var(--wallet-fade-color, #2563eb) 5.5%,
        color-mix(in srgb, var(--wallet-fade-color, #2563eb) 65%, transparent) 30%,
        color-mix(in srgb, var(--wallet-fade-color, #2563eb) 22%, transparent) 60%,
        color-mix(in srgb, var(--wallet-fade-color, #2563eb) 5%, transparent) 82%,
        transparent 100%
    );
    pointer-events: none;
}

.preview-disclaimer {
    font-size: 11px;
    color: rgba(36, 28, 61, 0.4);
    margin-top: 10px;
    max-width: 280px;
    line-height: 1.4;
}

.btn-brush {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding: 9px 16px;
    background: #fff;
    border: 1.5px solid var(--line);
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
    cursor: pointer;
    font-family: 'Inter', sans-serif;
}

.btn-brush:hover {
    border-color: var(--coral);
    color: var(--coral);
}

.wallet-editor {
    display: none;
    max-width: 380px;
    background: #fff;
    border-radius: 14px;
    padding: 20px;
    margin-top: 14px;
    border: 1px solid var(--line);
}

.wallet-editor.open {
    display: block;
}

.wallet-editor label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: rgba(36, 28, 61, 0.55);
    margin-bottom: 6px;
    margin-top: 16px;
}

.wallet-editor label:first-of-type {
    margin-top: 0;
}

.wallet-editor input[type="text"] {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    background: var(--cream);
    color: var(--ink);
}

.wallet-editor input[type="text"]:focus {
    outline: none;
    border-color: var(--coral);
    background: #fff;
}

.wallet-editor .color-input {
    width: 100%;
    height: 44px;
    padding: 4px;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    cursor: pointer;
    background: var(--cream);
}

.wallet-editor-file-row {
    margin-top: 16px;
}

.wallet-editor-hint {
    font-size: 12px;
    color: rgba(36, 28, 61, 0.45);
    margin-top: 6px;
}

/* ── Reste du dashboard ───────────────────── */

.logo-section {
    background: #fff;
    border-radius: 18px;
    padding: 22px;
    margin-bottom: 20px;
    box-shadow: 0 10px 26px -12px rgba(36, 28, 61, 0.14);
    border: 1px solid var(--line);
}

.current-logo {
    width: 84px;
    height: 84px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 16px;
    display: block;
    border: 3px solid #fff;
    box-shadow: 0 0 0 3px var(--coral);
}

.btn-file-choose {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--coral);
    color: #fff !important;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: transform 0.15s ease;
    text-decoration: none;
}

.btn-file-choose:hover {
    transform: translateY(-2px);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.stat-card {
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 10px 26px -12px rgba(36, 28, 61, 0.14);
    border: 1px solid var(--line);
    text-align: center;
    position: relative;
}

.stat-value {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 30px;
    font-weight: 700;
    color: var(--coral);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 12px;
    color: rgba(36, 28, 61, 0.6);
    font-weight: 500;
    position: relative;
    cursor: help;
}

.stat-tooltip {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--ink);
    color: #fff;
    font-size: 12px;
    font-weight: 400;
    text-align: left;
    line-height: 1.4;
    padding: 10px 12px;
    border-radius: 10px;
    width: 210px;
    z-index: 20;
    box-shadow: 0 10px 24px -8px rgba(36, 28, 61, 0.4);
}

.stat-tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--ink);
}

.stat-label:hover .stat-tooltip {
    display: block;
}

.chart-section {
    background: #fff;
    border-radius: 18px;
    padding: 22px;
    margin-bottom: 20px;
    box-shadow: 0 10px 26px -12px rgba(36, 28, 61, 0.14);
    border: 1px solid var(--line);
}

.chart-section h2 {
    font-size: 16px;
    margin-bottom: 16px;
}

.period-selector {
    display: flex;
    background: var(--cream);
    border-radius: 10px;
    padding: 3px;
    gap: 2px;
}

.period-btn {
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    color: rgba(36, 28, 61, 0.55);
    text-decoration: none;
}

.period-btn.active {
    background: #fff;
    color: var(--coral);
    box-shadow: 0 2px 6px rgba(36, 28, 61, 0.1);
}

.distribution-chart {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 160px;
    padding-top: 20px;
    overflow-x: auto;
}

.distribution-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 22px;
    height: 100%;
}

.distribution-count {
    font-size: 10px;
    font-weight: 600;
    color: rgba(36, 28, 61, 0.5);
    margin-bottom: 4px;
    white-space: nowrap;
}

.distribution-bar-track {
    width: 100%;
    flex: 1;
    display: flex;
    align-items: flex-end;
    background: var(--cream);
    border-radius: 4px;
    overflow: hidden;
}

.distribution-bar-fill {
    width: 100%;
    background: var(--coral);
    border-radius: 4px 4px 0 0;
    min-height: 2px;
    transition: height 0.2s ease;
}

.distribution-bar-fill.reward {
    background: var(--gold);
}

.distribution-label {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 10px;
    font-weight: 600;
    color: rgba(36, 28, 61, 0.5);
    margin-top: 6px;
}

.distribution-label.reward {
    color: #92650E;
}

.settings-section {
    background: #fff;
    border-radius: 18px;
    padding: 22px;
    margin-bottom: 20px;
    box-shadow: 0 10px 26px -12px rgba(36, 28, 61, 0.14);
    border: 1px solid var(--line);
}

.settings-section h2 {
    font-size: 16px;
    margin-bottom: 4px;
}

.tags-section {
    background: #fff;
    border-radius: 18px;
    padding: 22px;
    box-shadow: 0 10px 26px -12px rgba(36, 28, 61, 0.14);
    border: 1px solid var(--line);
    margin-bottom: 20px;
}

.tags-section h2 {
    font-size: 16px;
    margin-bottom: 16px;
}

.create-tag-form {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.tags-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tag-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 13px 14px;
    background: var(--cream);
    border-radius: 12px;
}

.tag-info {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.tag-code {
    font-family: 'Space Grotesk', monospace;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: 0.02em;
}

.tag-type {
    color: rgba(36, 28, 61, 0.55);
    font-size: 13px;
}

.tag-status {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.status-active {
    background: #E4F4F2;
    color: #0B5C52;
}

.status-inactive {
    background: #FEECEA;
    color: var(--danger);
}

.btn-toggle {
    padding: 7px 14px;
    background: #fff;
    border: 1.5px solid var(--line);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.btn-toggle:hover {
    border-color: var(--coral);
    color: var(--coral);
}

.empty-state {
    color: rgba(36, 28, 61, 0.45);
    font-size: 14px;
    text-align: center;
    padding: 20px;
}

.crop-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(36, 28, 61, 0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.crop-modal-content {
    background: white;
    border-radius: 20px;
    padding: 24px;
    max-width: 420px;
    width: 90%;
}

.crop-container {
    width: 100%;
    height: 300px;
    background: var(--ink);
    border-radius: 12px;
    overflow: hidden;
}

.crop-container img {
    max-width: 100%;
    display: block;
}

.crop-controls {
    margin-top: 16px;
}

.crop-controls label {
    margin-top: 0;
}

.crop-controls input[type="range"] {
    width: 100%;
    accent-color: var(--coral);
}

.crop-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.crop-actions button {
    flex: 1;
}

#crop-modal .cropper-view-box,
#crop-modal .cropper-face {
    border-radius: 50%;
}

@media (max-width: 640px) {
    body {
        padding: 20px 14px;
    }
    .dashboard-header {
        flex-wrap: wrap;
        gap: 12px;
    }
    .header-identity {
        gap: 10px;
    }
    .header-logo, .default-avatar, .header-logo-placeholder {
        width: 48px;
        height: 48px;
    }
    .dashboard-header h1 {
        font-size: 19px;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .create-tag-form {
        flex-direction: column;
    }
    .tag-row {
        flex-wrap: wrap;
        gap: 8px;
    }
    .bg-dots {
        display: none;
    }
    .distribution-chart {
        gap: 3px;
    }
    .distribution-col {
        min-width: 16px;
    }
    .tag-choice-grid {
    grid-template-columns: 1fr;
    }
}

.tag-choice-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 20px;
}

.tag-choice-card {
    background: #fff;
    border: 1.5px solid var(--line);
    border-radius: 20px;
    padding: 24px;
    text-align: center;
    display: flex;
    flex-direction: column;
}

.tag-choice-visual {
    width: 100%;
    height: 140px;
    border-radius: 14px;
    overflow: hidden;
    margin-bottom: 16px;
    background: var(--cream);
    display: flex;
    align-items: center;
    justify-content: center;
}

.tag-choice-visual img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tag-choice-visual.placeholder {
    border: 1.5px dashed var(--line);
}

.tag-choice-visual.placeholder span {
    font-size: 13px;
    color: rgba(36, 28, 61, 0.4);
}