:root {
    --bg: #f4f6f8;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --line: #d9dee7;
    --primary: #ad1a05;
    --primary-dark: #7f1202;
    --success: #0f766e;
    --warning: #b7791f;
    --danger: #b91c1c;
    --info: #2563eb;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a {
    color: inherit;
    text-decoration: none;
}

.layout {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px 1fr;
}

.sidebar {
    background: #111827;
    color: #fff;
    padding: 22px 18px;
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 28px;
}

.brand-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
}

.brand span {
    display: block;
    color: #cbd5e1;
    font-size: 12px;
    margin-top: 3px;
}

.sidebar nav {
    display: grid;
    gap: 8px;
}

.sidebar nav a {
    padding: 11px 12px;
    border-radius: 10px;
    color: #e5e7eb;
}

.sidebar nav a:hover {
    background: rgba(255,255,255,.08);
}

.main {
    padding: 24px;
    overflow-x: auto;
}

.topbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 18px;
}

.topbar div {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 10px 14px;
}

.topbar span {
    display: block;
    font-size: 11px;
    color: var(--muted);
}

.title {
    margin-bottom: 18px;
}

.title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.title h1 {
    margin: 0;
    font-size: 26px;
}

.title p {
    margin: 4px 0 0;
    color: var(--muted);
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 18px;
    box-shadow: 0 8px 22px rgba(15,23,42,.05);
    margin-bottom: 18px;
}

.card h2 {
    margin: 0 0 14px;
    font-size: 18px;
}

