/* MojoMixer — visual styling matched to the QuickQuote project
   Mosquito Joe palette: navy #003366 + yellow #FDB913 + dark green accent
*/

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --navy:        #003366;
    --navy-dark:   #002347;
    --navy-light:  #1d4e8a;
    --yellow:      #FDB913;
    --yellow-dark: #e0a30b;
    --green:       #2f8f3e;
    --red:         #c0392b;
    --orange:      #e67e22;
    --ink:         #1f2a37;
    --ink-soft:    #4b5563;
    --ink-muted:   #6b7280;
    --line:        #e5e7eb;
    --line-soft:   #eef0f3;
    --bg:          #f4f6f9;
    --card:        #ffffff;
    /* Branding contrast helpers (overridden per-company in layout.py):
       --header-bg = header background, --on-header = text on it,
       --on-accent = text on the accent/--yellow color. */
    --header-bg:   var(--navy);
    --header-bg2:  var(--navy-dark);
    --on-header:   #ffffff;
    --on-accent:   var(--navy);
}

html, body { height: 100%; }
body {
    font-family: 'Open Sans','Segoe UI',Tahoma,Geneva,Verdana,sans-serif;
    background-color: var(--bg);
    color: var(--ink);
    line-height: 1.55;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--ink-muted); }
.small { font-size: 0.85rem; }
.bold  { font-weight: 700; }

/* ---------- Layout ---------- */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
    width: 100%;
}

main.container {
    background: white;
    margin: 2rem auto;
    padding: 2rem 2rem 2.5rem;
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(15,23,42,0.06), 0 4px 12px rgba(15,23,42,0.05);
    flex: 1;
}

/* ---------- Header / Nav ---------- */
header {
    background: linear-gradient(135deg, var(--header-bg) 0%, var(--header-bg2) 100%);
    color: var(--on-header);
    padding: 0.75rem 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.18);
    position: sticky; top: 0; z-index: 50;
}
/* Header uses 95% of the viewport — overrides the global 1280px cap */
header > .container {
    max-width: 95% !important;
    width: 95% !important;
    padding: 0 !important;
    margin: 0 auto;
}
header .header-content {
    display: flex !important;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: nowrap !important;     /* NEVER wrap to a second row */
    width: 100%;
    min-width: 0;                     /* allow children to shrink */
}
.brand {
    display: inline-flex; align-items: center; gap: 0.6rem;
    color: var(--on-header); text-decoration: none;
    font-weight: 800; font-size: 1.15rem;
    flex-shrink: 0;                   /* brand keeps its size */
    margin-right: 0.4rem;
}
.brand:hover { text-decoration: none; }
.brand-mark {
    display: inline-grid; place-items: center;
    width: 38px; height: 38px;
    background: var(--yellow); color: var(--on-accent);
    border-radius: 10px;
    font-weight: 800; font-size: 1.2rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.25);
}
.brand-logo {
    height: 38px; max-height: 38px; width: auto; max-width: 130px;
    border-radius: 8px; background: #fff; padding: 2px;
    object-fit: contain; flex-shrink: 0; display: block;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-sub  { font-size: 0.65rem; letter-spacing: 0.2em; color: var(--on-header);
              opacity: 0.85; font-weight: 700; text-transform: uppercase; margin-top: 2px; }

/* Superadmin acting-company switcher in the header */
.co-switch { flex-shrink: 0; margin-right: 0.3rem; }
.co-switch select {
    background: rgba(255,255,255,0.12); color: #fff;
    border: 2px solid rgba(255,255,255,0.3); border-radius: 999px;
    padding: 0.3rem 0.6rem; font-weight: 600; font-size: 0.8rem;
    max-width: 150px; cursor: pointer;
}
.co-switch select option { color: var(--ink); }

/* Color swatches (company branding preview) */
.swatch {
    display: inline-block; width: 22px; height: 22px;
    border-radius: 5px; border: 1px solid var(--line);
    vertical-align: middle; margin-right: 3px;
}
/* Two-up form rows (e.g. the color pickers) */
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
@media (max-width: 520px) { .form-grid-2 { grid-template-columns: 1fr; } }

header nav {
    display: flex;
    gap: 0.2rem;
    flex: 1 1 auto;              /* take all remaining space */
    flex-wrap: wrap;             /* wrap rather than scroll (dropdowns can't clip) */
    overflow: visible;           /* let dropdown menus escape the bar */
    min-width: 0;
    justify-content: center;     /* center the nav items in the middle */
}

/* ---------- Dropdown nav groups ---------- */
.nav-group { position: relative; display: inline-flex; }
.nav-trigger { cursor: default; user-select: none; }
.nav-trigger .caret { font-size: 0.7em; opacity: 0.85; margin-left: 1px; }
.nav-menu {
    display: none;
    position: absolute;
    top: 100%; left: 0;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(15,23,42,0.18);
    padding: 6px;
    min-width: 180px;
    z-index: 1000;
}
.nav-group:hover .nav-menu,
.nav-group:focus-within .nav-menu { display: block; }
.nav-item {
    display: block;
    padding: 0.5rem 0.8rem;
    color: var(--navy);
    border-radius: 8px;
    white-space: nowrap;
    font-weight: 600; font-size: 0.86rem;
}
.nav-item:hover { background: var(--yellow); color: var(--on-accent); text-decoration: none; }
.nav-item-active { background: #eef2f7; }
.nav-sep { height: 1px; background: var(--line); margin: 5px 6px; }
.nav-link {
    color: var(--on-header); text-decoration: none;
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    transition: background-color 0.15s ease, color 0.15s ease;
    font-weight: 600; font-size: 0.86rem;
    border: 2px solid transparent;
    flex-shrink: 0 !important;
    white-space: nowrap !important;
}
.nav-link:hover {
    background-color: var(--yellow);
    color: var(--on-accent);
    text-decoration: none;
}
.nav-link-active {
    background: var(--yellow);
    color: var(--on-accent);
}
.nav-link-logout {
    color: var(--on-header);
    border: 2px solid rgba(255,255,255,0.45);
    margin-left: 0.5rem;
}
.nav-link-logout:hover {
    background-color: white;
    color: var(--navy);
    border-color: white;
}

.user-chip {
    display: inline-flex; align-items: center; gap: 0.5rem;
    color: var(--on-header); padding: 0.3rem 0.7rem 0.3rem 0.3rem;
    border-radius: 999px; background: rgba(255,255,255,0.08);
    border: 2px solid rgba(255,255,255,0.15);
    transition: all 0.18s ease;
    flex-shrink: 0 !important;            /* never shrink the user chip */
    margin-left: 0.4rem;
}
.user-chip:hover { background: var(--yellow); color: var(--on-accent); text-decoration: none; }
.user-chip:hover .user-avatar { background: var(--navy); color: var(--on-header); }
.user-avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--yellow); color: var(--on-accent);
    display: grid; place-items: center;
    font-weight: 800; font-size: 0.85rem;
}
.user-name { font-weight: 600; font-size: 0.9rem; }

