:root {
    --primary: #005B96;
    --secondary: #00A6D6;
    --accent: #F5A623;
    --success: #1B8A5A;
    --danger: #C0392B;
    --dark-danger: #7F1D1D;
    --bg: #F5F7FA;
    --surface: #FFFFFF;
    --text: #1F2937;
    --muted: #6B7280;
    --line: #D9E2EC;
    --shadow: 0 10px 30px rgba(31, 41, 55, .08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--text);
    background: var(--bg);
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

img {
    max-width: 100%;
}

.app-shell {
    min-height: 100vh;
    display: flex;
}

.sidebar {
    width: 260px;
    flex: 0 0 260px;
    background: #083A63;
    color: #fff;
    min-height: 100vh;
    position: sticky;
    top: 0;
    align-self: flex-start;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 22px 20px;
    border-bottom: 1px solid rgba(255,255,255,.12);
}

.brand img {
    width: 42px;
    height: 42px;
    object-fit: contain;
    background: #fff;
    border-radius: 6px;
    padding: 5px;
}

.brand strong,
.brand span {
    display: block;
}

.brand span {
    font-size: 12px;
    color: rgba(255,255,255,.74);
}

.nav-menu {
    padding: 12px;
}

.nav-menu a {
    display: block;
    padding: 11px 12px;
    margin: 2px 0;
    color: rgba(255,255,255,.82);
    border-radius: 6px;
    font-weight: 600;
}

.nav-menu a:hover,
.nav-menu a.active {
    background: rgba(0,166,214,.22);
    color: #fff;
    text-decoration: none;
}

.content-shell {
    flex: 1;
    min-width: 0;
}

.topbar {
    min-height: 82px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 16px 24px;
    position: sticky;
    top: 0;
    z-index: 5;
}

.topbar h1 {
    margin: 0;
    font-size: 23px;
}

.topbar p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.topbar-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: right;
}

.topbar-user strong,
.topbar-user .user-role {
    display: block;
}

.topbar-user .user-role {
    color: var(--muted);
    font-size: 12px;
}

.notification-pill {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    position: relative;
    border-radius: 999px;
    background: #FFFFFF;
    border: 1px solid #BFDBFE;
    box-shadow: 0 8px 18px rgba(15, 86, 130, 0.12);
    color: var(--primary);
    font-size: 18px;
    font-weight: 800;
    line-height: 1;
    text-decoration: none;
}

.notification-pill:hover,
.notification-pill:focus {
    background: #EFF6FF;
    border-color: var(--primary);
    color: #004C7A;
}

.notification-pill.is-empty {
    background: #FFFFFF;
    box-shadow: none;
    color: var(--muted);
}

.notification-bell {
    display: block;
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.notification-count {
    position: absolute;
    top: -7px;
    right: -7px;
    min-width: 21px;
    height: 21px;
    padding: 0 5px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: #B91C1C;
    border: 2px solid #FFFFFF;
    color: #FFFFFF;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
    box-shadow: 0 0 0 2px rgba(185, 28, 28, 0.18);
}

.notification-list {
    display: grid;
    gap: 12px;
}

.notification-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 14px;
    border: 1px solid var(--line);
    border-left: 4px solid transparent;
    border-radius: 8px;
    background: #FFFFFF;
}

.notification-row.is-unread {
    border-left-color: var(--primary);
    background: #F7FBFF;
}

.notification-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
}

.notification-title span {
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
}

.notification-row p {
    margin: 6px 0;
    color: #374151;
}

.notification-row small {
    color: var(--muted);
}

.notification-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.inline-form {
    margin: 0;
}

.sidebar-toggle {
    display: none;
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: 6px;
    padding: 8px 10px;
    cursor: pointer;
}

.main-content {
    padding: 24px;
}

