/* ===== STATS TABLE OPERATOR GROUPING ===== */
.stats-table tr.op-divider td {
    border-top: 2px solid #e94560;
}

.stats-table td.op-name {
    color: #ffffff;
    white-space: nowrap;
}

/* ===== STATISTICS PAGE ===== */
.stats-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 24px;
    padding: 16px 20px;
    background: #16213e;
    border-radius: 10px;
    border: 1px solid #0f3460;
}

.view-tabs {
    display: flex;
    gap: 4px;
    background: #0f1e3a;
    border-radius: 8px;
    padding: 4px;
}

.tab {
    padding: 7px 16px;
    border-radius: 6px;
    font-size: 0.88rem;
    font-weight: 600;
    color: #7a8fa6;
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
}

.tab:hover { color: #e0e0e0; }
.tab.active { background: #e94560; color: #ffffff; }

.filter-form {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-form label {
    font-size: 0.82rem;
    color: #7a8fa6;
    white-space: nowrap;
}

.filter-select {
    padding: 6px 10px;
    font-size: 0.85rem;
    min-width: 130px;
}

.btn-export {
    background-color: #1a4731;
    color: #6fcf97;
    border: 1px solid #28a745;
    padding: 8px 16px;
    font-size: 0.85rem;
    margin-left: auto;
}

.btn-export:hover {
    background-color: #28a745;
    color: #ffffff;
}

.stats-table-wrap {
    overflow-x: auto;
    border-radius: 10px;
    border: 1px solid #0f3460;
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.stats-table thead tr {
    background: #0f3460;
}

.stats-table th {
    padding: 12px 14px;
    text-align: left;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #a0b4c8;
    white-space: nowrap;
}

.stats-table tbody tr {
    border-bottom: 1px solid #1a2a4a;
    transition: background 0.15s;
}

.stats-table tbody tr:hover {
    background: #1a2a4a;
}

.stats-table td {
    padding: 10px 14px;
    color: #e0e0e0;
}

.stats-table td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.stats-table td.wph-cell {
    color: #81c784;
}

.stats-table td.mono {
    font-family: 'Courier New', monospace;
    font-size: 0.82rem;
    color: #a0b4c8;
}

.stats-table td.small {
    font-size: 0.78rem;
}

.empty-stats {
    text-align: center;
    padding: 60px 20px;
    color: #5a6a7a;
}

.empty-stats p { margin-bottom: 10px; }
.empty-stats strong { color: #a0b4c8; }

/* ===== RANK BADGES ===== */
.rank-badge {
    display: inline-block;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 12px;
    margin-left: 6px;
    vertical-align: middle;
    background: #1a2a4a;
    color: #a0b4c8;
    border: 1px solid #2a3a5a;
}

.rank-badge.rank-1 { background: rgba(255,215,0,0.15); color: #ffd700; border-color: #ffd700; }
.rank-badge.rank-2 { background: rgba(192,192,192,0.15); color: #c0c0c0; border-color: #c0c0c0; }
.rank-badge.rank-3 { background: rgba(205,127,50,0.15); color: #cd7f32; border-color: #cd7f32; }
.rank-badge.rank-none { color: #4a5a6a; border-color: #2a3a5a; }

.rank-badge-lg {
    display: inline-block;
    font-size: 1rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 16px;
    margin-left: 10px;
    vertical-align: middle;
    background: #1a2a4a;
    color: #a0b4c8;
    border: 1px solid #2a3a5a;
}

.big-number.wph-big {
    font-size: 2.2rem;
    color: #81c784;
}

/* ===== TILE STATS (overview cards) ===== */
.tile-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    background: rgba(15, 52, 96, 0.3);
    border: 1px solid #1a3a5a;
    border-radius: 8px;
    padding: 8px 10px;
}

.tile-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
    align-items: center;
    text-align: center;
}

.tile-stat-label {
    font-size: 0.62rem;
    color: #7a8fa6;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.tile-stat-value {
    font-size: 0.95rem;
    font-weight: 700;
    color: #4fc3f7;
    font-variant-numeric: tabular-nums;
}

.tile-stat-value.small-val {
    font-size: 0.72rem;
    font-weight: 500;
    color: #a0b4c8;
    word-break: break-all;
}

.muted-sm {
    color: #4a5a6a;
    font-weight: 400;
}

/* ===== WELDER CARD LINK ===== */
.welder-link {
    color: #ffffff;
    text-decoration: none;
    transition: color 0.2s;
}

.welder-link:hover {
    color: #e94560;
}

/* ===== WELDER DETAIL PAGE ===== */
.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 28px;
}

.detail-header h2 {
    font-size: 1.8rem;
    color: #ffffff;
    margin-bottom: 4px;
}

.device-name {
    font-size: 0.85rem;
    color: #7a8fa6;
    font-style: italic;
}

.detail-actions {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
    align-items: flex-start;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.detail-card {
    background: #16213e;
    border-radius: 12px;
    padding: 24px;
    border: 2px solid #0f3460;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.detail-card.highlight-card {
    border-color: #e94560;
    background: linear-gradient(135deg, #1a1a3e 0%, #2a0f1e 100%);
}

.detail-card-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #7a8fa6;
    border-bottom: 1px solid #1a2a4a;
    padding-bottom: 10px;
}

.detail-stat {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.detail-stat.center {
    align-items: center;
    text-align: center;
}

.detail-label {
    font-size: 0.72rem;
    color: #7a8fa6;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-value {
    font-size: 1rem;
    color: #e0e0e0;
    font-weight: 500;
}

.detail-value.large {
    font-size: 1.15rem;
    font-weight: 700;
    color: #ffffff;
}

.detail-value.small {
    font-size: 0.85rem;
    color: #a0b4c8;
}

.detail-value.mono {
    font-family: 'Courier New', monospace;
    font-size: 0.88rem;
    color: #4fc3f7;
}

.big-number {
    font-size: 3.5rem;
    font-weight: 900;
    color: #e94560;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.big-number.secondary {
    font-size: 2.2rem;
    color: #4fc3f7;
}

.big-label {
    font-size: 0.78rem;
    color: #7a8fa6;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

.muted {
    color: #5a6a7a;
    font-style: italic;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.welder-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    padding-top: 20px;
    border-top: 1px solid #1a2a4a;
}

/* ===== RESET & BASE ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #1a1a2e;
    color: #e0e0e0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== HEADER ===== */
header {
    background: linear-gradient(135deg, #16213e 0%, #0f3460 100%);
    border-bottom: 3px solid #e94560;
    padding: 20px 30px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
}

header h1 {
    font-size: 2rem;
    color: #ffffff;
    letter-spacing: 1px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

header .subtitle {
    color: #a0b4c8;
    font-size: 0.95rem;
    margin-top: 4px;
}

/* ===== MAIN ===== */
main {
    flex: 1;
    padding: 30px 20px;
}

/* ===== CONTAINER ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* ===== PAGE HEADER ===== */
.page-header {
    margin-bottom: 30px;
}

.page-header h2 {
    font-size: 1.6rem;
    color: #e94560;
    margin-bottom: 6px;
}

.page-header p {
    color: #a0b4c8;
    font-size: 0.95rem;
}

.back-link {
    display: inline-block;
    color: #a0b4c8;
    text-decoration: none;
    margin-bottom: 12px;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.back-link:hover {
    color: #e94560;
}

/* ===== FLASH MESSAGES ===== */
.flash-messages {
    max-width: 1200px;
    margin: 0 auto 20px auto;
}

.alert {
    padding: 12px 18px;
    border-radius: 8px;
    margin-bottom: 10px;
    font-size: 0.95rem;
    font-weight: 500;
}

.alert-success {
    background-color: #1a4731;
    border-left: 4px solid #28a745;
    color: #6fcf97;
}

.alert-danger {
    background-color: #4a1a1a;
    border-left: 4px solid #e94560;
    color: #f28b82;
}

.alert-info {
    background-color: #1a3a4a;
    border-left: 4px solid #17a2b8;
    color: #7ecfdf;
}

/* ===== STATIONS GRID ===== */
.stations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}

/* ===== STATION CARD ===== */
.station-card {
    background: #16213e;
    border-radius: 12px;
    padding: 20px;
    border: 2px solid #0f3460;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.station-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.4);
}

.station-card.active {
    border-color: #e94560;
}

.station-card.empty {
    border-color: #2a3a5a;
    opacity: 0.85;
}

.station-number {
    font-size: 1.2rem;
    font-weight: 700;
    color: #ffffff;
    border-bottom: 1px solid #0f3460;
    padding-bottom: 10px;
}

.station-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.info-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.info-row .label {
    font-size: 0.72rem;
    color: #7a8fa6;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-row .value {
    font-size: 0.95rem;
    color: #e0e0e0;
    font-weight: 500;
}

.info-row .value.small {
    font-size: 0.78rem;
    color: #7a8fa6;
}

.info-row.updated {
    margin-top: 4px;
}

.station-empty-msg {
    color: #5a6a7a;
    font-style: italic;
    font-size: 0.9rem;
    flex: 1;
}

/* ===== STATION ACTIONS ===== */
.station-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: background-color 0.2s, transform 0.1s;
    text-align: center;
}

.btn:active {
    transform: scale(0.97);
}

.btn-assign {
    background-color: #0f3460;
    color: #ffffff;
    flex: 1;
}

.btn-assign:hover {
    background-color: #1a4a80;
}

.btn-edit {
    background-color: #e94560;
    color: #ffffff;
    flex: 1;
}

.btn-edit:hover {
    background-color: #c73652;
}

.btn-clear {
    background-color: #2a3a5a;
    color: #a0b4c8;
}

.btn-clear:hover {
    background-color: #3a4a6a;
    color: #ffffff;
}

.btn-primary {
    background-color: #e94560;
    color: #ffffff;
    padding: 12px 28px;
    font-size: 1rem;
}

.btn-primary:hover {
    background-color: #c73652;
}

.btn-secondary {
    background-color: #2a3a5a;
    color: #a0b4c8;
    padding: 12px 28px;
    font-size: 1rem;
}

.btn-secondary:hover {
    background-color: #3a4a6a;
    color: #ffffff;
}

/* ===== FORM CARD ===== */
.form-card {
    background: #16213e;
    border-radius: 12px;
    padding: 36px;
    border: 2px solid #0f3460;
    max-width: 520px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}

/* ===== FORM ELEMENTS ===== */
.form-group {
    margin-bottom: 22px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    color: #a0b4c8;
}

.required {
    color: #e94560;
}

.form-control {
    width: 100%;
    padding: 12px 14px;
    background-color: #0f1e3a;
    border: 2px solid #2a3a5a;
    border-radius: 8px;
    color: #e0e0e0;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

.form-control:focus {
    border-color: #e94560;
    box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.2);
}

.form-control option {
    background-color: #0f1e3a;
    color: #e0e0e0;
}

.last-updated {
    font-size: 0.8rem;
    color: #5a6a7a;
    margin-bottom: 20px;
}

.form-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 10px;
}

/* ===== OVERVIEW HEADER ===== */
.overview-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 12px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.btn-settings {
    background-color: #0f3460;
    color: #a0b4c8;
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn-settings:hover {
    background-color: #1a4a80;
    color: #ffffff;
}

.refresh-indicator {
    font-size: 0.8rem;
    color: #28a745;
    font-weight: 600;
    padding: 4px 10px;
    background: rgba(40, 167, 69, 0.1);
    border-radius: 20px;
    border: 1px solid rgba(40, 167, 69, 0.3);
}

.refresh-indicator.stale {
    color: #e94560;
    background: rgba(233, 69, 96, 0.1);
    border-color: rgba(233, 69, 96, 0.3);
}

/* ===== LIVE DOT ===== */
.live-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin-left: 6px;
    vertical-align: middle;
    flex-shrink: 0;
}

.live-dot.online {
    background-color: #28a745;
    box-shadow: 0 0 6px rgba(40, 167, 69, 0.7);
    animation: pulse-green 2s infinite;
}

.live-dot.offline {
    background-color: #e94560;
    box-shadow: 0 0 4px rgba(233, 69, 96, 0.5);
}

@keyframes pulse-green {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ===== LIVE DATA PANEL ===== */
.live-data {
    background: rgba(15, 52, 96, 0.4);
    border: 1px solid #1a3a5a;
    border-radius: 8px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.live-data.offline-msg {
    color: #e94560;
    font-size: 0.82rem;
    font-style: italic;
    background: rgba(233, 69, 96, 0.07);
    border-color: rgba(233, 69, 96, 0.2);
}

.live-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.live-label {
    font-size: 0.72rem;
    color: #7a8fa6;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.live-value {
    font-size: 0.95rem;
    font-weight: 700;
    color: #4fc3f7;
    font-variant-numeric: tabular-nums;
}

.live-value.uptime {
    color: #81c784;
    font-size: 0.85rem;
    font-weight: 600;
}

/* ===== SETTINGS PAGE ===== */
.settings-card {
    background: #16213e;
    border-radius: 12px;
    padding: 30px;
    border: 2px solid #0f3460;
    box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}

.settings-grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 28px;
}

.settings-row {
    display: grid;
    grid-template-columns: 160px 1fr 110px;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    background: #0f1e3a;
    border-radius: 8px;
    border: 1px solid #1a2a4a;
    transition: border-color 0.2s;
}

.settings-row:hover {
    border-color: #2a4a7a;
}

.settings-row label {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin: 0;
}

.station-badge {
    font-size: 0.95rem;
    font-weight: 700;
    color: #ffffff;
}

.operator-hint {
    font-size: 0.75rem;
    color: #7a8fa6;
    font-style: italic;
}

.ip-input-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ip-prefix,
.ip-suffix {
    font-size: 0.78rem;
    color: #5a6a7a;
    white-space: nowrap;
    font-family: 'Courier New', monospace;
}

.ip-input {
    flex: 1;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    padding: 8px 12px;
}

.ip-status {
    font-size: 0.78rem;
    font-weight: 600;
    text-align: right;
    white-space: nowrap;
}

.ip-status.configured {
    color: #28a745;
}

.ip-status.unconfigured {
    color: #5a6a7a;
}

.settings-actions {
    border-top: 1px solid #1a2a4a;
    padding-top: 20px;
}

/* ===== FOOTER ===== */
footer {
    background: #0f1e3a;
    border-top: 1px solid #1a2a4a;
    text-align: center;
    padding: 16px;
    color: #5a6a7a;
    font-size: 0.85rem;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
    header h1 {
        font-size: 1.4rem;
    }

    .stations-grid {
        grid-template-columns: 1fr 1fr;
    }

    .form-card {
        padding: 22px;
    }
}

@media (max-width: 400px) {
    .stations-grid {
        grid-template-columns: 1fr;
    }
}

/* ── Welds-per-unit / finished-units display ─────────────────────────────── */
.unit-eq {
    margin: 8px 0 4px;
    padding: 6px 10px;
    background: #f4f7fb;
    border: 1px solid #e3e9f2;
    border-radius: 6px;
    font-size: 0.85rem;
    color: #44546a;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.unit-eq .ueq-raw { font-weight: 600; color: #1f2d3d; }
.unit-eq .ueq-units { font-weight: 700; color: #1b6e2f; }
.unit-eq .ueq-op { color: #8a94a6; }

.unit-eq-lg {
    font-size: 0.95rem;
    color: #5a6678;
    font-variant-numeric: tabular-nums;
}
.unit-eq-lg #ueqUnitsD { font-weight: 700; color: #1b6e2f; }

.field-hint {
    display: block;
    margin-top: 4px;
    font-size: 0.78rem;
    color: #8a94a6;
}
