/* ===== CSS Variables ===== */
:root {
    --red: #CC0000;
    --red-dark: #a30000;
    --red-light: #ff2222;
    --red-bg: rgba(204,0,0,0.08);
    --bg: #f5f5f7;
    --surface: #ffffff;
    --surface2: #f8f8fa;
    --border: #e2e2e8;
    --border-light: #eeeeF2;
    --text: #1a1a2e;
    --text-2: #4a4a6a;
    --text-3: #8888aa;
    --green: #00a651;
    --green-bg: rgba(0,166,81,0.1);
    --blue: #0066cc;
    --blue-bg: rgba(0,102,204,0.1);
    --orange: #e67e00;
    --orange-bg: rgba(230,126,0,0.1);
    --shadow-sm: 0 1px 4px rgba(0,0,0,0.06);
    --shadow: 0 4px 20px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.12);
    --radius: 14px;
    --radius-sm: 8px;
    --font: 'Outfit', sans-serif;
    --font-mono: 'Outfit', sans-serif; /*'JetBrains Mono', monospace;*/
    --nav-h: 64px;
    --transition: 0.2s ease;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ===== NAVBAR ===== */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--nav-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    z-index: 1000;
    box-shadow: var(--shadow-sm);
}

.navbar-inner {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 20px;
    gap: 16px;
    max-width: 1600px;
    margin: 0 auto;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.brand-logo {
    display: flex;
    align-items: center;
}

.logo-img{
    height: 32px;
}

.login-logo2{
    width: 75%;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.brand-main {
    font-size: 16px;
    font-weight: 700;
    color: var(--red);
    letter-spacing: -0.3px;
}

.brand-sub {
    font-size: 10px;
    font-weight: 500;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.navbar-center {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    justify-content: center;
}

.btn-nav-date {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-2);
    cursor: pointer;
    transition: var(--transition);
}

    .btn-nav-date:hover {
        background: var(--red-bg);
        border-color: var(--red);
        color: var(--red);
    }

.date-display {
    position: relative;
}

.date-input-nav {
    padding: 6px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    background: var(--surface);
    cursor: pointer;
    outline: none;
    transition: var(--transition);
}

    .date-input-nav:focus {
        border-color: var(--red);
        box-shadow: 0 0 0 3px var(--red-bg);
    }

.btn-today {
    padding: 6px 14px;
    background: var(--red);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

    .btn-today:hover {
        background: var(--red-dark);
    }

    .btn-today:disabled {
        background: var(--border);
        color: var(--text-3);
        cursor: default;
    }

.navbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: var(--red);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
}

.user-details {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.user-role {
    font-size: 11px;
    color: var(--text-3);
}

.logout-form {
    display: inline;
}

.btn-logout {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: transparent;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-2);
    cursor: pointer;
    transition: var(--transition);
}

    .btn-logout:hover {
        border-color: var(--red);
        color: var(--red);
        background: var(--red-bg);
    }

/* ===== MAIN CONTENT ===== */
.main-content {
    padding-top: var(--nav-h);
    min-height: 100vh;
}

/* ===== LOGIN PAGE ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a0000 0%, #2d0000 50%, #1a0000 100%);
    position: relative;
    overflow: hidden;
    padding: 24px;
}

.login-class-body {
    background: black;
}

.login-bg {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.login-bg-shape {
    position: absolute;
    border-radius: 50%;
    opacity: 0.08;
    background: var(--red);
}

    .login-bg-shape.s1 {
        width: 600px;
        height: 600px;
        top: -200px;
        right: -150px;
    }

    .login-bg-shape.s2 {
        width: 400px;
        height: 400px;
        bottom: -100px;
        left: -100px;
        opacity: 0.05;
    }

    .login-bg-shape.s3 {
        width: 200px;
        height: 200px;
        top: 50%;
        left: 50%;
        transform: translate(-50%,-50%);
        opacity: 0.04;
    }

.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    width: 100%;
    max-width: 420px;
    position: relative;
    z-index: 1;
}

.login-card {
    background: var(--surface);
    border-radius: 20px;
    padding: 40px 36px;
    width: 100%;
    box-shadow: 0 24px 80px rgba(0,0,0,0.4);
    animation: slideUp 0.5s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-header {
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin-bottom: 32px;
}

.login-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

.login-title {
    font-size: 26px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.5px;
}

.login-subtitle {
    font-size: 14px;
    color: var(--text-3);
    margin-top: 4px;
}

.alert-error {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff0f0;
    border: 1px solid #ffcccc;
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 13px;
    color: var(--red-dark);
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 18px;
}

.form-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 6px;
}

.input-wrapper {
    position: relative;
}

.form-input {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 14px;
    color: var(--text);
    background: var(--surface);
    outline: none;
    transition: var(--transition);
}

    .form-input:focus {
        border-color: var(--red);
        box-shadow: 0 0 0 3px var(--red-bg);
    }

.field-error {
    font-size: 12px;
    color: var(--red);
    margin-top: 4px;
    display: block;
}

.toggle-password {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-3);
    padding: 4px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 24px;
}

.check-input {
    width: 16px;
    height: 16px;
    accent-color: var(--red);
    cursor: pointer;
}

.check-label {
    font-size: 13px;
    color: var(--text-2);
    cursor: pointer;
}

.btn-login {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 24px;
    background: var(--red);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    letter-spacing: 0.2px;
}

    .btn-login:hover {
        background: var(--red-dark);
        transform: translateY(-1px);
        box-shadow: 0 4px 20px rgba(204,0,0,0.3);
    }

    .btn-login:active {
        transform: translateY(0);
    }

.login-demo-creds {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
}

.demo-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-3);
    margin-bottom: 10px;
    font-weight: 600;
}

.demo-accounts {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.demo-account {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--surface2);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text-2);
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-mono);
}

    .demo-account:hover {
        border-color: var(--red);
        background: var(--red-bg);
    }

.demo-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
    font-family: var(--font);
}

    .demo-badge.admin {
        background: var(--red-bg);
        color: var(--red);
    }

    .demo-badge.viewer {
        background: var(--blue-bg);
        color: var(--blue);
    }

.login-info {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    animation: slideUp 0.5s ease both;
}

    .info-item:nth-child(2) {
        animation-delay: 0.1s;
    }

    .info-item:nth-child(3) {
        animation-delay: 0.2s;
    }

.info-icon {
    font-size: 20px;
}

.info-item strong {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: white;
}

.info-item span {
    font-size: 12px;
    color: rgba(255,255,255,0.5);
}

/* ===== DASHBOARD ===== */
.dashboard {
    padding: 24px;
    max-width: 1600px;
    margin: 0 auto;
}

.kpi-section {
    margin-bottom: 24px;
}

.kpi-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 16px;
    flex-wrap: wrap;
}

.page-title {
    font-size: 24px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.5px;
}

.page-subtitle {
    font-size: 14px;
    color: var(--text-3);
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.live-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--red-bg);
    border: 1px solid rgba(204,0,0,0.2);
    color: var(--red);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    padding: 3px 8px;
    border-radius: 20px;
}

