:root {
    --bg: #f6f8fb;
    --surface: #ffffff;
    --text: #111827;
    --muted: #6b7280;
    --line: #e5e7eb;
    --primary: #0f766e;
    --primary-soft: #ccfbf1;
    --danger: #b91c1c;
    --shadow: 0 12px 30px rgba(16, 24, 40, 0.06);
    --radius: 16px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Manrope", sans-serif;
    background: linear-gradient(180deg, #ffffff 0%, #f4f7fb 100%);
    color: var(--text);
}

.container {
    width: min(1180px, 92vw);
    margin: 0 auto;
}

.topbar {
    background: rgba(255, 255, 255, 0.9);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    backdrop-filter: blur(8px);
    z-index: 10;
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    min-height: 72px;
}

.brand {
    text-decoration: none;
    color: var(--text);
    font-weight: 700;
    letter-spacing: 0.3px;
}

.nav {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}

.nav a {
    text-decoration: none;
    color: var(--muted);
    font-weight: 600;
}

.nav a:hover {
    color: var(--primary);
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
}

.layout {
    padding: 26px 0 56px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
    padding: 22px;
    margin-bottom: 18px;
}

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

h1, h2 {
    margin: 0;
}

h1 {
    font-size: 1.3rem;
}

h2 {
    font-size: 1.1rem;
}

.muted {
    color: var(--muted);
    font-size: 0.92rem;
}

.form-grid {
    display: grid;
    gap: 14px;
    margin-bottom: 16px;
}

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

label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-weight: 600;
    font-size: 0.92rem;
}

input,
textarea,
select,
button {
    font: inherit;
}

input:not([type="checkbox"]):not([type="radio"]),
textarea,
select {
    border: 1px solid #d1d5db;
    border-radius: 12px;
    padding: 10px 12px;
    background: #fff;
    color: var(--text);
}

textarea {
    resize: vertical;
}

button,
.button-link {
    border: none;
    background: var(--primary);
    color: white;
    border-radius: 12px;
    padding: 11px 14px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
}

button.secondary {
    background: white;
    color: var(--primary);
    border: 1px solid #99f6e4;
}

button.compact {
    min-height: 34px;
    padding: 8px 12px;
    font-size: 0.88rem;
}

button.danger {
    background: #fee2e2;
    color: var(--danger);
}

.link-button {
    background: transparent;
    color: var(--muted);
    padding: 0;
    min-height: auto;
}

.inline-select {
    display: flex;
    gap: 8px;
}

.inline-select select {
    flex: 1;
}

.stack-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.field-label {
    font-weight: 600;
    font-size: 0.92rem;
}

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

.checkbox-list {
    border: 1px solid #d1d5db;
    border-radius: 12px;
    padding: 8px;
    background: #fff;
    max-height: 176px;
    overflow: auto;
    display: grid;
    gap: 6px;
}

.checkbox-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    font-weight: 500;
    font-size: 0.92rem;
    cursor: pointer;
}

.checkbox-item:hover {
    background: #f8fafc;
}

.checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--primary);
    cursor: pointer;
}

.table-wrap {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
    -webkit-overflow-scrolling: touch;
}

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

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

thead th {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    background: #fafafa;
}

.line-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 14px 0 10px;
}

.summary-bar {
    margin-top: 14px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.summary-bar div {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fafafa;
}

.summary-bar span {
    display: block;
    font-size: 0.83rem;
    color: var(--muted);
}

.summary-bar strong {
    font-size: 1.05rem;
}

.flash-list {
    display: grid;
    gap: 8px;
    margin-bottom: 14px;
}

.flash {
    border-radius: 10px;
    padding: 10px 12px;
    border: 1px solid transparent;
    font-size: 0.92rem;
}

.flash-success {
    background: #ecfdf5;
    border-color: #a7f3d0;
}

.flash-error {
    background: #fef2f2;
    border-color: #fecaca;
}

.flash-info {
    background: #eff6ff;
    border-color: #bfdbfe;
}

.status {
    text-transform: capitalize;
    font-size: 0.8rem;
    border-radius: 999px;
    padding: 4px 10px;
}

.status-pending_supervisor {
    background: #fff7ed;
    color: #9a3412;
}

.status-returned_for_correction {
    background: #fef2f2;
    color: #991b1b;
}

.status-approved {
    background: #ecfdf5;
    color: #166534;
}

.pill {
    background: var(--primary-soft);
    color: #134e4a;
    border-radius: 999px;
    padding: 1px 8px;
    margin-left: 4px;
    font-size: 0.78rem;
}

.simple-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.simple-list li {
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.simple-list.compact li {
    padding: 8px 0;
}

.auth-card {
    width: min(520px, 96vw);
    margin: 50px auto;
}

.credential-box {
    margin-top: 14px;
    border: 1px dashed #d1d5db;
    border-radius: 10px;
    padding: 12px;
    font-size: 0.88rem;
}

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

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 20px;
    margin-bottom: 10px;
}

.actions {
    display: flex;
    gap: 10px;
}

.approval-form {
    display: grid;
    gap: 8px;
}

.filter-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    align-items: end;
}

@media (max-width: 900px) {
    .two-col,
    .detail-grid,
    .summary-bar,
    .filter-grid {
        grid-template-columns: 1fr;
    }

    .topbar-inner {
        flex-wrap: wrap;
        justify-content: center;
        padding: 10px 0;
    }

    .inline-select {
        flex-direction: column;
    }
}

@media (max-width: 760px) {
    .card {
        padding: 16px;
    }

    #line-items-table {
        min-width: 0;
    }

    #line-items-table thead {
        display: none;
    }

    #line-items-table,
    #line-items-table tbody,
    #line-items-table tr,
    #line-items-table td {
        display: block;
        width: 100%;
    }

    #line-items-table tr {
        border-bottom: 1px solid var(--line);
        padding: 10px;
        background: #fff;
    }

    #line-items-table td {
        border: none;
        padding: 6px 0;
    }

    #line-items-table td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 4px;
        color: var(--muted);
        font-size: 0.76rem;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        font-weight: 700;
    }

    #line-items-table td:last-child {
        padding-top: 10px;
    }

    #line-items-table .inline-select button,
    #line-items-table .remove-line {
        width: 100%;
    }
}