.cards {
    display: grid;
    grid-template-columns: repeat(6, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.kpi span {
    color: var(--muted);
    font-size: 12px;
}

.kpi strong {
    display: block;
    font-size: 30px;
    margin-top: 8px;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 10px;
    text-align: left;
    font-size: 14px;
    vertical-align: middle;
}

th {
    background: #f9fafb;
    font-size: 12px;
    text-transform: uppercase;
    color: #4b5563;
}

.empty {
    color: var(--muted);
    text-align: center;
    padding: 22px;
}

.btn {
    border: 0;
    border-radius: 10px;
    padding: 10px 14px;
    background: #e5e7eb;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.btn.small {
    padding: 7px 10px;
    font-size: 12px;
}

.btn.primary {
    background: var(--primary);
    color: #fff;
}

.btn.success {
    background: var(--success);
    color: #fff;
}

.btn.danger {
    background: var(--danger);
    color: #fff;
}

.full {
    width: 100%;
}

.badge {
    border-radius: 999px;
    padding: 7px 10px;
    font-size: 12px;
    font-weight: 800;
    display: inline-flex;
    white-space: nowrap;
}

.badge.info {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge.warning {
    background: #fef3c7;
    color: #92400e;
}

.badge.danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge.success {
    background: #ccfbf1;
    color: #115e59;
}

.badge.primary {
    background: #ede9fe;
    color: #5b21b6;
}

.badge.muted {
    background: #e5e7eb;
    color: #374151;
}

.alert {
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 14px;
    font-weight: 700;
}

.alert-success {
    background: #ccfbf1;
    color: #115e59;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
}

.bm-paper {
    background: #fff;
    border: 1px solid #cfd6df;
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 16px;
}

.bm-head {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    border: 1px solid #9ca3af;
    border-bottom: 0;
}

.bm-head > div {
    padding: 9px;
    border-right: 1px solid #9ca3af;
    border-bottom: 1px solid #9ca3af;
    min-height: 62px;
}

.bm-head .span-2 {
    grid-column: span 2;
}

.bm-head label,
.sign-grid label {
    display: block;
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.bm-head strong,
.sign-grid strong {
    font-size: 13px;
}

.notice {
    margin: 14px 0;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #9a3412;
    border-radius: 12px;
    padding: 12px;
}

.bm-table th,
.bm-table td {
    border: 1px solid #9ca3af;
    text-align: center;
    padding: 7px;
    font-size: 12px;
}

.bm-table th {
    background: #eef2f7;
}

.bm-table .text-left {
    text-align: left;
    min-width: 260px;
}

.bm-table tfoot th {
    background: #dbe4ef;
}

.editable-head {
    background: #ffe8df !important;
    color: #7c2d12 !important;
}

.editable-cell {
    background: #fff7ed;
}

.editable-cell input {
    width: 92px;
    border: 1px solid #f59e0b;
    border-radius: 8px;
    padding: 7px;
    text-align: right;
}

.sign-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 14px;
}

.sign-grid > div {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
}

.actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 12px;
}

.actions span {
    color: var(--muted);
    font-size: 13px;
}

textarea {
    width: 100%;
    min-height: 90px;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    resize: vertical;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.timeline {
    display: grid;
    gap: 10px;
}

.timeline > div {
    border-left: 4px solid var(--primary);
    padding: 8px 10px;
    background: #f9fafb;
    border-radius: 10px;
}

.timeline span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-top: 4px;
}

.timeline code {
    display: inline-block;
    margin-top: 6px;
    font-size: 11px;
}

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
    background: linear-gradient(135deg, #111827, #374151);
}

.login-card {
    width: min(420px, 100%);
    background: #fff;
    border-radius: 24px;
    padding: 28px;
    box-shadow: 0 22px 60px rgba(0,0,0,.22);
}

.login-card h1 {
    margin: 16px 0 6px;
}

.login-card p {
    color: var(--muted);
    margin-top: 0;
}

.login-card label {
    display: block;
    margin: 14px 0 6px;
    font-weight: 700;
}

.login-card input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    font-size: 15px;
}

.login-card button {
    margin-top: 18px;
}

.login-card small {
    display: block;
    margin-top: 16px;
    color: var(--muted);
}

@media (max-width: 1100px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .bm-head {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-2 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .main {
        padding: 14px;
    }

    .cards {
        grid-template-columns: 1fr;
    }

    .bm-head {
        grid-template-columns: 1fr;
    }

    .bm-head .span-2 {
        grid-column: span 1;
    }

    .sign-grid {
        grid-template-columns: 1fr;
    }

    .title-row {
        align-items: flex-start;
        flex-direction: column;
    }
}

.muted-text {
    color: var(--muted);
    margin-top: -4px;
}

.file-label {
    display: block;
    font-weight: 700;
    margin-bottom: 8px;
}

input[type="file"] {
    display: block;
    width: 100%;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 12px;
    padding: 12px;
}

.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.tabs a {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 10px 14px;
    font-weight: 800;
    color: #374151;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.tabs a.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.tabs a span {
    background: rgba(0,0,0,.08);
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 12px;
}

.tabs a.active span {
    background: rgba(255,255,255,.22);
}

.return-box {
    margin-top: 12px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 12px;
    padding: 12px;
}

.return-box label {
    display: block;
    font-weight: 800;
    margin-bottom: 8px;
    color: #7c2d12;
}

.return-box select {
    width: 100%;
    border: 1px solid #f59e0b;
    border-radius: 10px;
    padding: 10px;
    background: #fff;
}

.return-box small {
    display: block;
    margin-top: 8px;
    color: #9a3412;
}

.report-cards {
    grid-template-columns: repeat(6, minmax(170px, 1fr));
}

@media (max-width: 1300px) {
    .report-cards {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 720px) {
    .report-cards {
        grid-template-columns: 1fr;
    }
}

.sidebar-logo {
    width: 52px;
    height: 52px;
    object-fit: contain;
    border-radius: 12px;
    background: #fff;
    padding: 4px;
}

.login-logo-img {
    max-width: 180px;
    max-height: 90px;
    object-fit: contain;
    display: block;
    margin-bottom: 12px;
}

.search-form {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
}

.search-form label {
    font-weight: 800;
}

.search-form input,
.search-form select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    font-size: 15px;
}

.selected-contract {
    background: #f9fafb;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px;
    margin-bottom: 14px;
}

.selected-contract span {
    display: block;
    color: var(--muted);
    margin-top: 4px;
}

.card h3 {
    margin-top: 18px;
}

.suppliers-layout {
    grid-template-columns: minmax(420px, 520px) 1fr;
    align-items: start;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-grid .span-2 {
    grid-column: span 2;
}

.form-grid label,
.filter-form label {
    display: block;
    font-weight: 800;
    margin-bottom: 6px;
}

.form-grid input[type="text"],
.form-grid input[type="email"],
.form-grid textarea,
.form-grid select,
.filter-form input,
.filter-form select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 11px;
    font-size: 14px;
    background: #fff;
}

.form-grid textarea {
    min-height: 90px;
}

.checkbox-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    background: #f9fafb;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
}

.checkbox-row label,
.options-box label {
    display: flex;
    gap: 8px;
    align-items: center;
    margin: 0;
    font-weight: 700;
}

.options-box {
    background: #f9fafb;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    display: grid;
    gap: 10px;
}

.options-box small {
    color: var(--muted);
}

.filter-form {
    display: grid;
    grid-template-columns: 1fr 160px auto auto;
    gap: 10px;
    margin-bottom: 14px;
}

.inline-form {
    display: inline;
}

.pill {
    display: inline-flex;
    border-radius: 999px;
    padding: 4px 8px;
    background: #e0f2fe;
    color: #075985;
    font-size: 12px;
    font-weight: 800;
    margin: 2px;
}

@media (max-width: 1200px) {
    .suppliers-layout {
        grid-template-columns: 1fr;
    }

    .filter-form {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 680px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-grid .span-2 {
        grid-column: span 1;
    }
}
