:root {
    --ink: #1c2430;
    --muted: #637083;
    --line: #d9e1ea;
    --panel: #ffffff;
    --page: #f4f7fa;
    --nav: #1f2d3d;
    --nav-2: #2b3f55;
    --nav-3: #152131;
    --blue: #1769aa;
    --green: #177245;
    --red: #a73535;
    --amber: #9a6215;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--page);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    letter-spacing: 0;
}

a {
    color: var(--blue);
    text-decoration: none;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 250px;
    background: linear-gradient(180deg, var(--nav-3), var(--nav));
    color: #fff;
    padding: 0 0 22px;
    border-right: 1px solid #0f1a27;
    box-shadow: 2px 0 10px rgba(18, 31, 45, 0.12);
    display: grid;
    grid-template-rows: auto 1fr;
    max-height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 66px;
    padding: 14px 16px;
    background: #172334;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 19px;
    font-weight: 700;
    line-height: 1.1;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--blue);
    color: #fff;
    font-size: 18px;
}

.brand-text {
    display: grid;
    gap: 3px;
}

.brand-text span {
    color: #a9c6df;
    font-size: 13px;
    font-weight: 600;
}

nav {
    display: grid;
    align-content: start;
    grid-auto-rows: max-content;
    gap: 6px;
    padding: 12px 10px;
    overflow-y: auto;
    min-height: 0;
    scrollbar-color: #536b84 transparent;
    scrollbar-width: thin;
}

nav::-webkit-scrollbar {
    width: 8px;
}

nav::-webkit-scrollbar-thumb {
    background: #536b84;
    border-radius: 999px;
}

nav::-webkit-scrollbar-track {
    background: transparent;
}

nav a {
    color: #d7e2ed;
    padding: 9px 10px;
    border-radius: 6px;
}

nav a.active,
nav a:hover {
    background: var(--nav-2);
    color: #fff;
}

.nav-link {
    display: grid;
    grid-template-columns: 28px 1fr;
    align-items: center;
    gap: 9px;
    min-height: 38px;
    position: relative;
}

.nav-group {
    display: grid;
    align-content: start;
    gap: 2px;
}

.nav-items {
    display: none;
    gap: 2px;
}

.nav-group.open .nav-items {
    display: grid;
}

.nav-link.active {
    background: #253c56;
    box-shadow: inset 3px 0 0 #3f9bdb;
}

.nav-icon {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08);
    color: #b9cce0;
    font-size: 11px;
    font-weight: 700;
}

.nav-link.active .nav-icon,
.nav-link:hover .nav-icon {
    background: var(--blue);
    color: #fff;
}

.nav-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 34px;
    margin-top: 6px;
    border: 0;
    border-radius: 6px;
    padding: 0 10px;
    background: transparent;
    cursor: pointer;
}

.nav-group:first-child .nav-section {
    margin-top: 0;
}

.nav-label {
    color: #8ea6bd;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0;
}

.nav-caret {
    color: #8ea6bd;
    font-size: 18px;
    line-height: 1;
    transform: rotate(0deg);
    transition: transform 0.16s ease;
}

.nav-group.open .nav-caret {
    transform: rotate(90deg);
}

.nav-section:hover {
    background: rgba(255, 255, 255, 0.04);
}

.nav-section:hover .nav-label,
.nav-section:hover .nav-caret {
    color: #fff;
}

.page {
    margin-left: 250px;
    padding: 24px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    margin-bottom: 22px;
}

.topbar h1 {
    margin: 3px 0 0;
    font-size: 28px;
    font-weight: 650;
}

.eyebrow {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
}

.top-search {
    display: flex;
    align-items: center;
    gap: 0;
}

.top-search input {
    width: 260px;
    min-height: 36px;
    border-radius: 6px 0 0 6px;
}

.top-search button {
    min-height: 36px;
    border: 1px solid var(--blue);
    border-radius: 0 6px 6px 0;
    padding: 0 12px;
    background: var(--blue);
    color: #fff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.panel,
.login-card,
.install-box {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
}

.panel h3 {
    margin: 0 0 14px;
}

.summary-grid,
.fact-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.fact-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-top: 18px;
}

.summary-grid div,
.fact-row div {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}

.summary-grid span,
.fact-row span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 5px;
}

.summary-grid strong,
.fact-row strong {
    font-size: 20px;
}

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

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 10px 8px;
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

tr:hover td {
    background: #f8fbfd;
}

form {
    display: grid;
    gap: 10px;
}

label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

input,
select,
textarea {
    width: 100%;
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 10px;
    font: inherit;
    background: #fff;
}

textarea {
    min-height: 90px;
    resize: vertical;
}

.button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 38px;
    border: 0;
    border-radius: 6px;
    padding: 0 14px;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

.button.primary {
    background: var(--blue);
}

.button.warning {
    background: var(--amber);
}

.button.danger {
    background: var(--red);
}

.button.secondary {
    background: #607083;
}

.actions-bar,
.button-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.notice {
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 16px;
}

.notice.success {
    background: #e8f5ee;
    color: var(--green);
    border: 1px solid #b9dfc8;
}

.notice.danger {
    background: #fff0f0;
    color: var(--red);
    border: 1px solid #efc4c4;
}

.notice.warning-note {
    background: #fff8e9;
    color: var(--amber);
    border: 1px solid #ead3a7;
}

.login-card {
    max-width: 410px;
}

.install {
    display: grid;
    place-items: center;
    padding: 24px;
}

.install .sidebar {
    display: none;
}

.install-box {
    width: min(520px, 100%);
}

.credential {
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 8px 14px;
    background: #f8fbfd;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 16px;
}

