/* ============================================================
   IT Asset Management - modern UI
   ============================================================ */

:root {
    --bg: #f1f5fb;
    --card: #ffffff;
    --ink: #1e293b;
    --muted: #64748b;
    --line: #e2e8f0;
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --sidebar: linear-gradient(180deg, #1e1b4b 0%, #312e81 55%, #3730a3 100%);
    --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 8px 24px rgba(15, 23, 42, .06);
    --radius: 14px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 14.5px;
    line-height: 1.55;
}

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

h1, h2, h3 { margin: 0 0 10px; line-height: 1.25; }
h2 { font-size: 16px; font-weight: 700; }

.muted { color: var(--muted); font-size: 13px; }

/* ---------- App shell ---------- */

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

.sidebar {
    width: 250px;
    flex: 0 0 250px;
    background: var(--sidebar);
    color: #e0e7ff;
    display: flex;
    flex-direction: column;
    padding: 20px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px 18px;
    font-weight: 700;
    font-size: 15px;
    color: #fff;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #6366f1, #a855f7);
    color: #fff;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: .5px;
    box-shadow: 0 4px 12px rgba(99, 102, 241, .45);
    flex: 0 0 auto;
}

.brand-mark.big { width: 52px; height: 52px; font-size: 18px; border-radius: 14px; }

.nav { display: flex; flex-direction: column; gap: 3px; }

.nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 10px;
    color: #c7d2fe;
    font-weight: 500;
    font-size: 14px;
}

.nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; text-decoration: none; }

.nav a.active {
    background: rgba(255, 255, 255, .14);
    color: #fff;
    box-shadow: inset 3px 0 0 #a5b4fc;
}

.nav-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .55; flex: 0 0 auto; }
.nav a.active .nav-dot { background: #a5b4fc; opacity: 1; box-shadow: 0 0 8px #a5b4fc; }

.sidebar-footer { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, .12); padding-top: 14px; }

.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 6px 10px; }
.user-chip .user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-chip small { color: #a5b4fc; }

.avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px;
    flex: 0 0 auto;
}

.sidebar-footer .link { display: block; padding: 6px 12px; border-radius: 8px; color: #c7d2fe; font-size: 13px; }
.sidebar-footer .link:hover { background: rgba(255, 255, 255, .08); color: #fff; text-decoration: none; }
.sidebar-footer .link.danger { color: #fca5a5; }

.main { flex: 1; padding: 26px 30px 40px; min-width: 0; }

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

.page-title { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }

/* ---------- Cards & panels ---------- */

.panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px;
    margin-bottom: 18px;
}

.split { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }

.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)); gap: 12px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }

/* ---------- Stat cards ---------- */

.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.stat-card {
    border-radius: var(--radius);
    color: #fff;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: "";
    position: absolute;
    right: -30px; top: -30px;
    width: 110px; height: 110px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .12);
}

.stat-icon { font-size: 20px; margin-bottom: 4px; }
.stat-label { font-size: 12.5px; text-transform: uppercase; letter-spacing: .06em; opacity: .9; }
.stat-value { font-size: 30px; font-weight: 800; line-height: 1.1; }
.stat-sub { font-size: 12px; opacity: .85; margin-top: 4px; }

