:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --accent: #0ea5e9;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --bg: #f0f4f8;
    --surface: #ffffff;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 4px 24px rgba(15, 23, 42, 0.08);
    --radius: 14px;
    --header-height: 72px;
    --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

img {
    max-width: 100%;
    display: block;
}

a {
    color: inherit;
    text-decoration: none;
}

/* Header */
.site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 50%, #0ea5e9 100%);
    color: #fff;
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.35);
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.25rem;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.brand-logo {
    height: 46px;
    width: auto;
    object-fit: contain;
    flex-shrink: 0;
    background: #fff;
    border-radius: 10px;
    padding: 0.2rem 0.35rem;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.12);
}

.brand-logo-auth {
    height: 96px;
    padding: 0.35rem 0.5rem;
    margin: 0 auto;
}

.auth-brand-logo {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.75rem;
}

.brand-icon {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 1.1rem;
    backdrop-filter: blur(8px);
}

.brand-text h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.brand-text span {
    font-size: 0.78rem;
    opacity: 0.85;
}

.menu-toggle {
    display: none;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1.4rem;
}

.main-nav ul {
    list-style: none;
    display: flex;
    gap: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.1rem;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.95rem;
    transition: background 0.2s, transform 0.2s;
    cursor: pointer;
    border: none;
    background: transparent;
    color: #fff;
}

.nav-link:hover,
.nav-link.active {
    background: rgba(255, 255, 255, 0.2);
}

.nav-link.active {
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35);
}

/* Main layout */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem 3rem;
}

.page-section {
    display: none;
    animation: fadeIn 0.35s ease;
}

.page-section.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.section-header {
    margin-bottom: 1.5rem;
}

.section-header h2 {
    font-size: clamp(1.4rem, 3vw, 1.85rem);
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.35rem;
}

.section-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* Cards */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
}

.card-header {
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    background: linear-gradient(to right, #f8fafc, #fff);
}

.card-header h3 {
    font-size: 1.05rem;
    font-weight: 700;
}

.card-body {
    padding: 1.25rem;
}

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
}

.form-group label .required {
    color: var(--danger);
}