.panel,
.metric-card,
.request-hero {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.panel {
    padding: 20px;
    margin-bottom: 20px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.panel-header h2,
.panel h2,
.panel h3 {
    margin: 0 0 12px;
}

.panel h2 {
    font-size: 18px;
}

.panel h3 {
    font-size: 15px;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.compact-metrics {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
}

.metric-card {
    padding: 18px;
    border-top: 4px solid var(--secondary);
    color: var(--text);
    text-decoration: none;
    transition: transform .15s ease, box-shadow .15s ease;
}

.metric-card:hover,
.bar-row:hover,
.donut-legend a:hover {
    transform: translateY(-1px);
    text-decoration: none;
    box-shadow: 0 8px 22px rgba(31, 41, 55, .08);
}

.metric-card span {
    color: var(--muted);
    font-size: 13px;
    display: block;
    margin-bottom: 8px;
}

.metric-card strong {
    font-size: 30px;
}

.metric-delayed,
.metric-priority {
    border-top-color: var(--danger);
}

.metric-released {
    border-top-color: var(--success);
}

.metric-developed {
    border-top-color: var(--success);
}

.metric-purchase {
    border-top-color: var(--accent);
}

.metric-npd {
    border-top-color: var(--primary);
}

.metric-approval,
.metric-supplier {
    border-top-color: var(--secondary);
}

.metric-closed {
    border-top-color: var(--dark-danger);
}

.metric-prototype,
.metric-validation {
    border-top-color: var(--accent);
}

.two-column {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.wide-left {
    grid-template-columns: minmax(0, 1.45fr) minmax(320px, .75fr);
}

.form-grid,
.filter-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    align-items: end;
}

.filter-grid {
    grid-template-columns: repeat(4, minmax(170px, 1fr));
}

.stack-form {
    display: grid;
    gap: 14px;
}

.compact {
    gap: 10px;
}

label {
    display: grid;
    gap: 6px;
    font-weight: 700;
    font-size: 13px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
}

.checkbox-label input {
    width: auto;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 11px;
    font: inherit;
    color: var(--text);
    background: #fff;
}

textarea {
    min-height: 110px;
    resize: vertical;
}

select[multiple] {
    min-height: 128px;
}

.span-2 {
    grid-column: span 2;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 38px;
    padding: 9px 14px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover {
    text-decoration: none;
}

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

.btn-secondary {
    background: #E8F4FA;
    border-color: #B9DCEB;
    color: var(--primary);
}

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

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

.btn-warning {
    background: var(--accent);
    border-color: var(--accent);
    color: #2E2413;
}

.flash {
    padding: 12px 14px;
    border-radius: 6px;
    margin-bottom: 14px;
    border: 1px solid transparent;
}

.flash-success {
    background: #E9F8F1;
    border-color: #BEE8D3;
    color: #0F6841;
}

.flash-danger {
    background: #FDEDEC;
    border-color: #F5C6C1;
    color: var(--dark-danger);
}

.flash-warning {
    background: #FFF7E6;
    border-color: #FAD89A;
    color: #6E4B00;
}

.report-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.report-tabs a {
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font-weight: 700;
    padding: 10px 14px;
}

.report-tabs a:hover,
.report-tabs a.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    text-decoration: none;
}

.salvage-widget-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    gap: 12px;
}

.salvage-widget {
    display: grid;
    gap: 7px;
    min-height: 118px;
    padding: 15px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    text-decoration: none;
    border-top: 4px solid var(--primary);
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}

.salvage-widget:hover,
.salvage-widget.active {
    transform: translateY(-1px);
    box-shadow: 0 8px 22px rgba(31, 41, 55, .08);
    border-color: var(--primary);
    text-decoration: none;
}

.salvage-widget span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.salvage-widget strong {
    font-size: 20px;
    line-height: 1.2;
}

.salvage-widget small {
    color: var(--muted);
    font-weight: 700;
}

.responsive-table {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
    font-size: 14px;
}

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

.erp-stock-wrap {
    border: 1px solid #B8D8EA;
}

.erp-stock-table {
    min-width: 3400px;
}

.erp-stock-table th {
    background: var(--primary);
    color: #fff;
    border-bottom-color: #083A63;
    font-size: 11px;
    text-transform: none;
    white-space: nowrap;
}

.erp-stock-table th a,
.table-sort {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #fff;
    text-decoration: none;
}

.table-sort span {
    color: #CDEAF8;
    font-size: 10px;
    font-weight: 900;
}

.erp-stock-table td {
    border-bottom-color: #D7E7F2;
    font-size: 12px;
    white-space: nowrap;
}

.erp-stock-table tbody tr:nth-child(even) {
    background: #EEF7FC;
}

.erp-stock-table tbody tr:nth-child(odd) {
    background: #FBFDFF;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-top: 16px;
}

.pagination a {
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--primary);
    font-weight: 800;
    padding: 8px 11px;
    text-decoration: none;
}

.pagination a:hover,
.pagination a.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.pagination-ellipsis {
    color: var(--muted);
    font-weight: 800;
    padding: 8px 2px;
}

.record-summary {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.table-actions {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
}

.table-actions form {
    margin: 0;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 800;
}

.badge-grey {
    background: #E5E7EB;
    color: #374151;
}

.badge-blue {
    background: #DCEEFF;
    color: var(--primary);
}

.badge-amber {
    background: #FFF1CC;
    color: #7A4D00;
}

.badge-danger {
    background: #FDE2DF;
    color: var(--danger);
}

.badge-dark-danger {
    background: #7F1D1D;
    color: #fff;
}

.badge-success {
    background: #DCF7E9;
    color: var(--success);
}

.mini-progress,
.bar-track {
    height: 9px;
    background: #E5EAF0;
    border-radius: 999px;
    overflow: hidden;
}

.mini-progress span,
.bar-fill {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--secondary), var(--primary));
}