.c-blue   { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.c-green  { background: linear-gradient(135deg, #10b981, #059669); }
.c-orange { background: linear-gradient(135deg, #f59e0b, #d97706); }
.c-purple { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.c-red    { background: linear-gradient(135deg, #ef4444, #dc2626); }
.c-teal   { background: linear-gradient(135deg, #14b8a6, #0d9488); }

/* ---------- Charts ---------- */

.chart-panel { min-height: 260px; }
.chart { max-height: 260px; width: 100% !important; }

/* ---------- Forms ---------- */

label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .04em; }

input, select, textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid var(--line);
    border-radius: 10px;
    font: inherit;
    color: var(--ink);
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .15);
}

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

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 16px; }

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: 10px;
    border: 1.5px solid var(--line);
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
    text-decoration: none !important;
}

.btn:hover { border-color: #c7d2fe; background: #eef2ff; color: var(--primary-dark); }

.btn-primary {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 4px 12px rgba(79, 70, 229, .35);
}
.btn-primary:hover { background: linear-gradient(135deg, #4f46e5, #4338ca); color: #fff; }

.btn-danger { background: linear-gradient(135deg, #ef4444, #dc2626); border-color: transparent; color: #fff; }
.btn-danger:hover { background: #dc2626; color: #fff; }

.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; justify-content: center; }

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

.inline-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.inline-form input, .inline-form select { width: auto; }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

th {
    text-align: left;
    padding: 9px 10px;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    border-bottom: 2px solid var(--line);
    white-space: nowrap;
}

td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }

tbody tr:hover { background: #f8faff; }
tbody tr:last-child td { border-bottom: none; }

/* ---------- Badges & flash ---------- */

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge.ok   { background: #d1fae5; color: #065f46; }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.bad  { background: #fee2e2; color: #991b1b; }

.flash {
    border-radius: 10px;
    padding: 11px 16px;
    margin-bottom: 16px;
    font-weight: 600;
    border: 1px solid transparent;
}

.flash.success { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.flash.error   { background: #fef2f2; color: #991b1b; border-color: #fecaca; }

/* ---------- Login ---------- */

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background:
        radial-gradient(1200px 600px at 10% -10%, #c7d2fe 0%, transparent 55%),
        radial-gradient(1000px 500px at 110% 110%, #fbcfe8 0%, transparent 50%),
        linear-gradient(135deg, #eef2ff, #f8fafc);
}

.login-card {
    width: 100%;
    max-width: 410px;
    background: var(--card);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(30, 27, 75, .18);
    padding: 34px 32px;
}

.login-head { text-align: center; margin-bottom: 22px; }
.login-head .brand-mark { margin-bottom: 10px; }
.login-head h1 { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.login-head p { margin: 6px 0 0; }

/* ---------- QR labels ---------- */

.qr-mini { width: 54px; height: 54px; }
.qr-mini img, .qr-mini canvas { width: 100%; height: 100%; display: block; }

.qr-label {
    text-align: center;
    border: 2px dashed var(--line);
    border-radius: 12px;
    padding: 14px;
    margin: 10px;
    display: inline-block;
    min-width: 170px;
    background: #fff;
}

.qr-label .company { font-weight: 800; text-transform: uppercase; letter-spacing: .05em; font-size: 12px; color: var(--primary); }
.qr-label img, .qr-label canvas { margin-top: 8px; }

/* ---------- Repair rows ---------- */

.repair-row {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 10px;
    background: #fbfcfe;
}

.repair-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; font-size: 13px; }

/* ---------- Documents ---------- */

.document {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 34px 40px;
    margin-bottom: 18px;
}

.document-header { text-align: center; margin-bottom: 20px; }
.document-header strong { font-size: 18px; }
.document-title { font-size: 15px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-top: 2px; }

.document-table { width: 100%; border-collapse: collapse; }
.document-table th, .document-table td { border: 1px solid #cbd5e1; padding: 8px 12px; font-size: 13.5px; }
.document-table th { background: #f1f5f9; text-align: left; width: 16%; }

.signature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; margin-top: 40px; }
.signature-box { border-top: 1.5px solid var(--ink); padding-top: 8px; text-align: center; font-size: 12.5px; color: var(--muted); height: 46px; }

.scan-card { max-width: 720px; margin: 40px auto; }

/* ---------- Responsive ---------- */

@media (max-width: 980px) {
    .app { flex-direction: column; }
    .sidebar { width: 100%; flex: none; height: auto; position: static; }
    .nav { flex-direction: row; flex-wrap: wrap; }
    .sidebar-footer { margin-top: 14px; }
    .split, .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .main { padding: 18px 14px 30px; }
}

/* ---------- Print ---------- */

@media print {
    .sidebar, .topbar, .no-print, .flash { display: none !important; }
    .main { padding: 0; }
    body { background: #fff; }
    .panel, .document { box-shadow: none; border: none; }
}
