:root {
    --blue: #1e90ff;
    --blue-dark: #1a7de0;
    --blue-light: #e8f4ff;
    --black: #222;
    --gray: #666;
    --gray-light: #f5f5f5;
    --gray-border: #ddd;
    --white: #fff;
    --green: #2e7d32;
    --red: #c62828;
    --orange: #ef6c00;
    --radius: 8px;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --max-width: 960px;
    --header-height: 86px;
}

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

html {
    font-size: 18px;
    scroll-behavior: smooth;
}

body {
    font-family: Calibri, Verdana, 'Segoe UI', sans-serif;
    color: var(--black);
    background: var(--white);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-top: var(--header-height);
}

a {
    color: var(--blue);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Header */

.site-header {
    background: var(--white);
    border-bottom: 3px solid var(--blue);
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    align-self: stretch;
    z-index: 1200;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
}

.site-header .logo img {
    height: 42px;
    width: auto;
}

.site-header .logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.lang-switcher {
    display: flex;
    gap: 0.4rem;
}

.lang-switcher a {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray);
    transition: all 0.2s;
}

.lang-switcher a:hover {
    background: var(--blue-light);
    color: var(--blue);
    text-decoration: none;
}

.lang-switcher a.active {
    background: var(--blue);
    color: var(--white);
}

/* Main content */

main {
    flex: 1;
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 2rem;
}

/* Page title */

.page-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--black);
    margin-bottom: 0.25rem;
}

.page-subtitle {
    font-size: 1.1rem;
    color: var(--gray);
    margin-bottom: 2rem;
}

/* Help box */

.help-box {
    background: var(--blue-light);
    border-left: 4px solid var(--blue);
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 1.2rem 1.5rem;
    margin-bottom: 2rem;
    cursor: pointer;
    transition: all 0.2s;
}

.help-box .help-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    color: var(--blue-dark);
    font-size: 1rem;
}

.help-box .help-header .toggle-icon {
    transition: transform 0.2s;
    font-size: 1.2rem;
}

.help-box.collapsed .help-header .toggle-icon {
    transform: rotate(-90deg);
}

.help-box .help-content {
    margin-top: 0.8rem;
    color: var(--black);
    font-size: 0.95rem;
    line-height: 1.7;
}

.help-box.collapsed .help-content {
    display: none;
}

/* Flash messages */

.flash {
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    font-weight: 600;
}

.flash.success {
    background: #e8f5e9;
    color: var(--green);
    border-left: 4px solid var(--green);
}

.flash.error {
    background: #ffebee;
    color: var(--red);
    border-left: 4px solid var(--red);
}

/* Cards */

.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
    margin-bottom: 2rem;
}

/* Welcome / Landing */

.welcome-hero {
    text-align: center;
    padding: 3rem 1rem;
}

.welcome-hero .discount-badge {
    font-size: 4rem;
    font-weight: 800;
    color: var(--blue);
    line-height: 1;
    margin-bottom: 0.5rem;
}

.welcome-hero .discount-label {
    display: inline-block;
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 1.5rem;
}

.welcome-hero .discount-label .word-welcome {
    color: var(--red);
}

.welcome-hero .discount-label .word-discount {
    color: var(--green);
}

.welcome-hero p {
    font-size: 1.15rem;
    max-width: 600px;
    margin: 0 auto 1.5rem;
    color: var(--gray);
}

/* Buttons */

.btn {
    display: inline-block;
    padding: 0.75rem 1.8rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    text-decoration: none;
    line-height: 1.4;
}

.btn:hover {
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

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

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

.btn.is-active {
    box-shadow: 0 0 0 3px rgba(30, 144, 255, 0.2);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--gray-light);
    color: var(--black);
}

.btn-secondary:hover {
    background: var(--gray-border);
}

.btn-danger {
    background: var(--red);
    color: var(--white);
}

.btn-danger:hover {
    background: #b71c1c;
    color: var(--white);
}

.btn-success {
    background: var(--green);
    color: var(--white);
}

.btn-success:hover {
    background: #1b5e20;
    color: var(--white);
}

.btn-sm {
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
}

.btn-icon-delete {
    min-width: 2.1rem;
    padding: 0.35rem 0.5rem;
    line-height: 1;
    font-size: 1rem;
}

.btn-group {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}

/* Forms */

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.3rem;
    font-size: 0.95rem;
}

.form-group label .req {
    color: var(--red);
    margin-left: 2px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.7rem 1rem;
    border: 2px solid var(--gray-border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.2s;
    background: var(--white);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--blue);
}

.form-group input[readonly] {
    background: var(--gray-light);
    color: var(--gray);
}

