/* KATAPLAN — Rafiki Telematics. One teal primary, amber brand accent, neutral surfaces. */
:root {
    --kp-ink: #0f172a;
    --kp-muted: #64748b;
    --kp-bg: #f3f5f8;
    --kp-surface: #ffffff;
    --kp-border: #e3e8ef;
    --kp-primary: #0f766e;
    --kp-primary-dark: #0b5e58;
    --kp-primary-soft: #e6f4f2;
    --kp-accent: #f59e0b;
    --kp-side: #16222f;
    --kp-side-2: #1e2d3d;
    --kp-side-ink: #c7d2de;
    --kp-sidebar-w: 248px;
    --bs-primary: #0f766e;
    --bs-primary-rgb: 15, 118, 110;
    --bs-link-color: #0f766e;
    --bs-link-color-rgb: 15, 118, 110;
    --bs-link-hover-color: #0b5e58;
    --bs-body-color: #0f172a;
    --bs-border-color: #e3e8ef;
    --bs-font-sans-serif: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

body.kp { background: var(--kp-bg); color: var(--kp-ink); font-size: .925rem; }
[hidden] { display: none !important; }

/* ---- buttons / forms ---------------------------------------------------------------------------------------- */
.btn-primary { --bs-btn-bg: var(--kp-primary); --bs-btn-border-color: var(--kp-primary); --bs-btn-hover-bg: var(--kp-primary-dark);
    --bs-btn-hover-border-color: var(--kp-primary-dark); --bs-btn-active-bg: var(--kp-primary-dark); --bs-btn-active-border-color: var(--kp-primary-dark);
    --bs-btn-disabled-bg: var(--kp-primary); --bs-btn-disabled-border-color: var(--kp-primary); }
.btn-outline-primary { --bs-btn-color: var(--kp-primary); --bs-btn-border-color: var(--kp-primary); --bs-btn-hover-bg: var(--kp-primary);
    --bs-btn-hover-border-color: var(--kp-primary); --bs-btn-active-bg: var(--kp-primary-dark); --bs-btn-active-border-color: var(--kp-primary-dark); }
.btn-accent { background: var(--kp-accent); border-color: var(--kp-accent); color: #1f1300; font-weight: 600; }
.btn-accent:hover, .btn-accent:focus { background: #d97706; border-color: #d97706; color: #1f1300; }
.btn { font-weight: 500; }
.btn-icon { padding: .25rem .5rem; }
.form-label { font-weight: 500; font-size: .85rem; color: #334155; margin-bottom: .3rem; }
.form-control, .form-select { border-color: #d5dde7; }
.form-control:focus, .form-select:focus { border-color: #5fb3ab; box-shadow: 0 0 0 .2rem rgba(15, 118, 110, .15); }
.field-validation-error, .text-danger { font-size: .8rem; }
.input-validation-error { border-color: #dc3545 !important; }
.required::after { content: " *"; color: #dc3545; }

/* ---- shell ------------------------------------------------------------------------------------------------- */
.kp-sidebar { position: fixed; inset: 0 auto 0 0; width: var(--kp-sidebar-w); background: linear-gradient(180deg, var(--kp-side), #121b26);
    color: var(--kp-side-ink); display: flex; flex-direction: column; z-index: 1040; transition: transform .2s ease; }
.kp-brand { display: flex; gap: .7rem; align-items: center; padding: 1.15rem 1.2rem 1rem; color: #fff; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.06); }
.kp-brand:hover { color: #fff; }
.kp-logo svg { width: 36px; height: 36px; display: block; }
.kp-brand-name { display: block; font-weight: 800; letter-spacing: .14em; font-size: 1.12rem; line-height: 1.1; }
.kp-brand-sub { display: block; font-size: .7rem; color: #f8c466; letter-spacing: .03em; }
.kp-nav { flex: 1; overflow-y: auto; padding: .6rem .7rem 1rem; }
.kp-nav-title { font-size: .66rem; text-transform: uppercase; letter-spacing: .12em; color: #7f90a3; padding: 1rem .65rem .35rem; }
.kp-link { display: flex; align-items: center; gap: .7rem; padding: .5rem .7rem; border-radius: .5rem; color: var(--kp-side-ink); text-decoration: none; font-size: .9rem; }
.kp-link i { font-size: 1.05rem; width: 1.2rem; text-align: center; opacity: .85; }
.kp-link:hover { background: var(--kp-side-2); color: #fff; }
.kp-link.active { background: rgba(245, 158, 11, .14); color: #fff; box-shadow: inset 3px 0 0 var(--kp-accent); }
.kp-link.active i { color: var(--kp-accent); opacity: 1; }
.kp-sidebar-foot { font-size: .7rem; color: #6c7d90; padding: .8rem 1.2rem 1rem; border-top: 1px solid rgba(255,255,255,.06); }

.kp-main { margin-left: var(--kp-sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.kp-topbar { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: .75rem; background: rgba(255,255,255,.92);
    backdrop-filter: blur(6px); border-bottom: 1px solid var(--kp-border); padding: .6rem 1.5rem; min-height: 62px; }
.kp-title h1 { font-size: 1.2rem; font-weight: 700; margin: 0; }
.kp-crumb { font-size: .75rem; color: var(--kp-muted); }
.kp-burger { display: none; font-size: 1.6rem; color: var(--kp-ink); padding: 0 .25rem; }
.kp-user { display: flex; align-items: center; gap: .5rem; border: 1px solid var(--kp-border); background: #fff; border-radius: 2rem; padding: .25rem .75rem .25rem .3rem; }
.kp-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--kp-primary); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .8rem; }
.kp-content { padding: 1.4rem 1.5rem 2.5rem; flex: 1; }
.kp-alert { border: 0; box-shadow: 0 1px 2px rgba(15,23,42,.06); }
.kp-backdrop { display: none; }

@media (max-width: 991.98px) {
    .kp-sidebar { transform: translateX(-100%); }
    body.kp-nav-open .kp-sidebar { transform: none; }
    body.kp-nav-open .kp-backdrop { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 1030; }
    .kp-main { margin-left: 0; }
    .kp-burger { display: inline-block; }
    .kp-content { padding: 1rem .9rem 2rem; }
    .kp-topbar { padding: .5rem .9rem; }
}

/* ---- surfaces ---------------------------------------------------------------------------------------------- */
.kp-card { background: var(--kp-surface); border: 1px solid var(--kp-border); border-radius: .8rem; box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.kp-card-head { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; padding: .9rem 1.1rem; border-bottom: 1px solid var(--kp-border); }
.kp-card-head h2, .kp-card-head h3 { font-size: 1rem; font-weight: 650; margin: 0; }
.kp-card-body { padding: 1.1rem; }
.kp-card-foot { padding: .8rem 1.1rem; border-top: 1px solid var(--kp-border); background: #fafbfc; border-radius: 0 0 .8rem .8rem; }
.kp-toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.kp-toolbar .form-control, .kp-toolbar .form-select { max-width: 260px; }
.kp-toolbar .spacer { flex: 1; }
.kp-section-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--kp-muted); font-weight: 600; margin: 0 0 .6rem; }

/* stat cards */
.kp-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
@media (min-width: 1680px) { .kp-stats { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
@media (max-width: 767.98px) { .kp-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; } }
@media (max-width: 479.98px) { .kp-stat-icon { display: none !important; } }
.kp-stat { background: #fff; border: 1px solid var(--kp-border); border-radius: .8rem; padding: 1rem 1.1rem; display: flex; gap: .85rem; align-items: center; text-decoration: none; color: inherit; }
a.kp-stat:hover { border-color: #b9d9d5; box-shadow: 0 4px 14px rgba(15,23,42,.06); color: inherit; }
.kp-stat-icon { width: 44px; height: 44px; flex: none; border-radius: .7rem; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; }
.kp-stat-label { font-size: .78rem; color: var(--kp-muted); }
.kp-stat > div:last-child { min-width: 0; }
.kp-stat-value { font-size: 1.45rem; font-weight: 700; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 767.98px) { .kp-stat { padding: .75rem; gap: .6rem; } .kp-stat-icon { width: 36px; height: 36px; font-size: 1.05rem; } .kp-stat-value { font-size: 1.15rem; } }
.kp-stat-value small { font-size: .75rem; font-weight: 600; color: var(--kp-muted); }
.tone-teal { background: #e3f3f1; color: #0f766e; }
.tone-amber { background: #fdf3e1; color: #b45309; }
.tone-blue { background: #e7effd; color: #2557c7; }
.tone-green { background: #e5f5ea; color: #15803d; }
.tone-slate { background: #edf0f4; color: #475569; }
.tone-violet { background: #f0ebfd; color: #6d28d9; }

/* tables */
.kp-table { margin: 0; }
.kp-table > :not(caption) > * > * { padding: .62rem .8rem; vertical-align: middle; border-color: #edf1f5; }
.kp-table thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--kp-muted); font-weight: 600; background: #f8fafc; white-space: nowrap; }
.kp-table tbody tr:hover > * { background: #fafcfd; }
.kp-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kp-table tfoot td { font-weight: 700; background: #f8fafc; }
.kp-empty { text-align: center; color: var(--kp-muted); padding: 2.5rem 1rem; }
.kp-empty i { font-size: 2rem; display: block; margin-bottom: .5rem; color: #a3b1c2; }
.badge { font-weight: 600; letter-spacing: .02em; }
.text-bg-warning { color: #5b3a00 !important; }
.kp-dl dt { font-size: .75rem; color: var(--kp-muted); font-weight: 500; }
.kp-dl dd { margin-bottom: .7rem; font-weight: 500; }

/* ---- component grid ---------------------------------------------------------------------------------------- */
.kp-grid-wrap { overflow-x: auto; }
.kp-grid { min-width: 1080px; }
.kp-grid td { padding: .35rem .35rem !important; }
.kp-grid .form-control, .kp-grid .form-select { padding: .3rem .45rem; font-size: .86rem; }
.kp-grid .c-name { min-width: 180px; }
.kp-grid .c-type { min-width: 150px; }
.kp-grid .c-thick { width: 100px; }
.kp-grid .c-num { width: 95px; }
.kp-grid .c-qty { width: 72px; }
.kp-grid .c-grain { width: 145px; }
.kp-grid .c-rot { width: 70px; text-align: center; }
.kp-grid .c-act { width: 86px; white-space: nowrap; }
.kp-grid tr.is-new td { background: #fffbeb; }
.kp-grid-summary { display: flex; gap: 1.5rem; flex-wrap: wrap; font-size: .85rem; color: var(--kp-muted); }
.kp-grid-summary strong { color: var(--kp-ink); }

/* ---- cutting layouts --------------------------------------------------------------------------------------- */
.kp-board-nav { display: flex; gap: .4rem; flex-wrap: wrap; }
.kp-board-nav .btn { min-width: 2.6rem; }
.kp-board-nav .btn.is-offcut { border-style: dashed; }
.kp-board { display: none; }
.kp-board.is-current { display: block; }
.kp-board-svg { width: 100%; height: auto; display: block; background: #fff; }
.kp-board-svg text { font-family: "Segoe UI", system-ui, Arial, sans-serif; }
.kp-board-svg .part:hover rect { filter: brightness(.94); }
.kp-legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .8rem; color: var(--kp-muted); }
.kp-legend span::before { content: ""; display: inline-block; width: 14px; height: 10px; margin-right: .35rem; vertical-align: -1px; border-radius: 2px; border: 1px solid rgba(0,0,0,.25); }
.kp-legend .lg-off::before { background: #dcfce7; border: 1px dashed #16a34a; }
.kp-legend .lg-waste::before { background: repeating-linear-gradient(45deg, #e2e8f0 0 3px, #f8fafc 3px 6px); }
.kp-legend .lg-kerf::before { background: #dc2626; height: 3px; border: 0; vertical-align: 3px; }
.kp-legend .lg-trim::before { background: #94a3b8; }
.kp-swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(0,0,0,.2); vertical-align: -1px; }
.kp-metric { display: flex; justify-content: space-between; padding: .35rem 0; border-bottom: 1px dashed #e8edf3; font-size: .86rem; }
.kp-metric:last-child { border-bottom: 0; }
.kp-metric span { color: var(--kp-muted); }
.kp-metric strong { font-variant-numeric: tabular-nums; }
.kp-util { height: 8px; background: #e9eef4; border-radius: 4px; overflow: hidden; }
.kp-util > div { height: 100%; background: linear-gradient(90deg, #14b8a6, #0f766e); }

/* ---- auth -------------------------------------------------------------------------------------------------- */
.kp-auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: #fff; }
.kp-auth-art { position: relative; background: radial-gradient(circle at 20% 20%, #23384d, var(--kp-side) 60%); color: #e2e8f0; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; }
.kp-auth-art h2 { font-size: 2.1rem; font-weight: 800; color: #fff; max-width: 26rem; line-height: 1.2; }
.kp-auth-art p { color: #aebdcc; max-width: 26rem; }
.kp-auth-art svg.sheet { position: absolute; right: -60px; bottom: -40px; width: 520px; opacity: .9; }
.kp-auth-form { display: flex; align-items: center; justify-content: center; padding: 2rem 1.25rem; }
.kp-auth-box { width: 100%; max-width: 380px; }
.kp-auth-box h1 { font-size: 1.5rem; font-weight: 700; }
@media (max-width: 860px) { .kp-auth { grid-template-columns: 1fr; } .kp-auth-art { display: none; } }

/* ---- print ------------------------------------------------------------------------------------------------- */
.kp-print-page { background: #fff; }
.kp-print-board { background: #fff; }
@media screen { .kp-print-board { border: 1px solid var(--kp-border); border-radius: .6rem; padding: 1rem; } }
@media print {
    @page { size: A4 landscape; margin: 10mm; }
    body.kp { background: #fff; font-size: 10pt; }
    .kp-sidebar, .kp-topbar, .kp-backdrop, .no-print, .kp-alert { display: none !important; }
    .kp-main { margin: 0; }
    .kp-content { padding: 0; }
    .kp-card { border: 0; box-shadow: none; }
    .kp-board { display: block !important; }
    .print-break { break-after: page; page-break-after: always; }
    .print-avoid { break-inside: avoid; }
    a { text-decoration: none; color: inherit; }
}
