/* ---- Base layout ---- */
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: 'Segoe UI', Arial, sans-serif;
    background: #f1f5f9;
    color: #1e293b;
}
a { color: #d97706; text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
    display: flex; align-items: center; justify-content: space-between;
    background: #1e293b; color: #fff; padding: 14px 24px; flex-wrap: wrap; gap: 12px;
}
.topbar .brand { font-size: 20px; font-weight: 700; color: #fff; }
.topbar nav { display: flex; gap: 16px; flex-wrap: wrap; }
.topbar nav a { color: #cbd5e1; font-size: 14px; }
.topbar nav a:hover { color: #fff; text-decoration: none; }
.topbar nav a.active { color: #fff; font-weight: 600; border-bottom: 2px solid #d97706; padding-bottom: 2px; }
.topbar .user-info { font-size: 14px; color: #cbd5e1; }
.topbar .user-info a { color: #fca5a5; }

.content { max-width: 1100px; margin: 0 auto; padding: 24px; }

h1 { font-size: 26px; }
h2 { font-size: 20px; margin-top: 30px; }

.card-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px; margin: 20px 0;
}
.card {
    background: #fff; border-radius: 10px; padding: 20px; text-align: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}
.card h3 { margin: 0 0 6px; font-size: 28px; }
.card p { margin: 0; color: #64748b; font-size: 14px; }
.card-alert { border: 2px solid #dc2626; }
.card-alert h3 { color: #dc2626; }

.data-table {
    width: 100%; border-collapse: collapse; background: #fff;
    border-radius: 10px; overflow: hidden; box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}
.data-table th, .data-table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid #e2e8f0; }
.data-table th { background: #f8fafc; font-size: 13px; text-transform: uppercase; color: #64748b; }

.footer { text-align: center; padding: 20px; color: #94a3b8; font-size: 13px; }

/* ---- Login page ---- */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #1e293b; }
.login-box {
    background: #fff; padding: 40px; border-radius: 12px; width: 320px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2); text-align: center;
}
.login-box h1 { margin: 0 0 4px; }
.login-box .subtitle { color: #64748b; font-size: 14px; margin-bottom: 24px; }
.login-box form { text-align: left; display: flex; flex-direction: column; gap: 12px; }
.login-box label { font-size: 14px; font-weight: 600; }
.login-box input {
    padding: 10px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px;
}
.login-box button {
    margin-top: 10px; padding: 10px; border: none; border-radius: 6px;
    background: #d97706; color: #fff; font-weight: 600; cursor: pointer;
}
.login-box button:hover { background: #b45309; }

.alert-error { background: #fee2e2; color: #b91c1c; }

/* ---- Added for CRUD pages, forms, reports ---- */
.alert { padding: 10px 14px; border-radius: 6px; font-size: 14px; margin-bottom: 16px; }
.alert-success { background: #dcfce7; color: #166534; }

.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.page-header h1 { margin: 0; }

.btn {
    display: inline-block; padding: 8px 16px; border: none; border-radius: 6px;
    background: #d97706; color: #fff; font-size: 14px; font-weight: 600;
    cursor: pointer; text-decoration: none;
}
.btn:hover { background: #b45309; }
.btn-secondary { background: #64748b; }
.btn-secondary:hover { background: #475569; }
.btn-danger { background: #dc2626; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

.form-box {
    background: #fff; padding: 24px; border-radius: 10px; max-width: 520px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.form-group { margin-bottom: 14px; }
.form-group label { display: block; margin-bottom: 4px; font-size: 14px; font-weight: 600; color: #333; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 8px 10px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px;
}
.form-actions { margin-top: 20px; display: flex; gap: 10px; }

.search-bar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.search-bar input, .search-bar select { padding: 8px 10px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; }
.search-bar button { padding: 8px 16px; }

.data-table .actions { display: flex; gap: 6px; }
.data-table td.num { text-align: right; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-pending { background: #fef3c7; color: #b45309; }
.badge-received { background: #dcfce7; color: #166534; }
.badge-cancelled { background: #fee2e2; color: #b91c1c; }
.badge-stockin { background: #dcfce7; color: #166534; }
.badge-sale { background: #dbeafe; color: #1e40af; }
.badge-active { background: #dcfce7; color: #166534; }
.badge-inactive { background: #f1f5f9; color: #64748b; }

.report-tabs { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.report-tabs a {
    padding: 8px 14px; border-radius: 6px; text-decoration: none; font-size: 14px;
    background: #e2e8f0; color: #334155;
}
.report-tabs a.active { background: #1e293b; color: #fff; }

.empty-state { padding: 30px; text-align: center; color: #888; background: #fff; border-radius: 10px; }

.order-items-table { margin-top: 16px; }
.total-row td { font-weight: bold; border-top: 2px solid #1e293b; }

/* ---- Added in Step 1 (foundation) ---- */
.alert-warning { background: #fef3c7; color: #92400e; }
.alert-info { background: #dbeafe; color: #1e40af; }
.inline-form { display: inline; margin: 0; }   /* small POST buttons, e.g. Delete */
.table-wrap { overflow-x: auto; }              /* wrap wide tables on phones */
@media (max-width: 640px) {
    .content { padding: 14px; }
    .topbar { padding: 12px 14px; }
}

/* ---- Added in Step 2 (auth + users) ---- */
.link-button { background: none; border: none; padding: 0; font: inherit; font-size: 14px; color: #fca5a5; cursor: pointer; }
.link-button:hover { text-decoration: underline; }
.text-muted { color: #64748b; font-size: 13px; }

/* ---- Added in Steps 3 to 10 ---- */
.low-stock { color: #b91c1c; font-weight: 700; }
.check-label { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: #334155; }
.pager { display: flex; align-items: center; gap: 12px; margin: 16px 0; }
.low-stock-box { background: #fef3c7; color: #92400e; border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; font-size: 14px; }
.low-stock-box ul { list-style: none; margin: 8px 0 0; padding: 0; }
.low-stock-box li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 0; }
.order-items-table input, .order-items-table select {
    width: 100%; padding: 6px 8px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px;
}

/* Dashboard charts (plain HTML/CSS, no JavaScript library) */
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; margin: 24px 0; }
.chart-card { background: #fff; padding: 18px 20px; border-radius: 10px; box-shadow: 0 2px 6px rgba(0,0,0,0.08); }
.chart-card h2 { margin: 0 0 14px; font-size: 16px; }
.hbar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 13px; }
.hbar-label { flex: 0 0 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #334155; }
.hbar-track { flex: 1; background: #e2e8f0; border-radius: 4px; height: 14px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; background: #2563eb; border-radius: 4px; }
.hbar-value { flex: 0 0 50px; text-align: right; font-weight: 600; color: #1e293b; }
.vchart { display: flex; align-items: flex-end; gap: 4px; height: 170px; padding-top: 18px; }
.vcol { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; min-width: 0; }
.vbar { display: block; width: 100%; background: #2563eb; border-radius: 3px 3px 0 0; }
.vvalue { font-size: 11px; color: #1e293b; min-height: 14px; }
.vlabel { font-size: 11px; color: #64748b; margin-top: 4px; }