.live-dot {
    width: 6px;
    height: 6px;
    background: var(--red);
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

.region-filter {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 6px 14px;
    border: 1.5px solid var(--border);
    border-radius: 20px;
    background: var(--surface);
    font-family: var(--font);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-2);
    cursor: pointer;
    transition: var(--transition);
}

    .filter-btn:hover {
        border-color: var(--red);
        color: var(--red);
    }

    .filter-btn.active {
        background: var(--red);
        border-color: var(--red);
        color: white;
    }

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    animation: slideUp 0.4s ease both;
}

    .kpi-card:nth-child(2) {
        animation-delay: 0.05s;
    }

    .kpi-card:nth-child(3) {
        animation-delay: 0.1s;
    }

    .kpi-card:nth-child(4) {
        animation-delay: 0.15s;
    }

    .kpi-card:hover {
        box-shadow: var(--shadow);
        transform: translateY(-2px);
    }

    .kpi-card.primary {
        border-left: 3px solid var(--red);
    }

.kpi-icon {
    width: 44px;
    height: 44px;
    background: var(--red-bg);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--red);
    flex-shrink: 0;
}

    .kpi-icon.green {
        background: var(--green-bg);
        color: var(--green);
    }

    .kpi-icon.blue {
        background: var(--blue-bg);
        color: var(--blue);
    }

    .kpi-icon.orange {
        background: var(--orange-bg);
        color: var(--orange);
    }

.kpi-content {
    flex: 1;
    min-width: 0;
}

.kpi-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.kpi-value {
    display: block;
    font-size: 22px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.5px;
    margin-bottom: 6px;
    line-height: 1;
}

.kpi-change {
    font-size: 12px;
    font-weight: 600;
}

    .kpi-change.positive {
        color: var(--green);
    }

    .kpi-change.negative {
        color: var(--red);
    }

.kpi-sub {
    font-size: 12px;
    color: var(--text-3);
}