.form-hint {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.form-control {
    width: 100%;
    padding: 0.7rem 0.85rem;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 0.92rem;
    font-family: inherit;
    color: var(--text);
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-control:disabled {
    background: #f1f5f9;
    color: var(--text-muted);
}

textarea.form-control {
    min-height: 90px;
    resize: vertical;
}

.form-actions {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.7rem 1.25rem;
    border: none;
    border-radius: 10px;
    font-size: 0.92rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
}

.btn-secondary {
    background: #f1f5f9;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: #e2e8f0;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-sm {
    padding: 0.45rem 0.75rem;
    font-size: 0.82rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 8px;
}

/* Search bar */
.search-bar {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.search-bar .form-control {
    flex: 1;
    min-width: 200px;
}

/* Table */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 10px;
    border: 1px solid var(--border);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    min-width: 900px;
}

.data-table th,
.data-table td {
    padding: 0.85rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table th {
    background: #f8fafc;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
}

.data-table tbody tr:hover {
    background: #f8fafc;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table td.text-cell {
    max-width: 280px;
    white-space: pre-wrap;
    word-break: break-word;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
}

.badge-rent {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge-sale {
    background: #dcfce7;
    color: #15803d;
}

.badge-apartment {
    background: #fef3c7;
    color: #b45309;
}

.badge-plot {
    background: #ede9fe;
    color: #6d28d9;
}

.badge-poster {
    background: #fce7f3;
    color: #be185d;
}

.badge-template {
    background: #e0f2fe;
    color: #0369a1;
}

.badge-assigned {
    background: #ecfdf5;
    color: #047857;
}

.badge-pending {
    background: #fef3c7;
    color: #b45309;
}

.badge-done {
    background: #dcfce7;
    color: #15803d;
}

.response-text {
    color: var(--text);
    font-weight: 500;
}

.client-response-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
    font-size: 0.88rem;
    color: var(--text-muted);
}

.client-response-meta strong {
    color: var(--text);
}

.client-response-card .card-header {
    align-items: flex-start;
}

.user-panel {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-info {
    text-align: right;
    line-height: 1.3;
}

.user-info strong {
    display: block;
    font-size: 0.9rem;
}

.user-info span {
    font-size: 0.75rem;
    opacity: 0.85;
}

/* Auth page */
.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #eff6ff 0%, #f0f4f8 50%, #e0f2fe 100%);
    padding: 1.25rem;
}

.auth-wrapper {
    width: 100%;
    max-width: 460px;
}

.auth-card {
    background: #fff;
    border-radius: 18px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    padding: 1.5rem;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-bottom: 1.25rem;
}

.auth-brand h1 {
    font-size: 1.35rem;
    margin-bottom: 0.15rem;
}

.auth-brand p {
    color: var(--text-muted);
    font-size: 0.88rem;
}

.auth-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    background: #f8fafc;
    padding: 0.35rem;
    border-radius: 12px;
}

.auth-tab {
    border: none;
    background: transparent;
    padding: 0.7rem 1rem;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
    color: var(--text-muted);
}

.auth-tab.active {
    background: #fff;
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.12);
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.auth-form .form-group {
    margin-bottom: 0.85rem;
}

.auth-submit {
    width: 100%;
    margin-top: 0.5rem;
}

.auth-note {
    margin-top: 1rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.5;
}

.setup-success {
    text-align: center;
}

.setup-success h3 {
    margin-bottom: 0.5rem;
}

.client-id-box {
    display: inline-block;
    margin: 1rem 0;
    padding: 0.85rem 1.25rem;
    border-radius: 12px;
    background: linear-gradient(135deg, #dbeafe, #eff6ff);
    border: 2px dashed #2563eb;
    color: #1d4ed8;
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.client-id-text {
    color: #1d4ed8;
}

.highlight-stat {
    border: 2px solid #2563eb;
    background: linear-gradient(135deg, #eff6ff, #fff);
}

.highlight-stat .stat-value {
    color: #1d4ed8;
}

.auth-page-client {
    background: linear-gradient(135deg, #ecfdf5 0%, #f0f4f8 50%, #d1fae5 100%);
}

.client-icon {
    background: rgba(16, 185, 129, 0.2) !important;
}

.client-header {
    background: linear-gradient(135deg, #065f46 0%, #059669 50%, #10b981 100%) !important;
}

.client-btn {
    background: linear-gradient(135deg, #059669, #10b981) !important;
    box-shadow: 0 4px 14px rgba(5, 150, 105, 0.35) !important;
}

.incentive-stat-card {
    grid-column: span 1;
}

.incentive-input-wrap {
    display: flex;
    gap: 0.5rem;
    margin: 0.65rem 0;
}

.incentive-input-wrap .form-control {
    flex: 1;
    min-width: 0;
}

.incentive-preview {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.incentive-preview strong {
    color: #059669;
}

.incentive-display-card .stat-value {
    color: #059669;
}

.action-buttons {
    display: flex;
    gap: 0.4rem;
    flex-wrap: nowrap;
}

.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 0.75rem;
    opacity: 0.5;
}

/* Mobile cards (alternative to table on small screens) */
.mobile-cards {
    display: none;
}

.mobile-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 0.85rem;
}

.mobile-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
    gap: 0.5rem;
}

.mobile-card-title {
    font-weight: 700;
    font-size: 1rem;
}

.mobile-card-row {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.35rem 0;
    border-bottom: 1px dashed #f1f5f9;
    font-size: 0.85rem;
}

.mobile-card-row:last-child {
    border-bottom: none;
}

.mobile-card-label {
    color: var(--text-muted);
    font-weight: 600;
    flex-shrink: 0;
}

.mobile-card-value {
    text-align: right;
    word-break: break-word;
}

.mobile-card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.85rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--border);
}

/* Media preview */
.media-preview {
    width: 60px;
    height: 45px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.media-link {
    color: var(--primary);
    font-weight: 600;
    word-break: break-all;
}

.media-link:hover {
    text-decoration: underline;
}

/* Toast notification */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 0.85rem 1.25rem;
    border-radius: 10px;
    color: #fff;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    animation: slideIn 0.3s ease;
    max-width: 360px;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--primary); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Stats row */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-top: 0.2rem;
}

.revenue-stat-card .stat-value {
    color: var(--success, #059669);
}

.revenue-note {
    font-size: 0.88rem;
    color: var(--text-muted);
    margin: 0 0 1rem;
}

.revenue-card .data-table td:last-child,
.revenue-card .data-table th:last-child {
    text-align: right;
}

.submissions-list-title,
.client-section-title {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0 0 0.75rem;
    color: var(--text);
}

.client-section-title {
    margin-top: 1.25rem;
}

.submission-item {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 0.75rem;
    background: var(--surface-alt, #f8fafc);
}

.submission-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.submission-item-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.submission-field {
    margin-bottom: 0.65rem;
}

.submission-field:last-child {
    margin-bottom: 0;
}

.submission-field-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.25rem;
}

.submission-field-value {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.92rem;
}

.media-count-stat .stat-value {
    color: #7c3aed;
}

.media-stats-card .data-table td:not(:first-child),
.media-stats-card .data-table th:not(:first-child) {
    text-align: center;
}

.media-stats-card .data-table td:last-child,
.media-stats-card .data-table th:last-child {
    text-align: right;
}

.daily-assign-stat .stat-value {
    color: #2563eb;
}

.daily-assign-card {
    border-color: #bfdbfe;
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.08);
}

.daily-assign-card .card-header {
    background: linear-gradient(135deg, #eff6ff 0%, #ffffff 100%);
}

/* Footer */
.site-footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
    background: #fff;
}

/* Responsive */
@media (max-width: 768px) {
    .menu-toggle {
        display: grid;
        place-items: center;
    }

    .main-nav {
        position: absolute;
        top: var(--header-height);
        left: 0;
        right: 0;
        background: linear-gradient(135deg, #1e3a8a, #2563eb);
        padding: 0.75rem 1rem 1rem;
        transform: translateY(-120%);
        opacity: 0;
        pointer-events: none;
        transition: transform 0.3s, opacity 0.3s;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    }

    .main-nav.open {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
    }

    .main-nav ul {
        flex-direction: column;
    }

    .nav-link {
        width: 100%;
        padding: 0.85rem 1rem;
    }

    .user-info span {
        display: none;
    }

    .user-panel .btn {
        padding: 0.45rem 0.65rem;
        font-size: 0.78rem;
    }

    .table-wrapper {
        display: none;
    }

    .mobile-cards {
        display: block;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .header-inner {
        position: relative;
    }

    .toast-container {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
    }

    .toast {
        max-width: 100%;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .form-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 1rem 0.85rem 2.5rem;
    }

    .card-body {
        padding: 1rem;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
    }
}
