/* ==========================================================
   Global layout + shared components
   Loaded on every page by shared/base.html.
   ========================================================== */

:root {
    --purple-900: #2E1A4D;
    --purple-800: #3B2363;
    --purple-700: #4C2A85;
    --purple-500: #7B4FC9;
    --purple-50:  #F3EFFA;
    --orange-600: #D9662C;
    --orange-700: #C4571F;
    --ink: #211C2E;
    --slate: #6B6478;
    --muted: #9992A3;
    --line: #E3DEEC;
    --paper: #F7F6FA;
    --surface: #FFFFFF;
    --good: #2F7D5C;
    --good-bg: #E6F4EC;
    --warn: #9A6B2E;
    --warn-bg: #FBF1DE;
    --bad: #A3413A;
    --bad-bg: #FBEAE8;

    --radius: 8px;
    --shadow-sm: 0 1px 2px rgba(33, 28, 46, 0.06);
    --shadow-md: 0 4px 14px rgba(33, 28, 46, 0.08);
    --header-h: 64px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--paper);
    color: var(--ink);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.site-main {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--purple-700);
}

h1, h2, h3 {
    color: var(--purple-900);
    line-height: 1.25;
}

/* ==========================================================
   Header
   ========================================================== */

.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--purple-900);
    border-bottom: 3px solid var(--orange-600);
}

.site-header-inner {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 24px;
    min-height: var(--header-h);
    display: flex;
    align-items: center;
    gap: 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #fff;
    flex-shrink: 0;
}

.brand-mark {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    background: var(--orange-600);
    border-radius: 6px;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.2px;
}

.brand-name {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.2px;
    white-space: nowrap;
}

.primary-nav {
    display: flex;
    align-items: stretch;
    align-self: stretch;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.primary-nav a {
    display: flex;
    align-items: center;
    padding: 0 12px;
    color: rgba(255, 255, 255, 0.72);
    text-decoration: none;
    font-size: 16px;
    font-weight: 500;
    white-space: nowrap;
    border-bottom: 3px solid transparent;
    margin-bottom: -3px;
    transition: color 0.15s, border-color 0.15s;
}

.primary-nav a:hover {
    color: #fff;
}

.primary-nav a.active {
    color: #fff;
    border-bottom-color: #fff;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
    flex-shrink: 0;
}

.icon-button {
    position: relative;
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.85);
    transition: background 0.15s;
}

.icon-button:hover,
.icon-button.active {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.notif-count {
    position: absolute;
    top: 3px;
    right: 1px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--orange-600);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}

/* Driver sponsor switcher (bar under the header) */

.context-bar {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.context-bar-inner {
    max-width: 1240px;
    margin: 0 auto;
    padding: 8px 24px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 12px;
}

.context-bar label {
    color: var(--slate);
    font-size: 13px;
    font-weight: 600;
}

.context-bar select.input {
    width: auto;
    min-width: 220px;
    height: 34px;
    font-weight: 600;
    color: var(--purple-900);
}

.context-bar-note {
    color: var(--muted);
    font-size: 12px;
}

@media (max-width: 600px) {
    .context-bar-inner {
        padding: 8px 16px;
    }

    .context-bar select.input {
        min-width: 0;
        flex: 1;
    }

    .context-bar-note {
        display: none;
    }
}

/* Notifications dropdown */

.notif-menu {
    position: relative;
}

.notif-menu .icon-button {
    border: none;
    background: transparent;
    cursor: pointer;
    font: inherit;
}

.notif-menu .icon-button:hover,
.notif-menu .icon-button.active {
    background: rgba(255, 255, 255, 0.1);
}

.notif-panel {
    position: absolute;
    top: calc(100% + 12px);
    right: -8px;
    width: 360px;
    max-width: calc(100vw - 24px);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 12px 32px rgba(33, 28, 46, 0.18);
    color: var(--ink);
    overflow: hidden;
    z-index: 200;
}

.notif-panel[hidden] {
    display: none;
}

.notif-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    color: var(--purple-900);
    font-size: 14px;
    font-weight: 600;
}

.notif-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: min(420px, 70vh);
    overflow-y: auto;
}

.notif-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
}

.notif-item:last-child {
    border-bottom: none;
}

.notif-item.unread {
    background: #FDF6F1;
    box-shadow: inset 3px 0 0 var(--orange-600);
}

.notif-subject {
    margin: 0;
    color: var(--purple-900);
    font-size: 14px;
    font-weight: 600;
}

