:root {
    --bg: #f4f7fb;
    --bg-soft: #eef4ff;
    --card: #ffffff;
    --text: #17202a;
    --muted: #6b7280;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --border: #dbe3ee;
    --success: #16a34a;
    --success-dark: #15803d;
    --danger: #dc2626;
    --danger-dark: #b91c1c;
    --warning: #ffae00c4;
    --warning-dark: #ffbb00;
    --sidebar: #000747;
    --sidebar-text: #e2e8f0;
    --sidebar-muted: #cbd5e1;
    --shadow: 0 16px 40px rgba(37, 99, 235, 0.08);
    --radius: 20px;
    --radius-sm: 12px;
    --radius-md: 16px;
    --transition: 0.2s ease;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--bg);
    font-family: Arial, Helvetica, sans-serif;
    color: var(--text);
}

a {
    text-decoration: none;
    color: inherit;
}

button,
input,
textarea,
select {
    font: inherit;
}

img {
    max-width: 100%;
    display: block;
}

.layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--sidebar);
    color: #fff;
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-logo {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    padding: 6px;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.10);
}

.brand-logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.brand h2 {
    margin: 0;
    font-size: 20px;
    line-height: 1.2;
}

.brand p {
    margin: 4px 0 0;
    color: var(--sidebar-muted);
    font-size: 13px;
    line-height: 1.4;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nav a {
    display: block;
    padding: 12px 14px;
    border-radius: 14px;
    color: var(--sidebar-text);
    transition: var(--transition);
    font-weight: 600;
}

.nav a:hover {
    background: rgba(255, 255, 255, 0.08);
}

.logout-link {
    margin-top: 8px;
    color: #fecaca !important;
}

/* Main */
.main {
    flex: 1;
    padding: 28px;
    min-width: 0;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 26px;
    gap: 20px;
}

.topbar h1 {
    margin: 0 0 5px;
    font-size: 28px;
    line-height: 1.2;
}

.topbar p {
    margin: 0;
    color: var(--muted);
}

.user-badge {
    background: var(--card);
    border: 1px solid var(--border);
    padding: 12px 16px;
    border-radius: 14px;
    box-shadow: var(--shadow);
    font-weight: 600;
    min-width: 130px;
    text-align: right;
}

/* Cards / grids */
.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
    margin-bottom: 20px;
}

.card h2,
.card h3 {
    margin-top: 0;
    line-height: 1.25;
}

.card p:last-child {
    margin-bottom: 0;
}

.stat-number {
    font-size: 34px;
    font-weight: bold;
    margin-top: 8px;
    line-height: 1;
}

.muted {
    color: var(--muted);
}

.small {
    color: var(--muted);
    font-size: 13px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 11px 16px;
    border-radius: 12px;
    background: var(--primary);
    color: #fff;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
    text-align: center;
    white-space: nowrap;
}

.btn:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: #e5e7eb;
    color: #111827;
}

.btn-secondary:hover {
    background: #d1d5db;
}

.btn-danger {
    background: var(--danger);
}

.btn-danger:hover {
    background: var(--danger-dark);
}

.btn-success {
    background: var(--success);
}

.btn-success:hover {
    background: var(--success-dark);
}

.btn-warning {
    background: var(--warning);
}

.btn-warning:hover {
    background: var(--warning-dark);
}

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group.full {
    grid-column: 1 / -1;
}

label {
    font-weight: 600;
    font-size: 14px;
}

input,
textarea,
select {
    width: 100%;
    padding: 13px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    outline: none;
    font-size: 15px;
    background: #fff;
    transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus,
textarea:focus,
select:focus {
    border-color: #93c5fd;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.10);
}

textarea {
    min-height: 110px;
    resize: vertical;
}

/* Tables */
.table-wrap {
    overflow-x: auto;
    width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

th,
td {
    text-align: left;
    padding: 14px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

td {
    font-size: 15px;
}

/* Helpers */
.actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.alert {
    padding: 14px 16px;
    border-radius: 14px;
    margin-bottom: 16px;
    font-weight: 600;
}

.alert-success {
    background: #ecfdf3;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin-bottom: 14px;
}

.note-box,
.item-box {
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 12px;
    background: #fff;
}

.note-box p,
.item-box p {
    margin-bottom: 10px;
}

.note-date {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 8px;
}

.footer {
    margin-top: 30px;
    color: var(--muted);
    font-size: 14px;
    text-align: center;
}

hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}

/* Auth pages */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background:
        radial-gradient(circle at top right, rgba(96, 165, 250, 0.18), transparent 25%),
        radial-gradient(circle at bottom left, rgba(37, 99, 235, 0.10), transparent 30%),
        var(--bg);
}

.login-card {
    width: 100%;
    max-width: 460px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 32px;
    box-shadow: var(--shadow);
}

.login-card h1 {
    margin-top: 0;
    margin-bottom: 8px;
    line-height: 1.2;
    text-align: center;
}

.login-card p {
    color: var(--muted);
    margin-bottom: 24px;
    text-align: center;
}

.auth-logo-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 18px;
}