.credential span {
    color: var(--muted);
}

.item-card,
.two-column {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.two-column {
    grid-template-columns: minmax(280px, 430px) 1fr;
}

.item-image {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    place-items: center;
    min-height: 260px;
    padding: 16px;
}

.item-image img {
    max-width: 100%;
    max-height: 240px;
    object-fit: contain;
}

.item-main {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 20px;
}

.item-main h2 {
    margin: 4px 0 12px;
    font-size: 26px;
}

.form-grid,
.po-line {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.po-lines {
    display: grid;
    gap: 12px;
}

.po-line {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fbfd;
}

.po-line > div:first-child {
    grid-column: span 1;
}

.detail-list {
    display: grid;
    grid-template-columns: 130px 1fr;
    gap: 9px 14px;
    margin-bottom: 14px;
}

.detail-list span,
.document-list span {
    color: var(--muted);
}

.document-list {
    display: grid;
    gap: 8px;
    margin-top: 14px;
}

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

.document-delete-form {
    margin-left: 10px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    border-radius: 999px;
    padding: 0 10px;
    background: #e8f5ee;
    color: var(--green);
    font-size: 12px;
    font-weight: 700;
}

.status-pill.status-muted {
    background: #eef2f5;
    color: var(--muted);
}

.status-pill.status-info {
    background: #e7f1fb;
    color: var(--blue);
}

.status-pill.status-warning {
    background: #fff4e5;
    color: var(--amber);
}

.status-pill.status-danger {
    background: #fff0f0;
    color: var(--red);
}

.status-pill.status-alert {
    background: #fff0f0;
    color: var(--red);
    margin-left: 8px;
}

.receive-form {
    margin-top: 12px;
}

.inline-form {
    display: inline;
}

.link-button {
    border: 0;
    padding: 0;
    background: transparent;
    color: var(--red);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.dashboard-summary {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

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

.dashboard-alerts {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.dashboard-alert {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 54px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    background: #fff;
    color: var(--ink);
}

.dashboard-alert span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.dashboard-alert strong {
    font-size: 22px;
    font-weight: 700;
}

.dashboard-alert.needs-attention {
    border-color: #f2c46d;
    background: #fffaf0;
}

.dashboard-alert.needs-attention strong {
    color: var(--amber);
}

.panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.panel-heading h3 {
    margin: 0;
}

.heading-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    white-space: nowrap;
}

.danger-text {
    color: var(--red);
    font-weight: 700;
}

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

.qty-input {
    max-width: 110px;
}

.receive-actions {
    margin-top: 14px;
}

.related-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
}

.related-grid a {
    display: grid;
    gap: 6px;
    min-height: 70px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fbfd;
}

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

.related-grid strong {
    color: var(--ink);
    font-size: 18px;
}

.note-form {
    margin-bottom: 16px;
}

.note-list {
    display: grid;
    gap: 10px;
}

.note-entry {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fbfd;
    padding: 12px;
}

.note-entry p {
    margin: 8px 0 10px;
    line-height: 1.5;
}

.note-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
    font-size: 12px;
}

.note-meta strong {
    color: var(--ink);
}

.filter-panel {
    margin-bottom: 16px;
}

.filter-form {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) 220px 220px auto;
    gap: 12px;
    align-items: end;
}

.vendor-filter-form {
    grid-template-columns: minmax(240px, 1fr) 220px auto;
}

.po-filter-form {
    grid-template-columns: minmax(240px, 1fr) 180px 220px 200px auto;
}

.filter-actions {
    display: flex;
    gap: 8px;
}

.checkbox-line {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--ink);
    font-size: 14px;
    font-weight: 400;
    text-transform: none;
}

.checkbox-line input {
    width: auto;
    min-height: auto;
}

.table-button {
    margin-top: 8px;
    width: 100%;
}

.print-page {
    background: #e8edf3;
    padding: 24px;
}

.print-document {
    max-width: 980px;
    margin: 0 auto;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 30px;
}

.print-header {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    border-bottom: 2px solid var(--ink);
    padding-bottom: 18px;
    margin-bottom: 18px;
}

.print-header h1 {
    margin: 4px 0 8px;
    font-size: 30px;
}

.print-header p {
    margin: 0;
    color: var(--muted);
}

.print-facts {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.print-facts div {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
}

.print-facts span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 5px;
}

.print-note {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 20px;
}

.print-note h2 {
    margin: 0 0 8px;
    font-size: 16px;
}

.print-note p {
    margin: 0;
}

tfoot th {
    background: #f8fbfd;
}

@media print {
    body.print-page {
        background: #fff;
        padding: 0;
    }

    .print-document {
        max-width: none;
        border: 0;
        border-radius: 0;
        padding: 0;
    }

    .print-actions {
        display: none;
    }

    a {
        color: var(--ink);
    }
}

@media (max-width: 900px) {
    .sidebar {
        position: static;
        width: auto;
        max-height: none;
        display: block;
    }

    nav {
        overflow-y: visible;
    }

    .page {
        margin-left: 0;
    }

    .topbar,
    .panel-heading,
    .heading-actions,
    .item-card,
    .two-column,
    .summary-grid,
    .dashboard-summary,
    .dashboard-alerts,
    .dashboard-columns,
    .fact-row,
    .related-grid,
    .form-grid,
    .filter-form,
    .po-line {
        grid-template-columns: 1fr;
        display: grid;
    }

    .filter-actions {
        display: grid;
    }

    .user-menu {
        align-items: stretch;
        flex-wrap: wrap;
    }

    .top-search,
    .top-search input,
    .top-search button {
        width: 100%;
    }
}