.bar-chart {
    display: grid;
    gap: 12px;
}

.bar-row {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) minmax(120px, 2fr) 42px;
    gap: 12px;
    align-items: center;
    color: var(--text);
    padding: 6px;
    border-radius: 6px;
    text-decoration: none;
    transition: transform .15s ease, box-shadow .15s ease;
}

.bar-row span {
    color: var(--muted);
}

.market-price-dashboard .bar-fill {
    background: linear-gradient(90deg, var(--primary), var(--secondary));
}

.journey-status-panel .panel-header p {
    margin: 4px 0 0;
}

.journey-status-panel .bar-row {
    grid-template-columns: minmax(220px, 1.4fr) minmax(180px, 3fr) 58px;
}

.journey-status-panel .bar-fill {
    background: linear-gradient(90deg, var(--primary), var(--secondary));
}

.market-widget-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(150px, 1fr));
    gap: 12px;
}

.market-person-widget {
    display: grid;
    gap: 8px;
    min-height: 112px;
    padding: 14px;
    border: 1px solid var(--line);
    border-top: 4px solid var(--primary);
    border-radius: 8px;
    background: #FFFFFF;
    color: var(--text);
    text-decoration: none;
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}

.market-person-widget:hover,
.market-person-widget.active {
    transform: translateY(-1px);
    box-shadow: 0 8px 22px rgba(31, 41, 55, .08);
    border-color: var(--primary);
    text-decoration: none;
}

.market-person-widget span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.market-person-widget strong {
    font-size: 28px;
}

.market-person-widget small {
    color: var(--muted);
    font-weight: 800;
}

