/* ================================================================
   URCOD Operations Hub — Premium Dark Theme CSS v6
   V2 Upgrade: Foreman controls, MV, TIV Rigup, per-well progress
   ================================================================ */

/* ── CSS VARIABLES ──────────────────────────────────────────────── */
:root {
    --bg-dark: #060612;
    --bg-card: rgba(255,255,255,0.04);
    --bg-card-hover: rgba(255,255,255,0.06);
    --bg-input: rgba(255,255,255,0.06);
    --bg-header: rgba(6,6,18,0.92);

    --green: #2ecc71;
    --green-bright: #34d399;
    --green-dim: rgba(46,204,113,0.15);
    --red: #ef4444;
    --red-dim: rgba(239,68,68,0.12);
    --yellow: #f59e0b;
    --yellow-dim: rgba(245,158,11,0.12);
    --blue: #3b82f6;
    --blue-dim: rgba(59,130,246,0.12);
    --amber: #f59e0b;

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-dim: #475569;

    --border-subtle: rgba(255,255,255,0.06);
    --border-light: rgba(255,255,255,0.1);

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-pill: 100px;

    --shadow-card: 0 4px 24px rgba(0,0,0,0.3);
    --shadow-elevated: 0 8px 40px rgba(0,0,0,0.4);

    --transition: all 0.2s cubic-bezier(0.4,0,0.2,1);
    --ease-out: cubic-bezier(0.16,1,0.3,1);
    --ease-spring: cubic-bezier(0.34,1.56,0.64,1);

    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── RESET & BASE ───────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
    max-width: 100vw;
}

body {
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: -webkit-fill-available;
    overflow-x: hidden;
    max-width: 100vw;
    width: 100%;
}

body::before {
    content: '';
    position: fixed; inset: 0;
    background: radial-gradient(ellipse 60% 40% at 50% 0%, rgba(46,204,113,0.06) 0%, transparent 70%),
                radial-gradient(ellipse 40% 60% at 80% 100%, rgba(59,130,246,0.04) 0%, transparent 60%);
    pointer-events: none; z-index: 0;
}

input, textarea, select, button { font-family: inherit; }

/* ── LOGIN ──────────────────────────────────────────────────────── */
.login-screen {
    position: fixed; inset: 0; z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    background: #152238; padding: 16px;
}

.login-card {
    width: 100%; max-width: 380px; text-align: center;
    background: #152238;
}

/* ── NATIVE BRANDING ── */
.login-branding { padding: 20px 24px 0; }

.login-star {
    width: 72px; height: 72px; border-radius: 50%;
    object-fit: cover; margin-bottom: 14px;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.3));
}

.login-dept-code {
    font-size: 1.8rem; font-weight: 900; letter-spacing: 6px;
    color: #e0e4ea;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    margin-bottom: 4px;
}

.login-dept-name {
    font-size: 0.6rem; font-weight: 700; color: var(--green);
    letter-spacing: 2px; text-transform: uppercase;
    line-height: 1.5; margin-bottom: 12px;
}

.login-divider {
    width: 48px; height: 2px; margin: 0 auto 12px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
}

.login-app-name {
    font-size: 1.1rem; font-weight: 600; color: rgba(255,255,255,0.7);
    letter-spacing: 3px; text-transform: uppercase; margin-bottom: 6px;
}

.login-powered {
    font-size: 0.62rem; color: rgba(255,255,255,0.3);
    font-weight: 400; letter-spacing: 0.5px; margin-bottom: 0;
}

/* ── LOGIN FORM ── */
.login-form-area {
    padding: 20px 24px 24px; text-align: left;
}
.login-form-area .form-group label { color: rgba(255,255,255,0.6); }
.login-form-area .form-group input {
    background: rgba(255,255,255,0.08); color: #fff;
    border-color: rgba(255,255,255,0.12);
}
.login-form-area .form-group input::placeholder { color: rgba(255,255,255,0.3); }
.login-form-area .form-group input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(46,204,113,0.15); }

.login-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }

.btn-theme-mini {
    width: 36px; height: 36px; border: 1px solid rgba(255,255,255,0.15); border-radius: 50%;
    background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.5);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: var(--transition);
}
.btn-theme-mini:active { transform: scale(0.9); }

.login-hint { font-size: 0.72rem; color: rgba(255,255,255,0.4); margin: 0 0 16px; line-height: 1.5; }
.login-error { font-size: 0.8rem; color: #ef4444; margin: 0 0 12px; min-height: 1.2em; text-align: center; font-weight: 500; }

.stay-logged-in { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 0.82rem; color: rgba(255,255,255,0.5); }
.stay-logged-in input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--green); }

/* ── FORMS ──────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; text-align: left; }
.form-group label { display: block; font-size: 0.75rem; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.form-group input, .form-group textarea, .form-group select {
    width: 100%;
    background: var(--bg-input); border: 1px solid var(--border-light);
    border-radius: var(--radius-md); color: var(--text-primary);
    font-size: 0.95rem; padding: 14px 16px;
    transition: var(--transition);
}
.form-group input:focus, .form-group textarea:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-dim); }

.optional { font-weight: 400; color: var(--text-muted); text-transform: none; letter-spacing: 0; }

.form-card { padding: 20px; position: relative; z-index: 1; }

.well-inputs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.well-input-item label { font-size: 0.7rem; color: var(--text-muted); margin-bottom: 4px; }
.well-input-item input { padding: 10px 12px; font-size: 0.9rem; }

/* ── BUTTONS ────────────────────────────────────────────────────── */
.btn-primary {
    width: 100%; padding: 16px; border: none; border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--green), #27ae60);
    color: #fff; font-size: 1rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    cursor: pointer; transition: var(--transition);
}
.btn-primary:active { transform: scale(0.97); }

.btn-secondary {
    padding: 12px 20px; border: 1px solid var(--border-light); border-radius: var(--radius-md);
    background: var(--bg-card); color: var(--text-primary);
    font-size: 0.85rem; font-weight: 600;
    display: flex; align-items: center; gap: 6px; cursor: pointer;
    transition: var(--transition);
}
.btn-secondary:active { transform: scale(0.97); }
.btn-secondary.btn-accent { border-color: rgba(46,204,113,0.3); color: var(--green); }

.btn-icon {
    width: 40px; height: 40px; border: none; border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.06); color: var(--text-secondary);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: var(--transition); position: relative;
}
.btn-icon:active { transform: scale(0.9); }

.btn-back {
    width: 44px; height: 44px; border: none; border-radius: var(--radius-sm);
    background: transparent; color: var(--text-primary);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
}

.btn-add {
    padding: 8px 14px; border: 1px solid rgba(46,204,113,0.3); border-radius: var(--radius-pill);
    background: var(--green-dim); color: var(--green);
    font-size: 0.78rem; font-weight: 600;
    display: flex; align-items: center; gap: 4px; cursor: pointer;
    transition: var(--transition);
}

.btn-delete { color: var(--red); }

.btn-red-flag {
    width: 100%; padding: 14px; margin-top: 12px;
    border: 1px solid rgba(239,68,68,0.2); border-radius: var(--radius-md);
    background: var(--red-dim); color: var(--red);
    font-size: 0.88rem; font-weight: 600; cursor: pointer;
    transition: var(--transition); position: relative; z-index: 1;
}

.btn-send-msg {
    padding: 6px 14px; border: 1px solid rgba(46,204,113,0.3); border-radius: var(--radius-pill);
    background: var(--green-dim); color: var(--green);
    font-size: 0.78rem; font-weight: 600; cursor: pointer;
}

/* ── HEADER ─────────────────────────────────────────────────────── */
.app-header {
    position: sticky; top: 0; z-index: 100;
    background: var(--bg-header); backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-subtle);
    padding-top: var(--safe-top);
    max-width: 100vw;
    overflow: hidden;
}

.header-content {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; max-width: 600px; margin: 0 auto;
    overflow: hidden;
}