.mini-progress {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.mini-progress-bar {
    height: 100%;
    background: var(--green);
    border-radius: 2px;
    transition: width 0.8s ease;
}

/* ===== HIGHLIGHT STRIP ===== */
.highlight-strip {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.highlight-item {
    flex: 1;
    min-width: 200px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    background: var(--surface);
}

    .highlight-item.best {
        border-left: 3px solid var(--green);
    }

    .highlight-item.worst {
        border-left: 3px solid var(--orange);
    }

    .highlight-item.neutral {
        border-left: 3px solid var(--blue);
    }

.hl-emoji {
    font-size: 24px;
}

.hl-label {
    display: block;
    font-size: 11px;
    color: var(--text-3);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.hl-name {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.hl-value {
    margin-left: auto;
    font-size: 15px;
    font-weight: 800;
    color: var(--text);
    font-family: var(--font-mono);
    white-space: nowrap;
}

/* ===== CONTENT GRID ===== */
.content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

/* ===== CARDS ===== */
.card {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-light);
    gap: 12px;
    flex-wrap: wrap;
}

    .card-header h3 {
        font-size: 15px;
        font-weight: 700;
        color: var(--text);
    }

.chart-legend {
    display: flex;
    gap: 12px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--text-3);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
}

    .legend-dot.red {
        background: var(--red);
    }

    .legend-dot.gray {
        background: var(--border);
    }

.chart-container {
    padding: 16px;
    height: 280px;
}

    .chart-container canvas {
        max-height: 100%;
    }

.store-selector {
    padding: 6px 10px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 12px;
    color: var(--text);
    background: var(--surface);
    cursor: pointer;
    outline: none;
    max-width: 200px;
}

    .store-selector:focus {
        border-color: var(--red);
    }

/* ===== TABLE ===== */
.table-card {
    margin-bottom: 24px;
}

.table-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.search-input {
    padding: 7px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 13px;
    color: var(--text);
    background: var(--surface);
    outline: none;
    width: 220px;
    transition: var(--transition);
}

    .search-input:focus {
        border-color: var(--red);
        width: 260px;
    }

.btn-export {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: var(--surface2);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-2);
    cursor: pointer;
    transition: var(--transition);
}

    .btn-export:hover {
        border-color: var(--green);
        color: var(--green);
    }

.table-wrapper {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

    .data-table th {
        padding: 11px 14px;
        text-align: left;
        font-weight: 700;
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        color: var(--text-3);
        border-bottom: 1px solid var(--border);
        white-space: nowrap;
        background: var(--surface2);
    }

        .data-table th.sortable {
            cursor: pointer;
            user-select: none;
        }

            .data-table th.sortable:hover {
                color: var(--red);
            }

    .data-table td {
        padding: 12px 14px;
        border-bottom: 1px solid var(--border-light);
        color: var(--text);
        vertical-align: middle;
    }

    .data-table tbody tr:hover td {
        background: var(--red-bg);
    }

    .data-table tbody tr {
        transition: background var(--transition);
    }

.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    background: var(--surface2);
    color: var(--text-3);
}

    .rank-badge.top {
        background: #fff3cd;
        color: #856404;
    }

.store-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.store-code {
    font-size: 10px;
    color: var(--text-3);
    font-family: var(--font-mono);
}

.store-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.region-tag {
    display: inline-block;
    padding: 3px 8px;
    background: var(--blue-bg);
    color: var(--blue);
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.num-cell {
    text-align: right;
    font-family: var(--font-mono);
    font-size: 12px;
}

    .num-cell.muted {
        color: var(--text-3);
    }

.achieve-cell {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 120px;
}

.achieve-bar-wrap {
    flex: 1;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.achieve-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s ease;
}

    .achieve-bar.achieve-great {
        background: var(--green);
    }

    .achieve-bar.achieve-ok {
        background: var(--orange);
    }

    .achieve-bar.achieve-low {
        background: var(--red);
    }

.achieve-pct {
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

    .achieve-pct.achieve-great {
        color: var(--green);
    }

    .achieve-pct.achieve-ok {
        color: var(--orange);
    }

    .achieve-pct.achieve-low {
        color: var(--red);
    }

.table-total td {
    background: var(--surface2);
    font-size: 12px;
    border-top: 2px solid var(--border);
    border-bottom: none;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .content-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .navbar-center {
        /*display: none;*/
    }

    .dashboard {
        padding: 16px;
    }

    .user-details {
        display: none;
    }

    .btn-logout span {
        display: none;
    }

    .kpi-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .kpi-value {
        font-size: 18px;
    }

    .highlight-strip {
        flex-direction: column;
    }

    .kpi-header {
        flex-direction: column;
    }
}

@media (max-width: 600px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .login-card {
        padding: 28px 20px;
    }

    .search-input {
        width: 100%;
    }

    .region-filter {
        display: none;
    }

    .navbar-inner {
        padding: 0 12px;
    }
}

/* ===== Mobile date nav ===== */
.mobile-date-bar {
    display: none;
    align-items: center;
    gap: 8px;
    justify-content: center;
    padding: 10px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

@media (max-width: 900px) {
    .mobile-date-bar {
        display: flex;
    }
}