.form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.form-group .hint {
    font-size: 0.8rem;
    color: var(--gray);
    margin-top: 0.25rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Tables */

.table-wrap {
    overflow-x: auto;
    margin-bottom: 2rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

thead th {
    text-align: left;
    padding: 0.75rem 1rem;
    border-bottom: 2px solid var(--blue);
    font-weight: 700;
    color: var(--blue-dark);
    white-space: nowrap;
}

tbody td {
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--gray-border);
    vertical-align: top;
}

tbody tr:hover {
    background: var(--blue-light);
}

.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-used {
    background: #e8f5e9;
    color: var(--green);
}

.badge-unused {
    background: var(--blue-light);
    color: var(--blue);
}

.badge-active {
    background: #e8f5e9;
    color: var(--green);
}

.badge-inactive {
    background: #ffebee;
    color: var(--red);
}

.badge-lead {
    background: #fff3e0;
    color: var(--orange);
}

/* Stats */

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

.stat-card {
    background: var(--gray-light);
    border-radius: var(--radius);
    padding: 1.2rem;
    text-align: center;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--blue);
}

.stat-card .stat-label {
    font-size: 0.85rem;
    color: var(--gray);
    margin-top: 0.2rem;
}

/* Brand Ambassador identity */

.ba-identity-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--blue-light);
    border: 1px solid rgba(30, 144, 255, 0.25);
    border-radius: var(--radius);
    padding: 1rem 1.2rem;
    margin-bottom: 1.5rem;
}

.ba-identity-logo-wrap {
    flex: 0 0 auto;
    width: 82px;
    height: 82px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--white);
    border: 1px solid var(--gray-border);
    border-radius: var(--radius);
    padding: 0.5rem;
}

.ba-identity-logo {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    display: block;
}

.ba-identity-details {
    min-width: 0;
}

.ba-identity-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--blue-dark);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.15rem;
}

.ba-identity-name {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--black);
    line-height: 1.25;
}

.ba-identity-address {
    color: var(--gray);
    font-size: 0.95rem;
    margin-top: 0.2rem;
}

.ba-identity-address-label {
    font-weight: 700;
    color: var(--black);
}

/* Voucher preview */

.voucher-preview {
    max-width: 500px;
    margin: 0 auto 2rem;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.voucher-preview img {
    width: 100%;
    height: auto;
    display: block;
}

/* Modal */

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

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--white);
    border-radius: var(--radius);
    padding: 2rem;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.modal-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
}

.logo-preview {
    padding: 0.8rem;
    border: 1px solid var(--gray-border);
    border-radius: var(--radius);
    background: #fafbfd;
}

.logo-preview-label {
    font-size: 0.8rem;
    color: var(--gray);
    margin-bottom: 0.5rem;
}

.logo-preview-image {
    max-height: 90px;
    width: auto;
    display: block;
}

.dropzone {
    display: block;
    border: 2px dashed var(--gray-border);
    border-radius: var(--radius);
    padding: 1rem;
    background: #fbfcff;
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
}

.dropzone:hover {
    border-color: var(--blue);
    background: var(--blue-light);
}

.dropzone.is-dragover {
    border-color: var(--blue);
    background: var(--blue-light);
    box-shadow: 0 0 0 3px rgba(30, 144, 255, 0.2);
}

.dropzone-title {
    display: block;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.dropzone-subtitle {
    display: block;
    font-size: 0.85rem;
    color: var(--gray);
    margin-bottom: 0.6rem;
}

.dropzone input[type="file"] {
    width: 100%;
}

.dropzone-selected-file {
    display: block;
    margin-top: 0.6rem;
    font-size: 0.85rem;
    color: var(--blue-dark);
}

/* Footer */

.site-footer {
    border-top: 2px solid var(--gray-border);
    padding: 1.2rem 2rem;
    text-align: center;
    font-size: 0.85rem;
    color: var(--gray);
    margin-top: auto;
}

/* Responsive */

@media (max-width: 768px) {
    html {
        font-size: 16px;
    }

    .site-header {
        padding: 0.8rem 1rem;
    }

    main {
        padding: 1rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .welcome-hero {
        padding: 2rem 0.5rem;
    }

    .welcome-hero .discount-badge {
        font-size: 3rem;
    }

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

    table {
        font-size: 0.85rem;
    }

    thead th, tbody td {
        padding: 0.5rem 0.6rem;
    }

    .btn-group {
        flex-direction: column;
    }

    .btn-group .btn {
        width: 100%;
    }

    .ba-identity-card {
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .stats-row {
        grid-template-columns: 1fr;
    }

    .page-title {
        font-size: 1.5rem;
    }

    .ba-identity-card {
        flex-direction: column;
    }

    .ba-identity-logo-wrap {
        width: 100%;
        height: 96px;
        align-items: center;
    }
}

/* Utility */

.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.text-muted { color: var(--gray); }
.text-small { font-size: 0.85rem; }
.code-display {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.95rem;
    letter-spacing: 1px;
}
