:root {
    --lh-navy: #24414a;
    --lh-navy-700: #1c333a;
    --lh-navy-800: #16282d;
    --lh-orange: #2a9d8f;
    --lh-orange-600: #218a7c;
    --lh-sidebar-w: 252px;
    --bs-body-font-family: 'Prompt', 'Sarabun', system-ui, sans-serif;
}

body {
    font-family: 'Prompt', 'Sarabun', system-ui, sans-serif;
    background: #eef3f2;
}

[data-bs-theme="dark"] body {
    background: #0d1424;
}

.btn-primary {
    --bs-btn-bg: var(--lh-orange);
    --bs-btn-border-color: var(--lh-orange);
    --bs-btn-hover-bg: var(--lh-orange-600);
    --bs-btn-hover-border-color: var(--lh-orange-600);
    --bs-btn-active-bg: var(--lh-orange-600);
    --bs-btn-active-border-color: var(--lh-orange-600);
}

/* ===== Layout ===== */
.app-wrapper { display: flex; min-height: 100vh; }

.app-sidebar {
    width: var(--lh-sidebar-w);
    background: linear-gradient(180deg, var(--lh-navy) 0%, var(--lh-navy-800) 100%);
    color: #cdd6ea;
    position: fixed;
    inset: 0 auto 0 0;
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform .25s ease;
}

