* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background: #eef2f5;
    font-family: 'Inter', 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    color: #1a2634;
}

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

.sidebar {
    width: 240px;
    background: linear-gradient(180deg, #1f2e3a 0%, #2c3e2f 100%);
    color: #fff;
    position: fixed; top: 0; left: 0; bottom: 0;
    display: flex; flex-direction: column;
    z-index: 100;
}

.sidebar-brand {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-brand h2 { font-size: 1.2rem; font-weight: 600; }
.sidebar-brand small { font-size: 0.7rem; opacity: 0.7; }

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }

.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 20px; color: rgba(255,255,255,0.85);
    text-decoration: none; font-size: 0.9rem; transition: 0.15s;
    cursor: pointer;
}
.nav-item:hover, .nav-item.active {
    background: rgba(201, 160, 61, 0.25); color: #c9a03d;
}
.nav-sub { font-size: 0.82rem; }

/* Tree menu */
.nav-item.has-children { font-weight: 600; }
.nav-arrow {
    font-size: 0.6rem; transition: transform 0.2s; display: inline-block; width: 14px; text-align: center; flex-shrink: 0;
}
.nav-arrow.expanded { transform: rotate(90deg); }
.nav-children { display: none; }
.nav-children.expanded { display: block; }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}
.user-info { font-size: 0.8rem; margin-bottom: 10px; opacity: 0.85; }
.btn-logout {
    width: 100%; background: rgba(255,255,255,0.1); color: #fff;
    border: 1px solid rgba(255,255,255,0.2); padding: 8px;
    border-radius: 8px; cursor: pointer; font-size: 0.8rem;
}
.btn-logout:hover { background: rgba(255,255,255,0.2); }

.main-content {
    margin-left: 240px; flex: 1; padding: 28px 24px;
    background: #eef2f5; min-height: 100vh;
}