.notif-message {
    margin: 3px 0 0;
    color: var(--ink);
    font-size: 13px;
    line-height: 1.45;
}

.notif-time {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.notif-empty {
    padding: 32px 16px;
    text-align: center;
    color: var(--slate);
    font-size: 14px;
}

@media (max-width: 600px) {
    .notif-panel {
        position: fixed;
        top: 60px;
        left: 12px;
        right: 12px;
        width: auto;
        max-width: none;
    }
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-left: 14px;
    border-left: 1px solid rgba(255, 255, 255, 0.15);
}

.user-avatar {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--purple-500);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
}

.user-meta {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    min-width: 0;
}

.user-name {
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.user-role {
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
}

.logout-link {
    color: #fff;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    padding: 7px 14px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    white-space: nowrap;
    transition: border-color 0.15s, background 0.15s;
}

.logout-link:hover {
    border-color: var(--orange-600);
    background: rgba(217, 102, 44, 0.15);
}

/* The nav drops to its own row when its links would run under the header
   icons. main.js measures this and sets .nav-wrapped; the media query is
   the fallback for small screens. */
.site-header.nav-wrapped .site-header-inner {
    flex-wrap: wrap;
    row-gap: 0;
    padding-top: 10px;
}

.site-header.nav-wrapped .primary-nav {
    order: 3;
    flex-basis: 100%;
    overflow-x: auto;
    min-height: 44px;
    margin: 0 -12px;
}

@media (max-width: 900px) {
    .site-header-inner {
        flex-wrap: wrap;
        row-gap: 0;
        padding-top: 10px;
    }

    .primary-nav {
        order: 3;
        flex-basis: 100%;
        overflow-x: auto;
        min-height: 44px;
        margin: 0 -12px;
    }
}

@media (max-width: 600px) {
    .site-header-inner {
        padding-left: 16px;
        padding-right: 16px;
        gap: 12px;
    }

    .brand-name,
    .user-role {
        display: none;
    }

    .user-chip {
        padding-left: 10px;
    }

    .user-name {
        max-width: 110px;
    }
}

/* ==========================================================
   Footer
   ========================================================== */

.site-footer {
    flex-shrink: 0;
    background: var(--surface);
    border-top: 1px solid var(--line);
    color: var(--slate);
    font-size: 13px;
}

.site-footer-inner {
    max-width: 1240px;
    margin: 0 auto;
    padding: 18px 24px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 24px;
}

.site-footer-links {
    display: flex;
    gap: 20px;
}

.site-footer-links a {
    color: var(--slate);
    text-decoration: none;
}

.site-footer-links a:hover {
    color: var(--purple-700);
}

/* ==========================================================
   Page shell
   ========================================================== */

.page {
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
    padding: 32px 24px 56px;
}

.page-narrow {
    max-width: 780px;
}

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px 24px;
    margin-bottom: 24px;
}

.page-header h1 {
    margin: 4px 0 4px;
    font-size: 28px;
    font-weight: 700;
}

.page-header p {
    margin: 0;
    color: var(--slate);
}

.eyebrow {
    color: var(--orange-600);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.breadcrumb {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
    color: var(--slate);
    font-size: 14px;
    text-decoration: none;
}

.breadcrumb:hover {
    color: var(--purple-700);
}

.stack > * + * {
    margin-top: 20px;
}

@media (max-width: 600px) {
    .page {
        padding: 24px 16px 40px;
    }

    .page-header h1 {
        font-size: 24px;
    }
}

/* ==========================================================
   Cards
   ========================================================== */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px 16px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
}

.card-header h2 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
}

.card-header p {
    margin: 2px 0 0;
    color: var(--slate);
    font-size: 13px;
}

.card-body {
    padding: 20px;
}

.card-body > :first-child {
    margin-top: 0;
}

.card-body > :last-child {
    margin-bottom: 0;
}

.muted {
    color: var(--slate);
}

.small {
    font-size: 13px;
}

