*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 15px; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
    background: #f0f2f5; color: #333; line-height: 1.5;
}

a { color: #2563eb; text-decoration: none; }
a:hover { color: #1d4ed8; }

/* ── Layout ── */
#app { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ── */
.sidebar {
    width: 230px; min-width: 230px;
    background: #1e293b; color: #cbd5e1;
    display: flex; flex-direction: column;
    border-right: 1px solid #0f172a;
}
.sidebar-header {
    height: 56px; display: flex; align-items: center;
    padding: 0 20px; border-bottom: 1px solid #334155;
    flex-shrink: 0;
}
.sidebar-header h3 { color: #f1f5f9; font-size: 16px; font-weight: 600; letter-spacing: 1px; }
.sidebar-nav { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.menu-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 4px 0; }
.menu-scroll::-webkit-scrollbar { width: 4px; }
.menu-scroll::-webkit-scrollbar-thumb { background: #475569; border-radius: 2px; }

/* ── Category ── */
.menu-cat { border-bottom: 1px solid #334155; }
.cat-header {
    display: flex; align-items: center; gap: 6px;
    padding: 12px 16px; cursor: pointer; user-select: none;
    color: #94a3b8; font-size: 13px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.5px;
    transition: background 0.15s;
}
.cat-header:hover { background: #334155; color: #e2e8f0; }
.cat-arrow { font-size: 10px; width: 14px; text-align: center; color: #64748b; }
.cat-icon { width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; }
.cat-name { flex: 1; }
.cat-body { display: none; }

/* ── Menu Items ── */
.item-link {
    display: flex; align-items: center; gap: 4px;
    padding: 10px 16px 10px 44px; color: #94a3b8; font-size: 14px;
    transition: all 0.12s; cursor: pointer; white-space: nowrap;
}
.item-link:hover { color: #e2e8f0; background: #334155; }
.item-link.active { color: #fff; background: #2563eb; }
.item-parent { padding-left: 28px; }
.item-child { padding-left: 56px; font-size: 13px; }
.sub-arrow { font-size: 9px; width: 14px; text-align: center; color: #64748b; }
.sub-items { display: none; }
.menu-item.sub-open > .item-parent { color: #e2e8f0; }
.menu-item.sub-open > .sub-items { display: block; }

.cat-icon { position: relative; }
.cat-icon-purchase::after  { content: '📋'; font-size: 14px; }
.cat-icon-sales::after     { content: '🏷️'; font-size: 14px; }
.cat-icon-storage::after   { content: '🏭'; font-size: 14px; }
.cat-icon-finance::after   { content: '💰'; font-size: 14px; }
.cat-icon-report::after    { content: '📊'; font-size: 14px; }
.cat-icon-settings::after  { content: '⚙️'; font-size: 14px; }
.cat-icon-other::after     { content: '📌'; font-size: 14px; }

/* ── Main Content ── */
.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
    height: 56px; background: #fff; border-bottom: 1px solid #e2e8f0;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px; flex-shrink: 0;
}
.welcome { font-size: 15px; color: #64748b; }
.welcome strong { color: #1e293b; font-weight: 600; }
.btn-logout {
    padding: 8px 18px; border-radius: 6px; font-size: 14px;
    color: #ef4444; border: 1px solid #fecaca; transition: all 0.12s;
}
.btn-logout:hover { background: #fef2f2; color: #dc2626; }

.content-body { flex: 1; padding: 20px 24px 24px; overflow: auto; }
.content-body iframe { width: 100%; height: 100%; border: none; background: transparent; display: block; }

/* ── Page Title ── */
h2 {
    font-size: 20px; font-weight: 600; color: #1e293b;
    margin-bottom: 16px; padding-bottom: 12px;
    border-bottom: 2px solid #e2e8f0;
}
h3 { font-size: 16px; font-weight: 600; color: #334155; margin-bottom: 12px; }

/* ── Toolbar ── */
.toolbar { margin-bottom: 16px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ── Search / Filter Bar ── */
.form-inline { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.form-inline label { font-size: 14px; color: #64748b; white-space: nowrap; }
.form-inline input, .form-inline select {
    padding: 8px 12px; border: 1px solid #d1d5db; border-radius: 6px;
    font-size: 14px; outline: none; transition: border-color 0.15s; background: #fff;
}
.form-inline input:focus, .form-inline select:focus {
    border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

/* ── Data Table ── */
.data-table {
    width: 100%; border-collapse: collapse; background: #fff;
    border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.data-table th, .data-table td {
    padding: 11px 14px; border-bottom: 1px solid #f1f5f9;
    text-align: left; font-size: 14px;
}
.data-table th {
    background: #f8fafc; font-weight: 600; color: #475569;
    border-bottom: 2px solid #e2e8f0; white-space: nowrap;
}
.data-table td { color: #334155; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f8fafc; }

/* ── Buttons ── */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 4px; padding: 8px 18px; font-size: 14px; font-weight: 500;
    border-radius: 6px; border: 1px solid #d1d5db;
    cursor: pointer; background: #fff; color: #374151;
    transition: all 0.12s; white-space: nowrap;
}
.btn:hover { background: #f9fafb; border-color: #9ca3af; }
.btn-primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.btn-primary:hover { background: #1d4ed8; border-color: #1d4ed8; }
.btn-danger { background: #ef4444; color: #fff; border-color: #ef4444; }
.btn-danger:hover { background: #dc2626; border-color: #dc2626; }
.btn-sm { padding: 5px 12px; font-size: 13px; }

/* ── Forms ── */
.form-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px;
    background: #fff; padding: 24px; border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06); margin-bottom: 16px;
}
.form-grid .full-width { grid-column: 1 / -1; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 14px; font-weight: 500; color: #374151; }
.form-group input, .form-group select, .form-group textarea {
    padding: 9px 12px; border: 1px solid #d1d5db; border-radius: 6px;
    font-size: 14px; outline: none; transition: border-color 0.15s;
    background: #fff; width: 100%;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

/* ── Pagination ── */
.pagination { margin-top: 16px; display: flex; gap: 4px; align-items: center; justify-content: center; }
.pagination a {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 34px; height: 34px; padding: 0 10px;
    border: 1px solid #d1d5db; border-radius: 6px;
    color: #374151; font-size: 14px; transition: all 0.12s;
}
.pagination a:hover { background: #f3f4f6; border-color: #9ca3af; }
.pagination a.active { background: #2563eb; color: #fff; border-color: #2563eb; }

/* ── Login ── */
.login-container { display: flex; justify-content: center; align-items: center; min-height: 100vh; background: #f0f2f5; }
.login-box {
    background: #fff; padding: 40px; border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.08); width: 400px;
}
.login-box h2 { text-align: center; margin-bottom: 28px; color: #1e293b; font-size: 22px; border: none; }
.login-box .form-group { margin-bottom: 18px; }
.login-box button[type="submit"] { width: 100%; padding: 10px; margin-top: 8px; }
.error-msg { color: #ef4444; margin-top: 10px; text-align: center; display: none; font-size: 14px; }

/* ── Misc ── */
form + button, form > .btn, form > button { margin-top: 4px; }
iframe + script { display: none; }

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-danger { color: #ef4444; font-weight: 600; }
.text-muted { color: #94a3b8; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }

/* ═══════════════════════════════════════
   Dashboard
   ═══════════════════════════════════════ */
.dashboard { padding: 0; }

.d-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px;
}
.d-header h2 { margin-bottom: 0; padding-bottom: 0; border: none; }
.d-date { font-size: 14px; color: #94a3b8; }

.d-cards {
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 16px; margin-bottom: 24px;
}

.d-card {
    display: flex; align-items: center; gap: 16px;
    padding: 20px; border-radius: 10px; background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    transition: transform 0.15s, box-shadow 0.15s;
}
.d-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }

.card-icon { font-size: 28px; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; border-radius: 10px; flex-shrink: 0; }
.card-body { flex: 1; min-width: 0; }
.card-num { font-size: 26px; font-weight: 700; line-height: 1.2; }
.card-label { font-size: 13px; color: #94a3b8; margin-top: 2px; }

.card-blue .card-icon { background: #eff6ff; }
.card-blue .card-num { color: #2563eb; }
.card-green .card-icon { background: #f0fdf4; }
.card-green .card-num { color: #16a34a; }
.card-orange .card-icon { background: #fff7ed; }
.card-orange .card-num { color: #ea580c; }
.card-purple .card-icon { background: #faf5ff; }
.card-purple .card-num { color: #9333ea; }
.card-teal .card-icon { background: #f0fdfa; }
.card-teal .card-num { color: #0d9488; }
.card-pink .card-icon { background: #fdf2f8; }
.card-pink .card-num { color: #db2777; }
.card-indigo .card-icon { background: #eef2ff; }
.card-indigo .card-num { color: #4f46e5; }
.card-amber .card-icon { background: #fffbeb; }
.card-amber .card-num { color: #d97706; }

.d-grid-2 {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 16px; margin-bottom: 24px;
}

.d-panel {
    background: #fff; border-radius: 10px; box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    overflow: hidden;
}
.panel-header {
    padding: 14px 20px; font-size: 15px; font-weight: 600; color: #1e293b;
    border-bottom: 1px solid #f1f5f9;
}
.panel-body { padding: 16px 20px; }
.panel-body .data-table { box-shadow: none; }
.panel-body .data-table th { background: #f8fafc; }
.panel-empty { color: #94a3b8; font-size: 14px; text-align: center; padding: 24px 0; }

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