.currency-cell {
    white-space: nowrap;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.sales-stack-panel {
    width: 100%;
}

.stack-legend {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.stack-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.stack-legend i {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.legend-make,
.stack-make {
    background: #005B96;
}

.legend-new,
.stack-new {
    background: #00A6D6;
}

.legend-component,
.stack-component {
    background: #F5A623;
}

.sales-stack-chart {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(96px, 1fr);
    align-items: end;
    gap: 16px;
    min-height: 330px;
    overflow-x: auto;
    padding: 12px 4px 4px;
}

.sales-stack-column {
    display: grid;
    grid-template-rows: auto 240px auto;
    justify-items: center;
    align-items: end;
    gap: 8px;
    min-width: 96px;
}

.stack-total {
    color: var(--text);
    font-size: 14px;
    line-height: 1;
}

.stack-bar {
    width: min(74px, 100%);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    overflow: hidden;
    border-radius: 8px 8px 4px 4px;
    background: #E5EAF0;
    border: 1px solid var(--line);
}

.stack-segment {
    display: grid;
    min-height: 24px;
    place-items: center;
    color: #fff;
    text-decoration: none;
    font-size: 12px;
    font-weight: 900;
    transition: filter .15s ease;
}

.stack-segment:hover {
    filter: brightness(.92);
    text-decoration: none;
}

.stack-component {
    color: #2E2413;
}

.stack-name {
    max-width: 118px;
    min-height: 34px;
    color: var(--text);
    font-size: 12px;
    font-weight: 800;
    line-height: 1.25;
    text-align: center;
    text-decoration: none;
}

.stack-name:hover {
    color: var(--primary);
}

.donut-layout {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 22px;
    align-items: center;
}

.donut-chart {
    width: 150px;
    aspect-ratio: 1;
    border-radius: 50%;
    position: relative;
}

.donut-chart::after {
    content: "";
    position: absolute;
    inset: 34px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--line);
}

.donut-legend {
    display: grid;
    gap: 8px;
}

.donut-legend a {
    display: grid;
    grid-template-columns: 14px 1fr auto;
    gap: 8px;
    align-items: center;
    color: var(--text);
    padding: 7px;
    border-radius: 6px;
    text-decoration: none;
    transition: transform .15s ease, box-shadow .15s ease;
}

.donut-legend span {
    width: 14px;
    height: 14px;
    border-radius: 50%;
}

.request-hero {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    padding: 24px;
    margin-bottom: 18px;
    border-left: 5px solid var(--primary);
}

.request-hero h2 {
    margin: 10px 0 6px;
    font-size: 25px;
}

.request-hero p {
    margin: 0;
    color: var(--muted);
}

.hero-progress {
    width: 200px;
    align-self: center;
}

.hero-progress strong {
    display: block;
    text-align: right;
    margin-bottom: 8px;
    font-size: 24px;
}

.action-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.action-strip form,
.row-actions {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.feasibility-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(260px, 1fr));
    gap: 16px;
}

.feasibility-option {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    background: #f8fafc;
}

.feasibility-option h3 {
    margin-bottom: 6px;
}

.feasibility-option textarea {
    min-height: 76px;
}

.inline-approval input {
    width: 180px;
}

.detail-grid {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 9px 16px;
}

.detail-grid dt {
    color: var(--muted);
    font-weight: 700;
}

.detail-grid dd {
    margin: 0;
}

.timeline {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

.timeline-card {
    border: 1px solid var(--line);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    padding: 14px;
    background: #fff;
}

.timeline-card.status-completed {
    border-left-color: var(--success);
}

.timeline-card.status-blocked,
.timeline-card.status-rejected {
    border-left-color: var(--danger);
}

.timeline-card span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.timeline-card h3 {
    margin: 8px 0;
}

.timeline-card small {
    display: block;
    color: var(--muted);
    margin-top: 8px;
}

.activity-list,
.attachment-list {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.activity-item,
.attachment-list a {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: #fff;
}

.activity-item span,
.attachment-list span,
.muted {
    color: var(--muted);
    font-size: 13px;
}

.activity-item p {
    margin: 8px 0 0;
}

.attachment-list a {
    display: grid;
    gap: 4px;
}

.empty-state {
    text-align: center;
    color: var(--muted);
    padding: 28px;
}

.login-page,
.install-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: radial-gradient(circle at top left, #E6F6FD, var(--bg) 42%);
}

.login-card,
.install-panel {
    width: min(100%, 460px);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 26px;
}

.install-panel {
    width: min(100%, 860px);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
}

.login-brand img {
    width: 56px;
    height: 56px;
}

.login-brand h1 {
    margin: 0;
    font-size: 24px;
}

.login-brand p {
    margin: 5px 0 0;
    color: var(--muted);
}

.code-textarea {
    width: 100%;
    min-height: 280px;
    font-family: Consolas, Monaco, monospace;
}

code {
    font-family: Consolas, Monaco, monospace;
    font-size: 12px;
    white-space: normal;
}

@media (max-width: 1100px) {
    .metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .two-column,
    .wide-left {
        grid-template-columns: 1fr;
    }

    .filter-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .salvage-widget-grid,
    .market-widget-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .app-shell {
        display: block;
    }

    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        z-index: 20;
        transition: left .2s ease;
    }

    body.sidebar-open .sidebar {
        left: 0;
    }

    .sidebar-toggle {
        display: inline-flex;
    }

    .topbar {
        align-items: flex-start;
        padding: 14px;
    }

    .topbar-user {
        display: none;
    }

    .main-content {
        padding: 14px;
    }

    .metric-grid,
    .form-grid,
    .filter-grid,
    .salvage-widget-grid,
    .market-widget-grid {
        grid-template-columns: 1fr;
    }

    .donut-layout {
        grid-template-columns: 1fr;
    }

    .donut-chart {
        margin: 0 auto;
    }

    .feasibility-grid {
        grid-template-columns: 1fr;
    }

    .span-2 {
        grid-column: span 1;
    }

    .request-hero {
        display: grid;
    }

    .hero-progress {
        width: 100%;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .bar-row {
        grid-template-columns: 1fr;
    }

    .inline-approval input {
        width: 100%;
    }
}