/* ==========================================================
   Buttons
   ========================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 38px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn-primary {
    background: var(--purple-700);
    color: #fff;
}

.btn-primary:hover {
    background: var(--purple-900);
}

.btn-accent {
    background: var(--orange-600);
    color: #fff;
}

.btn-accent:hover {
    background: var(--orange-700);
}

.btn-secondary {
    background: var(--surface);
    border-color: var(--line);
    color: var(--purple-900);
}

.btn-secondary:hover {
    border-color: var(--purple-500);
    color: var(--purple-700);
}

.btn-success {
    background: var(--good);
    color: #fff;
}

.btn-success:hover {
    background: #25664a;
}

.btn-danger {
    background: var(--bad);
    color: #fff;
}

.btn-danger:hover {
    background: #8a3630;
}

.btn-ghost-danger {
    background: transparent;
    border-color: var(--line);
    color: var(--bad);
}

.btn-ghost-danger:hover {
    background: var(--bad-bg);
    border-color: var(--bad);
}

.btn-sm {
    height: 32px;
    padding: 0 12px;
    font-size: 13px;
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    background: #D8D3DE;
    border-color: #D8D3DE;
    color: #817A89;
    cursor: not-allowed;
}

/* ==========================================================
   Badges
   ========================================================== */

.badge {
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 9px;
    border-radius: 11px;
    background: var(--purple-50);
    color: var(--purple-700);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-success { background: var(--good-bg); color: var(--good); }
.badge-warn    { background: var(--warn-bg); color: var(--warn); }
.badge-danger  { background: var(--bad-bg);  color: var(--bad); }
.badge-neutral { background: #EEECF2;        color: var(--slate); }
.badge-accent  { background: #FCE9DE;        color: var(--orange-700); }

/* ==========================================================
   Stat tiles
   ========================================================== */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 16px;
}

.stat-tile {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
}

.stat-label {
    color: var(--slate);
    font-size: 13px;
    font-weight: 500;
}

.stat-value {
    margin-top: 4px;
    color: var(--purple-900);
    font-size: 26px;
    font-weight: 700;
    line-height: 1.2;
}

.stat-value.good { color: var(--good); }
.stat-value.bad  { color: var(--bad); }
.stat-value.text { font-size: 18px; }

/* ==========================================================
   Quick-action tiles (dashboards)
   ========================================================== */

.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.action-tile {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.action-tile:hover {
    border-color: var(--purple-500);
    box-shadow: var(--shadow-md);
}

.action-tile h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.action-tile p {
    margin: 0;
    color: var(--slate);
    font-size: 14px;
}

.action-tile .tile-link {
    margin-top: auto;
    padding-top: 8px;
    color: var(--orange-600);
    font-size: 13px;
    font-weight: 600;
}

/* ==========================================================
   Row lists (drivers, applications, notifications, ...)
   ========================================================== */

.row-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.row-item {
    border-bottom: 1px solid var(--line);
}

.row-item:last-child {
    border-bottom: none;
}

.row-main {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 20px;
}

.row-link {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
    min-width: 0;
    text-decoration: none;
    color: inherit;
}

.row-link:hover .row-title {
    color: var(--orange-600);
}

.row-item.is-clickable:hover {
    background: #FBFAFD;
}

.avatar {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--purple-50);
    color: var(--purple-700);
    font-size: 14px;
    font-weight: 600;
}

.row-text {
    min-width: 0;
}

.row-title {
    margin: 0;
    color: var(--purple-900);
    font-size: 15px;
    font-weight: 600;
    transition: color 0.15s;
}

.row-sub {
    margin: 2px 0 0;
    color: var(--slate);
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.row-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    min-width: 90px;
    flex-shrink: 0;
}

.row-meta-label {
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.row-meta-value {
    color: var(--purple-900);
    font-size: 15px;
    font-weight: 600;
}

.row-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.row-detail {
    padding: 0 20px 16px 74px;
    color: var(--slate);
    font-size: 14px;
}

.row-detail p {
    margin: 4px 0;
}

.row-unread {
    box-shadow: inset 3px 0 0 var(--orange-600);
}

@media (max-width: 700px) {
    .row-main {
        flex-wrap: wrap;
        padding: 14px 16px;
    }

    .row-link {
        flex-basis: 100%;
    }

    .row-meta {
        align-items: flex-start;
    }

    .row-actions {
        margin-left: auto;
    }

    .row-detail {
        padding-left: 16px;
        padding-right: 16px;
    }
}

/* Inline expanding panel (used for "Adjust points" etc.) */

.inline-panel {
    padding: 0 20px 16px 74px;
}

.inline-panel[hidden] {
    display: none;
}

@media (max-width: 700px) {
    .inline-panel {
        padding-left: 16px;
        padding-right: 16px;
    }
}

/* ==========================================================
   Tables
   ========================================================== */

.table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th {
    padding: 10px 20px;
    background: #FBFAFD;
    border-bottom: 1px solid var(--line);
    color: var(--slate);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.4px;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
}

.data-table td {
    padding: 12px 20px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.positive { color: var(--good); font-weight: 600; }
.negative { color: var(--bad); font-weight: 600; }

/* ==========================================================
   Forms
   ========================================================== */

.form-group {
    margin-bottom: 18px;
}

.form-group label,
.field-label {
    display: block;
    margin-bottom: 6px;
    color: var(--purple-900);
    font-size: 13px;
    font-weight: 600;
}

.input,
.form-group input:not([type="checkbox"]):not([type="radio"]),
.form-group select {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus,
.form-group input:focus,
.form-group select:focus {
    border-color: var(--purple-500);
    box-shadow: 0 0 0 3px rgba(123, 79, 201, 0.15);
}

.form-group input:disabled {
    background: var(--paper);
    color: var(--slate);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 16px;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 6px;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 14px;
    cursor: pointer;
}

.fieldset {
    margin: 0 0 18px;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 6px;
}

.fieldset legend {
    padding: 0 6px;
    color: var(--purple-900);
    font-size: 13px;
    font-weight: 600;
}

/* Inline toolbar of filters */

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
}

.toolbar .form-group {
    margin-bottom: 0;
}

.toolbar .input,
.toolbar select {
    width: auto;
    min-width: 140px;
}

.segmented {
    display: inline-flex;
    flex-wrap: wrap;
    border: 1px solid var(--line);
    border-radius: 6px;
    overflow: hidden;
    background: var(--surface);
}

.segmented a {
    padding: 7px 14px;
    border-right: 1px solid var(--line);
    color: var(--slate);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
}

.segmented a:last-child {
    border-right: none;
}

.segmented a:hover {
    color: var(--purple-700);
    background: #FBFAFD;
}

.segmented a.active {
    background: var(--purple-700);
    color: #fff;
}

@media (max-width: 600px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================
   Alerts + empty states
   ========================================================== */

.alert {
    padding: 12px 16px;
    border-radius: 6px;
    border-left: 3px solid;
    font-size: 14px;
    margin-bottom: 20px;
}

.alert-success { background: var(--good-bg); color: var(--good); border-color: var(--good); }
.alert-error   { background: var(--bad-bg);  color: var(--bad);  border-color: var(--bad); }
.alert-warn    { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }

.empty-state {
    padding: 48px 24px;
    text-align: center;
    color: var(--slate);
}

.empty-state h3 {
    margin: 0 0 6px;
    font-size: 17px;
}

.empty-state p {
    margin: 0 0 18px;
}

.empty-state p:last-child {
    margin-bottom: 0;
}

/* ==========================================================
   Key/value detail list (profiles)
   ========================================================== */

.detail-list {
    margin: 0;
}

.detail-row {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 16px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--line);
    font-size: 14px;
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-row dt {
    color: var(--slate);
    font-weight: 500;
}

.detail-row dd {
    margin: 0;
    color: var(--ink);
    word-break: break-word;
}

@media (max-width: 600px) {
    .detail-row {
        grid-template-columns: 1fr;
        gap: 2px;
    }
}

.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}

@media (max-width: 850px) {
    .two-col {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================
   Dashboards
   ========================================================== */

.welcome-banner {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 20px 32px;
    margin-bottom: 24px;
    padding: 30px 32px;
    border-radius: 12px;
    background: linear-gradient(120deg, var(--purple-900) 0%, var(--purple-700) 100%);
    color: #fff;
    box-shadow: 0 10px 30px rgba(46, 26, 77, 0.18);
}

/* Dashed "route" accent, echoing the login page */
.welcome-banner::after {
    content: "";
    position: absolute;
    right: -60px;
    top: -80px;
    width: 340px;
    height: 340px;
    border: 3px dashed rgba(217, 102, 44, 0.45);
    border-radius: 50%;
    pointer-events: none;
}

.welcome-banner > * {
    position: relative;
    z-index: 1;
}

.welcome-date {
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    font-weight: 500;
}

.welcome-banner h1 {
    margin: 4px 0 6px;
    color: #fff;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.4px;
}

.welcome-banner p {
    margin: 0;
    max-width: 560px;
    color: rgba(255, 255, 255, 0.82);
}

.welcome-banner strong {
    color: #fff;
}

.welcome-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.btn-light {
    background: #fff;
    color: var(--purple-900);
}

.btn-light:hover {
    background: var(--purple-50);
}

.btn-outline-light {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.4);
    color: #fff;
}

.btn-outline-light:hover {
    border-color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.balance-figure {
    text-align: right;
}

.balance-figure .balance-value {
    display: block;
    font-size: 46px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -1px;
}

.balance-figure .balance-label {
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    font-weight: 500;
}

/* Stat tiles with icons */

.stat-tile.has-icon {
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    border-radius: 10px;
    background: var(--purple-50);
    color: var(--purple-700);
}

.stat-icon.green  { background: var(--good-bg); color: var(--good); }
.stat-icon.orange { background: #FCE9DE; color: var(--orange-600); }
.stat-icon.gold   { background: var(--warn-bg); color: var(--warn); }

.stat-tile.attention {
    border-color: #F2C3A6;
    box-shadow: inset 3px 0 0 var(--orange-600), var(--shadow-sm);
}

.stat-tile.attention .stat-value {
    color: var(--orange-600);
}

.stat-hint {
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
}

/* Quick links */

.quick-links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.quick-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--purple-900);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.quick-link:hover {
    border-color: var(--purple-500);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.quick-link .stat-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
}

.quick-link .arrow {
    margin-left: auto;
    color: var(--muted);
}

.section-title {
    margin: 0 0 12px;
    color: var(--slate);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
}

.dash-grid {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 20px;
    align-items: start;
}

@media (max-width: 900px) {
    .dash-grid {
        grid-template-columns: 1fr;
    }

    .balance-figure {
        text-align: left;
    }
}

@media (max-width: 600px) {
    .welcome-banner {
        padding: 24px 20px;
    }

    .welcome-banner h1 {
        font-size: 24px;
    }
}

/* Small "time waiting" text in attention lists */

.waiting {
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}

.waiting.long {
    color: var(--orange-600);
    font-weight: 600;
}

@media (max-width: 600px) {
    .stat-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .stat-tile.has-icon {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 16px;
    }

    .stat-icon {
        width: 36px;
        height: 36px;
    }
}

.assume-driver-banner {
    background: #fff3cd;
    color: #664d03;
    border-bottom: 1px solid #ffecb5;
    padding: 12px 24px;
}

.assume-driver-banner-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.assume-driver-banner-inner > div {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.assume-driver-banner-inner strong {
    font-weight: 700;
}

.assume-driver-banner-inner form {
    flex-shrink: 0;
}

@media (max-width: 600px) {
    .assume-driver-banner-inner {
        align-items: flex-start;
        flex-direction: column;
    }
}
/* Visible to screen readers only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* Unread count next to a nav link (Messages) */
.nav-count {
    display: inline-block;
    min-width: 18px;
    height: 18px;
    margin-left: 4px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--orange-600);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    vertical-align: 1px;
}

/* ==========================================
   CHAT
   ========================================== */

.chat-card {
    display: flex;
    flex-direction: column;
    max-width: 820px;
}

.chat-log {
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: min(60vh, 560px);
    overflow-y: auto;
    padding: 20px;
    background: var(--paper);
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.chat-empty {
    margin: auto;
    color: var(--slate);
    font-size: 14px;
}

.chat-bubble {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--ink);
    align-self: flex-start;
}

.chat-bubble.mine {
    align-self: flex-end;
    background: var(--purple-700);
    border-color: var(--purple-700);
    border-bottom-left-radius: 14px;
    border-bottom-right-radius: 4px;
    color: #fff;
}

.chat-body {
    margin: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    line-height: 1.45;
}

.chat-meta {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    opacity: 0.75;
}

.chat-form {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    padding: 16px 20px;
}

.chat-form textarea {
    flex: 1;
    min-height: 44px;
    max-height: 160px;
    resize: vertical;
    font: inherit;
}

.chat-closed {
    padding: 16px 20px;
    margin: 0;
    color: var(--slate);
    font-size: 14px;
}

.inbox-preview {
    max-width: 52ch;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ==========================================
   SETTINGS
   ========================================== */

.settings-grid {
    display: grid;
    gap: 20px;
    max-width: 760px;
}

.setting-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 0;
    border-top: 1px solid var(--line);
    cursor: pointer;
}

.setting-toggle:first-of-type {
    border-top: 0;
}

.setting-toggle input {
    width: 20px;
    height: 20px;
    accent-color: var(--purple-700);
    flex: none;
}

.settings-form .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

@media (max-width: 600px) {
    .settings-form .form-row {
        grid-template-columns: 1fr;
    }

    .chat-bubble {
        max-width: 90%;
    }
}

:root[data-theme="dark"] .chat-bubble.mine {
    background: #6042A0;
    border-color: #6042A0;
}