/* Cards */
.supplier-card {
    background: #fff; border-radius: 28px;
    box-shadow: 0 20px 35px -12px rgba(0,0,0,0.08);
    margin-bottom: 32px; overflow: hidden; transition: all 0.2s;
}
.supplier-header {
    background: linear-gradient(115deg, #1f2e3a 0%, #2c3e2f 100%);
    padding: 20px 32px; color: #fff;
    display: flex; justify-content: space-between; align-items: center;
    flex-wrap: wrap; gap: 12px;
}
.supplier-header h1, .supplier-header h2 {
    font-weight: 600; letter-spacing: -0.3px;
}
.supplier-header h1 { font-size: 1.7rem; }
.supplier-header h1 small { font-size: 0.9rem; opacity: 0.8; margin-left: 12px; }
.badge-supplier {
    background: #c9a03d; color: #1e2a1f; padding: 6px 16px;
    border-radius: 40px; font-weight: 600; font-size: 0.8rem;
}
.supplier-body { padding: 28px 32px; }

/* Forms */
.form-grid-2col {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 24px 36px; margin-bottom: 32px;
}
.field { display: flex; flex-direction: column; gap: 8px; }
.field label {
    font-weight: 700; font-size: 0.75rem; text-transform: uppercase;
    letter-spacing: 1px; color: #5f6c7a;
}
.field input, .field select, .field textarea {
    padding: 12px 14px; border: 1px solid #cfdfed; border-radius: 18px;
    font-size: 0.9rem; font-family: inherit; background: #fefefe; transition: all 0.2s;
}
.field input:focus, .field select:focus, .field textarea:focus {
    border-color: #b8860b; outline: none;
    box-shadow: 0 0 0 3px rgba(184,134,11,0.15);
}

.section-title {
    font-size: 1.2rem; font-weight: 700; margin: 28px 0 18px 0;
    padding-left: 8px; border-left: 5px solid #c9a03d; color: #1f2e3a;
    display: flex; justify-content: space-between; align-items: center;
}

/* Buttons */
.btn-outline-sm {
    background: transparent; border: 1.5px solid #c9a03d;
    padding: 6px 16px; border-radius: 40px; font-weight: 600;
    font-size: 0.75rem; cursor: pointer; transition: 0.2s; color: #8b691b;
}
.btn-outline-sm:hover { background: #c9a03d; color: #1e2a1f; }

.btn-primary {
    background: #c9a03d; color: #1e2a1f; border: none;
    padding: 12px 28px; border-radius: 40px; font-weight: 700;
    cursor: pointer; transition: 0.2s;
}
.btn-primary:hover { background: #b3862c; transform: translateY(-1px); }
.btn-secondary {
    background: #eef2ff; color: #2d3a46; border: none;
    padding: 12px 28px; border-radius: 40px; font-weight: 600; cursor: pointer;
}
.btn-icon {
    background: none; border: 1px solid #cbdae9; padding: 4px 10px;
    border-radius: 30px; font-size: 0.7rem; cursor: pointer; transition: 0.1s;
}
.btn-icon:hover { background: #c9a03d20; border-color: #c9a03d; }

.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

/* Tables */
.table-wrapper { overflow-x: auto; border-radius: 20px; border: 1px solid #e9edf2; margin-top: 10px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; min-width: 900px; }
.data-table th {
    background: #f8fafc; padding: 14px 10px; text-align: left;
    font-weight: 700; color: #2c4b35; border-bottom: 1px solid #e2e8f0;
}
.data-table td { padding: 12px 10px; border-bottom: 1px solid #ecf3f9; vertical-align: middle; }

.status-active { background: #dcfce7; color: #166534; padding: 4px 12px; border-radius: 30px; font-size: 0.7rem; font-weight: 600; display: inline-block; }
.status-inactive { background: #ffe4e2; color: #b45a48; padding: 4px 12px; border-radius: 30px; font-size: 0.7rem; font-weight: 600; display: inline-block; }
.status-warning { background: #fff3cd; color: #856404; padding: 4px 12px; border-radius: 30px; font-size: 0.7rem; font-weight: 600; display: inline-block; }
.rating-star { color: #f5b042; letter-spacing: 2px; }
/* Grade badges */
.grade-badge { padding: 3px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 700; display: inline-block; text-align: center; min-width: 28px; }
.grade-a { background: #d4edda; color: #155724; }
.grade-b { background: #d6eaf8; color: #1a5276; }
.grade-c { background: #fcf3cf; color: #7d6608; }
.grade-d { background: #fadbd8; color: #922b21; }

/* Form tabs */
.form-tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 2px solid #e2e8f0; flex-wrap: wrap; }
.form-tab { background: none; border: none; padding: 10px 18px; font-size: 0.82rem; font-weight: 600; cursor: pointer; color: #5f6c7a; border-bottom: 3px solid transparent; margin-bottom: -2px; transition: 0.15s; }
.form-tab:hover { color: #1f2e3a; }
.form-tab.active { color: #c9a03d; border-bottom-color: #c9a03d; }
.form-tab-content { display: none; }
.form-tab-content.active { display: block; }

.action-bar { display: flex; justify-content: flex-end; gap: 18px; margin-top: 28px; flex-wrap: wrap; }
.filter-area { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 24px; align-items: flex-end; }
.search-input { flex: 2; min-width: 220px; }

.stat-bar {
    background: #f9f6ec; border-radius: 20px; padding: 14px 20px;
    margin-top: 20px; display: flex; justify-content: space-between;
    flex-wrap: wrap; gap: 12px; font-weight: 600; font-size: 0.8rem;
}

/* Toast */
.toast-msg {
    position: fixed; bottom: 24px; right: 24px; color: #fff;
    padding: 12px 24px; border-radius: 48px; font-size: 0.8rem; z-index: 9999;
    animation: fadeOut 2.8s forwards;
}
@keyframes fadeOut {
    0% { opacity: 1; transform: translateY(0); }
    70% { opacity: 1; }
    100% { opacity: 0; visibility: hidden; }
}

/* Modal */
.modal-overlay {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 1000; justify-content: center; align-items: center;
}
.modal-overlay.active { display: flex; }
.modal-box {
    background: #fff; border-radius: 24px; width: 90%; max-width: 800px;
    max-height: 85vh; overflow-y: auto; box-shadow: 0 20px 50px rgba(0,0,0,0.2);
}
.modal-header {
    background: linear-gradient(115deg, #1f2e3a 0%, #2c3e2f 100%);
    padding: 18px 28px; color: #fff; display: flex;
    justify-content: space-between; align-items: center;
}
.modal-header h3 { font-size: 1.1rem; }
.modal-close {
    background: none; border: none; color: #fff; font-size: 1.5rem;
    cursor: pointer; padding: 0 4px;
}
.modal-body { padding: 24px 28px; }
.modal-footer {
    padding: 16px 28px; border-top: 1px solid #ecf3f9;
    display: flex; justify-content: flex-end; gap: 12px;
}

/* Login */
.login-wrapper {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: #eef2f5;
}
.login-card {
    background: #fff; border-radius: 28px;
    box-shadow: 0 20px 35px -12px rgba(0,0,0,0.08); overflow: hidden; width: 420px;
}
.login-header {
    background: linear-gradient(115deg, #1f2e3a 0%, #2c3e2f 100%);
    padding: 28px 32px; color: #fff;
}
.login-header h1 { font-size: 1.4rem; font-weight: 600; }
.login-header p { font-size: 0.8rem; opacity: 0.8; margin-top: 4px; }
.login-body { padding: 32px; }
.login-body h2 { font-size: 1.1rem; margin-bottom: 24px; color: #1f2e3a; }
.login-body .field { margin-bottom: 20px; }
.error-msg {
    background: #ffe4e2; color: #b45a48; padding: 10px 14px;
    border-radius: 12px; font-size: 0.8rem; margin-bottom: 16px; display: none;
}

/* Loading */
.loading-overlay {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.7); z-index: 9999;
    justify-content: center; align-items: center;
}
.loading-overlay.active { display: flex; }
.spinner {
    width: 48px; height: 48px; border: 4px solid #e2e8f0;
    border-top-color: #c9a03d; border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Menu management expand arrow */
.menu-expand-arrow { cursor: pointer; display: inline-block; width: 16px; text-align: center; font-size: 0.65rem; color: #5f6c7a; transition: transform 0.15s; user-select: none; }
.menu-expand-arrow:hover { color: #c9a03d; }

/* Role management menu tree */
.menu-parent { user-select: none; }
.menu-parent:hover { background: #f4f6f9; border-radius: 6px; }
.menu-arrow { font-size: 0.6rem; display: inline-block; width: 12px; text-align: center; flex-shrink: 0; color: #5f6c7a; transition: transform 0.15s; }
.menu-children { display: none; }

/* Pagination */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 16px; }
.pagination button {
    padding: 6px 14px; border: 1px solid #cfdfed; border-radius: 12px;
    background: #fff; cursor: pointer; font-size: 0.8rem;
}
.pagination button.active { background: #c9a03d; color: #1e2a1f; border-color: #c9a03d; }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