.header-brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex-shrink: 1; overflow: hidden; }
.header-icon { width: 40px; height: 40px; flex-shrink: 0; }
.header-icon svg { width: 100%; height: 100%; }
.header-logo-img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }
.header-title { font-size: 0.85rem; font-weight: 800; color: var(--text-primary); white-space: nowrap; }
.header-by { color: var(--green); font-weight: 700; font-size: 0.75rem; }
.header-subtitle { font-size: 0.65rem; font-weight: 700; color: var(--green); text-transform: uppercase; letter-spacing: 1.5px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.notif-badge {
    position: absolute; top: -4px; right: -4px;
    min-width: 18px; height: 18px; padding: 0 5px;
    background: var(--red); border-radius: 9px;
    font-size: 0.65rem; font-weight: 800; color: #fff;
    display: flex; align-items: center; justify-content: center;
}

.btn-bell { position: relative; }

/* ── HEADER DROPDOWNS ──────────────────────────────────────────── */
.header-dropdown-wrap {
    position: relative;
}
.header-dropdown {
    display: none; position: fixed;
    min-width: 200px; padding: 6px;
    background: rgba(18,18,30,0.98); border: 1px solid var(--border-light);
    border-radius: var(--radius-md); box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.05);
    z-index: 10000; animation: ddFadeIn 0.15s ease-out;
    max-height: calc(100vh - 80px); overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
body.light .header-dropdown {
    background: rgba(255,255,255,0.98); border-color: rgba(0,0,0,0.1);
    box-shadow: 0 8px 32px rgba(0,0,0,0.15), 0 0 0 1px rgba(0,0,0,0.05);
}
.header-dropdown.open { display: block; }
@keyframes ddFadeIn { from { opacity:0; transform: translateY(-6px); } to { opacity:1; transform: none; } }

.header-dropdown-item {
    display: flex; align-items: center; gap: 10px;
    width: 100%; padding: 11px 14px; border: none; border-radius: var(--radius-sm);
    background: none; color: var(--text-primary);
    font-size: 0.82rem; font-weight: 600; cursor: pointer;
    transition: background 0.15s ease; text-align: left;
    white-space: nowrap; min-height: 40px;
}
.header-dropdown-item:hover, .header-dropdown-item:active {
    background: rgba(255,255,255,0.08);
}
body.light .header-dropdown-item:hover,
body.light .header-dropdown-item:active {
    background: rgba(0,0,0,0.05);
}
.header-dropdown-item.active-size {
    color: var(--green); background: var(--green-dim);
}
.header-dropdown-item svg { flex-shrink: 0; }

/* ── DISPLAY SIZE SYSTEM ───────────────────────────────────────── */
/* Large: +18% scaling */
body.size-large { font-size: 18.8px; } /* 16 * 1.18 */
body.size-large .btn-icon { width: 46px; height: 46px; }
body.size-large .btn-back { width: 50px; height: 50px; }
body.size-large .header-title { font-size: 1rem; }
body.size-large .header-by { font-size: 0.88rem; }
body.size-large .header-subtitle { font-size: 0.78rem; }
body.size-large .card-fleet-name { font-size: 1.2rem; }
body.size-large .card-well-name { font-size: 0.9rem; }
body.size-large .card-metrics .metric-value { font-size: 1.28rem; }
body.size-large .card-metrics .metric-label { font-size: 0.7rem; }
body.size-large .status-badge { font-size: 0.75rem; padding: 5px 12px; }
body.size-large .mini-well-bar { height: 10px; }
body.size-large .mini-well-label { font-size: 0.75rem; }
body.size-large .mini-well-pct { font-size: 0.7rem; }
body.size-large .inline-btn { width: 68px; height: 68px; }
body.size-large .inline-well-toggle { min-height: 58px; padding: 12px 4px; }
body.size-large .inline-wt-code { font-size: 1.15rem; }
body.size-large .inline-stage-big { font-size: 2.6rem; }
body.size-large .inline-stage-sub { font-size: 0.78rem; }
body.size-large .issue-btn { font-size: 0.72rem; padding: 7px 10px; min-height: 36px; }
body.size-large .card-footer { padding: 12px 16px; }
body.size-large .card-timestamp { font-size: 0.8rem; }
body.size-large .card-detail-link { font-size: 0.85rem; }
body.size-large .tab-item { font-size: 0.7rem; padding: 8px 12px; }
body.size-large .tab-item svg { width: 22px; height: 22px; }
body.size-large .screen-title { font-size: 1.3rem; }
body.size-large .foreman-stage-big { font-size: 4rem; }
body.size-large .foreman-btn { min-height: 82px; }
body.size-large .notif-badge { min-width: 20px; height: 20px; font-size: 0.72rem; }
body.size-large .integrated-seg { min-height: 9px; }
body.size-large .mv-table { font-size: 0.9rem; }
body.size-large .btn-primary { padding: 18px; font-size: 1.1rem; }
body.size-large .header-dropdown-item { font-size: 0.92rem; min-height: 44px; padding: 13px 16px; }

/* Extra Large: +33% scaling */
body.size-xl { font-size: 21.3px; } /* 16 * 1.33 */
body.size-xl .btn-icon { width: 52px; height: 52px; }
body.size-xl .btn-back { width: 54px; height: 54px; }
body.size-xl .header-title { font-size: 1.1rem; }
body.size-xl .header-by { font-size: 0.95rem; }
body.size-xl .header-subtitle { font-size: 0.85rem; }
body.size-xl .card-fleet-name { font-size: 1.35rem; }
body.size-xl .card-well-name { font-size: 1rem; }
body.size-xl .card-metrics .metric-value { font-size: 1.45rem; }
body.size-xl .card-metrics .metric-label { font-size: 0.8rem; }
body.size-xl .status-badge { font-size: 0.82rem; padding: 6px 14px; }
body.size-xl .mini-well-bar { height: 12px; }
body.size-xl .mini-well-label { font-size: 0.82rem; }
body.size-xl .mini-well-pct { font-size: 0.78rem; }
body.size-xl .inline-btn { width: 76px; height: 76px; }
body.size-xl .inline-btn svg { width: 34px; height: 34px; }
body.size-xl .inline-well-toggle { min-height: 64px; padding: 14px 6px; }
body.size-xl .inline-wt-code { font-size: 1.3rem; }
body.size-xl .inline-wt-sub { font-size: 0.72rem; }
body.size-xl .inline-stage-big { font-size: 3rem; }
body.size-xl .inline-stage-sub { font-size: 0.88rem; }
body.size-xl .issue-btn { font-size: 0.8rem; padding: 9px 12px; min-height: 44px; }
body.size-xl .card-footer { padding: 14px 16px; }
body.size-xl .card-timestamp { font-size: 0.88rem; }
body.size-xl .card-detail-link { font-size: 0.95rem; }
body.size-xl .tab-item { font-size: 0.78rem; padding: 10px 12px; }
body.size-xl .tab-item svg { width: 24px; height: 24px; }
body.size-xl .screen-title { font-size: 1.45rem; }
body.size-xl .foreman-stage-big { font-size: 4.5rem; }
body.size-xl .foreman-btn { min-height: 92px; }
body.size-xl .foreman-btn svg { width: 42px; height: 42px; }
body.size-xl .notif-badge { min-width: 22px; height: 22px; font-size: 0.78rem; }
body.size-xl .integrated-seg { min-height: 10px; }
body.size-xl .mv-table { font-size: 1rem; }
body.size-xl .mv-table thead th { padding: 14px 12px; }
body.size-xl .mv-row-label { font-size: 0.85rem; padding: 10px; }
body.size-xl .mv-row-val { font-size: 0.95rem; padding: 10px; }
body.size-xl .btn-primary { padding: 20px; font-size: 1.2rem; }
body.size-xl .form-group input, body.size-xl .form-group textarea, body.size-xl .form-group select { font-size: 1.1rem; padding: 16px 18px; min-height: 52px; }
body.size-xl .form-group label { font-size: 0.85rem; }
body.size-xl .header-dropdown-item { font-size: 1rem; min-height: 48px; padding: 14px 18px; }
body.size-xl .rigup-chip { padding: 10px 14px; min-width: 56px; }
body.size-xl .rigup-chip-code { font-size: 0.82rem; }
body.size-xl .rigup-chip-status { font-size: 0.6rem; }
body.size-xl .card-order-label { font-size: 0.72rem; }
body.size-xl .detail-fleet-name { font-size: 1.5rem; }
body.size-xl .detail-progress-num { font-size: 3rem; }

/* ── MAIN ──────────────────────────────────────────────────────── */
.app-main {
    max-width: 600px; margin: 0 auto;
    padding: 16px 16px calc(80px + var(--safe-bottom));
    position: relative; z-index: 1;
    overflow-x: hidden;
    width: 100%;
}

.screen { display: none; }
.screen.active { display: block; animation: fadeIn 0.25s var(--ease-out); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.screen-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px; min-height: 44px;
}
.screen-title { font-size: 1.15rem; font-weight: 800; }

/* ── FLEET CARDS ────────────────────────────────────────────────── */
.fleet-list { display: flex; flex-direction: column; gap: 14px; }

.fleet-card {
    background: var(--bg-card); border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg); overflow: hidden;
    cursor: pointer; transition: var(--transition);
    max-width: 100%;
}
.fleet-card:active { transform: scale(0.985); background: var(--bg-card-hover); }
.fleet-card[data-status="On Track"] { border-left: 3px solid var(--green); }
.fleet-card[data-status="Risk"] { border-left: 3px solid var(--yellow); }
.fleet-card[data-status="Delayed"] { border-left: 3px solid var(--red); }
.fleet-card[data-status="Completed"] { border-left: 3px solid var(--blue); }

.card-inner { padding: 16px 16px 12px; overflow: hidden; }

.card-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.card-fleet-name { font-size: 1.05rem; font-weight: 800; }
.card-well-name { font-size: 0.78rem; color: var(--text-secondary); margin-top: 2px; }

/* ── Status badges ── */
.status-badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 10px; border-radius: var(--radius-pill);
    font-size: 0.65rem; font-weight: 800; letter-spacing: 0.5px;
}
.status-badge.sm { font-size: 0.6rem; padding: 3px 8px; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; }
.on-track { background: var(--green-dim); color: var(--green); }
.on-track .status-dot { background: var(--green); }
.risk { background: var(--yellow-dim); color: var(--yellow); }
.risk .status-dot { background: var(--yellow); }
.delayed { background: var(--red-dim); color: var(--red); }
.delayed .status-dot { background: var(--red); }
.completed { background: var(--blue-dim); color: var(--blue); }
.completed .status-dot { background: var(--blue); }

/* ── Mini well bars (dashboard card) ── */
.card-wells-mini { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 12px; overflow: hidden; }
.mini-well { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; }
.mini-well-label { font-size: 0.65rem; font-weight: 700; color: var(--text-muted); min-width: 18px; flex-shrink: 0; }
.mini-well-bar { flex: 1; height: 8px; background: rgba(255,255,255,0.08); border-radius: 4px; overflow: hidden; position: relative; min-width: 0; }
.mini-well-fill { height: 100%; background: var(--green); border-radius: 4px; transition: width 0.3s var(--ease-out); }
.mini-well-pct { font-size: 0.6rem; font-weight: 700; color: var(--text-muted); min-width: 28px; text-align: right; flex-shrink: 0; }

/* ── Progress bar ── */
.progress-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.progress-bar-container { flex: 1; height: 6px; background: rgba(255,255,255,0.08); border-radius: 3px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, var(--green), var(--green-bright)); border-radius: 3px; transition: width 0.5s var(--ease-out); }
.progress-pct { font-size: 0.8rem; font-weight: 800; color: var(--green); min-width: 36px; text-align: right; }

/* ── Card metrics ── */
.card-metrics { display: flex; gap: 0; }
.metric { flex: 1; text-align: center; padding: 8px 0; border-right: 1px solid var(--border-subtle); }
.metric:last-child { border-right: none; }
.metric-value { font-size: 1.1rem; font-weight: 800; }
.metric-value.green { color: var(--green); }
.metric-value.red { color: var(--red); }
.metric-label { font-size: 0.6rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }

.card-footer {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 16px; border-top: 1px solid var(--border-subtle);
    background: rgba(0,0,0,0.15);
}
.card-timestamp { font-size: 0.7rem; color: var(--text-muted); }
.card-arrow { color: var(--text-dim); }

.card-detail-link {
    border: none; background: none; color: var(--green);
    font-size: 0.75rem; font-weight: 700; cursor: pointer;
    padding: 4px 0; text-decoration: none;
}

/* ── Inline Foreman Panel (on dashboard card) ─────────────────── */
.inline-foreman {
    padding: 12px 16px 14px; border-top: 1px solid var(--border-subtle);
    background: rgba(0,0,0,0.12);
}

.inline-well-toggles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 12px; }
.inline-well-toggle {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 10px 4px; border: 2px solid var(--border-light); border-radius: var(--radius-sm);
    background: var(--bg-card); color: var(--text-secondary);
    cursor: pointer; transition: var(--transition); min-height: 52px;
}
.inline-well-toggle.active {
    border-color: var(--green); background: var(--green-dim); color: var(--green);
}
.inline-well-toggle:active { transform: scale(0.93); }
.inline-wt-code { font-size: 1rem; font-weight: 900; }
.inline-wt-sub { font-size: 0.6rem; font-weight: 600; margin-top: 1px; }

.inline-stage-row {
    display: flex; align-items: center; gap: 12px;
}
.inline-stage-info { flex: 1; text-align: center; }
.inline-stage-big { font-size: 2.2rem; font-weight: 900; color: var(--green); line-height: 1; }
.inline-stage-sub { font-size: 0.68rem; color: var(--text-muted); margin: 4px 0 6px; }
.inline-progress-bar { height: 6px; }

.inline-btn {
    display: flex; align-items: center; justify-content: center;
    width: 60px; height: 60px; border: none; border-radius: var(--radius-md);
    cursor: pointer; transition: var(--transition); flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}
.inline-btn:active:not(:disabled) { transform: scale(0.9); }
.inline-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.inline-btn.inline-plus { background: linear-gradient(135deg, var(--green), #27ae60); color: #fff; }
.inline-btn.inline-minus { background: var(--red-dim); color: var(--red); border: 2px solid rgba(239,68,68,0.2); }

/* ── Card Check-in Bar ──────────────────────────────────────────── */
.card-checkin-bar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 16px; border-top: 1px solid var(--border-subtle);
    background: rgba(46,204,113,0.06);
}
.card-checkin-who { font-size: 0.7rem; color: var(--text-muted); font-weight: 600; }
.card-switch-btn {
    border: 1px solid var(--border-light); background: none;
    color: var(--text-secondary); font-size: 0.65rem; font-weight: 700;
    padding: 4px 10px; border-radius: var(--radius-pill); cursor: pointer;
    transition: var(--transition);
}
.card-switch-btn:active { transform: scale(0.93); background: rgba(255,255,255,0.05); }

/* ── Check-In Overlay ───────────────────────────────────────────── */
.checkin-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.85); z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.checkin-card {
    background: var(--bg-card); border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg); padding: 28px 24px;
    width: 100%; max-width: 400px;
    animation: slideUp 0.3s var(--ease-out);
}
.checkin-icon { text-align: center; margin-bottom: 12px; }
.checkin-title { text-align: center; font-size: 1.2rem; font-weight: 800; margin-bottom: 4px; }
.checkin-sub { text-align: center; font-size: 0.78rem; color: var(--text-muted); margin-bottom: 20px; }

.checkin-site-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.checkin-site-btn {
    padding: 14px 8px; border: 2px solid var(--border-light); border-radius: var(--radius-sm);
    background: var(--bg-card); color: var(--text-primary);
    font-size: 0.85rem; font-weight: 700; cursor: pointer;
    text-align: center; transition: var(--transition);
}
.checkin-site-btn.active { border-color: var(--green); background: var(--green-dim); color: var(--green); }
.checkin-site-btn:active { transform: scale(0.95); }

/* ── DETAIL ─────────────────────────────────────────────────────── */
.detail-content { position: relative; z-index: 1; overflow-x: hidden; }

