:root {
    --primary: #714b67;
    --primary-dark: #5d3d54;
    --accent: #017e84;
    --accent-soft: rgba(1, 126, 132, 0.12);
    --success: #28a745;
    --warning: #f0ad4e;
    --danger: #dc3545;
    --info: #17a2b8;
    --text: #212529;
    --muted: #6c757d;
    --border: #dee2e6;
    --surface: #f9fafb;
    --card: #ffffff;
    --shadow: 0 8px 18px rgba(33, 37, 41, 0.06);
    --chip: rgba(113, 75, 103, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: "Inter", sans-serif;
    background: #eef2f7;
    color: var(--text);
}

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: linear-gradient(135deg, #f3eff4, #eaf5f5);
}

.auth-card {
    width: min(100%, 420px);
    padding: 32px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--card);
    box-shadow: var(--shadow);
}

.auth-card .brand-mark {
    color: #fff;
    background: var(--primary);
}

.auth-card h1 {
    margin: 18px 0 24px;
    font-size: 1.5rem;
}

.auth-card form,
.auth-card label {
    display: grid;
    gap: 12px;
}

.auth-card form {
    gap: 18px;
}

.auth-card label {
    gap: 7px;
    color: var(--muted);
    font-size: 0.9rem;
}

.auth-card input {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    background: #fff;
}

.auth-error {
    padding: 12px;
    border-radius: 8px;
    color: #842029;
    background: #f8d7da;
}

.workflow-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    align-items: end;
    gap: 14px;
    padding: 18px;
}

.lpo-item-list {
    display: grid;
    grid-column: 1 / -1;
    gap: 12px;
}

.lpo-item-row {
    display: grid;
    grid-template-columns: minmax(180px, 1.5fr) minmax(160px, 1fr) repeat(2, minmax(130px, 0.75fr)) auto;
    align-items: end;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #f8f9fb;
}

.lpo-remove-item {
    white-space: nowrap;
}

#addLpoItem {
    justify-self: start;
}

.workflow-form label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 0.88rem;
}

.workflow-form input,
.workflow-form select,
.workflow-form textarea {
    width: 100%;
    min-height: 42px;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
}

.workflow-form .checkbox-field {
    display: flex;
    align-items: center;
    gap: 9px;
}

.workflow-form .checkbox-field input {
    width: 18px;
    min-height: 18px;
}

.workflow-form .form-wide {
    grid-column: 1 / -1;
}

.action-stack,
.action-stack form,
.issue-signature-form {
    display: grid;
    gap: 8px;
}

.action-stack input,
.issue-signature-form input:not([type="checkbox"]) {
    width: 100%;
    min-height: 38px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
}

.action-stack form {
    grid-template-columns: minmax(110px, 1fr) auto;
}

.issue-signature-form {
    min-width: 190px;
}

.issue-signature-form label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 0.82rem;
}

.issue-signature-form .checkbox-field {
    display: flex;
    align-items: center;
    gap: 8px;
}

.issue-signature-form .checkbox-field input {
    width: 18px;
    min-height: 18px;
}

.equipment-action-form {
    display: grid;
    gap: 8px;
    min-width: 190px;
}

.equipment-action-form label {
    display: grid;
    gap: 5px;
    color: var(--muted);
    font-size: 0.82rem;
}

.equipment-action-form input,
.equipment-action-form select {
    width: 100%;
    min-height: 38px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
}

.equipment-maintenance {
    margin-top: 10px;
    min-width: 190px;
}

.equipment-maintenance summary {
    padding: 8px 0;
    color: var(--accent);
    cursor: pointer;
    font-weight: 600;
}

.receipt-form {
    margin: 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
}

.form-heading {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px;
}

.inline-form {
    display: inline;
}

.workflow-message,
.empty-state {
    margin: 14px 0;
    padding: 14px 16px;
    border-radius: 10px;
    background: #fff;
}

.workflow-message.error {
    color: #842029;
    background: #f8d7da;
}

.workflow-message.success {
    color: #0f5132;
    background: #d1e7dd;
}

.empty-state {
    color: var(--muted);
    border: 1px dashed var(--border);
}

button,
input {
    font: inherit;
}

button {
    border: none;
    background: none;
    cursor: pointer;
}

.app-shell {
    min-height: 100vh;
}

.topbar {
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 14px 26px;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
    position: sticky;
    top: 0;
    z-index: 20;
}

.brand-block {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 180px;
}

.brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.14);
    font-weight: 800;
    letter-spacing: 0.04em;
}

