:root {
    --brand-primary: #0072CE;
    --brand-dark: #004E8C;
    --brand-light: #c4e2f5;
    --brand-accent: #00A3E0;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --radius-sm: 8px;
    --radius-md: 12px;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: #f7f9fc;
}

.container.mt-4 {
    flex: 1;
    max-width: 1400px;
}

/* Headings with accent bar */
h4 {
    border-left: 3px solid var(--brand-primary);
    padding-left: 0.75rem;
}

/* Tables */
.table th {
    white-space: nowrap;
}

.table {
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.btn-group .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

/* Validation */
.input-validation-error {
    border-color: #dc3545 !important;
}

.field-validation-error {
    color: #dc3545;
    font-size: 0.8rem;
}

/* Navbar */
.navbar-brand img {
    height: 32px;
    margin-right: 6px;
    filter: brightness(0) invert(1);
}

.navbar {
    background-color: var(--brand-dark) !important;
    min-height: 56px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
}

/* Cards */
.card {
    border: 1px solid #e0e4e8;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    background-color: #fff;
    transition: box-shadow 0.2s ease;
}

@media (hover: hover) {
    .card:hover {
        box-shadow: var(--shadow-md);
    }
}

.card-header {
    border-radius: var(--radius-md) var(--radius-md) 0 0 !important;
}

/* Buttons */
.btn {
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
}

.btn-brand {
    background-color: var(--brand-primary);
    border-color: var(--brand-primary);
    color: #fff;
}

.btn-brand:hover {
    background-color: var(--brand-dark);
    border-color: var(--brand-dark);
    color: #fff;
}

.btn-outline-brand {
    color: var(--brand-primary);
    border-color: var(--brand-primary);
}

.btn-outline-brand:hover {
    background-color: var(--brand-primary);
    border-color: var(--brand-primary);
    color: #fff;
}

/* Form inputs */
.form-control, .form-select {
    border-radius: var(--radius-sm);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus, .form-select:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(0, 114, 206, 0.15);
}

/* Badges */
.badge {
    border-radius: 50rem;
    padding: 0.35em 0.75em;
}

/* Alerts */
.alert {
    border-radius: var(--radius-md);
    border: none;
    box-shadow: var(--shadow-sm);
}

/* Table brand header */
.table-brand {
    --bs-table-bg: var(--brand-dark);
    --bs-table-color: #fff;
}

.table-brand th i.bi {
    opacity: 0.5 !important;
}

.table-brand th i.bi.bi-sort-down,
.table-brand th i.bi.bi-sort-up {
    opacity: 1 !important;
}

.card-header.bg-brand {
    background-color: var(--brand-dark) !important;
    color: #fff;
}

.badge.bg-brand {
    background-color: var(--brand-primary) !important;
}

.login-card .card-header {
    background-color: var(--brand-dark);
    color: #fff;
}

.login-card {
    box-shadow: var(--shadow-lg);
}

.text-brand {
    color: var(--brand-primary) !important;
}

/* Tabs */
.nav-tabs {
    border-bottom: 2px solid #dee2e6;
}

.nav-tabs .nav-link {
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    transition: all 0.15s ease;
}

.nav-tabs .nav-link.active {
    border-color: #dee2e6 #dee2e6 #fff;
    font-weight: 600;
}

/* Dropdown menus */
.dropdown-menu {
    border: none;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 0.5rem;
}

.dropdown-item {
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.75rem;
    transition: background-color 0.1s ease;
}

/* Footer */
footer {
    border-top: 1px solid #e0e4e8;
    padding: 0.5rem 0;
}

/* Analysis Sensor Chips */
.sensor-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.6rem;
    border-radius: 50rem;
    border: 2px solid #dee2e6;
    background: #fff;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
    font-size: 0.8rem;
    width: calc(50% - 0.5rem);
    box-sizing: border-box;
}

@media (min-width: 576px) {
    .sensor-chip {
        width: calc(33.333% - 0.5rem);
    }
}

@media (min-width: 768px) {
    .sensor-chip {
        width: calc(25% - 0.5rem);
    }
}

@media (min-width: 992px) {
    .sensor-chip {
        width: calc(20% - 0.5rem);
    }
}

.sensor-chip:hover {
    box-shadow: var(--shadow-sm);
}

.sensor-chip .chip-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 2px solid #adb5bd;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.sensor-chip .chip-name {
    display: inline-block;
    max-width: 20ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
}

.sensor-chip .chip-serial {
    font-size: 0.7rem;
    opacity: 0.6;
    line-height: 1;
    margin-top: -1px;
}

.sensor-chip.selected {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
    color: #fff;
}

.sensor-chip.selected .chip-dot {
    background: #fff;
    border-color: #fff;
}

.sensor-chip.selected .chip-serial {
    opacity: 0.8;
}

.sensor-chip.inactive {
    opacity: 0.5;
}

.sensor-chip.inactive .chip-tag {
    font-size: 0.6rem;
    background: rgba(0,0,0,0.1);
    padding: 0.05rem 0.35rem;
    border-radius: 50rem;
}

.sensor-chip.selected.inactive .chip-tag {
    background: rgba(255,255,255,0.2);
}

/* Chart filter chips (auto-width, not fixed like sensor chips) */
#chartFilterChips .sensor-chip {
    width: auto;
}

/* Dashboard Sensor/Gateway Tile Grid */
.sensor-tile-col {
    width: 100%;
    flex: 0 0 100%;
}

@media (min-width: 576px) {
    .sensor-tile-col {
        width: 50%;
        flex: 0 0 50%;
    }
}

@media (min-width: 768px) {
    .sensor-tile-col {
        width: 33.333%;
        flex: 0 0 33.333%;
    }
}

@media (min-width: 992px) {
    .sensor-tile-col {
        width: 20%;
        flex: 0 0 20%;
    }
}

/* Dashboard Sensor Tiles */
.sensor-tile {
    background-color: var(--brand-light);
    border: none;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: background-color 0.5s ease, box-shadow 0.2s ease, transform 0.15s ease;
    cursor: default;
}

@media (hover: hover) {
    .sensor-tile:hover {
        box-shadow: var(--shadow-md);
        transform: translateY(-2px);
    }
}

.sensor-value {
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1.2;
}

/* Responsive tables: min-width forces scroll in Bootstrap table-responsive */
.table-responsive > table {
    min-width: 600px;
}

/* Smartphone adjustments */
@media (max-width: 575px) {
    .container.mt-4 {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    h4 {
        font-size: 1.15rem;
    }

    .sensor-value {
        font-size: 1.4rem;
    }

    /* Show exactly 2 values side-by-side on mobile to save height */
    .sensor-values-2 {
        flex-direction: row !important;
        gap: 1.5rem;
        justify-content: center !important;
    }
}