.detail-hero {
    background: var(--bg-card); border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg); padding: 20px; margin-bottom: 16px;
}
.detail-hero-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; }
.detail-fleet-name { font-size: 1.3rem; font-weight: 900; }
.detail-well-name { font-size: 0.82rem; color: var(--text-secondary); margin-top: 2px; }
.detail-progress-num { font-size: 2.5rem; font-weight: 900; color: var(--green); text-align: center; margin-bottom: 4px; }
.detail-progress-sub { font-size: 0.78rem; color: var(--text-secondary); text-align: center; margin-bottom: 12px; }
.detail-progress-bar { height: 8px; }

.detail-section {
    background: var(--bg-card); border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg); padding: 16px; margin-bottom: 14px;
}
.detail-section-title { font-size: 0.72rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 14px; }

/* ── Per-well progress (Upgrade 2) ── */
.well-progress-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.well-progress-card { background: rgba(255,255,255,0.03); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); padding: 12px; overflow: hidden; min-width: 0; }
.well-progress-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.well-progress-label { font-size: 0.82rem; font-weight: 700; }
.well-progress-pct { font-size: 0.82rem; font-weight: 800; color: var(--green); }
.well-progress-stats { display: flex; gap: 8px; margin-top: 6px; font-size: 0.65rem; color: var(--text-muted); }
.well-progress-stats strong { font-weight: 700; }
.well-progress-stats .green { color: var(--green); }
.well-progress-stats .red { color: var(--red); }

