:root {
    --smd-bg: #f4f5fb;
    --smd-card-bg: #ffffff;
    --smd-border: #e2e8f0;
    --smd-radius: 0.75rem;
    --smd-shadow: 0 10px 30px rgba(15, 23, 42, 0.14);
    --smd-primary: #3695ac;
    --smd-primary-soft: rgba(54, 149, 172, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Kanit', sans-serif;
    background-color: var(--smd-bg);
    margin: 0;
    padding: 0;
    color: #1f2933;
}

.dashboard-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.smd-topbar {
    background: #ffffff;
    border-bottom: 1px solid var(--smd-border);
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
}

.smd-topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.smd-logo {
    height: 40px;
}

.smd-title-main {
    font-size: 1.2rem;
    font-weight: 500;
    line-height: 1.2;
}

.smd-title-sub {
    font-size: 0.85rem;
    color: #6b7280;
}

.smd-topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
}

.env-badge {
    background-color: #f97316;
    color: #fff;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.7rem;
}

.dashboard-content {
    padding: 16px 20px 24px;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    flex: 1;
}

.smd-card {
    background-color: var(--smd-card-bg);
    border-radius: var(--smd-radius);
    border: 1px solid var(--smd-border);
    box-shadow: var(--smd-shadow);
    padding: 18px 18px 16px;
}

.smd-card-title {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 6px;
}

.smd-card-subtitle {
    font-size: 0.8rem;
    color: #6b7280;
}

.summary-value {
    font-size: 2rem;
    font-weight: 600;
}

.summary-label {
    font-size: 0.85rem;
    color: #6b7280;
}

.summary-badge-positive {
    font-size: 0.75rem;
    color: #16a34a;
    background-color: #dcfce7;
    border-radius: 999px;
    padding: 2px 8px;
}

.summary-badge-warning {
    font-size: 0.75rem;
    color: #b45309;
    background-color: #fef3c7;
    border-radius: 999px;
    padding: 2px 8px;
}

.filter-bar {
    margin-bottom: 16px;
}

.filter-bar .form-label {
    margin-bottom: 3px;
}

.filter-bar .form-control,
.filter-bar .form-select {
    font-size: 0.85rem;
}

.table-wrapper {
    margin-top: 16px;
}

.table thead th {
    font-size: 0.8rem;
    white-space: nowrap;
    background-color: #f9fafb;
    /* fixed header */
    position: sticky;
    top: 0;
    z-index: 5;
}

.table tbody td {
    font-size: 0.85rem;
    vertical-align: middle;
}

.score-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    min-width: 40px;
}

.score-low {
    background-color: #fee2e2;
    color: #b91c1c;
}

.score-mid {
    background-color: #fef9c3;
    color: #854d0e;
}

.score-high {
    background-color: #dcfce7;
    color: #15803d;
}

.ellipsis {
    max-width: 260px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.device-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    word-break: break-all;
}

.badge-channel {
    font-size: 0.75rem;
    border-radius: 999px;
    padding: 2px 8px;
}

.badge-channel-online {
    background-color: #dbeafe;
    color: #1d4ed8;
}

.badge-channel-walkin {
    background-color: #e0f2fe;
    color: #0369a1;
}

.badge-channel-unknown {
    background-color: #e5e7eb;
    color: #4b5563;
}

.service-badge {
    --service-color: #113b6d;
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 0.75rem;
    color: var(--service-color);
    background-color: color-mix(in srgb, var(--service-color) 12%, white);
    border: 1px solid color-mix(in srgb, var(--service-color) 32%, white);
}

.badge-date {
    font-size: 0.75rem;
    background-color: #eef2ff;
    color: #4f46e5;
    border-radius: 999px;
    padding: 2px 8px;
}

.card-section-title {
    font-size: 0.95rem;
    font-weight: 500;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-section-title small {
    font-size: 0.75rem;
    color: #6b7280;
}

.table-responsive {
    max-height: 420px;
    overflow-y: auto;
}

.search-input {
    font-size: 0.85rem;
}

/* Scrollbar เล็ก ๆ */
.table-responsive::-webkit-scrollbar {
    width: 6px;
}

.table-responsive::-webkit-scrollbar-thumb {
    background-color: rgba(148, 163, 184, 0.7);
    border-radius: 999px;
}

.table-responsive::-webkit-scrollbar-track {
    background-color: transparent;
}

@media (max-width: 767.98px) {
    .smd-topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .dashboard-content {
        padding: 12px 10px 20px;
    }

    .smd-card {
        padding: 14px 12px;
    }
}

.chart-box {
    position: relative;
    width: 100%;
    height: 260px;
    /* ปรับความสูงที่ต้องการได้ เช่น 220 / 240 / 300 */
    margin-top: 4px;
}

.chart-box canvas {
    width: 100% !important;
    height: 100% !important;
}

.circle-ripple {
    animation: ripple 1s linear infinite;
}

@keyframes ripple {
    0% {
        box-shadow: 0 0 0 0 rgba(17, 59, 109, 0.7),
            0 0 0 0.2em rgba(17, 59, 109, 0.7);
    }

    50% {
        box-shadow: 0 0 0 0.1em rgba(17, 59, 109, 0.7),
            0 0 0 0.5em rgba(17, 59, 109, 0.5);
    }

    100% {
        box-shadow: 0 0 0 0.2em rgba(17, 59, 109, 0.7),
            0 0 0 0.7em rgba(17, 59, 109, 0);
    }
}


.circle-btn {
    animation: ripple 1s linear infinite;
}

@keyframes ripple {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.7),
            0 0 0 0.2em rgba(0, 0, 0, 0.7);
    }

    50% {
        box-shadow: 0 0 0 0.1em rgba(0, 0, 0, 0.7),
            0 0 0 0.5em rgba(0, 0, 0, 0.5);
    }

    100% {
        box-shadow: 0 0 0 0.2em rgba(0, 0, 0, 0.7),
            0 0 0 0.7em rgba(0, 0, 0, 0);
    }
}
