:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --bg: #f4f6f9;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --gray: #6b7280;
}

* { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', 'Sarabun', Tahoma, sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    font-size: 14px;
}

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

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

.sidebar {
    width: 220px;
    background: #111827;
    color: #e5e7eb;
    flex-shrink: 0;
    padding: 20px 0;
}
.sidebar .brand {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    padding: 0 20px 20px;
    border-bottom: 1px solid #1f2937;
    margin-bottom: 10px;
}
.sidebar nav a {
    display: block;
    padding: 10px 20px;
    color: #cbd5e1;
    font-size: 14px;
}
.sidebar nav a:hover, .sidebar nav a.active {
    background: #1f2937;
    color: #fff;
    text-decoration: none;
}
.sidebar .user-box {
    padding: 15px 20px;
    border-top: 1px solid #1f2937;
    margin-top: 10px;
    font-size: 13px;
    color: #94a3b8;
}

.main {
    flex: 1;
    padding: 24px 30px;
    max-width: 100%;
    overflow-x: auto;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.topbar h1 { font-size: 22px; margin: 0; }

/* ---------- Cards ---------- */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 18px;
}
.stat-card .label { color: var(--text-muted); font-size: 13px; margin-bottom: 6px; }
.stat-card .value { font-size: 26px; font-weight: 700; }
.stat-card.blue .value { color: var(--primary); }
.stat-card.green .value { color: var(--success); }
.stat-card.orange .value { color: var(--warning); }
.stat-card.red .value { color: var(--danger); }

/* ---------- Table ---------- */
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
}
th, td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    white-space: nowrap;
}
th { background: #f8fafc; font-weight: 600; color: var(--text-muted); font-size: 13px; }
tr:hover td { background: #f9fafb; }

.table-wrap {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: auto;
}

/* ---------- Badges ---------- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}
.badge-in_stock { background: #e0f2fe; color: #0369a1; }
.badge-in_use { background: #dcfce7; color: #15803d; }
.badge-maintenance { background: #fef3c7; color: #b45309; }
.badge-retired { background: #f1f5f9; color: #475569; }
.badge-lost { background: #fee2e2; color: #b91c1c; }

/* ---------- Forms ---------- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}
label { display: block; font-size: 13px; margin-bottom: 4px; color: var(--text-muted); }
input, select, textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #93c5fd; border-color: var(--primary); }
textarea { resize: vertical; min-height: 70px; }

.field-full { grid-column: 1 / -1; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 6px;
    border: none;
    font-size: 14px;
    cursor: pointer;
    font-weight: 600;
    text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; }
.btn-secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #f1f5f9; text-decoration: none; }
.btn-danger { background: #fff; color: var(--danger); border: 1px solid #fecaca; }
.btn-danger:hover { background: #fef2f2; text-decoration: none; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

.actions { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.actions-left { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Alerts ---------- */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}
.alert-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.alert-danger { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }

/* ---------- Login ---------- */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b, #0f172a);
}
.login-box {
    background: #fff;
    padding: 36px;
    border-radius: 12px;
    width: 340px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.login-box h1 { font-size: 20px; margin-bottom: 4px; }
.login-box p { color: var(--text-muted); margin-top: 0; margin-bottom: 20px; font-size: 13px; }
.login-box .btn { width: 100%; margin-top: 10px; }

.search-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.search-bar input, .search-bar select { width: auto; min-width: 160px; }

@media (max-width: 768px) {
    .app-shell { flex-direction: column; }
    .sidebar { width: 100%; padding: 10px 0; }
    .sidebar nav { display: flex; overflow-x: auto; }
    .main { padding: 16px; }
}