/* ── Detail metrics ── */
.detail-metrics-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.detail-metric-card {
    background: rgba(255,255,255,0.03); border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md); padding: 12px; text-align: center;
}
.detail-metric-label { font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.detail-metric-value { font-size: 1.15rem; font-weight: 800; }

.detail-notes {
    font-size: 0.85rem; color: var(--text-secondary); line-height: 1.6;
    background: rgba(255,255,255,0.02); border-radius: var(--radius-sm);
    padding: 12px;
}

.detail-actions { display: flex; gap: 10px; margin-bottom: 8px; position: relative; z-index: 1; }
.detail-actions .btn-secondary { flex: 1; justify-content: center; }

.updated-by { font-size: 0.72rem; color: var(--text-muted); }
.updated-by strong { color: var(--green); }

/* ── FOREMAN QUICK UPDATE (Upgrade 1) ──────────────────────────── */
.foreman-content { position: relative; z-index: 1; overflow-x: hidden; }

.foreman-fleet-info { text-align: center; margin-bottom: 16px; }
.foreman-fleet-name { font-size: 1.3rem; font-weight: 900; }
.foreman-site-name { font-size: 0.82rem; color: var(--text-secondary); margin-top: 2px; }

/* Fleet Summary Stats Row */
.foreman-fleet-summary {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
    margin-bottom: 16px; padding: 12px; border-radius: var(--radius-lg);
    background: var(--bg-card); border: 1px solid var(--border-subtle);
}
.foreman-summary-stat { text-align: center; }
.foreman-summary-val { display: block; font-size: 1.4rem; font-weight: 900; line-height: 1.2; }
.foreman-summary-val.green { color: var(--green); }
.foreman-summary-val.red { color: var(--red); }
.foreman-summary-val.accent { color: var(--green); }
.foreman-summary-lbl { font-size: 0.6rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* All Wells Progress Grid */
.foreman-wells-grid {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
    margin-bottom: 16px;
}
.foreman-well-card {
    padding: 12px; border-radius: var(--radius-md);
    background: var(--bg-card); border: 2px solid var(--border-light);
    cursor: pointer; transition: var(--transition);
    overflow: hidden; min-width: 0;
}
.foreman-well-card:active { transform: scale(0.97); }
.foreman-well-card.active {
    border-color: var(--green); background: var(--green-dim);
    box-shadow: 0 0 12px rgba(34,197,94,0.15);
}
.foreman-well-card-header {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px;
}
.foreman-well-card-code { font-size: 0.82rem; font-weight: 800; }
.foreman-well-card.active .foreman-well-card-code { color: var(--green); }
.foreman-well-card-pct { font-size: 0.82rem; font-weight: 800; color: var(--green); }
.foreman-well-card-stats { font-size: 0.68rem; color: var(--text-muted); margin-top: 4px; text-align: center; font-weight: 600; }

/* Selected Well Update Card */
.foreman-update-card {
    padding: 20px 16px; border-radius: var(--radius-lg);
    background: var(--bg-card); border: 2px solid var(--green);
    box-shadow: 0 4px 20px rgba(34,197,94,0.08);
    margin-bottom: 16px;
}
.foreman-update-card-title {
    font-size: 0.75rem; font-weight: 800; color: var(--green);
    text-transform: uppercase; letter-spacing: 1px; margin-bottom: 12px;
    text-align: center;
}

.foreman-stage-display {
    text-align: center; margin-bottom: 16px; padding: 16px 12px;
    background: rgba(0,0,0,0.08); border-radius: var(--radius-md);
}
.foreman-stage-label { font-size: 0.72rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.foreman-stage-big { font-size: 3.5rem; font-weight: 900; color: var(--green); line-height: 1; margin-bottom: 6px; }
.foreman-stage-sub { font-size: 0.78rem; color: var(--text-secondary); margin-bottom: 10px; }
.foreman-progress-bar { height: 8px; }

.foreman-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.foreman-btn {
    display: flex; align-items: center; justify-content: center;
    min-height: 72px; border: none; border-radius: var(--radius-lg);
    cursor: pointer; transition: var(--transition);
    -webkit-tap-highlight-color: transparent;
}
.foreman-btn:active:not(:disabled) { transform: scale(0.93); }
.foreman-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.foreman-btn.plus { background: linear-gradient(135deg, var(--green), #27ae60); color: #fff; }
.foreman-btn.minus { background: var(--red-dim); color: var(--red); border: 2px solid rgba(239,68,68,0.2); }

/* Stage Bar Section inside Update Card */
.foreman-stage-bar-section {
    margin-top: 16px; padding-top: 14px;
    border-top: 1px solid var(--border-subtle);
}
.foreman-stage-bar-label {
    font-size: 0.68rem; font-weight: 700; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px;
}

/* ── MANAGEMENT VIEW — Executive Table Dashboard ──────────────── */
.mv-content { position: relative; z-index: 1; overflow-x: hidden; }

.mv-section-title {
    font-size: 1rem; font-weight: 800; color: var(--text-primary);
    text-transform: uppercase; letter-spacing: 1.5px; margin-bottom: 12px;
    padding-bottom: 8px; border-bottom: 2px solid var(--green);
}

.mv-table-wrap {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    margin-bottom: 8px; border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    background: var(--bg-card);
}

.mv-table {
    width: 100%; border-collapse: collapse; font-size: 0.78rem;
    min-width: 320px;
}

.mv-table thead th {
    text-align: center; padding: 12px 10px; background: rgba(0,0,0,0.15);
    border-bottom: 2px solid var(--border-subtle);
}
.mv-label-col { width: 100px; min-width: 90px; }

.mv-fleet-col { min-width: 90px; }
.mv-col-num {
    font-size: 1.1rem; font-weight: 900; color: var(--text-primary);
    letter-spacing: 0.5px;
}
.mv-col-site { font-size: 0.65rem; color: var(--text-secondary); margin-top: 2px; }
.mv-col-rank {
    font-size: 0.55rem; font-weight: 700; color: var(--green);
    text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px;
}

.mv-table tbody tr { border-bottom: 1px solid var(--border-subtle); }
.mv-table tbody tr:last-child { border-bottom: none; }
.mv-table tbody tr:hover { background: rgba(46,204,113,0.03); }

.mv-row-label {
    padding: 8px 10px; font-size: 0.72rem; font-weight: 700;
    color: var(--text-secondary); text-align: left; white-space: nowrap;
}

.mv-row-val {
    padding: 8px 10px; text-align: center; font-size: 0.82rem;
    font-weight: 700; color: var(--text-primary);
}
.mv-row-val.green { color: var(--green); }
.mv-row-val.red { color: var(--red); }
.mv-row-val.date-val {
    color: #d4a017; font-size: 0.72rem; font-weight: 800;
}

.mv-bar-row td { padding: 10px 10px 4px; }
.mv-inline-bar {
    height: 8px; background: rgba(255,255,255,0.08);
    border-radius: 4px; overflow: hidden;
}
.mv-inline-fill {
    height: 100%; background: var(--green); border-radius: 4px;
    transition: width 0.4s var(--ease-out);
}
.mv-bar-pct {
    font-size: 0.65rem; font-weight: 800; color: var(--green);
    text-align: center; margin-top: 4px;
}

/* Light mode adjustments */
body.light .mv-table thead th { background: rgba(0,0,0,0.04); }
body.light .mv-table tbody tr:hover { background: rgba(46,204,113,0.06); }
body.light .mv-inline-bar { background: rgba(0,0,0,0.08); }
body.light .mv-row-val.date-val { color: #b8860b; }

/* MV item progress (X/4 format) */
.mv-item-progress { display: flex; align-items: center; gap: 6px; justify-content: center; }
.mv-item-bar {
    flex: 1; max-width: 50px; height: 5px;
    border-radius: 3px; background: rgba(255,255,255,0.08); overflow: hidden;
}
body.light .mv-item-bar { background: rgba(0,0,0,0.08); }
.mv-item-fill { height: 100%; border-radius: 3px; transition: width 0.3s; background: var(--text-muted); }
.mv-item-fill.green { background: var(--green); }
.mv-item-fill.amber { background: var(--amber); }
.mv-item-count { font-size: 0.72rem; font-weight: 800; min-width: 24px; text-align: center; }
.mv-item-count.green { color: var(--green); }
.mv-item-count.amber { color: var(--amber); }
.mv-row-val.dim { color: var(--text-muted); opacity: 0.5; }

/* TIV Fleet Assignment */
.tiv-assign-row {
    display: flex; align-items: center; gap: 12px;
    padding: 8px 16px; border-bottom: 1px solid var(--border-subtle);
    background: rgba(46,204,113,0.03);
}
.tiv-fleet-assign {
    flex: 1; padding: 10px 12px; border-radius: 10px;
    border: 1px solid var(--border-subtle); background: var(--bg-card);
    color: var(--text-primary); font-size: 0.88rem; font-weight: 600;
    cursor: pointer; outline: none;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.tiv-fleet-assign:focus { border-color: var(--green); box-shadow: 0 0 0 2px rgba(46,204,113,0.15); }
body.light .tiv-fleet-assign { background: #fff; }
.tiv-assign-label {
    font-size: 0.82rem; font-weight: 700; color: var(--green);
}

/* ── TIV RIGUP (Upgrade 4) ─────────────────────────────────────── */
.tiv-content { position: relative; z-index: 1; overflow-x: hidden; }

.rigup-fleet-card {
    background: var(--bg-card); border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg); margin-bottom: 14px; overflow: hidden;
    max-width: 100%;
}
.rigup-fleet-header {
    padding: 14px 16px; border-bottom: 1px solid var(--border-subtle);
}
.rigup-fleet-name { font-size: 1rem; font-weight: 800; }
.rigup-fleet-site { font-size: 0.75rem; color: var(--text-secondary); margin-top: 2px; }

.tiv-dates-row {
    display: flex; gap: 12px; padding: 10px 16px;
    border-bottom: 1px solid var(--border-subtle);
}
.tiv-date-field { flex: 1; }
.tiv-date-label {
    display: block; font-size: 0.6rem; font-weight: 700;
    color: var(--text-muted); text-transform: uppercase;
    letter-spacing: 0.5px; margin-bottom: 4px;
}
.tiv-date-input {
    width: 100%; padding: 6px 8px; border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle); background: var(--bg-secondary);
    color: var(--text-primary); font-size: 0.75rem; font-weight: 700;
    font-family: inherit;
}
.tiv-date-input:focus { outline: none; border-color: var(--green); }

.rigup-item-row {
    padding: 12px 16px; border-bottom: 1px solid var(--border-subtle);
    display: flex; align-items: center; gap: 12px;
}
.rigup-item-row:last-child { border-bottom: none; }

.rigup-item-left { min-width: 80px; flex-shrink: 0; }
.rigup-item-name { font-size: 0.78rem; font-weight: 700; margin-bottom: 2px; }
.rigup-item-pct { font-size: 0.65rem; color: var(--text-muted); margin-bottom: 4px; }
.rigup-item-bar { height: 3px; background: rgba(255,255,255,0.08); border-radius: 2px; overflow: hidden; }
.rigup-item-fill { height: 100%; background: var(--green); border-radius: 2px; transition: width 0.3s var(--ease-out); }

.rigup-item-wells { display: flex; gap: 6px; flex: 1; flex-wrap: wrap; }

.rigup-chip {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 6px 10px; border-radius: var(--radius-sm);
    border: 1px solid var(--border-light); cursor: pointer;
    transition: var(--transition); min-width: 50px; flex: 1;
}
.rigup-chip:disabled { cursor: default; }
.rigup-chip:active:not(:disabled) { transform: scale(0.93); }
.rigup-chip-code { font-size: 0.7rem; font-weight: 800; margin-bottom: 1px; }
.rigup-chip-status { font-size: 0.5rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; }

.rigup-chip.not-started {
    background: rgba(255,255,255,0.04); color: var(--text-muted);
    border-color: var(--border-light);
}
.rigup-chip.in-progress {
    background: var(--yellow-dim); color: var(--amber);
    border-color: rgba(245,158,11,0.3);
}
.rigup-chip.complete {
    background: var(--green-dim); color: var(--green);
    border-color: rgba(46,204,113,0.3);
}

/* ── TAB BAR ────────────────────────────────────────────────────── */
.tab-bar {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
    background: rgba(6,6,18,0.96); backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-subtle);
    display: flex; justify-content: space-around;
    padding: 6px 8px calc(6px + var(--safe-bottom));
    max-width: 600px; margin: 0 auto;
    overflow: hidden;
}
.tab-item {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 6px 12px; border: none; background: none;
    color: var(--text-dim); font-size: 0.6rem; font-weight: 600;
    letter-spacing: 0.3px; text-transform: uppercase;
    cursor: pointer; transition: var(--transition);
}
.tab-item.active { color: var(--green); }
.tab-item svg { transition: var(--transition); }
.tab-item.active svg { stroke: var(--green); transform: scale(1.05); }

/* ── DIALOGS ────────────────────────────────────────────────────── */
.dialog-overlay {
    position: fixed; inset: 0; z-index: 2000;
    background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
}
.dialog-box {
    width: 100%; max-width: 380px;
    background: #12121e; border: 1px solid var(--border-light);
    border-radius: var(--radius-lg); padding: 24px;
}
.dialog-title { font-size: 1.1rem; font-weight: 800; margin-bottom: 8px; }
.dialog-msg { font-size: 0.82rem; color: var(--text-secondary); line-height: 1.5; }
.dialog-btns { display: flex; gap: 10px; margin-top: 20px; }
.dialog-cancel {
    flex: 1; padding: 12px; border: 1px solid var(--border-light);
    border-radius: var(--radius-md); background: transparent;
    color: var(--text-secondary); font-weight: 600; cursor: pointer;
}
.dialog-confirm {
    flex: 1; padding: 12px; border: none;
    border-radius: var(--radius-md); background: var(--red);
    color: #fff; font-weight: 700; cursor: pointer;
}

/* ── TOAST ──────────────────────────────────────────────────────── */
.toast {
    position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%) translateY(120%);
    background: #1e293b; color: var(--text-primary);
    padding: 12px 24px; border-radius: var(--radius-pill);
    font-size: 0.82rem; font-weight: 600; white-space: nowrap;
    box-shadow: var(--shadow-elevated);
    transition: transform 0.3s var(--ease-spring), opacity 0.3s;
    opacity: 0; z-index: 3000; pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ── NOTIFICATIONS ──────────────────────────────────────────────── */
.notif-list { position: relative; z-index: 1; }
.notif-item {
    background: var(--bg-card); border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md); padding: 14px; margin-bottom: 10px;
}
.notif-item.unread { border-left: 3px solid var(--red); }
.notif-item.msg-item.unread { border-left-color: var(--blue); }
.notif-fleet-tag { font-size: 0.75rem; font-weight: 700; margin-bottom: 6px; color: var(--red); }
.notif-item-header { display: flex; justify-content: space-between; margin-bottom: 6px; }
.notif-item-from { font-size: 0.75rem; font-weight: 600; color: var(--text-secondary); }
.notif-item-time { font-size: 0.65rem; color: var(--text-muted); }
.notif-item-msg { font-size: 0.82rem; color: var(--text-primary); line-height: 1.5; }

/* ── EMPTY / SKELETON ──────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state p { margin-bottom: 6px; }
.empty-sub { font-size: 0.78rem; color: var(--text-dim); }

.skeleton { background: linear-gradient(90deg, rgba(255,255,255,0.03) 25%, rgba(255,255,255,0.06) 50%, rgba(255,255,255,0.03) 75%);
    background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: var(--radius-lg); }
.skeleton-card { height: 180px; margin-bottom: 14px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── UPDATE INFO ───────────────────────────────────────────────── */
.update-info { text-align: center; margin-bottom: 20px; padding: 16px; background: var(--bg-card); border-radius: var(--radius-md); border: 1px solid var(--border-subtle); }
.update-info-name { font-size: 1.1rem; font-weight: 800; }
.update-info-sub { font-size: 0.78rem; color: var(--text-secondary); margin-top: 4px; }


/* ================================================================
   LIGHT THEME — body.light overrides
   ================================================================ */
body.light {
    --bg-dark: #f0f2f5;
    --bg-card: #ffffff;
    --bg-card-hover: #f8f9fa;
    --bg-input: #f1f3f5;
    --bg-header: rgba(255,255,255,0.92);

    --text-primary: #1a1a2e;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --text-dim: #a0aec0;

    --border-subtle: rgba(0,0,0,0.08);
    --border-light: rgba(0,0,0,0.12);

    --shadow-card: 0 2px 12px rgba(0,0,0,0.08);
    --shadow-elevated: 0 4px 24px rgba(0,0,0,0.12);

    --green-dim: rgba(46,204,113,0.12);
    --red-dim: rgba(239,68,68,0.08);
    --yellow-dim: rgba(245,158,11,0.1);
    --blue-dim: rgba(59,130,246,0.1);

    background: var(--bg-dark);
    color: var(--text-primary);
}

body.light .app-header {
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-subtle);
    backdrop-filter: blur(20px);
}
body.light .app-header .header-title { color: var(--text-primary); }
body.light .app-header .header-by { color: var(--green); }
body.light .app-header .header-subtitle { color: var(--text-muted); }
body.light .btn-icon { color: var(--text-secondary); }
body.light .btn-icon:hover { background: rgba(0,0,0,0.06); }

body.light .login-screen { background: linear-gradient(135deg, #e8f5e9 0%, #f0f2f5 50%, #e3f2fd 100%); }
body.light .login-card {
    background: #fff; border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-elevated);
}
body.light .login-title { color: var(--text-primary); }
body.light .login-brand { color: var(--green); }
body.light .login-subtitle { color: var(--text-muted); }
body.light .login-hint { color: var(--text-muted); }
body.light #loginCode {
    background: var(--bg-input); color: var(--text-primary);
    border-color: var(--border-light);
}
body.light #loginCode::placeholder { color: var(--text-dim); }

body.light .fleet-card {
    background: var(--bg-card); border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-card);
}
body.light .fleet-card:hover { background: var(--bg-card-hover); }
body.light .card-fleet-name { color: var(--text-primary); }
body.light .card-well-name { color: var(--text-muted); }
body.light .card-timestamp { color: var(--text-muted); }
body.light .card-detail-link { color: var(--green); }

body.light .progress-bar-container,
body.light .inline-progress-bar,
body.light .foreman-progress-bar,
body.light .detail-progress-bar { background: rgba(0,0,0,0.06); }

body.light .inline-well-toggle {
    background: var(--bg-input); border-color: var(--border-light);
    color: var(--text-secondary);
}
body.light .inline-well-toggle.active {
    background: var(--green-dim); border-color: var(--green); color: var(--green);
}
body.light .inline-stage-big { color: var(--text-primary); }
body.light .inline-stage-sub { color: var(--text-muted); }
body.light .inline-btn.inline-minus { background: var(--red-dim); border-color: rgba(239,68,68,0.18); }

body.light .card-checkin-bar { background: rgba(46,204,113,0.06); border-top-color: var(--border-subtle); }
body.light .card-switch-btn { border-color: var(--border-light); color: var(--text-muted); }
body.light .card-switch-btn:active { background: rgba(0,0,0,0.04); }

body.light .checkin-overlay { background: rgba(0,0,0,0.4); }
body.light .checkin-card {
    background: #fff; border-color: var(--border-subtle);
    box-shadow: var(--shadow-elevated);
}
body.light .checkin-title { color: var(--text-primary); }
body.light .checkin-sub { color: var(--text-muted); }
body.light .checkin-site-btn {
    background: #fff; border-color: var(--border-light); color: var(--text-primary);
}
body.light .checkin-site-btn.active { border-color: var(--green); background: var(--green-dim); color: var(--green); }
body.light #checkinForeman {
    background: var(--bg-input); color: var(--text-primary);
    border-color: var(--border-light);
}

body.light .tab-bar { background: rgba(255,255,255,0.95); border-top: 1px solid var(--border-subtle); }
body.light .tab-btn { color: var(--text-muted); }
body.light .tab-btn.active { color: var(--green); }

body.light .detail-content { color: var(--text-primary); }
body.light .detail-hero { background: linear-gradient(135deg, rgba(46,204,113,0.08), rgba(59,130,246,0.05)); border: 1px solid var(--border-subtle); }
body.light .detail-metric-card { background: var(--bg-input); border: 1px solid var(--border-subtle); }
body.light .detail-metric-label { color: var(--text-muted); }
body.light .detail-metric-value { color: var(--text-primary); }
body.light .detail-section-title { color: var(--text-primary); }
body.light .detail-notes { background: var(--bg-input); color: var(--text-secondary); border-color: var(--border-subtle); }

body.light .foreman-fleet-name { color: var(--text-primary); }
body.light .foreman-site-name { color: var(--text-muted); }
body.light .foreman-stage-label { color: var(--text-muted); }
body.light .foreman-stage-big { color: var(--text-primary); }
body.light .foreman-stage-sub { color: var(--text-muted); }
body.light .well-toggle { background: var(--bg-input); border-color: var(--border-light); color: var(--text-secondary); }
body.light .well-toggle.active { background: var(--green-dim); border-color: var(--green); color: var(--green); }
body.light .foreman-btn.minus { background: var(--red-dim); border-color: rgba(239,68,68,0.18); }

body.light .mv-card,
body.light .mv-metric-card { background: var(--bg-input); border: 1px solid var(--border-subtle); }
body.light .overlay-content { background: #fff; border-color: var(--border-subtle); box-shadow: var(--shadow-elevated); }
body.light .overlay-content input,
body.light .overlay-content textarea,
body.light .overlay-content select { background: var(--bg-input); color: var(--text-primary); border-color: var(--border-light); }

body.light .stay-logged-in span { color: var(--text-secondary); }
body.light .toast { background: #333; color: #fff; }

body.light .status-badge.on-track { background: var(--green-dim); color: #16a34a; }
body.light .status-badge.risk { background: var(--yellow-dim); color: #d97706; }
body.light .status-badge.delayed { background: var(--red-dim); color: #dc2626; }

body.light .btn-secondary { background: var(--bg-input); color: var(--text-primary); border-color: var(--border-light); }
body.light .btn-secondary:hover { background: rgba(0,0,0,0.06); }
body.light .form-group label { color: var(--text-secondary); }
body.light .screen-title { color: var(--text-primary); }
body.light .section-title { color: var(--text-primary); }

/* ── LOGIN always stays dark (logo has dark navy background) ── */
body.light .login-screen { background: #152238; }
body.light .login-card { background: #152238; }
body.light .login-form-area .form-group label { color: rgba(255,255,255,0.6); }
body.light .login-form-area .form-group input {
    background: rgba(255,255,255,0.08); color: #fff;
    border-color: rgba(255,255,255,0.12);
}
body.light .login-form-area .form-group input::placeholder { color: rgba(255,255,255,0.3); }
body.light .login-hint { color: rgba(255,255,255,0.4); }
body.light .login-screen .stay-logged-in span { color: rgba(255,255,255,0.5); }

/* ── MANAGEMENT VIEW — Executive Table Dashboard ─────────────── */
.mv-content { position: relative; z-index: 1; overflow-x: hidden; }

.mv-section-title {
    font-size: 1rem; font-weight: 800; color: var(--text-primary);
    text-transform: uppercase; letter-spacing: 1.5px; margin-bottom: 12px;
    padding-bottom: 8px; border-bottom: 2px solid var(--green);
}

.mv-header-bar {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 14px;
}
.mv-count { font-size: 0.85rem; font-weight: 700; color: var(--text-secondary); }
.btn-outline {
    padding: 7px 14px; border: 1px solid var(--green);
    border-radius: var(--radius-pill); background: transparent;
    color: var(--green); font-size: 0.75rem; font-weight: 700;
    cursor: pointer; transition: var(--transition);
}
.btn-outline:hover { background: var(--green-dim); }
body.light .btn-outline { border-color: #16a34a; color: #16a34a; }

.mv-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 8px; border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    background: var(--bg-card);
    position: relative;
    max-width: 100%;
}

.mv-table {
    width: 100%; border-collapse: collapse; font-size: 0.78rem;
    min-width: 320px;
}

.mv-table thead th {
    text-align: center; padding: 12px 10px; background: rgba(0,0,0,0.15);
    border-bottom: 2px solid var(--border-subtle);
}
.mv-label-col { width: 100px; min-width: 90px; }

.mv-fleet-col { min-width: 90px; }
.mv-col-num {
    font-size: 1.1rem; font-weight: 900; color: var(--text-primary);
    letter-spacing: 0.5px;
}
.mv-col-site { font-size: 0.65rem; color: var(--text-secondary); margin-top: 2px; }
.mv-col-rank {
    font-size: 0.55rem; font-weight: 700; color: var(--green);
    text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px;
}

.mv-table tbody tr { border-bottom: 1px solid var(--border-subtle); }
.mv-table tbody tr:last-child { border-bottom: none; }
.mv-table tbody tr:hover { background: rgba(46,204,113,0.03); }

.mv-row-label {
    padding: 8px 10px; font-size: 0.72rem; font-weight: 700;
    color: var(--text-secondary); text-align: left; white-space: nowrap;
}

.mv-row-val {
    padding: 8px 10px; text-align: center; font-size: 0.82rem;
    font-weight: 700; color: var(--text-primary);
}
.mv-row-val.green { color: var(--green); }
.mv-row-val.red { color: var(--red); }
.mv-row-val.date-val {
    color: #d4a017; font-size: 0.72rem; font-weight: 800;
}
.mv-row-val.dim { color: var(--text-muted); opacity: 0.5; }

.mv-bar-row td { padding: 10px 10px 4px; }
.mv-inline-bar {
    height: 8px; background: rgba(255,255,255,0.08);
    border-radius: 4px; overflow: hidden;
}
.mv-inline-fill {
    height: 100%; background: var(--green); border-radius: 4px;
    transition: width 0.4s var(--ease-out);
}
.mv-bar-pct {
    font-size: 0.65rem; font-weight: 800; color: var(--green);
    text-align: center; margin-top: 4px;
}

/* MV item progress (X/4 format) */
.mv-item-progress { display: flex; align-items: center; gap: 6px; justify-content: center; }
.mv-item-bar {
    flex: 1; max-width: 50px; height: 5px;
    border-radius: 3px; background: rgba(255,255,255,0.08); overflow: hidden;
}
body.light .mv-item-bar { background: rgba(0,0,0,0.08); }
.mv-item-fill { height: 100%; border-radius: 3px; transition: width 0.3s; background: var(--text-muted); }
.mv-item-fill.green { background: var(--green); }
.mv-item-fill.amber { background: var(--amber); }
.mv-item-count { font-size: 0.72rem; font-weight: 800; min-width: 24px; text-align: center; }
.mv-item-count.green { color: var(--green); }
.mv-item-count.amber { color: var(--amber); }

.mv-issue-tag {
    display: inline-block; padding: 2px 6px; margin: 1px 2px;
    font-size: 0.65rem; font-weight: 600; border-radius: 4px;
    background: rgba(255,255,255,0.05);
}

/* TIV Fleet Assignment in MV */
.tiv-assign-row {
    display: flex; align-items: center; gap: 12px;
    padding: 8px 16px; border-bottom: 1px solid var(--border-subtle);
    background: rgba(46,204,113,0.03);
}
.tiv-fleet-assign {
    flex: 1; padding: 10px 12px; border-radius: 10px;
    border: 1px solid var(--border-subtle); background: var(--bg-card);
    color: var(--text-primary); font-size: 0.88rem; font-weight: 600;
    cursor: pointer; outline: none;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.tiv-fleet-assign:focus { border-color: var(--green); box-shadow: 0 0 0 2px rgba(46,204,113,0.15); }
body.light .tiv-fleet-assign { background: #fff; }
.tiv-assign-label {
    font-size: 0.82rem; font-weight: 700; color: var(--green);
}

/* Light mode MV */
body.light .mv-table thead th { background: rgba(0,0,0,0.04); }
body.light .mv-table tbody tr:hover { background: rgba(46,204,113,0.06); }
body.light .mv-inline-bar { background: rgba(0,0,0,0.08); }
body.light .mv-row-val.date-val { color: #b8860b; }

/* ── STICKY LEFT LABEL COLUMN (MV & TIV tables on mobile) ────── */
@media (max-width: 768px) {
    .mv-table .mv-label-col,
    .mv-table .mv-row-label {
        position: sticky;
        left: 0;
        z-index: 10;
        background: #0c0c1a;
        box-shadow: 3px 0 8px rgba(0,0,0,0.4);
    }
    .mv-table thead .mv-label-col {
        background: #0a0a16;
        z-index: 11;
    }
    .mv-table tbody tr:hover .mv-row-label {
        background: #111122;
    }
    body.light .mv-table .mv-row-label {
        background: #ffffff;
        box-shadow: 3px 0 8px rgba(0,0,0,0.08);
    }
    body.light .mv-table thead .mv-label-col {
        background: #f3f4f6;
        box-shadow: 3px 0 8px rgba(0,0,0,0.08);
    }
    body.light .mv-table tbody tr:hover .mv-row-label {
        background: #f0fdf4;
    }
}

/* ── EDIT MODE TOGGLE ────────────────────────────────────────── */
.edit-mode-toggle {
    display: flex; align-items: center; gap: 8px;
    padding: 4px 12px; border-radius: var(--radius-pill);
    background: rgba(59,130,246,0.08);
    border: 1px solid rgba(59,130,246,0.2);
    cursor: pointer; font-size: 0.7rem; font-weight: 700;
    color: var(--text-secondary);
    transition: var(--transition);
    -webkit-user-select: none;
    user-select: none;
    white-space: nowrap;
}
.edit-mode-toggle:hover {
    background: rgba(59,130,246,0.15);
    border-color: rgba(59,130,246,0.4);
}
.edit-mode-toggle.active {
    background: rgba(59,130,246,0.15);
    border-color: var(--blue);
    color: var(--blue);
}
.edit-mode-toggle .toggle-dot {
    width: 28px; height: 16px;
    border-radius: 8px;
    background: rgba(255,255,255,0.15);
    position: relative;
    transition: background 0.2s;
}
.edit-mode-toggle .toggle-dot::after {
    content: '';
    position: absolute; top: 2px; left: 2px;
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--text-muted);
    transition: transform 0.2s, background 0.2s;
}
.edit-mode-toggle.active .toggle-dot {
    background: rgba(59,130,246,0.3);
}
.edit-mode-toggle.active .toggle-dot::after {
    transform: translateX(12px);
    background: var(--blue);
}
body.light .edit-mode-toggle {
    background: rgba(59,130,246,0.06);
    border-color: rgba(59,130,246,0.15);
}
body.light .edit-mode-toggle.active {
    background: rgba(59,130,246,0.1);
    border-color: #3b82f6;
    color: #2563eb;
}

/* ── EDIT MODE GATING — hide indicators unless edit-mode on body ── */
/* Default: editable-field has no visible indicators */
.editable-field {
    border-bottom-color: transparent !important;
}
.editable-field::after {
    display: none !important;
}
.editable-field:hover {
    background: none;
    border-bottom-color: transparent;
}
/* When edit mode is ON, show the dashed indicators */
body.edit-mode .editable-field {
    border-bottom: 1px dashed rgba(59,130,246,0.3) !important;
    cursor: pointer;
}
body.edit-mode .editable-field::after {
    display: block !important;
}
body.edit-mode .editable-field:hover {
    border-bottom-color: var(--blue) !important;
    background: rgba(59,130,246,0.06);
    border-radius: 4px;
    padding: 1px 4px;
    margin: -1px -4px;
}
body.edit-mode .editable-field:hover::after { opacity: 0.8; }

/* Also gate mv-admin-edit and tiv-editable */
.mv-admin-edit {
    border-bottom-color: transparent !important;
    cursor: default;
}
.mv-admin-edit:hover {
    border-bottom-color: transparent;
    background: none;
}
body.edit-mode .mv-admin-edit {
    cursor: pointer;
    border-bottom: 1px dashed rgba(59,130,246,0.5) !important;
}
body.edit-mode .mv-admin-edit:hover {
    border-bottom-color: var(--blue) !important;
    background: rgba(59,130,246,0.08);
}
.tiv-editable {
    border-bottom-color: transparent !important;
    cursor: default;
}
body.edit-mode .tiv-editable {
    cursor: pointer;
    border-bottom: 1px dashed rgba(59,130,246,0.5) !important;
}
body.edit-mode .tiv-editable:hover {
    border-bottom-color: var(--blue) !important;
    background: rgba(59,130,246,0.08);
}

/* MV edit hint hidden unless edit mode */
.mv-edit-hint { display: none; }
body.edit-mode .mv-edit-hint {
    display: inline;
    font-size: 0.65rem; font-weight: 400; color: var(--blue);
    opacity: 0.7; margin-left: 8px; letter-spacing: 0.02em;
}

/* ── MOBILE RESPONSIVE FIXES ─────────────────────────────────── */
@media (max-width: 480px) {
    .app-main { padding: 10px 8px calc(68px + var(--safe-bottom)); }
    .header-content { padding: 8px 10px; }
    .header-icon { width: 32px; height: 32px; }
    .header-title { font-size: 0.78rem; }
    .header-by { font-size: 0.68rem; }
    .header-subtitle { font-size: 0.58rem; letter-spacing: 1px; }
    .header-brand { gap: 8px; }

    .fleet-list { gap: 10px; }

    .card-inner { padding: 10px 10px 8px; }
    .card-top { margin-bottom: 8px; }
    .card-fleet-name { font-size: 0.92rem; }
    .card-well-name { font-size: 0.7rem; }
    .card-order-label { font-size: 0.55rem; }
    .card-wells-mini { gap: 4px; margin-bottom: 8px; }
    .mini-well { gap: 4px; }
    .mini-well-label { min-width: 16px; font-size: 0.6rem; }
    .mini-well-pct { font-size: 0.55rem; min-width: 24px; }
    .mini-well-bar { height: 6px; }

    .card-metrics { gap: 0; }
    .card-metrics .metric { padding: 6px 0; }
    .card-metrics .metric-value { font-size: 0.9rem; }
    .card-metrics .metric-label { font-size: 0.52rem; letter-spacing: 0.3px; }

    .card-footer { padding: 7px 10px; }
    .card-timestamp { font-size: 0.62rem; }

    .issue-summary { gap: 4px; padding: 4px 0; }
    .issue-tag { padding: 3px 6px; font-size: 0.62rem; }

    .status-badge { font-size: 0.58rem; padding: 3px 8px; gap: 4px; }
    .status-dot { width: 5px; height: 5px; }

    .inline-foreman { padding: 8px 10px 10px; }
    .inline-well-toggles { gap: 4px; margin-bottom: 8px; }
    .inline-well-toggle { padding: 6px 2px; min-height: 42px; border-width: 1.5px; }
    .inline-wt-code { font-size: 0.85rem; }
    .inline-wt-sub { font-size: 0.52rem; }
    .inline-stage-row { gap: 8px; }
    .inline-stage-big { font-size: 1.8rem; }
    .inline-stage-sub { font-size: 0.6rem; margin: 2px 0 4px; }
    .inline-btn { width: 50px; height: 50px; border-radius: 12px; }
    .inline-btn svg { width: 22px; height: 22px; }

    .issue-selector { gap: 3px; padding: 4px 0; }
    .issue-btn { padding: 2px 7px; font-size: 0.52rem; }

    .card-checkin-bar { padding: 6px 10px; }
    .card-checkin-who { font-size: 0.62rem; }
    .card-switch-btn { font-size: 0.58rem; padding: 3px 8px; }

    .detail-hero { padding: 14px; }
    .detail-fleet-name { font-size: 1.1rem; }
    .detail-progress-num { font-size: 2rem; }
    .detail-section { padding: 12px; margin-bottom: 10px; }
    .detail-section-title { font-size: 0.65rem; margin-bottom: 10px; }
    .detail-metrics-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
    .detail-metric-card { padding: 8px; }
    .detail-metric-label { font-size: 0.58rem; }
    .detail-metric-value { font-size: 1rem; }

    .mv-section-title { font-size: 0.82rem; letter-spacing: 1px; }
    .mv-table { font-size: 0.7rem; }
    .mv-col-num { font-size: 0.88rem; }
    .mv-col-site { font-size: 0.58rem; }
    .mv-row-label { padding: 5px 6px; font-size: 0.62rem; }
    .mv-row-val { padding: 5px 6px; font-size: 0.68rem; }
    .mv-row-val.date-val { font-size: 0.62rem; }
    .mv-issue-tag { font-size: 0.55rem; padding: 1px 4px; }

    .screen-header { gap: 6px; margin-bottom: 14px; min-height: 36px; }
    .screen-title { font-size: 0.95rem; }

    .rigup-fleet-header { padding: 10px 12px; }
    .rigup-item-row { padding: 8px 10px; }

    .edit-mode-toggle { font-size: 0.6rem; padding: 3px 8px; gap: 5px; }
    .edit-mode-toggle .toggle-dot { width: 22px; height: 13px; }
    .edit-mode-toggle .toggle-dot::after { width: 9px; height: 9px; }
    .edit-mode-toggle.active .toggle-dot::after { transform: translateX(9px); }

    .fleet-card, .detail-section, .detail-hero, .rigup-fleet-card {
        max-width: 100%; overflow: hidden;
    }

    .btn-icon { width: 32px; height: 32px; }
    .btn-icon svg { width: 17px; height: 17px; }

    .tab-bar { height: 54px; }
    .tab-item { font-size: 0.55rem; gap: 2px; }
    .tab-item svg { width: 18px; height: 18px; }

    .btn-add { font-size: 0.72rem; padding: 6px 12px; }
    .btn-add svg { width: 13px; height: 13px; }

    .form-card { padding: 16px 14px; }
    .form-group label { font-size: 0.72rem; }
    .form-group input, .form-group select { padding: 9px 10px; font-size: 0.82rem; }

    .foreman-fleet-name { font-size: 1.05rem; }
    .foreman-site-name { font-size: 0.7rem; }
    .foreman-fleet-summary { padding: 8px; gap: 4px; margin-bottom: 10px; }
    .foreman-summary-val { font-size: 1.1rem; }
    .foreman-summary-lbl { font-size: 0.52rem; }
    .foreman-wells-grid { gap: 6px; margin-bottom: 10px; }
    .foreman-well-card { padding: 8px; }
    .foreman-well-card-code { font-size: 0.75rem; }
    .foreman-well-card-pct { font-size: 0.75rem; }
    .foreman-well-card-stats { font-size: 0.6rem; }
    .foreman-well-card .integrated-bar { height: 5px; }
    .foreman-update-card { padding: 14px 12px; margin-bottom: 10px; }
    .foreman-update-card-title { font-size: 0.68rem; margin-bottom: 8px; }
    .foreman-stage-display { padding: 10px 8px; margin-bottom: 10px; }
    .foreman-stage-label { font-size: 0.65rem; margin-bottom: 4px; }
    .foreman-stage-big { font-size: 2.6rem; }
    .foreman-stage-sub { font-size: 0.7rem; margin-bottom: 6px; }
    .foreman-progress-bar { height: 6px; }
    .foreman-controls { gap: 8px; margin-bottom: 8px; }
    .foreman-btn { min-height: 56px; border-radius: 14px; }
    .foreman-btn svg { width: 26px; height: 26px; }
    .foreman-update-card .integrated-bar { height: 10px; }
    .foreman-update-card .integrated-seg { border-radius: 1px; }
    .foreman-stage-bar-section { margin-top: 10px; padding-top: 10px; }
    .foreman-stage-bar-label { font-size: 0.6rem; margin-bottom: 6px; }
    .foreman-issue-sel { padding: 6px 0 2px; }
    .foreman-issue-sel .issue-btn { padding: 4px 8px; font-size: 0.55rem; }
}

@media (max-width: 360px) {
    .app-main { padding: 8px 6px calc(64px + var(--safe-bottom)); }
    .header-content { padding: 6px 8px; }
    .header-icon { width: 28px; height: 28px; }
    .header-title { font-size: 0.72rem; }
    .header-by { font-size: 0.62rem; }
    .header-subtitle { font-size: 0.52rem; }

    .card-inner { padding: 8px 8px 6px; }
    .card-fleet-name { font-size: 0.85rem; }
    .card-top { flex-direction: column; gap: 4px; }
    .card-top-right { align-self: flex-end; }
    .card-metrics .metric-value { font-size: 0.82rem; }

    .foreman-stage-big { font-size: 2.2rem; }
    .foreman-summary-val { font-size: 0.95rem; }
    .foreman-well-card { padding: 6px; }
    .foreman-well-card-code { font-size: 0.7rem; }
    .foreman-well-card-pct { font-size: 0.7rem; }
    .foreman-update-card { padding: 10px 8px; }
    .foreman-stage-display { padding: 8px 6px; }
    .detail-metrics-grid { grid-template-columns: repeat(2, 1fr); }
    .well-progress-grid { grid-template-columns: 1fr; }

    .inline-btn { width: 44px; height: 44px; }
    .inline-btn svg { width: 20px; height: 20px; }
    .inline-stage-big { font-size: 1.5rem; }
    .inline-well-toggle { padding: 4px 2px; min-height: 36px; }
    .inline-wt-code { font-size: 0.75rem; }

    .tab-bar { height: 50px; }
    .tab-item { font-size: 0.5rem; }
    .tab-item svg { width: 16px; height: 16px; }

    .btn-icon { width: 28px; height: 28px; }
    .btn-icon svg { width: 15px; height: 15px; }
    .edit-mode-toggle { font-size: 0; gap: 0; padding: 3px 6px; }
    .edit-mode-toggle .toggle-dot { width: 20px; height: 12px; }
    .edit-mode-toggle .toggle-dot::after { width: 8px; height: 8px; }
    .edit-mode-toggle.active .toggle-dot::after { transform: translateX(8px); }
}

/* ── TIV SITE SPECIFIC ─────────────────────────────────────────── */
.tiv-opened-toggle {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.tiv-opened-toggle.tiv-opened-yes {
    background: var(--green-dim);
    color: var(--green-bright);
    border-color: var(--green);
}
.tiv-opened-toggle.tiv-opened-no {
    background: var(--red-dim);
    color: var(--red);
    border-color: rgba(239,68,68,0.3);
}
.tiv-opened-toggle:disabled { opacity: 0.5; cursor: not-allowed; }

.rigup-combined-pct {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--green-bright);
}

.rigup-combined-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.rigup-combined-bar {
    height: 6px;
    background: rgba(255,255,255,0.08);
    border-radius: 3px;
    margin: 8px 0 12px;
    overflow: hidden;
}
.rigup-combined-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--green), var(--green-bright));
    border-radius: 3px;
    transition: width 0.4s var(--ease-out);
}

.rigup-footer {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border-subtle);
    font-size: 0.75rem;
    color: var(--text-muted);
}
.rigup-footer strong { color: var(--text-secondary); }

/* Light mode TIV overrides */
body.light .rigup-combined-bar { background: rgba(0,0,0,0.06); }
body.light .tiv-opened-toggle.tiv-opened-yes { color: #16a34a; }
body.light .tiv-opened-toggle.tiv-opened-no { color: #dc2626; }
body.light .rigup-combined-pct { color: #16a34a; }
body.light .rigup-footer { border-top-color: rgba(0,0,0,0.08); }

/* ── PRIVACY DISCLOSURE POPUP ──────────────────────────────────── */
#privacyOverlay {
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(0,0,0,0.55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.3s ease;
    padding: 20px;
}
#privacyOverlay.show { opacity: 1; }
.privacy-modal {
    background: var(--bg-card); border-radius: 16px;
    padding: 28px 24px; max-width: 380px; width: 100%;
    text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,0.3);
    transform: translateY(20px); transition: transform 0.3s ease;
}
#privacyOverlay.show .privacy-modal { transform: translateY(0); }
.privacy-icon {
    width: 56px; height: 56px; margin: 0 auto 16px;
    background: linear-gradient(135deg, #2dd4bf, #0ea5e9);
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    color: #fff;
}
.privacy-title {
    font-size: 1.15rem; font-weight: 800; margin: 0 0 12px;
    color: var(--text-primary);
}
.privacy-text {
    font-size: 0.82rem; line-height: 1.5; color: var(--text-secondary);
    margin: 0 0 10px;
}
.privacy-btn {
    display: inline-block; margin-top: 10px;
    padding: 10px 36px; font-size: 0.85rem; font-weight: 700;
    border: none; border-radius: 10px; cursor: pointer;
    background: linear-gradient(135deg, #2dd4bf, #0ea5e9);
    color: #fff; letter-spacing: 0.3px;
    transition: transform 0.15s, box-shadow 0.15s;
}
.privacy-btn:hover { transform: scale(1.04); box-shadow: 0 4px 14px rgba(13,165,233,0.35); }

/* ── STAGE ISSUE TRACKING ──────────────────────────────────────── */

/* Issue Selector — compact toggle chips */
.issue-selector {
    display: flex; flex-wrap: wrap; gap: 5px;
    padding: 6px 0; justify-content: center;
}
.foreman-issue-sel { padding: 10px 0 4px; }
.issue-btn {
    padding: 3px 9px; font-size: 0.6rem; font-weight: 700;
    border: 1px solid var(--border-subtle); border-radius: var(--radius-pill);
    background: transparent; color: var(--text-muted);
    cursor: pointer; transition: all 0.15s; text-transform: uppercase;
    letter-spacing: 0.3px; line-height: 1.4;
}
.issue-btn:active { transform: scale(0.93); }
.issue-btn.active { color: #fff; border-color: transparent; }
.issue-btn.issue-screen_out { border-color: rgba(239,68,68,0.25); }
.issue-btn.issue-screen_out.active { background: #ef4444; }
.issue-btn.issue-operational_issue { border-color: rgba(249,115,22,0.25); }
.issue-btn.issue-operational_issue.active { background: #f97316; }
.issue-btn.issue-below_80_percent { border-color: rgba(234,179,8,0.25); }
.issue-btn.issue-below_80_percent.active { background: #eab308; color: #1a1a2e; }
.issue-btn.issue-other_issue { border-color: rgba(139,92,246,0.25); }
.issue-btn.issue-other_issue.active { background: #8b5cf6; }
body.light .issue-btn { color: var(--text-muted); border-color: rgba(0,0,0,0.1); }
body.light .issue-btn.active { color: #fff; }
body.light .issue-btn.issue-below_80_percent.active { color: #1a1a2e; }

/* Segmented Stage Bar (legacy) */
.stage-bar-wrap { padding: 4px 0 6px; }
.stage-bar {
    display: flex; gap: 1px; height: 10px; border-radius: 3px; overflow: hidden;
}
.stage-seg {
    flex: 1; min-width: 2px; border-radius: 1px;
    cursor: default; transition: transform 0.1s, opacity 0.1s;
    position: relative;
}
.stage-seg:hover { transform: scaleY(1.4); z-index: 2; opacity: 0.85; }
@media (max-width: 600px) { .stage-bar { height: 12px; } .stage-seg { min-width: 3px; } }

/* Integrated Segmented Progress Bar */
.integrated-bar-wrap { padding: 2px 0; overflow: hidden; width: 100%; max-width: 100%; box-sizing: border-box; }
.integrated-bar {
    display: flex; gap: 1px; height: 10px; border-radius: 4px; overflow: hidden;
    background: var(--bg-card); width: 100%; max-width: 100%;
}
.integrated-seg {
    flex: 1; min-width: 2px; border-radius: 1px;
    cursor: default; transition: transform 0.15s, opacity 0.15s;
    position: relative;
}
.integrated-seg:hover { transform: scaleY(1.5); z-index: 2; opacity: 0.85; }
@media (max-width: 600px) { .integrated-bar { height: 12px; } .integrated-seg { min-width: 3px; } }

/* Integrated bar inside mini-well row (replaces old green fill bar) */
.mini-well-bar .integrated-bar { height: 8px; border-radius: 4px; }
.mini-well-bar .integrated-seg { border-radius: 1px; }
/* Hide the default green fill + background when integrated bar is loaded */
.mini-well-bar:has(.integrated-bar) .mini-well-fill { display: none; }
.mini-well-bar:has(.integrated-bar) { background: transparent; }

/* Integrated bar inside foreman well cards */
.foreman-well-card .integrated-bar-wrap { overflow: hidden; width: 100%; max-width: 100%; }
.foreman-well-card .integrated-bar { height: 6px; width: 100%; max-width: 100%; }

/* Integrated bar inside foreman update card */
.foreman-update-card .integrated-bar { height: 12px; border-radius: 5px; }
.foreman-update-card .integrated-seg { border-radius: 2px; }

/* Integrated bar inside admin detail well cards */
.well-progress-card .integrated-bar { height: 10px; border-radius: 4px; width: 100%; max-width: 100%; }
.well-progress-card .integrated-bar-wrap { padding: 4px 0; overflow: hidden; width: 100%; max-width: 100%; }

/* Issue Summary Tags */
.issue-summary { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 0; overflow: hidden; }
.issue-tag {
    padding: 4px 8px; font-size: 0.72rem; font-weight: 600;
    background: rgba(255,255,255,0.06); border-radius: 6px;
    color: var(--text-secondary);
}
body.light .issue-tag { background: rgba(0,0,0,0.04); }

/* MV Issue Tags */
.mv-issue-tag {
    display: inline-block; padding: 2px 5px; margin: 1px;
    font-size: 0.62rem; font-weight: 600; border-radius: 4px;
    background: rgba(255,255,255,0.06); color: var(--text-secondary);
}
body.light .mv-issue-tag { background: rgba(0,0,0,0.04); }

/* Admin Detail Stage Wells */
.detail-stage-well {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 6px;
}
.detail-stage-well-label {
    font-size: 0.72rem; font-weight: 700; min-width: 56px;
    color: var(--text-secondary);
}
.detail-stage-well .stage-bar { flex: 1; }

/* ── INLINE EDIT SYSTEM ──────────────────────────────────────── */
.editable-field {
    cursor: pointer;
    position: relative;
    border-bottom: 1px dashed rgba(59,130,246,0.3);
    transition: var(--transition);
    padding-bottom: 1px;
}
.editable-field:hover {
    border-bottom-color: var(--blue);
    background: rgba(59,130,246,0.06);
    border-radius: 4px;
    padding: 1px 4px;
    margin: -1px -4px;
}
.editable-field::after {
    content: '✎';
    position: absolute;
    right: -14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.6rem;
    color: var(--blue);
    opacity: 0;
    transition: opacity 0.2s ease;
}
.editable-field:hover::after { opacity: 0.8; }

.editable-field.saving {
    opacity: 0.6;
    pointer-events: none;
}

.inline-edit-input {
    background: var(--bg-input);
    border: 1.5px solid var(--blue);
    border-radius: 6px;
    color: var(--text-primary);
    font: inherit;
    font-size: inherit;
    padding: 2px 6px;
    width: 100%;
    min-width: 60px;
    max-width: 200px;
    outline: none;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
    animation: editPulse 0.3s ease;
}
.inline-edit-input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 4px rgba(59,130,246,0.2);
}
@keyframes editPulse {
    0% { transform: scale(0.95); opacity: 0.5; }
    100% { transform: scale(1); opacity: 1; }
}

body.light .inline-edit-input {
    background: #fff;
    border-color: #3b82f6;
    color: #1e293b;
}
body.light .editable-field:hover {
    background: rgba(59,130,246,0.04);
}

/* ── FLEET ORDER ASSIGNMENT DROPDOWN ─────────────────────────── */
.fleet-assign-select {
    display: none; /* hidden by default, shown in edit mode */
    padding: 10px 28px 10px 12px;
    font-size: 0.78rem;
    font-weight: 700;
    border: 1px solid rgba(59,130,246,0.25);
    border-radius: 10px;
    background: var(--bg-card);
    color: var(--text-primary);
    cursor: pointer;
    min-width: 100px;
    min-height: 44px;
    outline: none;
    transition: border-color 0.2s;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236b7280'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
body.edit-mode .fleet-assign-select {
    display: inline-block;
}
.fleet-assign-select:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 2px rgba(59,130,246,0.15);
}
body.light .fleet-assign-select {
    background-color: #fff;
    border-color: rgba(0,0,0,0.12);
    color: #1e293b;
}


/* ── FLEET ORDER LABEL ───────────────────────────────────────── */
.card-order-label {
    font-size: 0.62rem;
    font-weight: 700;
    color: var(--blue);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-top: 2px;
    opacity: 0.85;
}
body.light .card-order-label { color: #2563eb; }

/* Card top-right grouping */
.card-top-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    max-width: 50%;
}

/* ── MV ADMIN INLINE EDIT (gated by edit-mode, see above) ────── */
/* Base styles for mv-tiv-assign dropdown (always visible) */
.mv-tiv-assign {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid rgba(59,130,246,0.25);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 0.78rem;
    cursor: pointer;
    min-width: 100px;
    min-height: 44px;
    transition: border-color 0.2s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.mv-tiv-assign:hover, .mv-tiv-assign:focus {
    border-color: var(--blue);
    outline: none;
}
body.light .mv-tiv-assign {
    background: #fff;
    border-color: rgba(0,0,0,0.15);
    color: #1e293b;
}

/* ══════════════════════════════════════════════════════════════════════════
   AUDIT LOG — Settings Page
   ══════════════════════════════════════════════════════════════════════════ */

/* Period filter buttons */
.audit-period-btn {
    padding: 6px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
}
.audit-period-btn:hover { border-color: var(--primary); color: var(--primary); }
.audit-period-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* Desktop table */
.audit-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 10px;
    border: 1px solid var(--border-color);
}
.audit-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
    white-space: nowrap;
}
.audit-table thead th {
    padding: 10px 10px;
    text-align: left;
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
    background: rgba(255,255,255,0.02);
    position: sticky;
    top: 0;
    z-index: 1;
}
.audit-table tbody tr {
    border-bottom: 1px solid var(--border-subtle);
    transition: background 0.12s;
}
.audit-table tbody tr:hover { background: rgba(255,255,255,0.03); }
.audit-table tbody td {
    padding: 8px 10px;
    vertical-align: top;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Action type badge */
.audit-action-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
}
.audit-action-badge.login_success { background: rgba(16,185,129,0.15); color: var(--green); }
.audit-action-badge.login_failure { background: rgba(239,68,68,0.15); color: var(--red); }
.audit-action-badge.stage_increment { background: rgba(59,130,246,0.15); color: var(--blue); }
.audit-action-badge.stage_decrement { background: rgba(251,191,36,0.15); color: var(--amber); }
.audit-action-badge.edit_field { background: rgba(139,92,246,0.15); color: #a78bfa; }
.audit-action-badge.create_user,
.audit-action-badge.update_user,
.audit-action-badge.deactivate_user { background: rgba(236,72,153,0.15); color: #f472b6; }
.audit-action-badge.settings_change { background: rgba(245,158,11,0.15); color: var(--amber); }

/* Before → After styling */
.audit-diff {
    font-size: 0.72rem;
    white-space: normal;
    word-break: break-word;
    max-width: 200px;
}
.audit-diff .old { color: var(--red); text-decoration: line-through; opacity: 0.7; }
.audit-diff .arrow { color: var(--text-secondary); margin: 0 4px; }
.audit-diff .new { color: var(--green); font-weight: 600; }

/* Role badge */
.audit-role {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(255,255,255,0.06);
}

/* Mobile cards — hidden on desktop */
.audit-cards-wrap { display: none; }

.audit-card {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 8px;
}
.audit-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}
.audit-card-time {
    font-size: 0.68rem;
    color: var(--text-secondary);
    font-weight: 600;
}
.audit-card-user {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-primary);
}
.audit-card-body {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 10px;
    font-size: 0.74rem;
}
.audit-card-label {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.68rem;
    text-transform: uppercase;
}
.audit-card-value {
    color: var(--text-primary);
    word-break: break-word;
}
.audit-card-context {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--border-subtle);
    font-size: 0.68rem;
    color: var(--text-secondary);
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Empty state */
.audit-empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}
.audit-empty svg { margin-bottom: 8px; opacity: 0.4; }

/* Pagination */
.audit-page-btn {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.12s;
}
.audit-page-btn:hover { border-color: var(--primary); color: var(--primary); }
.audit-page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.audit-page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Light mode overrides */
body.light .audit-table-wrap { border-color: rgba(0,0,0,0.1); }
body.light .audit-table thead th { background: rgba(0,0,0,0.03); color: #475569; border-color: rgba(0,0,0,0.1); }
body.light .audit-table tbody tr:hover { background: rgba(0,0,0,0.02); }
body.light .audit-card { background: #fff; border-color: rgba(0,0,0,0.08); }
body.light .audit-period-btn { background: #fff; border-color: rgba(0,0,0,0.15); color: #475569; }
body.light .audit-period-btn.active { background: var(--primary); color: #fff; }
body.light .audit-role { background: rgba(0,0,0,0.05); }

/* ── Mobile responsive ───────────────────────────────────────── */
@media (max-width: 768px) {
    .audit-table-wrap { display: none; }
    .audit-cards-wrap { display: block; }
}

/* ── SYSTEM BACKUP ───────────────────────────────────────────── */
.backup-desc {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin: 0 0 16px;
    line-height: 1.5;
}
.backup-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.backup-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 20px;
    font-size: 0.88rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    color: #fff;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}
.backup-btn:active { transform: scale(0.97); }
.backup-btn.loading {
    opacity: 0.65;
    pointer-events: none;
}

.backup-btn-json {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
    box-shadow: 0 2px 10px rgba(5, 150, 105, 0.25);
}
.backup-btn-json:hover { box-shadow: 0 4px 16px rgba(5, 150, 105, 0.4); }

.backup-btn-excel {
    background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
    box-shadow: 0 2px 10px rgba(37, 99, 235, 0.25);
}
.backup-btn-excel:hover { box-shadow: 0 4px 16px rgba(37, 99, 235, 0.4); }

.backup-status {
    margin-top: 12px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    text-align: center;
    min-height: 1.2em;
}
.backup-status.success { color: var(--green); font-weight: 600; }
.backup-status.error { color: #ef4444; font-weight: 600; }

/* Light mode */
body.light .backup-desc { color: #64748b; }

/* ══════════════════════════════════════════════════════════════════════════
   SETTINGS HUB — Section-based navigation
   ══════════════════════════════════════════════════════════════════════════ */

.settings-home {
    animation: settingsFadeIn 0.25s ease;
}
.settings-tiles {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ── Settings Tile Button ─────────────────────────────────────── */
.settings-tile {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 16px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    text-align: left;
    color: var(--text-primary);
}
.settings-tile:hover {
    border-color: var(--border-color);
    background: rgba(255,255,255,0.04);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.settings-tile:active {
    transform: scale(0.98);
    box-shadow: none;
}
.settings-tile-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.settings-tile-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.settings-tile-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
}
.settings-tile-desc {
    font-size: 0.72rem;
    color: var(--text-secondary);
    line-height: 1.3;
}
.settings-tile-arrow {
    flex-shrink: 0;
    color: var(--text-muted);
    opacity: 0.5;
    transition: transform 0.15s, opacity 0.15s;
}
.settings-tile:hover .settings-tile-arrow {
    opacity: 0.9;
    transform: translateX(2px);
}

/* ── Settings Sub-Panel ───────────────────────────────────────── */
.settings-panel {
    animation: settingsSlideIn 0.2s ease;
}
.settings-panel-back {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    padding: 8px 4px;
    margin-bottom: 12px;
    border-radius: 8px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition: all 0.15s;
}
.settings-panel-back:hover {
    background: rgba(99,102,241,0.08);
}
.settings-panel-back:active {
    transform: scale(0.97);
}
.settings-panel-back svg {
    flex-shrink: 0;
}

/* ── Animations ───────────────────────────────────────────────── */
@keyframes settingsFadeIn {
    0% { opacity: 0; transform: translateY(8px); }
    100% { opacity: 1; transform: translateY(0); }
}
@keyframes settingsSlideIn {
    0% { opacity: 0; transform: translateX(16px); }
    100% { opacity: 1; transform: translateX(0); }
}

/* ── Light mode overrides ─────────────────────────────────────── */
body.light .settings-tile {
    background: #fff;
    border-color: rgba(0,0,0,0.08);
}
body.light .settings-tile:hover {
    background: #f8fafc;
    border-color: rgba(0,0,0,0.12);
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}
body.light .settings-tile-title { color: #1e293b; }
body.light .settings-tile-desc { color: #64748b; }
body.light .settings-tile-arrow { color: #94a3b8; }
body.light .settings-panel-back { color: var(--primary); }
body.light .settings-panel-back:hover { background: rgba(99,102,241,0.06); }

/* ── Mobile: smaller tiles ────────────────────────────────────── */
@media (max-width: 480px) {
    .settings-tile { padding: 14px 12px; gap: 12px; border-radius: 12px; }
    .settings-tile-icon { width: 40px; height: 40px; border-radius: 10px; }
    .settings-tile-icon svg { width: 20px; height: 20px; }
    .settings-tile-title { font-size: 0.85rem; }
    .settings-tile-desc { font-size: 0.68rem; }
    .settings-panel-back { font-size: 0.78rem; padding: 6px 2px; margin-bottom: 10px; }
}
@media (max-width: 360px) {
    .settings-tile { padding: 12px 10px; gap: 10px; }
    .settings-tile-icon { width: 36px; height: 36px; border-radius: 9px; }
    .settings-tile-icon svg { width: 18px; height: 18px; }
    .settings-tile-title { font-size: 0.8rem; }
    .settings-tile-desc { font-size: 0.62rem; }
}

/* ══════════════════════════════════════════════════════════════════════════
   DAILY REPORTS — Settings Panel
   ══════════════════════════════════════════════════════════════════════════ */

.dr-section-title {
    margin: 0 0 4px;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}
.dr-desc {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin: 0 0 18px;
    line-height: 1.5;
}

/* ── Toggle Control Row ──────────────────────────────────────── */
.dr-control-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-subtle);
}
.dr-control-label { flex: 1; min-width: 0; }
.dr-control-title {
    display: block;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}
.dr-control-sub {
    display: block;
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-top: 2px;
    line-height: 1.3;
}

/* ── Toggle Switch ───────────────────────────────────────────── */
.dr-toggle {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
    cursor: pointer;
}
.dr-toggle input { opacity: 0; width: 0; height: 0; }
.dr-toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--border-color);
    border-radius: 26px;
    transition: background 0.25s;
}
.dr-toggle-slider::before {
    content: "";
    position: absolute;
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.25s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.dr-toggle input:checked + .dr-toggle-slider {
    background: var(--green);
}
.dr-toggle input:checked + .dr-toggle-slider::before {
    transform: translateX(22px);
}

/* ── Time Select ─────────────────────────────────────────────── */
.dr-select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
    min-width: 130px;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
}

/* ── Generate Now Button ─────────────────────────────────────── */
.dr-generate-row {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--border-subtle);
}
.dr-generate-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 20px;
    font-size: 0.9rem;
    font-weight: 700;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    color: #fff;
    background: linear-gradient(135deg, #0ea5e9 0%, #3b82f6 100%);
    box-shadow: 0 2px 12px rgba(14, 165, 233, 0.3);
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}
.dr-generate-btn:hover {
    box-shadow: 0 4px 18px rgba(14, 165, 233, 0.45);
    transform: translateY(-1px);
}
.dr-generate-btn:active { transform: scale(0.97); }
.dr-generate-btn:disabled {
    opacity: 0.65;
    pointer-events: none;
}

/* ── Status Messages ─────────────────────────────────────────── */
.dr-status {
    margin-top: 10px;
    font-size: 0.8rem;
    text-align: center;
    min-height: 1.4em;
    font-weight: 600;
    transition: all 0.2s;
}
.dr-status-pending { color: var(--amber); }
.dr-status-success { color: var(--green); }
.dr-status-error { color: #ef4444; }

/* ── Report History ──────────────────────────────────────────── */
.dr-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding-top: 14px;
    border-top: 1px solid var(--border-subtle);
    margin-bottom: 12px;
}
.dr-history-title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}
.dr-history-count {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
}
.dr-history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 4px;
}

/* ── Report Card ─────────────────────────────────────────────── */
.dr-report-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    transition: all 0.15s;
}
.dr-report-card:hover {
    border-color: var(--border-color);
    background: rgba(255,255,255,0.03);
}
.dr-report-info { flex: 1; min-width: 0; }
.dr-report-date {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
}
.dr-report-meta {
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}
.dr-report-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* ── Badges ──────────────────────────────────────────────────── */
.dr-badge {
    display: inline-flex;
    padding: 2px 7px;
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    line-height: 1.4;
}
.dr-badge-auto { background: rgba(14,165,233,0.15); color: #0ea5e9; }
.dr-badge-manual { background: rgba(139,92,246,0.15); color: #8b5cf6; }

/* ── Action Buttons ──────────────────────────────────────────── */
.dr-btn-download,
.dr-btn-delete {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.dr-btn-download:hover { color: var(--primary); border-color: var(--primary); background: rgba(99,102,241,0.08); }
.dr-btn-delete:hover { color: #ef4444; border-color: #ef4444; background: rgba(239,68,68,0.08); }

/* ── Empty State ─────────────────────────────────────────────── */
.dr-empty {
    text-align: center;
    padding: 28px 16px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    background: var(--bg-primary);
    border: 1px dashed var(--border-subtle);
    border-radius: 12px;
}
.dr-loading {
    text-align: center;
    padding: 20px;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

/* ── Light Mode ──────────────────────────────────────────────── */
body.light .dr-report-card {
    background: #fff;
    border-color: rgba(0,0,0,0.08);
}
body.light .dr-report-card:hover {
    background: #f8fafc;
    border-color: rgba(0,0,0,0.12);
}
body.light .dr-btn-download,
body.light .dr-btn-delete {
    background: #fff;
    border-color: rgba(0,0,0,0.1);
}
body.light .dr-empty {
    background: #fafafa;
    border-color: rgba(0,0,0,0.1);
}
body.light .dr-toggle-slider { background: #d1d5db; }
body.light .dr-select { background: #fff; border-color: rgba(0,0,0,0.15); }

/* ── Mobile ──────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .dr-control-row { padding: 12px 0; }
    .dr-control-title { font-size: 0.82rem; }
    .dr-select { min-width: 110px; font-size: 0.8rem; padding: 7px 10px; }
    .dr-generate-btn { padding: 12px 16px; font-size: 0.85rem; }
    .dr-report-card { padding: 10px 12px; border-radius: 10px; }
    .dr-report-date { font-size: 0.82rem; }
    .dr-report-meta { font-size: 0.68rem; }
    .dr-btn-download,
    .dr-btn-delete { width: 34px; height: 34px; border-radius: 8px; }
    .dr-history-list { max-height: 350px; }
}
@media (max-width: 360px) {
    .dr-control-title { font-size: 0.78rem; }
    .dr-control-sub { font-size: 0.66rem; }
    .dr-select { min-width: 95px; font-size: 0.76rem; }
    .dr-generate-btn { padding: 10px 12px; font-size: 0.82rem; border-radius: 10px; }
    .dr-report-card { padding: 8px 10px; gap: 8px; }
    .dr-btn-download,
    .dr-btn-delete { width: 30px; height: 30px; border-radius: 7px; }
    .dr-btn-download svg,
    .dr-btn-delete svg { width: 14px; height: 14px; }
}

/* ── TIV Delete Button ───────────────────────────── */
.tiv-delete-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 2px 6px;
    margin-left: 6px;
    border-radius: 4px;
    opacity: 0.5;
    transition: opacity 0.2s, background 0.2s;
    vertical-align: middle;
}
.tiv-delete-btn:hover {
    opacity: 1;
    background: rgba(239, 68, 68, 0.15);
}

/* ── Connection Status Indicator ─────────────────── */
.conn-status {
    position: fixed;
    bottom: 12px;
    left: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: var(--radius-pill);
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    z-index: 9999;
    box-shadow: var(--shadow-card);
    transition: all 0.3s ease;
}
.conn-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    flex-shrink: 0;
}
.conn-status.offline {
    border-color: rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.08);
}
.conn-badge {
    background: var(--green);
    color: #fff;
    font-size: 0.55rem;
    min-width: 16px;
    height: 16px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}
.conn-status.offline .conn-badge {
    background: #ef4444;
}

/* ── Issue Chip Active — New Issue Types ──────────── */
.issue-btn.issue-hp_leak { border-color: rgba(185,28,28,0.25); }
.issue-btn.issue-hp_leak.active { background: #b91c1c; }
.issue-btn.issue-blender_fail { border-color: rgba(249,115,22,0.25); }
.issue-btn.issue-blender_fail.active { background: #f97316; }
.issue-btn.issue-early_flush { border-color: rgba(234,179,8,0.25); }
.issue-btn.issue-early_flush.active { background: #eab308; color: #1a1a2e; }
.issue-btn.issue-ht_pressure { border-color: rgba(139,92,246,0.25); }
.issue-btn.issue-ht_pressure.active { background: #8b5cf6; }
.issue-btn.issue-surface_equip { border-color: rgba(100,116,139,0.25); }
.issue-btn.issue-surface_equip.active { background: #64748b; }
body.light .issue-btn.issue-early_flush.active { color: #1a1a2e; }

/* Enhanced selected state — glow + scale */
.issue-btn.active {
    box-shadow: 0 0 10px currentColor;
    transform: scale(1.08);
    font-weight: 800;
}

@media (max-width: 480px) {
    .conn-status { bottom: 8px; left: 8px; padding: 4px 8px; font-size: 0.55rem; }
}