.sidebar-brand {
    display: flex; align-items: center; gap: .6rem;
    padding: 1.1rem 1.25rem;
    font-size: 1.25rem; font-weight: 600; color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand .brand-icon { color: var(--lh-orange); font-size: 1.5rem; }

.sidebar-nav { padding: .75rem .5rem; overflow-y: auto; }
.sidebar-nav ul { list-style: none; margin: 0; padding: 0; }
.sidebar-nav .nav-link {
    display: flex; align-items: center; gap: .75rem;
    padding: .65rem .85rem; margin-bottom: .15rem;
    color: #cdd6ea; border-radius: .55rem;
    font-weight: 400; text-decoration: none;
    transition: background .15s, color .15s;
}
.sidebar-nav .nav-link i { font-size: 1.1rem; width: 1.4rem; text-align: center; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar-nav .nav-link.active {
    background: var(--lh-orange); color: #fff; font-weight: 500;
    box-shadow: 0 4px 12px rgba(42,157,143,.35);
}
.sidebar-nav .nav-link.is-soon { opacity: .72; }
.badge-soon {
    margin-left: auto; font-size: .62rem; padding: .15rem .4rem;
    background: rgba(255,255,255,.14); border-radius: 1rem; color: #e7ecf7;
}

.app-main {
    flex: 1; min-width: 0;
    margin-left: var(--lh-sidebar-w);
    display: flex; flex-direction: column;
}

/* ===== Navbar ===== */
.app-navbar {
    position: sticky; top: 0; z-index: 1030;
    display: flex; align-items: center; gap: .75rem;
    padding: .6rem 1.1rem;
    background: var(--bs-body-bg);
    border-bottom: 1px solid var(--bs-border-color);
    backdrop-filter: blur(6px);
}
.btn-icon {
    width: 40px; height: 40px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: .55rem; border: none; background: transparent;
    color: var(--bs-body-color); font-size: 1.15rem;
}
.btn-icon:hover { background: var(--bs-secondary-bg); }

.navbar-search { flex: 1; max-width: 460px; align-items: center; position: relative; }
.navbar-search i { position: absolute; left: .75rem; color: #9aa3b2; }
.navbar-search input { padding-left: 2.2rem; border-radius: 2rem; background: var(--bs-secondary-bg); }

.navbar-right { margin-left: auto; display: flex; align-items: center; gap: .35rem; }
.btn-user { display: flex; align-items: center; gap: .5rem; border: none; background: transparent; color: var(--bs-body-color); }
.user-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--lh-navy); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
}

/* ===== Content ===== */
.content { padding: 1.4rem 1.4rem 2rem; flex: 1; }
.app-footer { padding: .85rem 1.4rem; color: #8a93a5; font-size: .85rem; border-top: 1px solid var(--bs-border-color); }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1.1rem; flex-wrap: wrap; gap: .6rem; }
.page-title { font-size: 1.5rem; font-weight: 600; margin: 0; }
.page-sub { color: #8a93a5; margin: .15rem 0 0; font-size: .9rem; }

/* ===== KPI cards ===== */
.kpi-grid {
    display: grid; gap: 1rem;
    grid-template-columns: repeat(6, 1fr);
}
.kpi-card {
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: .9rem; padding: 1rem;
    display: flex; align-items: center; gap: .85rem;
    border-left: 4px solid var(--lh-navy);
    box-shadow: 0 2px 8px rgba(20,30,60,.04);
}
.kpi-icon {
    width: 46px; height: 46px; flex: none; border-radius: .7rem;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.35rem; color: #fff; background: var(--lh-navy);
}
.kpi-value { font-size: 1.7rem; font-weight: 700; line-height: 1; }
.kpi-label { font-size: .82rem; color: #8a93a5; margin-top: .2rem; }

.kpi-info    { border-left-color: #0dcaf0; } .kpi-info .kpi-icon    { background: #0dcaf0; }
.kpi-primary { border-left-color: var(--lh-navy); } .kpi-primary .kpi-icon { background: var(--lh-navy); }
.kpi-warning { border-left-color: #ffc107; } .kpi-warning .kpi-icon { background: #ffc107; }
.kpi-orange  { border-left-color: var(--lh-orange); } .kpi-orange .kpi-icon { background: var(--lh-orange); }
.kpi-danger  { border-left-color: #dc3545; } .kpi-danger .kpi-icon  { background: #dc3545; }
.kpi-success { border-left-color: #198754; } .kpi-success .kpi-icon { background: #198754; }
a.kpi-card { color: inherit; text-decoration: none; transition: transform .08s ease, box-shadow .12s ease; }
a.kpi-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(20,30,60,.15); }

/* ===== Panels ===== */
.panel {
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: .9rem; height: 100%;
    box-shadow: 0 2px 8px rgba(20,30,60,.04);
}
.panel-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: .9rem 1.1rem; border-bottom: 1px solid var(--bs-border-color);
}
.panel-head h2 { font-size: 1.05rem; font-weight: 600; margin: 0; }
.panel-body { padding: 1.1rem; }

.progress-row { display: flex; align-items: center; gap: .75rem; margin-bottom: .7rem; }
.progress-label { width: 110px; font-size: .85rem; flex: none; }
.progress { height: 12px; background: var(--bs-secondary-bg); }
.progress-count { width: 32px; text-align: right; font-weight: 600; font-size: .9rem; }
.status-pending { background: #9aa3b2; }
.status-acknowledged { background: #0dcaf0; }
.status-in_progress { background: var(--lh-navy); }
.status-awaiting_document { background: #ffc107; }
.status-pending_approval { background: #6f42c1; }
.status-completed { background: #198754; }

.mini-stat {
    display: flex; justify-content: space-between; align-items: center;
    padding: .6rem 0; border-bottom: 1px dashed var(--bs-border-color);
}
.mini-stat:last-child { border-bottom: none; }
.mini-stat strong { font-size: 1.1rem; }

.empty-hint { color: #8a93a5; font-size: .88rem; margin: .4rem 0 0; }
.setup-note {
    display: flex; gap: .5rem; align-items: flex-start;
    background: rgba(42,157,143,.08); border: 1px solid rgba(42,157,143,.25);
    color: var(--bs-body-color); border-radius: .7rem; padding: .9rem 1.1rem;
}
.setup-note i { color: var(--lh-orange); font-size: 1.2rem; }

/* ===== Auth ===== */
.auth-body { background: linear-gradient(135deg, var(--lh-navy) 0%, var(--lh-navy-800) 100%); }
.auth-wrapper { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.25rem; }
.auth-card {
    width: 100%; max-width: 410px; background: #fff;
    border-radius: 1rem; padding: 2rem; box-shadow: 0 18px 50px rgba(0,0,0,.3);
}
.auth-brand { text-align: center; margin-bottom: 1.5rem; }
.auth-brand i { font-size: 2.6rem; color: var(--lh-orange); }
.auth-brand h1 { font-size: 1.5rem; font-weight: 700; color: var(--lh-navy); margin: .35rem 0 .1rem; }
.auth-brand p { color: #8a93a5; font-size: .85rem; margin: 0; }

/* ===== Error pages ===== */
.error-page { text-align: center; padding: 3rem 1rem; }
.error-code { font-size: 4.5rem; font-weight: 700; color: var(--lh-orange); line-height: 1; }
.error-page h1 { font-size: 1.4rem; margin: .5rem 0; }

/* ===== Responsive ===== */
@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); }
    .app-wrapper.sidebar-open .app-sidebar { transform: translateX(0); }
    .app-main { margin-left: 0; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 992px) {
    .app-wrapper.sidebar-collapsed .app-sidebar { transform: translateX(-100%); }
    .app-wrapper.sidebar-collapsed .app-main { margin-left: 0; }
}
@media (max-width: 575.98px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .content { padding: 1rem; }
}

.sidebar-backdrop {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1035;
}
.app-wrapper.sidebar-open .sidebar-backdrop { display: block; }
@media (min-width: 992px) { .sidebar-backdrop { display: none !important; } }

/* ===== Smart table: status chips + leading dot ===== */
.status-chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.status-chips .chip { display: inline-flex; align-items: center; gap: .4rem; background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color); border-radius: 2rem; padding: .35rem .85rem; font-size: .85rem; }
.status-chips .chip .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.status-chips .chip strong { font-size: 1rem; }
.status-dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.ob-chip { display: inline-block; min-width: 26px; text-align: center; font-size: .72rem; padding: 1px 5px; border-radius: 4px; color: #fff; font-weight: 600; }
.ob-na { color: #c0c6d0; }

/* ===== Vehicle side KPI cards (Smart Table layout) ===== */
.vkpi { display: flex; align-items: center; gap: .7rem; padding: .7rem .9rem; border-radius: .7rem; margin-bottom: .6rem; color: #fff; }
.vkpi .n { font-size: 1.5rem; font-weight: 700; line-height: 1; }
.vkpi .l { font-size: .8rem; opacity: .95; }
.vkpi-ic { width: 38px; height: 38px; border-radius: .6rem; background: rgba(255,255,255,.22); display: flex; align-items: center; justify-content: center; font-size: 1.2rem; }
a.vkpi { transition: transform .08s ease, box-shadow .12s ease; }
a.vkpi:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(20,30,60,.18); color: #fff; }
.vkpi-active { outline: 3px solid rgba(255,255,255,.6); outline-offset: 1px; }

/* ===== Urgency-grouped list (design 3) ===== */
.urg { margin-bottom: 1rem; background: var(--bs-body-bg); border: 1px solid var(--bs-border-color); border-radius: .9rem; overflow: hidden; box-shadow: 0 2px 8px rgba(20,30,60,.04); }
.urg-h { display: flex; align-items: center; gap: .6rem; padding: .7rem 1.1rem; font-weight: 600; border-left: 5px solid #9aa3b2; }
.urg-h .cnt { margin-left: auto; background: var(--bs-secondary-bg); border-radius: 2rem; padding: .1rem .7rem; font-size: .85rem; font-weight: 400; }
.urg.red .urg-h { border-left-color: #dc3545; background: rgba(220,53,69,.05); }
.urg.orange .urg-h { border-left-color: #fd7e14; background: rgba(253,126,20,.05); }
.urg.yellow .urg-h { border-left-color: #e0a800; background: rgba(255,193,7,.06); }
.urg.green .urg-h { border-left-color: #198754; }
.urg-item { display: flex; align-items: center; gap: .8rem; padding: .6rem 1.1rem; border-top: 1px solid var(--bs-border-color); flex-wrap: wrap; }
.urg-item .veh { font-weight: 600; min-width: 110px; }
.urg-item .what { color: #6c757d; font-size: .9rem; flex: 1; min-width: 160px; }
.urg-item .due { font-size: .85rem; white-space: nowrap; }
.urg-empty { padding: .7rem 1.1rem; color: #9aa3b2; border-top: 1px solid var(--bs-border-color); font-size: .9rem; }
.due-badge { display: inline-block; padding: 2px 9px; border-radius: 2rem; font-size: .72rem; font-weight: 600; color: #fff; }

/* ===== KPI matrix ===== */
.kpi-matrix th { background: var(--bs-secondary-bg); white-space: nowrap; }
.kpi-matrix .mrow-label { font-weight: 500; white-space: nowrap; }
.kpi-matrix .mrow-expired { background: rgba(220,53,69,.06); }
.kpi-matrix .mrow-renewable { background: rgba(25,135,84,.07); }
.kpi-matrix .matrix-cell { font-weight: 600; text-decoration: none; }
.kpi-matrix .matrix-cell:hover { text-decoration: underline; }

/* ===== Settings hub ===== */
.settings-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.settings-card {
    display: flex; align-items: center; gap: 1rem;
    background: var(--bs-body-bg); border: 1px solid var(--bs-border-color);
    border-radius: .9rem; padding: 1.1rem; text-decoration: none; color: var(--bs-body-color);
    border-left: 4px solid var(--lh-navy); transition: transform .12s, box-shadow .12s;
}
.settings-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(20,30,60,.1); color: var(--bs-body-color); }
.settings-icon {
    width: 48px; height: 48px; flex: none; border-radius: .7rem;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.4rem; color: #fff; background: var(--lh-navy);
}
.settings-info { flex: 1; min-width: 0; }
.settings-label { font-weight: 600; font-size: 1.05rem; }
.settings-desc { font-size: .82rem; color: #8a93a5; }
.settings-count { font-size: 1.4rem; font-weight: 700; color: var(--lh-navy); }
.settings-navy   { border-left-color: var(--lh-navy); }
.settings-orange { border-left-color: var(--lh-orange); } .settings-orange .settings-icon { background: var(--lh-orange); } .settings-orange .settings-count { color: var(--lh-orange); }
.settings-info    { border-left-color: #0dcaf0; } .settings-info .settings-icon { background: #0dcaf0; } .settings-info .settings-count { color: #0a93b0; }
.settings-success { border-left-color: #198754; } .settings-success .settings-icon { background: #198754; } .settings-success .settings-count { color: #198754; }
.settings-warning { border-left-color: #ffc107; } .settings-warning .settings-icon { background: #ffc107; } .settings-warning .settings-count { color: #b8860b; }

/* ===== Detail page ===== */
.detail-list { display: grid; grid-template-columns: 130px 1fr; gap: .5rem .75rem; margin: 0; }
.detail-list dt { color: #8a93a5; font-weight: 400; font-size: .9rem; }
.detail-list dd { margin: 0; font-weight: 500; }
.current-renewal {
    display: flex; justify-content: space-between; align-items: flex-start;
    background: rgba(42,157,143,.06); border: 1px solid rgba(42,157,143,.2);
    border-radius: .7rem; padding: 1rem; margin-bottom: 1rem;
}
.renewal-form { background: var(--bs-secondary-bg); border-radius: .6rem; padding: 1rem; }

.attach-list { list-style: none; margin: 0; padding: 0; }
.attach-list li { display: flex; align-items: center; gap: .5rem; padding: .5rem 0; border-bottom: 1px dashed var(--bs-border-color); }
.attach-list li:last-child { border-bottom: none; }
.attach-name { font-weight: 500; text-decoration: none; }
.attach-meta { margin-left: auto; color: #8a93a5; font-size: .8rem; white-space: nowrap; }
.section-label { color: var(--lh-navy); font-weight: 600; border-bottom: 2px solid var(--lh-orange); display: inline-block; padding-bottom: .2rem; margin-bottom: .25rem; }
[data-bs-theme="dark"] .section-label { color: #aebde0; }

/* ===== Vehicle obligation create cards ===== */
.ob-create-card { border: 1px solid var(--bs-border-color); border-radius: .6rem; padding: .85rem 1rem; margin-bottom: .75rem; }
.ob-create-card .row { transition: opacity .15s; }

/* ===== Timeline (branch moves) ===== */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 .85rem 1.1rem; border-left: 2px solid var(--bs-border-color); }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before { content: ''; position: absolute; left: -5px; top: .3rem; width: 8px; height: 8px; border-radius: 50%; background: var(--lh-orange); }

/* ===== Kanban ===== */
.kanban { display: flex; gap: 1rem; overflow-x: auto; padding-bottom: .5rem; align-items: flex-start; }
.kanban-col { flex: 0 0 268px; min-width: 268px; }
.kanban-head { display: flex; justify-content: space-between; align-items: center; padding: .55rem .8rem;
    background: var(--bs-body-bg); border: 1px solid var(--bs-border-color); border-top: 3px solid var(--lh-navy);
    border-radius: .6rem .6rem 0 0; font-weight: 600; }
.kanban-count { background: var(--bs-secondary-bg); border-radius: 1rem; padding: 0 .55rem; font-size: .8rem; }
.kanban-body { background: var(--bs-secondary-bg); border: 1px solid var(--bs-border-color); border-top: none;
    border-radius: 0 0 .6rem .6rem; padding: .6rem; min-height: 110px; }
.kanban-empty { text-align: center; color: #9aa3b2; padding: .75rem 0; }
.kanban-card { display: block; background: var(--bs-body-bg); border: 1px solid var(--bs-border-color);
    border-radius: .55rem; padding: .6rem .7rem; margin-bottom: .5rem; text-decoration: none; color: inherit; transition: box-shadow .12s; }
.kanban-card:hover { box-shadow: 0 4px 12px rgba(20,30,60,.12); color: inherit; }
.kanban-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: .3rem; }
.task-no { font-size: .74rem; color: #8a93a5; }
.kanban-card-title { font-weight: 500; font-size: .9rem; margin-bottom: .4rem; }
.kanban-card-meta { display: flex; justify-content: space-between; align-items: center; font-size: .8rem; gap: .3rem; flex-wrap: wrap; }
.kanban-card-user { font-size: .78rem; color: #8a93a5; margin-top: .35rem; }

/* ===== Notifications ===== */
.notif-dot { position: absolute; top: 3px; right: 3px; background: #dc3545; color: #fff; font-size: .6rem;
    min-width: 16px; height: 16px; line-height: 16px; text-align: center; border-radius: 1rem; padding: 0 3px; }
.notif-menu { width: 332px; max-height: 430px; overflow-y: auto; }
.notif-item { white-space: normal; border-bottom: 1px solid var(--bs-border-color); }
.notif-item.unread { background: rgba(13,202,240,.08); }
.notif-title { font-weight: 500; font-size: .85rem; }
.notif-msg { font-size: .78rem; color: #8a93a5; }
.notif-time { font-size: .72rem; color: #9aa3b2; }

/* ===== Calendar ===== */
.cal-legend { display: flex; flex-wrap: wrap; gap: 1rem; font-size: .82rem; color: #6c757d; }
.cal-legend .dot, .cal-event .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: .25rem; vertical-align: middle; }
.cal-nav { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-bottom: 1rem; }
.cal-title { font-size: 1.2rem; font-weight: 600; margin: 0; min-width: 180px; text-align: center; }
.cal-grid { width: 100%; table-layout: fixed; border-collapse: separate; border-spacing: 4px; }
.cal-grid th { text-align: center; font-weight: 500; color: #8a93a5; font-size: .85rem; padding: .25rem; }
.cal-grid td { vertical-align: top; height: 96px; border: 1px solid var(--bs-border-color); border-radius: .5rem; padding: .25rem; }
.cal-grid td.cal-empty { background: var(--bs-secondary-bg); border-style: dashed; }
.cal-grid td.cal-today { border-color: var(--lh-orange); box-shadow: inset 0 0 0 1px var(--lh-orange); }
.cal-day { font-weight: 600; font-size: .85rem; margin-bottom: .2rem; }
.cal-event { display: flex; align-items: center; gap: .15rem; font-size: .72rem; text-decoration: none; color: var(--bs-body-color); padding: 1px 2px; border-radius: 3px; overflow: hidden; white-space: nowrap; }
.cal-event:hover { background: var(--bs-secondary-bg); color: var(--bs-body-color); }
.cal-more { font-size: .68rem; color: #8a93a5; padding-left: 2px; }
.mini-cal { width: 100%; table-layout: fixed; border-collapse: collapse; }
.mini-cal th { text-align: center; font-size: .62rem; color: #9aa3b2; padding: 2px 0; font-weight: 400; }
.mini-cal td { text-align: center; font-size: .72rem; padding: 3px 0; height: 22px; }
.mini-cal-title { font-weight: 600; text-decoration: none; color: var(--lh-navy); }
[data-bs-theme="dark"] .mini-cal-title { color: #aebde0; }

/* ===== Forms ===== */
.form-panel { max-width: 880px; }
.form-actions { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--bs-border-color); display: flex; gap: .5rem; }
[data-bs-theme="dark"] .auth-card { background: #1a2438; }
.dataTables_wrapper { padding-top: .25rem; }
