:root {
    color-scheme: light;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: "Segoe UI", Arial, sans-serif;
    margin: 0;
    background-color: #f4f4f4;
    color: #212529;
}

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

.topbar {
    background-color: #1f8ceb;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.topbar__inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 20px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 16px;
    position: relative;
}

.topbar__brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 1.25rem;
    font-weight: 600;
    color: inherit;
    text-decoration: none;
}

.brand-logo {
    height: 36px;
    width: auto;
    display: block;
}

.topbar__nav {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-start;
}

.topbar__nav a,
.topbar__nav summary {
    padding: 6px 10px;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

.topbar__nav a:hover,
.topbar__nav summary:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.dropdowns {
    gap: 8px;
}

.nav-group {
    position: relative;
    display: inline-block;
}

.nav-group summary {
    list-style: none;
    cursor: pointer;
    color: #fff;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.nav-group summary::-webkit-details-marker {
    display: none;
}

.nav-group[open] > summary {
    background-color: rgba(255, 255, 255, 0.2);
}

.nav-group a {
    display: block;
    color: #1f2937;
}

.nav-group > a {
    display: none;
}

.nav-group > .nav-menu {
    position: absolute;
    top: 110%;
    left: 0;
    min-width: 220px;
    background: #fff;
    color: #1f2937;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    display: none;
    z-index: 10;
}

.nav-group[open] > .nav-menu {
    display: block;
}

.nav-menu a {
    padding: 10px 12px;
    border-radius: 6px;
    width: 100%;
}

.nav-menu a:hover {
    background-color: #f3f4f6;
}

@media (hover: hover) {
    .nav-group:hover > .nav-menu {
        display: block;
    }
    .nav-group:hover > summary {
        background-color: rgba(255, 255, 255, 0.2);
    }
}

.topbar__user {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.875rem;
    justify-self: end;
}

.topbar__user-name {
    opacity: 0.9;
}

.topbar__logout {
    background-color: rgba(0, 0, 0, 0.3);
    padding: 8px 14px;
}

.topbar__logout:hover {
    background-color: rgba(0, 0, 0, 0.45);
}

@media (max-width: 900px) {
    .topbar__inner {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .topbar__user {
        justify-self: stretch;
        justify-content: space-between;
    }

    .topbar__nav {
        width: 100%;
        justify-content: flex-start;
    }
}

.layout {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px 48px;
}

.layout-wide {
    max-width: min(1600px, calc(100vw - 40px));
}

.card {
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 24px;
    margin-bottom: 24px;
}

h1,
h2 {
    margin: 0 0 16px;
    color: #1f2937;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
}

.actions-header {
    margin-bottom: 16px;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: #1f2937;
}

input[type="text"],
input[type="date"],
input[type="email"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 10px 12px;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    font-size: 0.95rem;
    background-color: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="text"]:focus,
input[type="date"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: #1f8ceb;
    box-shadow: 0 0 0 3px rgba(31, 140, 235, 0.2);
}

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

.grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.grid-full {
    grid-column: 1 / -1;
}

.allocation-wrapper {
    grid-column: 1 / -1;
    margin-top: 4px;
}

button,
.button-link {
    background-color: #1f8ceb;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    padding: 5px 8px;
    font-size: 0.95rem;
    font-weight: 200;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

button:hover,
.button-link:hover {
    background-color: #176bb5;
}

button:active,
.button-link:active {
    transform: translateY(1px);
}

.button-secondary {
    background-color: #6c757d;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    padding: 5px 8px;
    font-size: 0.95rem;
    font-weight: 200;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.button-secondary:hover {
    background-color: #545b62;
}

.button-danger {
    background-color: #d9534f;
    padding: 2px 3px;
    font-size: 0.85rem;
    border-radius: 5px;
}

.button-danger:hover {
    background-color: #c9302c;
}

.message {
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 16px;
}

.message-success {
    background-color: #d4edda;
    color: #155724;
}

.message-error {
    background-color: #f8d7da;
    color: #721c24;
}

.chart-card {
    padding: 0;
    margin-bottom: 24px;
    background: none;
    box-shadow: none;
}

.chart-wrapper {
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 24px;
    margin-bottom: 24px;
}

.chart-wrapper canvas {
    width: 100% !important;
    max-height: 320px;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

.filters .actions {
    margin-top: 0;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

.tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: 999px;
    border: 1px solid #d1d5db;
    background-color: #f9fafb;
    color: #1f2937;
    font-weight: 600;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.tab:hover {
    background-color: #e5e7eb;
}

.tab-active {
    background-color: #1f8ceb;
    border-color: #1f8ceb;
    color: #fff;
}

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

.maintenance-table {
    overflow-x: hidden;
}

.maintenance-table table {
    width: 100%;
    min-width: 100%;
    table-layout: auto;
}

.maintenance-table th,
.maintenance-table td {
    word-break: normal;
    overflow-wrap: break-word;
    white-space: normal;
    padding: 10px 6px;
    font-size: 0.95rem;
    vertical-align: top;
}

.maintenance-table small {
    font-size: 0.85rem;
}

.maintenance-table .status-tag {
    padding: 4px 8px;
    font-size: 0.75rem;
}

.maintenance-table .status-tag {
    white-space: nowrap;
}

.maintenance-table th:nth-child(5),
.maintenance-table td:nth-child(5) { min-width: 140px; }
.maintenance-table th:nth-child(6),
.maintenance-table td:nth-child(6) { min-width: 120px; }
.maintenance-table th:nth-child(7),
.maintenance-table td:nth-child(7) { min-width: 170px; }
.maintenance-table th:nth-child(11),
.maintenance-table td:nth-child(11) { min-width: 140px; }
.maintenance-table th:nth-child(12),
.maintenance-table td:nth-child(12) { min-width: 140px; }
.maintenance-table th:nth-child(13),
.maintenance-table td:nth-child(13) { min-width: 130px; }
.maintenance-table th:nth-child(15),
.maintenance-table td:nth-child(15) { min-width: 140px; }
.maintenance-table th:nth-child(16),
.maintenance-table td:nth-child(16) { min-width: 110px; text-align: center; }

.label-print-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-top: 16px;
    padding: 12px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background-color: #f9fafb;
}

.label-print-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.label-print-bar p {
    margin: 4px 0 0;
    color: #4b5563;
    font-size: 0.9rem;
}
.label-edit-bar p {
    margin: 4px 0 0;
    color: #9ab84a;
    font-size: 0.9rem;
}

.select-column {
    width: 48px;
    text-align: center;
}

.select-column input[type="checkbox"] {
    transform: scale(1.1);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

.table-scroll table {
    width: 100%;
    min-width: 0;
}

th,
td {
    padding: 12px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
    vertical-align: top;
}

th {
    background-color: #f9fafb;
    font-weight: 600;
    color: #374151;
}

.status-tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
}

.status-open { background-color: #f0ad4e; }
.status-sent { background-color: #5bc0de; }
.status-maintenance { background-color: #0275d8; }
.status-waiting { background-color: #6f42c1; }
.status-returned { background-color: #5cb85c; }
.status-delivered { background-color: #2d995b; }
.status-cancelled { background-color: #868e96; }
.status-cotacao { background-color: #f59e0b; }
.status-cotado { background-color: #3b82f6; }
.status-pedido_emitido { background-color: #2563eb; }
.status-recebido { background-color: #16a34a; }
.status-cancelado { background-color: #9ca3af; }
.status-aguardando_gestor { background-color: #f59e0b; }
.status-em_compra { background-color: #3b82f6; }
.status-rejeitada { background-color: #ef4444; }
.status-concluida { background-color: #16a34a; }

.alert-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-left: 6px;
    color: #b45309;
    background: #fef3c7;
    border-radius: 50%;
    font-size: 0.9rem;
    line-height: 1;
}

.table-actions a {
    color: #1f8ceb;
    font-weight: 600;
}

.notes {
    white-space: pre-wrap;
}

.field-help {
    margin-top: 6px;
    font-size: 0.85rem;
    color: #4b5563;
}

.field-help a {
    color: #1f8ceb;
    text-decoration: underline;
}

.inline-form {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.stock-indicator {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
}

.stock-indicator--ok {
    background-color: #d1fae5;
    color: #065f46;
}

.stock-indicator--alert {
    background-color: #fee2e2;
    color: #b91c1c;
}

.stock-indicator--assigned {
    background-color: #dbeafe;
    color: #1d4ed8;
}

.items-table {
    min-width: 0;
}

.items-table input[type="text"],
.items-table input[type="number"] {
    width: 100%;
}

.items-list {
    margin: 6px 0 0;
    padding-left: 18px;
    color: #374151;
}

.inline-option {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #1f2937;
    font-weight: 500;
}

.button-small {
    padding: 6px 10px;
    font-size: 0.85rem;
}

.muted {
    color: #6b7280;
}

.button-danger {
    background-color: #e11d48;
    padding: 6px 10px;
    font-size: 0.85rem;
    border-radius: 5px;
}

.actions-cell {
    text-align: left;
}

.stock-alert-row td {
    background-color: #fff1f2;
}

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

.card__header .actions {
    margin-top: 0;
}

.kb-index {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 8px;
}

.kb-index__item {
    background-color: #f3f4f6;
    color: #111827;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    text-decoration: none;
    transition: transform 0.1s ease, background-color 0.2s ease;
}

.kb-index__item:hover {
    background-color: #e5e7eb;
    transform: translateY(-1px);
}

.kb-category-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.kb-category-description {
    margin: 6px 0 0;
    color: #4b5563;
}

.kb-count {
    color: #6b7280;
    font-weight: 600;
    background-color: #f9fafb;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.kb-articles {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 12px;
}

.kb-article {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 16px;
    background-color: #fff;
    transition: box-shadow 0.2s ease, transform 0.1s ease;
}

.kb-article[open] {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.kb-article summary {
    list-style: none;
    cursor: pointer;
}

.kb-article summary::-webkit-details-marker {
    display: none;
}

.kb-article__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.kb-article__title h3 {
    margin: 0;
}

.kb-article__meta {
    display: flex;
    align-items: center;
    gap: 8px;
}

.kb-article__summary {
    color: #374151;
    margin: 8px 0 12px;
}

.kb-article__content {
    color: #111827;
    line-height: 1.6;
}

.kb-article__footer {
    margin-top: 12px;
    color: #6b7280;
    font-size: 0.9rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.85rem;
}

.badge-warning {
    background-color: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
}

.admin-stack {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.kb-editor {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
}

.kb-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px;
    background: #f3f4f6;
    border-bottom: 1px solid #e5e7eb;
}

.kb-toolbar button {
    background: #fff;
    color: #111827;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 0.9rem;
}

.kb-editor__area {
    min-height: 200px;
    padding: 12px;
    outline: none;
    font-size: 1rem;
    position: relative;
}

.kb-editor__area img {
    display: inline-block;
    max-width: 100%;
    height: auto;
}

.kb-editor__area table {
    border-collapse: collapse;
    width: 100%;
}

.kb-editor__area table, .kb-editor__area th, .kb-editor__area td {
    border: 1px solid #d1d5db;
}

.kb-editor__area th, .kb-editor__area td {
    padding: 6px;
}

.kb-editor__textarea {
    display: none !important;
}

.inline-form {
    display: inline;
}

.kb-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.kb-modal[aria-hidden="false"] {
    display: flex;
}

.kb-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
}

.kb-modal__dialog {
    position: relative;
    background: #fff;
    border-radius: 12px;
    width: min(1100px, 95vw);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.kb-modal__header,
.kb-modal__footer {
    padding: 12px 16px;
    background: #f9fafb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.kb-modal__body {
    padding: 12px 16px 16px;
    overflow: auto;
    flex: 1;
}

.kb-editor--modal .kb-editor__area {
    min-height: 500px;
}

.kb-resize-box {
    position: absolute;
    border: 1px dashed #2563eb;
    pointer-events: none;
    box-sizing: border-box;
}

.kb-resize-box__handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #2563eb;
    border: 2px solid #fff;
    border-radius: 50%;
    bottom: -8px;
    right: -8px;
    cursor: se-resize;
    pointer-events: auto;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.footer {
    background-color: #111827;
    color: rgba(255, 255, 255, 0.75);
    padding: 20px 0;
    text-align: center;
}

.footer__inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.login-card {
    max-width: 420px;
    margin: 80px auto;
    text-align: center;
}

.login-card p {
    color: #4b5563;
    margin-bottom: 24px;
    line-height: 1.5;
}

@media (max-width: 768px) {
    .layout {
        padding: 20px 16px 40px;
    }

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

    table {
        min-width: 100%;
        font-size: 0.85rem;
    }

    th,
    td {
        padding: 10px;
    }
}
