:root {
    --bg: #f3f4f6;
    --panel: #ffffff;
    --text: #111827;
    --muted: #6b7280;
    --line: #e5e7eb;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-soft: #dbeafe;
    --success: #15803d;
    --warning: #a16207;
    --danger: #b91c1c;
    --sidebar: #111827;
    --sidebar-soft: #1f2937;
    --shadow: 0 16px 40px rgba(15, 23, 42, .08);
    --radius: 18px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, Helvetica, sans-serif; background: var(--bg); color: var(--text); line-height: 1.45; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
.app-shell { min-height: 100vh; display: flex; }
.sidebar { width: 282px; background: linear-gradient(180deg, var(--sidebar), #0f172a); color: #fff; padding: 22px 16px; position: fixed; inset: 0 auto 0 0; overflow-y: auto; z-index: 20; transition: transform .2s ease; border-right: 1px solid rgba(255,255,255,.08); }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; padding: 8px; border-radius: 18px; background: rgba(255,255,255,.05); }
.brand-logo, .brand-mark { width: 48px; height: 48px; border-radius: 14px; background: var(--primary); display: grid; place-items: center; font-weight: 800; color: #fff; object-fit: contain; flex: 0 0 auto; padding: 5px; }
.logo-fallback { background: linear-gradient(135deg, var(--primary), #38bdf8); color: #fff; letter-spacing: .03em; }
.brand strong { display: block; color: #fff; font-size: 15px; line-height: 1.2; }
.brand span { display: block; color: #cbd5e1; font-size: 12px; margin-top: 3px; }
.nav { display: grid; gap: 6px; }
.nav a { color: #d1d5db; padding: 12px 14px; border-radius: 12px; font-weight: 650; transition: background .18s ease, color .18s ease, transform .18s ease; }
.nav a:hover, .nav a.active { background: rgba(255,255,255,.10); color: #fff; transform: translateX(2px); }
.main { margin-left: 282px; width: calc(100% - 282px); }
.topbar { background: rgba(255,255,255,.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); padding: 18px 28px; display: flex; align-items: center; justify-content: space-between; gap: 18px; position: sticky; top: 0; z-index: 10; }
.topbar h1 { margin: 0; font-size: 24px; letter-spacing: -.02em; }
.topbar p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.menu-button { display: none; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 9px 12px; cursor: pointer; box-shadow: 0 4px 16px rgba(15,23,42,.06); }
.user-menu { display: flex; align-items: center; gap: 14px; }
.user-menu span { color: var(--text); font-weight: 750; }
.user-menu small { display: block; color: var(--muted); font-weight: 500; text-align: right; }
.content { padding: 28px; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.card-header h2, .card h2 { margin: 0; font-size: 18px; letter-spacing: -.01em; }
.stat { display: flex; flex-direction: column; gap: 8px; }
.stat .num { font-size: 34px; font-weight: 850; letter-spacing: -.04em; }
.stat .label { color: var(--muted); font-weight: 650; }
.table-wrapper { overflow-x: auto; border-radius: 14px; }
table { width: 100%; border-collapse: collapse; background: var(--panel); }
th, td { padding: 12px 13px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #f8fafc; }
tr:hover td { background: #fbfdff; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 7px; }
.form-group.full { grid-column: 1 / -1; }
label { font-weight: 750; font-size: 13px; color: #374151; }
input, select, textarea { width: 100%; border: 1px solid #cbd5e1; border-radius: 12px; padding: 11px 12px; font: inherit; background: #fff; transition: box-shadow .16s ease, border-color .16s ease; }
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 0; box-shadow: 0 0 0 4px rgba(37, 99, 235, .14); border-color: var(--primary); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 12px; padding: 10px 14px; cursor: pointer; font-weight: 750; background: #e5e7eb; color: #111827; box-shadow: 0 4px 12px rgba(15, 23, 42, .05); transition: transform .14s ease, filter .14s ease, background .14s ease; }
.btn:hover { filter: brightness(.98); transform: translateY(-1px); color: inherit; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: #f59e0b; color: #111827; }
.btn-sm { padding: 7px 10px; border-radius: 10px; font-size: 13px; }
.alert { border-radius: 14px; padding: 12px 14px; margin-bottom: 16px; border: 1px solid transparent; }
.alert-success { background: #dcfce7; border-color: #86efac; color: #14532d; }
.alert-danger { background: #fee2e2; border-color: #fca5a5; color: #7f1d1d; }
.alert-warning { background: #fef3c7; border-color: #fcd34d; color: #713f12; }
.alert-info { background: #dbeafe; border-color: #93c5fd; color: #1e3a8a; }
.badge { display: inline-block; padding: 5px 9px; border-radius: 999px; font-size: 12px; font-weight: 800; background: #e5e7eb; color: #374151; }
.badge-deployed, .badge-delivered, .badge-accepted, .badge-resolved, .badge-closed { background: #dcfce7; color: #14532d; }
.badge-pending, .badge-open, .badge-in-progress { background: #fef3c7; color: #713f12; }
.badge-for-repair, .badge-overdue { background: #fee2e2; color: #7f1d1d; }
.badge-in-stock { background: #dbeafe; color: #1e3a8a; }
.badge-complete { background: #dcfce7; color: #14532d; }
.badge-needs-completion { background: #fef3c7; color: #713f12; }
.badge-condemned, .badge-lost, .badge-cancelled { background: #e5e7eb; color: #374151; }
.search-row, .toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.search-row input, .toolbar input { max-width: 360px; }
.empty-state { color: var(--muted); text-align: center; padding: 24px; }
.helper-text { color: var(--muted); font-size: 13px; }
.checkbox-line { flex-direction: row; align-items: center; gap: 10px; }
.checkbox-line input { width: auto; }
.checkbox-line label { margin: 0; }
.print-only { display: none; }
.print-letterhead { align-items: center; gap: 14px; border-bottom: 2px solid #111827; padding-bottom: 14px; margin-bottom: 18px; }
.print-letterhead h2 { margin: 0; font-size: 20px; }
.print-letterhead p { margin: 2px 0; color: #374151; }
.print-logo { width: 64px; height: 64px; object-fit: contain; border-radius: 10px; padding: 4px; }
.logo-preview-card { border: 1px dashed #cbd5e1; border-radius: 20px; padding: 28px; text-align: center; background: #f8fafc; }
.preview-logo-wrap { display: grid; place-items: center; min-height: 140px; }
.preview-logo { max-width: 220px; max-height: 120px; object-fit: contain; border-radius: 16px; }
.logo-preview-card h3 { margin: 16px 0 4px; font-size: 22px; }
.logo-preview-card p { margin: 0; color: var(--muted); }

.login-page { min-height: 100vh; padding: 0; background: #f8fafc; }
.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(420px, .95fr) minmax(420px, 1.05fr); }
.login-hero { position: relative; overflow: hidden; display: flex; align-items: center; padding: 56px; color: #fff; background: radial-gradient(circle at top left, rgba(96,165,250,.9), transparent 28%), linear-gradient(135deg, #0f172a, #1d4ed8 56%, #0284c7); }
.login-hero::after { content: ""; position: absolute; inset: auto -110px -170px auto; width: 360px; height: 360px; border-radius: 999px; background: rgba(255,255,255,.12); }
.login-hero-overlay { position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.08) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.08) 1px, transparent 1px); background-size: 44px 44px; opacity: .35; }
.login-hero-content { position: relative; z-index: 1; max-width: 560px; }
.login-hero-logo { width: 84px; height: 84px; object-fit: contain; border-radius: 24px; background: rgba(255,255,255,.16); padding: 8px; display: grid; place-items: center; font-weight: 900; color: #fff; margin-bottom: 26px; }
.eyebrow { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .12em; font-weight: 850; color: var(--primary); }
.login-hero .eyebrow { color: #bfdbfe; }
.login-hero h1 { margin: 0; font-size: clamp(34px, 5vw, 58px); line-height: 1.02; letter-spacing: -.05em; }
.login-hero p { color: #dbeafe; font-size: 17px; max-width: 460px; }
.login-feature-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 28px; }
.login-feature-grid span { border: 1px solid rgba(255,255,255,.24); background: rgba(255,255,255,.10); border-radius: 14px; padding: 12px; font-weight: 700; color: #f8fafc; }
.login-panel { display: grid; place-items: center; padding: 36px; }
.login-card { width: 100%; max-width: 440px; background: #fff; border: 1px solid #e5e7eb; border-radius: 24px; padding: 34px; box-shadow: 0 24px 70px rgba(15, 23, 42, .12); }
.login-brand-mobile { display: none; align-items: center; gap: 12px; margin-bottom: 24px; }
.login-logo { width: 50px; height: 50px; object-fit: contain; border-radius: 14px; padding: 5px; }
.login-brand-mobile strong { display: block; }
.login-brand-mobile span { display: block; color: var(--muted); font-size: 12px; }
.login-card-header { margin-bottom: 22px; }
.login-card-header h2 { margin: 0; font-size: 28px; letter-spacing: -.03em; }
.login-card-header p:not(.eyebrow) { margin: 7px 0 0; color: var(--muted); }
.login-card .form-group { margin-bottom: 16px; }
.login-submit { width: 100%; margin-top: 4px; padding: 12px 16px; }
.login-card .helper-text { margin: 18px 0 0; text-align: center; }

.mini-card { box-shadow: none; }
.bulk-table { max-height: 520px; overflow: auto; border: 1px solid var(--line); border-radius: 14px; }
.bulk-table table { min-width: 1100px; }
.bulk-table input, .bulk-table select { min-width: 140px; padding: 8px 9px; border-radius: 9px; }
.bulk-table textarea { min-width: 200px; min-height: 70px; }
.bulk-table th, .bulk-table td { padding: 8px; }
details summary { cursor: pointer; font-weight: 700; }

@media print {
    body { background: #fff; color: #000; }
    .sidebar, .topbar, .no-print, .actions, .search-row, .toolbar { display: none !important; }
    .main { margin: 0; width: 100%; }
    .content { padding: 0; }
    .card { box-shadow: none; border: 0; padding: 10px 0; }
    .print-only { display: flex; }
    a { color: #000; }
    th { background: #f3f4f6 !important; color: #111827; }
}
@media (max-width: 1100px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .login-shell { grid-template-columns: 1fr; }
    .login-hero { display: none; }
    .login-brand-mobile { display: flex; }
}
@media (max-width: 960px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; width: 100%; }
    .menu-button { display: inline-block; }
    .grid-2, .grid-3, .grid-4, .form-grid { grid-template-columns: 1fr; }
    .user-menu { flex-direction: column; align-items: flex-end; gap: 4px; }
}
@media (max-width: 560px) {
    .content, .topbar { padding: 18px; }
    .login-panel { padding: 20px; }
    .login-card { padding: 24px; border-radius: 20px; }
}