/* ---------- Footer ---------- */
/* Mirror the header so both ends of the page share the brand colors. */
footer {
    background: linear-gradient(135deg, var(--header-bg) 0%, var(--header-bg2) 100%);
    color: var(--on-header);
    text-align: center;
    padding: 1rem 0;
    font-size: 0.85rem;
}
footer .muted { color: color-mix(in srgb, var(--on-header) 70%, transparent); }
footer a      { color: color-mix(in srgb, var(--on-header) 85%, transparent); }

/* ---------- Page header (h1 row with actions) ---------- */
.page-head {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem;
}
.page-head h1 { font-size: 1.75rem; font-weight: 800; color: var(--navy); }
.page-head .subtitle { color: var(--ink-muted); font-size: 0.95rem; margin-top: 0.15rem; }
.page-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 0.45rem;
    padding: 0.6rem 1.2rem;
    border-radius: 999px;
    font-size: 0.9rem; font-weight: 700;
    text-decoration: none;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.18s ease;
    font-family: inherit;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary   { background: var(--yellow); color: var(--on-accent); border-color: var(--yellow); }
.btn-primary:hover { background: var(--yellow-dark); border-color: var(--yellow-dark); }
.btn-navy      { background: var(--navy); color: white; border-color: var(--navy); }
.btn-navy:hover { background: var(--navy-dark); }
.btn-secondary { background: white; color: var(--navy); border-color: var(--line); }
.btn-secondary:hover { background: #f0f3f7; border-color: var(--navy); }
.btn-danger    { background: var(--red); color: white; border-color: var(--red); }
.btn-danger:hover { background: #a83121; }
.btn-sm { padding: 0.35rem 0.85rem; font-size: 0.82rem; }
.btn-block { width: 100%; }

/* ---------- Cards ---------- */
.card {
    background: white;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 1px 2px rgba(15,23,42,0.04);
}
.card-tight { padding: 1rem; }
.card-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 0.85rem; padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--line-soft);
}
.card-title { font-weight: 700; color: var(--navy); font-size: 1rem; }
.card-sub   { color: var(--ink-muted); font-size: 0.82rem; }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) {
    .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ---------- Stat cards ---------- */
.stat {
    background: white;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 1.1rem 1.25rem;
    position: relative;
    overflow: hidden;
}
.stat::before {
    content: '';
    position: absolute; left: 0; top: 0; bottom: 0;
    width: 4px; background: var(--yellow);
}
.stat-label { color: var(--ink-muted); font-size: 0.82rem;
              text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.stat-value { font-size: 1.9rem; font-weight: 800; color: var(--navy); margin-top: 0.2rem; }
.stat-foot  { font-size: 0.78rem; color: var(--ink-muted); margin-top: 0.2rem; }
.stat.alert::before { background: var(--red); }
.stat.alert .stat-value { color: var(--red); }
.stat.ok::before { background: var(--green); }

/* ---------- Tables ---------- */
.table-wrap {
    background: white;
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
}
table.data {
    width: 100%; border-collapse: collapse;
}
table.data th {
    background: #f7f9fc;
    text-align: left;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-muted);
    font-weight: 700;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--line);
}
table.data td {
    padding: 0.85rem 1rem;
    border-top: 1px solid var(--line-soft);
    font-size: 0.92rem;
    color: var(--ink);
    vertical-align: middle;
}
table.data tbody tr:hover { background: #fafbfd; }
table.data tbody tr:first-child td { border-top: none; }
table.data .col-actions { text-align: right; }
.empty-row td {
    text-align: center; color: var(--ink-muted);
    padding: 2.5rem 1rem !important;
    font-style: italic;
}

/* ---------- Badges ---------- */
.badge {
    display: inline-block;
    padding: 0.18rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    background: #eef2f7; color: var(--ink-soft);
    text-transform: uppercase; letter-spacing: 0.04em;
}
.badge-yellow { background: #fff3cf; color: #92670b; }
.badge-navy   { background: #dde7f5; color: var(--navy); }
.badge-green  { background: #d6f0db; color: #1e6b2b; }
.badge-red    { background: #fadcd8; color: #8a2018; }
.badge-orange { background: #fde2c8; color: #9a4d11; }

/* ---------- Forms ---------- */
.form-row { margin-bottom: 1.1rem; }
.form-row label, label.field-label {
    display: block;
    font-weight: 700;
    color: var(--navy);
    margin-bottom: 0.35rem;
    font-size: 0.85rem;
}
.input, input[type=text], input[type=email], input[type=password],
input[type=number], input[type=date], textarea, select {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1.5px solid var(--line);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    background: white;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--navy);
    box-shadow: 0 0 0 3px rgba(0,51,102,0.12);
}
textarea { min-height: 80px; resize: vertical; }
.form-actions {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 1.5rem; padding-top: 1rem;
    border-top: 1px solid var(--line-soft);
    gap: 0.5rem; flex-wrap: wrap;
}
.form-actions .right { display: flex; gap: 0.5rem; }
.form-grid {
    display: grid; gap: 1rem;
    grid-template-columns: 1fr 1fr;
}
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }
.checkbox-row { display: inline-flex; align-items: center; gap: 0.5rem; }
.checkbox-row input { width: auto; }

/* ---------- Alerts ---------- */
.alert {
    padding: 0.85rem 1rem;
    border-radius: 10px;
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
    border-left: 4px solid;
}
.alert-success { background: #ebfaef; color: #1e6b2b; border-left-color: var(--green); }
.alert-error   { background: #fdecea; color: #8a2018; border-left-color: var(--red); }
.alert-info    { background: #e6f0fb; color: var(--navy); border-left-color: var(--navy); }

/* ---------- Login screen ---------- */
.public-body {
    background:
        radial-gradient(1100px 560px at 12% -10%, rgba(255,209,102,0.16), transparent 60%),
        radial-gradient(900px 520px at 112% 112%, rgba(255,255,255,0.08), transparent 55%),
        linear-gradient(135deg, var(--navy) 0%, var(--navy-dark) 100%);
    color: white;
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 1.5rem;
}
.login-card {
    position: relative;
    background: #fff;
    color: var(--ink);
    width: 100%; max-width: 400px;
    border-radius: 18px;
    padding: 2.5rem 2rem 2rem;
    box-shadow: 0 30px 70px -20px rgba(0,0,0,0.55), 0 2px 10px rgba(0,0,0,0.18);
    overflow: hidden;
}
.login-card::before {                 /* brand accent bar across the top */
    content: ""; position: absolute; top: 0; left: 0; right: 0; height: 5px;
    background: linear-gradient(90deg, var(--yellow), #ffb703);
}
.login-card .brand-row {
    display: flex; flex-direction: column; align-items: center;
    gap: 0.55rem; margin-bottom: 1.75rem;
}
.login-card .login-logo {
    display: block; width: 78%; max-width: 250px; height: auto; margin: 0 auto 0.15rem;
}
.login-card .brand-row .brand-mark {
    width: 72px; height: 72px; font-size: 2.1rem; border-radius: 18px;
    background: linear-gradient(135deg, var(--yellow), #ffb703);
    box-shadow: 0 12px 26px -8px rgba(255,183,3,0.65);
}
.login-card h1 {
    font-size: 1.5rem; color: var(--navy); font-weight: 800;
    letter-spacing: -0.01em; margin: 0;
}
.login-card .subtitle { color: var(--ink-muted); font-size: 0.9rem; margin-top: 0.12rem; }

/* Login form fields + button */
.login-card .form-row { margin-bottom: 1rem; }
.login-card label {
    display: block; font-size: 0.75rem; font-weight: 700; color: var(--navy);
    text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.35rem;
}
.login-card input[type="text"],
.login-card input[type="password"] {
    width: 100%; padding: 0.75rem 0.85rem; font-size: 1rem;
    border: 1.5px solid var(--line); border-radius: 10px; background: #f8fafc;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.login-card input[type="text"]:focus,
.login-card input[type="password"]:focus {
    outline: none; border-color: var(--yellow); background: #fff;
    box-shadow: 0 0 0 3px rgba(255,209,102,0.35);
}
.login-card .btn-block {
    margin-top: 0.5rem; padding: 0.8rem; font-size: 1.02rem; font-weight: 800;
    border-radius: 10px; box-shadow: 0 10px 20px -8px rgba(13,27,62,0.45);
    transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.login-card .btn-block:hover { transform: translateY(-1px); filter: brightness(1.03); }
.login-card .tech-hint {
    margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--line);
    text-align: center; font-size: 0.82rem; color: var(--ink-muted); line-height: 1.4;
}

/* ---------- Tank visualization (fleet + van detail) ---------- */
.tank-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0.6rem;
}
.tank-grid.tank-grid-lg {
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 1rem;
}
.tank {
    display: flex; flex-direction: column; align-items: center;
    text-align: center;
}
.tank-num {
    font-size: 0.7rem; color: var(--ink-muted); font-weight: 700; margin-bottom: 0.2rem;
}
.tank-cylinder {
    position: relative;
    width: 100%;
    height: 130px;
    background: #eef2f7;
    border-radius: 10px 10px 6px 6px;
    overflow: hidden;
    border: 2px solid #d0d7e2;
    box-shadow: inset 0 -4px 8px rgba(0,0,0,0.06);
}
.tank-cylinder-sm { height: 80px; }
.tank-fill {
    position: absolute; left: 0; right: 0; bottom: 0;
    transition: height 0.5s ease;
    background: linear-gradient(180deg, var(--green) 0%, #226d2c 100%);
}
.tank-fill.med {
    background: linear-gradient(180deg, var(--yellow) 0%, var(--yellow-dark) 100%);
}
.tank-fill.low {
    background: linear-gradient(180deg, #ef6c5b 0%, var(--red) 100%);
}
.tank-fill::after {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
    background: rgba(255,255,255,0.45);
}
.tank-label {
    margin-top: 0.4rem;
    font-size: 0.78rem; font-weight: 600;
    color: var(--ink); max-width: 100%;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tank-pct {
    font-size: 0.78rem; font-weight: 800; color: var(--navy);
}
.tank-vol { font-size: 0.7rem; color: var(--ink-muted); }

/* Compact fleet card */
.fleet-card {
    background: white; border: 1px solid var(--line);
    border-radius: 12px; padding: 1.1rem 1.25rem;
}
.fleet-card-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 0.85rem; flex-wrap: wrap; gap: 0.4rem;
}
.fleet-card-head h3 {
    margin: 0; font-size: 1.05rem; color: var(--navy); font-weight: 700;
}
.fleet-card-head h3 a { color: var(--navy); }
.fleet-card-head .last-seen { font-size: 0.78rem; color: var(--ink-muted); }

/* ---------- Misc ---------- */
.search-bar { display: flex; gap: 0.5rem; align-items: center; }
.search-bar input { max-width: 280px; }
.text-right  { text-align: right !important; }
.text-center { text-align: center !important; }
.text-left   { text-align: left !important; }
.text-red   { color: var(--red); }
.text-green { color: #1e6b2b; }
.text-navy  { color: var(--navy); }
.font-mono  { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.85em; }
.divider    { height: 1px; background: var(--line-soft); margin: 1rem 0; }

/* Chart canvas containers */
.chart-wrap { position: relative; height: 220px; }
.chart-wrap.tall { height: 280px; }