.brand-copy {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.brand-name {
    font-size: 1.05rem;
    font-weight: 700;
}

.brand-copy small {
    opacity: 0.8;
    font-size: 0.7rem;
}

.main-nav {
    display: flex;
    align-items: center;
    flex: 1 1 auto;
    min-width: 0;
    gap: 2px;
    flex-wrap: nowrap;
    justify-content: center;
}

.nav-group {
    position: relative;
}

.nav-group-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: rgba(255, 255, 255, 0.82);
    padding: 9px 10px;
    border-radius: 10px;
    font-weight: 600;
    transition: all 0.2s ease;
    cursor: pointer;
    list-style: none;
    white-space: nowrap;
}

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

.nav-group:hover > .nav-group-trigger,
.nav-group[open] > .nav-group-trigger,
.nav-group.active > .nav-group-trigger {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.nav-group-trigger:focus-visible,
.nav-group-item:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.nav-group-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    display: none;
    flex-direction: column;
    align-items: stretch;
    min-width: 220px;
    max-height: min(70vh, 480px);
    overflow-y: auto;
    padding: 8px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    z-index: 40;
}

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

.nav-group-item {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--text);
    font-weight: 600;
    text-decoration: none;
    text-align: left;
}

.nav-group-item:hover,
.nav-group-item.active {
    background: var(--chip);
    color: var(--primary);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.project-switcher {
    position: relative;
}

.project-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.09);
    color: #fff;
    border-radius: 999px;
    padding: 8px 12px;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.14);
}

.project-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.18);
}

.caret {
    font-size: 0.8rem;
    opacity: 0.9;
}

.project-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: min(320px, 80vw);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 8px;
    display: none;
    z-index: 30;
}

.project-switcher.open .project-menu {
    display: grid;
}

.project-option {
    width: 100%;
    text-align: left;
    padding: 11px 12px;
    border-radius: 8px;
    color: var(--text);
    font-weight: 600;
}

.project-option.active,
.project-option:hover {
    background: var(--chip);
    color: var(--primary);
}

.icon-btn {
    position: relative;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 1.1rem;
}

.badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--danger);
    color: white;
    border-radius: 999px;
    padding: 2px 6px;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 18px;
    text-align: center;
    line-height: 1.5;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    padding: 6px 10px 6px 6px;
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    display: grid;
    place-items: center;
    font-weight: 700;
}

.user-chip strong,
.user-chip small {
    display: block;
}

.user-chip small {
    opacity: 0.8;
    font-size: 0.7rem;
}

.main-content {
    width: min(1400px, calc(100% - 28px));
    margin: 28px auto 50px;
}

.page-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(113, 75, 103, 0.08);
    border-radius: 14px;
    padding: 14px 18px;
}

.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.92rem;
    color: var(--muted);
}

.breadcrumbs strong {
    color: var(--text);
}

.sep {
    opacity: 0.5;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    width: min(360px, 46vw);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--muted);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.search-box input {
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text);
    outline: none;
}

.btn,
.chip-btn,
.text-btn {
    border-radius: 10px;
    transition: 0.2s ease;
}

.btn {
    padding: 10px 16px;
    font-weight: 700;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 10px 18px rgba(113, 75, 103, 0.18);
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: #f3f5f9;
    color: var(--text);
    border: 1px solid var(--border);
}

.chip-btn {
    background: var(--chip);
    color: var(--primary);
    padding: 9px 10px;
    border: 1px solid transparent;
    font-weight: 600;
}

.chip-btn.active {
    border-color: rgba(113, 75, 103, 0.18);
}

.text-btn {
    background: transparent;
    color: var(--primary);
    font-weight: 700;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(8, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}

.kpi-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 16px 16px 14px;
}

.kpi-card .label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.kpi-card .icon-bubble {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-size: 1.1rem;
    background: rgba(113, 75, 103, 0.08);
}

.kpi-card .value {
    margin-top: 14px;
    font-size: clamp(1.5rem, 2vw, 2rem);
    font-weight: 800;
    letter-spacing: -0.04em;
}

.kpi-card .trend {
    margin-top: 8px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
}

.trend.positive {
    background: rgba(40, 167, 69, 0.1);
    color: var(--success);
}

.trend.warning {
    background: rgba(240, 173, 78, 0.14);
    color: #a76500;
}

.trend.danger {
    background: rgba(220, 53, 69, 0.1);
    color: var(--danger);
}

.widget-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 18px;
}

.panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 16px 18px 18px;
}

.panel-xl {
    grid-column: span 2;
}

.budget-panel {
    min-height: 250px;
}

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

.eyebrow {
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.68rem;
    font-weight: 700;
}

