/* SPIMS — industrial ERP light theme: white surfaces, navy text, restrained blue accents */
:root {
    --navy: #0f1f3d;
    --navy-2: #1e2f50;
    --text: #1a2744;
    --muted: #64748b;
    --accent: #1d4ed8;
    --accent-soft: #e8efff;
    --border: #e3e8f0;
    --bg: #f4f6fa;
    --sidebar-w: 256px;
    --sidebar-w-collapsed: 68px;
    --bs-body-color: var(--text);
    --bs-primary: #1d4ed8;
    --bs-primary-rgb: 29, 78, 216;
    --bs-link-color: #1d4ed8;
    --bs-link-color-rgb: 29, 78, 216;
}
body { background: var(--bg); color: var(--text); font-size: .925rem; font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
h1, h2, h3, h4, h5, h6 { color: var(--navy); font-weight: 600; }
.text-muted { color: var(--muted) !important; }
a { text-decoration: none; }
.btn-primary { --bs-btn-bg: #1d4ed8; --bs-btn-border-color: #1d4ed8; --bs-btn-hover-bg: #1e40af; --bs-btn-hover-border-color: #1e40af; --bs-btn-active-bg: #1e3a8a; }
.btn-outline-primary { --bs-btn-color: #1d4ed8; --bs-btn-border-color: #1d4ed8; --bs-btn-hover-bg: #1d4ed8; --bs-btn-hover-border-color: #1d4ed8; }

/* ---------- shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--navy); color: #cbd5e1; position: fixed; inset: 0 auto 0 0; z-index: 1040; display: flex; flex-direction: column; transition: width .2s ease, transform .2s ease; }
.sidebar-brand { padding: 1rem 1.1rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-mark { width: 36px; height: 36px; border-radius: 9px; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 1.1rem; flex-shrink: 0; }
.brand-mark-lg { width: 54px; height: 54px; font-size: 1.6rem; border-radius: 13px; }
.brand-text { color: #fff; font-weight: 700; margin-left: .7rem; line-height: 1.1; letter-spacing: .5px; white-space: nowrap; }
.brand-text small { display: block; font-weight: 400; font-size: .72rem; color: #94a3b8; letter-spacing: 0; }
.sidebar-nav { overflow-y: auto; padding: .5rem 0 1.5rem; flex: 1; scrollbar-width: thin; }
.nav-section { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: #64748b; padding: 1rem 1.25rem .35rem; white-space: nowrap; }
.nav-item { display: flex; align-items: center; gap: .75rem; color: #cbd5e1; padding: .48rem 1.25rem; margin: 1px .6rem; border-radius: 7px; white-space: nowrap; font-size: .88rem; }
.nav-item i { font-size: 1.05rem; width: 20px; text-align: center; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--accent); color: #fff; }
.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; transition: margin-left .2s ease; }
.topbar { position: sticky; top: 0; z-index: 1030; background: #fff; border-bottom: 1px solid var(--border); height: 60px; display: flex; align-items: center; gap: .75rem; padding: 0 1.25rem; }
.btn-icon { width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; color: var(--navy); font-size: 1.25rem; padding: 0; }
.btn-icon:hover { background: var(--bg); }
.global-search { position: relative; align-items: center; width: min(460px, 45vw); }
.global-search i { position: absolute; left: .8rem; color: var(--muted); }
.global-search input { padding-left: 2.2rem; background: var(--bg); border-color: transparent; }
.global-search input:focus { background: #fff; }
.btn-user { display: flex; align-items: center; gap: .6rem; border: 0; padding: .25rem .5rem; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.content { padding: 1.5rem; flex: 1; }
.app-footer { padding: .9rem 1.5rem; font-size: .78rem; color: var(--muted); border-top: 1px solid var(--border); background: #fff; }
.sidebar-backdrop { display: none; }

body.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
body.sidebar-collapsed .main { margin-left: var(--sidebar-w-collapsed); }
body.sidebar-collapsed .brand-text, body.sidebar-collapsed .nav-item span, body.sidebar-collapsed .nav-section { display: none; }
body.sidebar-collapsed .nav-item { justify-content: center; padding: .55rem 0; }

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); width: var(--sidebar-w) !important; }
    .main { margin-left: 0 !important; }
    body.sidebar-open .sidebar { transform: none; }
    body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(15,31,61,.45); z-index: 1035; }
    body.sidebar-collapsed .brand-text, body.sidebar-collapsed .nav-item span, body.sidebar-collapsed .nav-section { display: initial; }
    .content { padding: 1rem; }
}

/* ---------- page elements ---------- */
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem; margin-bottom: 1.25rem; }
.page-header h1 { font-size: 1.45rem; margin: 0; }
.page-header .subtitle { color: var(--muted); margin: .2rem 0 0; font-size: .88rem; }
.breadcrumb { font-size: .8rem; margin-bottom: .25rem; }
.card { border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 1px 2px rgba(15,31,61,.04); }
.card-header { background: #fff; border-bottom: 1px solid var(--border); font-weight: 600; color: var(--navy); padding: .8rem 1rem; display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.card-header .card-title { margin: 0; font-size: .98rem; }

.kpi { display: block; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 1rem 1.1rem; height: 100%; color: var(--text); transition: border-color .15s, box-shadow .15s; position: relative; }
a.kpi:hover { border-color: #93b4f5; box-shadow: 0 3px 12px rgba(29,78,216,.08); }
.kpi-label { font-size: .76rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.kpi-value { font-size: 1.6rem; font-weight: 700; color: var(--navy); line-height: 1.2; margin-top: .25rem; }
.kpi-sub { font-size: .78rem; color: var(--muted); }
.kpi-icon { position: absolute; top: .9rem; right: 1rem; width: 36px; height: 36px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; background: var(--accent-soft); color: var(--accent); }
.kpi-success .kpi-icon { background: #e7f7ee; color: #15803d; }
.kpi-warning .kpi-icon { background: #fff4e0; color: #b45309; }
.kpi-danger .kpi-icon { background: #fde8e8; color: #b91c1c; }
.kpi-muted .kpi-icon { background: #eef1f6; color: #475569; }

.table { --bs-table-color: var(--text); margin-bottom: 0; }
.table > thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #f8fafc; border-bottom-width: 1px; white-space: nowrap; }
.table td { vertical-align: middle; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: #f5f8ff; }
th a.sort { color: inherit; display: inline-flex; align-items: center; gap: .25rem; }
th a.sort:hover { color: var(--accent); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ref { white-space: nowrap; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .82rem; }

.thumb { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; border: 1px solid var(--border); background: #fff; flex-shrink: 0; }
.thumb-sm { width: 30px; height: 30px; }
.thumb-lg { width: 96px; height: 96px; }
.thumb-empty { display: inline-flex; align-items: center; justify-content: center; color: #94a3b8; background: #f1f5f9; }
.part-cell { display: flex; align-items: center; gap: .6rem; min-width: 180px; }
.part-cell .name { font-weight: 600; color: var(--navy); line-height: 1.2; }
.part-cell .meta { font-size: .76rem; color: var(--muted); }

.badge { font-weight: 600; letter-spacing: .02em; }
.badge-soft-success { background: #e7f7ee; color: #15803d; }
.badge-soft-warning { background: #fff4e0; color: #b45309; }
.badge-soft-danger { background: #fde8e8; color: #b91c1c; }
.badge-soft-primary { background: var(--accent-soft); color: var(--accent); }
.badge-soft-secondary { background: #eef1f6; color: #475569; }
.badge-soft-info { background: #e0f4fb; color: #0e7490; }

.filter-bar { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: .85rem 1rem; margin-bottom: 1rem; }
.filter-bar .form-label { font-size: .74rem; color: var(--muted); font-weight: 600; margin-bottom: .2rem; text-transform: uppercase; letter-spacing: .03em; }
.form-label { font-weight: 600; color: var(--navy-2); font-size: .85rem; }
.form-label .req { color: #dc2626; }
.form-text { font-size: .78rem; }
.form-section-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; border-bottom: 1px solid var(--border); padding-bottom: .4rem; margin: 1.25rem 0 .9rem; }

.part-preview { display: flex; gap: 1rem; align-items: center; border: 1px dashed #c7d2e3; border-radius: 10px; padding: .75rem; background: #fafbfd; min-height: 116px; }
.part-preview img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); background: #fff; }
.part-preview .placeholder-img { width: 96px; height: 96px; border-radius: 8px; background: #eef2f7; display: flex; align-items: center; justify-content: center; color: #94a3b8; font-size: 2rem; }
.stock-pill { font-size: 1.05rem; font-weight: 700; }

.ts-dropdown .opt-row, .ts-control .opt-row { display: flex; align-items: center; gap: .55rem; }
.ts-dropdown .opt-row img, .ts-control .opt-row img { width: 32px; height: 32px; object-fit: cover; border-radius: 5px; border: 1px solid var(--border); }
.ts-dropdown .opt-meta { font-size: .75rem; color: var(--muted); }
.ts-wrapper.form-select, .ts-wrapper.form-control { padding: 0; }

.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty-state i { font-size: 2.3rem; color: #c3cedf; display: block; margin-bottom: .5rem; }

.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 220px; }

.alert-list .list-group-item { display: flex; align-items: center; gap: .6rem; }
.progress { height: 8px; background: #edf1f7; }
.machine-tile { display: block; border: 1px solid var(--border); border-radius: 10px; background: #fff; padding: .8rem; color: var(--text); height: 100%; }
.machine-tile:hover { border-color: #93b4f5; }
.machine-tile .code { font-weight: 700; color: var(--navy); font-size: 1.05rem; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.status-running { background: #16a34a; box-shadow: 0 0 0 3px rgba(22,163,74,.18); }
.status-idle { background: #94a3b8; }
.status-maintenance { background: #f59e0b; }
.status-inactive { background: #dc2626; }

.btn .spinner-border { width: 1rem; height: 1rem; border-width: .15em; }
.guest-body { background: linear-gradient(160deg, #0f1f3d 0%, #1e3a8a 100%); min-height: 100vh; }
.guest-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.guest-card { width: 100%; max-width: 440px; border: 0; border-radius: 14px; }
.perm-group { border: 1px solid var(--border); border-radius: 8px; padding: .75rem 1rem; height: 100%; }
.sheet-table td, .sheet-table th { padding: .35rem .5rem; font-size: .82rem; }
.sticky-col { position: sticky; left: 0; background: #fff; z-index: 1; }
dl.detail dt { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; font-weight: 600; }
dl.detail dd { margin-bottom: .8rem; color: var(--navy); }
@media print { .sidebar, .topbar, .app-footer, .no-print, .filter-bar { display: none !important; } .main { margin: 0 !important; } .content { padding: 0; } }