.auth-logo {
    max-width: 160px;
    max-height: 100px;
    width: auto;
    height: auto;
    object-fit: contain;
}

/* Responsive */
@media (max-width: 1100px) {
    .grid-3 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 980px) {
    .layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .topbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .user-badge {
        text-align: left;
    }
}

@media (max-width: 640px) {
    .main {
        padding: 18px;
    }

    .card {
        padding: 18px;
    }

    .login-card {
        padding: 24px;
    }

    .section-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .actions {
        width: 100%;
    }

    .actions .btn {
        width: 100%;
    }

    .topbar h1 {
        font-size: 24px;
    }

    table {
        min-width: 640px;
    }
}
/* ===== Suppliers page ===== */

.suppliers-page-card {
    background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
}

.suppliers-search-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 24px;
    padding: 18px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 18px;
}

.suppliers-search-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.suppliers-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.supplier-row-card {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: #ffffff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.supplier-row-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.08);
    border-color: #cdd9ea;
}

.supplier-row-main {
    flex: 1;
    min-width: 0;
}

.supplier-row-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
}

.supplier-row-head h3 {
    margin: 0;
    font-size: 20px;
    line-height: 1.2;
}

.supplier-meta-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 18px;
}

.supplier-meta-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 14px;
    background: #f8fbff;
    border: 1px solid #e5edf7;
    border-radius: 14px;
}

.supplier-meta-label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--muted);
}

.supplier-meta-value {
    font-size: 15px;
    color: var(--text);
    word-break: break-word;
}

.supplier-row-actions {
    width: 150px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-shrink: 0;
}

.btn-fixed {
    width: 150px;
    min-width: 150px;
}

.btn-neutral-action {
    background: #1f2937;
    color: #ffffff;
}

.btn-neutral-action:hover {
    background: #111827;
}

.supplier-status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    text-transform: capitalize;
    white-space: nowrap;
}

.status-active {
    background: #ecfdf3;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.status-inactive {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.empty-state-box {
    padding: 24px;
    border: 1px dashed var(--border);
    border-radius: 18px;
    background: #fbfdff;
}

/* Responsive suppliers */
@media (max-width: 900px) {
    .supplier-row-card {
        flex-direction: column;
    }

    .supplier-row-actions {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .btn-fixed {
        width: auto;
        min-width: 140px;
    }
}

@media (max-width: 640px) {
    .supplier-meta-grid {
        grid-template-columns: 1fr;
    }

    .supplier-row-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .supplier-row-actions {
        flex-direction: column;
    }

    .btn-fixed {
        width: 100%;
        min-width: 100%;
    }
}
/* ===== User badge clickable ===== */

.user-badge-link {
    text-decoration: none;
    color: inherit;
    display: block;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.user-badge-link:hover {
    transform: translateY(-1px);
    box-shadow: 0 18px 32px rgba(37, 99, 235, 0.12);
    border-color: #c9d8ee;
}

.user-badge-inner {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-badge-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    overflow: hidden;
    background: #eef4ff;
    border: 1px solid #d9e4f2;
    flex-shrink: 0;
}

.user-badge-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-badge-text {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    min-width: 0;
}

/* ===== Profile page ===== */

.profile-card {
    background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
}

.profile-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 24px;
    align-items: start;
}

.profile-side {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.profile-avatar-box,
.profile-role-box {
    background: #f8fbff;
    border: 1px solid #e5edf7;
    border-radius: 18px;
    padding: 20px;
}

.profile-avatar-large {
    width: 100%;
    max-width: 180px;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 50%;
    margin: 0 auto;
    border: 3px solid #ffffff;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
}

.profile-role-value {
    margin-top: 6px;
    font-size: 18px;
    font-weight: 700;
    text-transform: capitalize;
    color: var(--text);
}

.profile-main {
    min-width: 0;
}

@media (max-width: 900px) {
    .profile-layout {
        grid-template-columns: 1fr;
    }

    .user-badge-text {
        align-items: flex-start;
    }
}

@media (max-width: 640px) {
    .user-badge {
        width: 100%;
    }

    .user-badge-link {
        width: 100%;
    }

    .user-badge-inner {
        width: 100%;
    }

    .user-badge-text {
        align-items: flex-start;
    }
}
/* ===== Auth buttons (login/register) ===== */

.auth-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 24px;
}

.btn-equal {
    width: 180px;
    justify-content: center;
}

/* Mobile */
@media (max-width: 480px) {
    .auth-actions {
        flex-direction: column;
        align-items: center;
    }

    .btn-equal {
        width: 100%;
        max-width: 260px;
    }
}