.panel h3 {
    margin: 4px 0 0;
    font-size: 1.15rem;
}

.mini-list {
    display: grid;
    gap: 12px;
}

.list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
    background: #fbfcfd;
}

.list-item-main {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.item-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-weight: 700;
    color: var(--primary);
    background: var(--chip);
}

.item-copy {
    min-width: 0;
}

.item-copy strong,
.item-copy span {
    display: block;
}

.item-copy strong {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-copy span {
    font-size: 0.74rem;
    color: var(--muted);
}

.badge-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
}

.badge-pill.warning {
    background: rgba(240, 173, 78, 0.12);
    color: #b66d08;
}

.badge-pill.danger {
    background: rgba(220, 53, 69, 0.1);
    color: var(--danger);
}

.badge-pill.success {
    background: rgba(40, 167, 69, 0.12);
    color: var(--success);
}

.badge-pill.info {
    background: rgba(23, 162, 184, 0.12);
    color: var(--info);
}

.budget-chart {
    display: grid;
    gap: 12px;
    margin-top: 8px;
}

.budget-row {
    display: grid;
    gap: 8px;
}

.budget-meta {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.82rem;
    color: var(--muted);
}

.bar {
    position: relative;
    height: 12px;
    background: #edf1f4;
    border-radius: 999px;
    overflow: hidden;
}

.bar-fill {
    position: absolute;
    inset: 0 auto 0 0;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent), #40b9bf);
}

.bar-fill.warning {
    background: linear-gradient(90deg, #f3ba4d, #f6cb7a);
}

.bar-fill.danger {
    background: linear-gradient(90deg, #ef6978, #d7485b);
}

.data-panel {
    padding-bottom: 8px;
}

.sticky-header {
    position: sticky;
    top: 88px;
    background: rgba(255, 255, 255, 0.96);
    z-index: 5;
    padding-bottom: 6px;
    margin-bottom: 8px;
}

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

.table-wrap {
    overflow: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 900px;
}

.data-table th,
.data-table td {
    padding: 13px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    font-size: 0.82rem;
}

.data-table thead th {
    background: #f7f8fb;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.7rem;
    font-weight: 700;
}

.data-table tbody tr:hover {
    background: rgba(113, 75, 103, 0.025);
}

.stock-product {
    display: flex;
    align-items: center;
    gap: 10px;
}

.stock-product .mini-square {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: rgba(113, 75, 103, 0.08);
    display: grid;
    place-items: center;
    font-weight: 700;
    color: var(--primary);
}

.status-chip {
    display: inline-flex;
    align-items: center;
    padding: 6px 9px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.72rem;
}

.status-chip.good {
    background: rgba(40, 167, 69, 0.1);
    color: var(--success);
}

.status-chip.warning {
    background: rgba(240, 173, 78, 0.12);
    color: #a76500;
}

.status-chip.info {
    background: rgba(23, 162, 184, 0.12);
    color: var(--info);
}

.status-chip.danger {
    background: rgba(220, 53, 69, 0.1);
    color: var(--danger);
}

.bottom-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 18px;
    margin-top: 18px;
}

.activity-feed {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 12px;
}

.activity-feed li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    border-left: 2px solid rgba(113, 75, 103, 0.18);
    padding: 0 0 0 12px;
}

.activity-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    margin-top: 6px;
}

.activity-body strong,
.activity-body small {
    display: block;
}

.activity-body small {
    margin-top: 4px;
    color: var(--muted);
}

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

.tool-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
}

.tool-label {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tool-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(1, 126, 132, 0.08);
    display: grid;
    place-items: center;
    font-size: 1.1rem;
}

@media (max-width: 1180px) {
    .topbar {
        flex-wrap: wrap;
    }

    .main-nav {
        order: 3;
        flex: 0 0 100%;
        width: 100%;
        justify-content: flex-start;
    }

    .kpi-grid {
        grid-template-columns: repeat(4, minmax(150px, 1fr));
    }

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

@media (max-width: 840px) {
    .topbar {
        padding: 12px 14px;
        flex-wrap: wrap;
    }

    .main-nav {
        order: 3;
        width: 100%;
        justify-content: flex-start;
    }

    .project-switcher,
    .user-chip,
    .topbar-actions {
        width: auto;
    }

    .page-toolbar,
    .page-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .search-box {
        width: 100%;
    }

    .widget-grid,
    .bottom-grid,
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .panel-xl {
        grid-column: auto;
    }

    .lpo-item-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 520px) {
    .lpo-item-row {
        grid-template-columns: 1fr;
    }
}
