:root {
    /* G7FIT theme: change these values to update the whole interface. */
    --bg: #f3f3f1;
    --surface: #ffffff;
    --surface-soft: #f8f8f6;
    --text: #171719;
    --muted: #6d6d70;
    --border: #deded9;
    --topbar: #111113;
    --primary: #e74b28;
    --primary-dark: #c83a1b;
    --success: #247a56;
    --danger: #b63b42;
    --warning: #9d620e;
    --shadow: 0 14px 40px rgba(0, 0, 0, 0.2);
    --radius: 10px;
}

* { box-sizing: border-box; }

html { font-family: Tahoma, Arial, sans-serif; color: var(--text); background: var(--bg); }
body { margin: 0; min-height: 100vh; background: var(--bg); }
a { color: inherit; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(1.6rem, 3vw, 2.1rem); }
h2 { margin-bottom: 0; font-size: 1.15rem; }
.muted { color: var(--muted); }
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.login-page {
    display: grid;
    place-items: center;
    padding: 24px;
    background: var(--topbar);
}
.login-card {
    width: min(100%, 430px);
    padding: 0;
    border: 0;
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow);
    text-align: center;
    overflow: hidden;
}
.login-brand-panel {
    padding: 28px 36px 24px;
    border-top: 4px solid var(--primary);
    background: #0b0b0d;
}
.login-brand-panel img {
    display: block;
    width: min(100%, 285px);
    height: auto;
    margin: 0 auto;
}
.login-card-body { padding: 28px 34px 34px; }
.login-card-body h1 { margin-bottom: 7px; font-size: 1.55rem; }
.login-card-body > .muted { margin-bottom: 24px; font-size: 0.92rem; }
.login-card .alert { text-align: right; }
.login-card .stack-form { margin-top: 0; }
.login-card .button-primary {
    min-height: 46px;
    margin-top: 2px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    min-height: 66px;
    padding: 12px max(20px, calc((100% - 1180px) / 2));
    border-bottom: 3px solid var(--primary);
    background: var(--topbar);
}
.topbar > div:first-child { display: flex; align-items: center; gap: 10px; }
.brand { display: inline-flex; align-items: center; text-decoration: none; }
.brand img { display: block; width: 108px; height: 35px; object-fit: contain; }
.role-chip {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid #3d3d42;
    background: #242428;
    color: #f2f2f2;
    font-size: 0.75rem;
    font-weight: 700;
}
.user-menu { display: flex; align-items: center; gap: 10px; color: #d2d2d4; font-size: 0.9rem; }
.topbar .button-light { border-color: #3d3d42; background: transparent; color: #ffffff; }
.topbar .button-light:hover { border-color: var(--primary); background: #242428; }
.page-shell { width: min(1180px, calc(100% - 32px)); margin: 30px auto 60px; }
.page-shell-wide { width: min(1500px, calc(100% - 32px)); }
.form-page-shell { width: min(860px, calc(100% - 32px)); }
.page-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }

.panel {
    margin-bottom: 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
}
.panel-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}

.stack-form { display: grid; gap: 18px; margin-top: 26px; text-align: right; }
.form-grid, .filter-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; padding: 20px; }
.filter-grid { grid-template-columns: repeat(4, minmax(150px, 1fr)); }
label { display: grid; gap: 7px; font-size: 0.9rem; font-weight: 700; color: var(--text); }
label small { color: var(--muted); font-weight: 400; }
input, select, textarea {
    width: 100%;
    min-height: 43px;
    padding: 9px 11px;
    border: 1px solid #cfcfca;
    border-radius: 7px;
    outline: none;
    background: white;
    color: var(--text);
    font: inherit;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(231, 75, 40, 0.14); }
.field-wide { grid-column: 1 / -1; }
.form-actions, .filter-actions { display: flex; align-items: end; gap: 9px; flex-wrap: wrap; }
.filter-actions { grid-column: 1 / -1; }
.form-hint {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-inline-start: 4px solid var(--primary);
    border-radius: 7px;
    background: #fff3ef;
}
.form-hint strong { font-size: 0.92rem; }
.form-hint span { color: #6f4a40; font-size: 0.82rem; }
.receipt-field {
    padding: 15px;
    border: 2px solid #f0a18f;
    border-radius: 8px;
    background: #fff7f4;
}
.receipt-field-title { display: flex; align-items: center; gap: 8px; }
.receipt-field-title b {
    padding: 3px 7px;
    border-radius: 999px;
    background: var(--primary);
    color: #ffffff;
    font-size: 0.7rem;
}
.receipt-current { color: var(--success); font-size: 0.84rem; font-weight: 700; }
.optional-fields {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-soft);
    overflow: hidden;
}
.optional-fields summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    cursor: pointer;
    font-weight: 800;
    list-style: none;
}
.optional-fields summary::-webkit-details-marker { display: none; }
.optional-fields summary::after { content: '+'; color: var(--primary); font-size: 1.25rem; }
.optional-fields[open] summary::after { content: '−'; }
.optional-fields summary small { color: var(--muted); font-weight: 400; }
.optional-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    padding: 16px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 42px;
    padding: 9px 15px;
    border: 1px solid transparent;
    border-radius: 7px;
    cursor: pointer;
    text-decoration: none;
    font: inherit;
    font-weight: 700;
    transition: background-color 0.16s ease, border-color 0.16s ease;
}
.button:disabled { opacity: 0.65; cursor: wait; }
.button-primary { background: var(--primary); color: white; }
.button-primary:hover { background: var(--primary-dark); }
.button-secondary { border-color: var(--border); background: var(--surface-soft); color: var(--text); }
.button-success { background: var(--success); color: white; }
.button-light { border-color: var(--border); background: white; color: var(--text); }
.button-small { min-height: 34px; padding: 6px 10px; font-size: 0.82rem; }
.button-block { width: 100%; }
.text-link { color: var(--primary); font-weight: 700; }

.alert { margin-bottom: 20px; padding: 13px 16px; border: 1px solid; border-radius: 7px; }
.alert-success { border-color: #a7e1c9; background: #ebfaf3; color: #126343; }
.alert-error { border-color: #f0b9bc; background: #fff0f1; color: #9f2e34; }

.summary-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; margin-bottom: 24px; }
.summary-card { min-height: 108px; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.summary-card span { display: block; margin-bottom: 13px; color: var(--muted); font-size: 0.86rem; }
.summary-card strong { display: block; font-size: 1.1rem; line-height: 1.5; overflow-wrap: anywhere; }
.summary-warning { border-top: 3px solid #d88a20; }
.summary-success { border-top: 3px solid var(--success); }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--border); text-align: right; vertical-align: top; font-size: 0.88rem; }
th { background: var(--surface-soft); color: #4f4f52; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafaf8; }
.admin-table { min-width: 1220px; }
.amount-cell { direction: ltr; text-align: right; white-space: nowrap; font-weight: 800; }
.table-note { margin-top: 5px; color: var(--muted); font-size: 0.8rem; line-height: 1.5; }
.empty-state { padding: 35px; color: var(--muted); text-align: center; }
.processing-cell { min-width: 260px; }
.inline-update-form { display: grid; gap: 9px; margin-top: 10px; }
.inline-update-form label { font-size: 0.78rem; }
.inline-update-form input, .inline-update-form select, .inline-update-form textarea { min-height: 35px; padding: 6px 8px; font-size: 0.82rem; }

.status { display: inline-block; padding: 5px 9px; border-radius: 999px; font-size: 0.76rem; font-weight: 800; white-space: nowrap; }
.status-pending { background: #fff3d9; color: #925408; }
.status-approved { background: #e8f8f1; color: #126c4a; }
.status-rejected { background: #ffebed; color: #a32d35; }
.status-entered-in-odoo { background: #fff0eb; color: #b53a20; }
.user-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.reset-form { display: flex; gap: 6px; }
.reset-form input { width: 165px; min-height: 34px; }

@media (max-width: 1100px) {
    .summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
    .topbar { position: static; align-items: flex-start; padding: 13px 16px; }
    .user-menu { justify-content: flex-end; flex-wrap: wrap; }
    .user-menu > span { display: none; }
    .page-shell, .page-shell-wide { width: min(100% - 20px, 1180px); margin-top: 20px; }
    .form-grid, .filter-grid { grid-template-columns: 1fr; padding: 15px; }
    .field-wide, .filter-actions { grid-column: auto; }
    .form-hint { align-items: flex-start; flex-direction: column; }
    .optional-grid { grid-template-columns: 1fr; }
    .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .summary-card { min-height: 100px; padding: 14px; }
    .panel-heading { padding: 15px; }

    .admin-table { min-width: 0; }
    .responsive-table thead { display: none; }
    .responsive-table,
    .responsive-table tbody,
    .responsive-table tr,
    .responsive-table td { display: block; width: 100%; }
    .responsive-table tr { padding: 10px 14px; border-bottom: 1px solid var(--border); }
    .responsive-table td { display: grid; grid-template-columns: 115px 1fr; gap: 10px; padding: 7px 0; border: 0; }
    .responsive-table td::before { content: attr(data-label); color: var(--muted); font-weight: 700; }
    .responsive-table .empty-state { display: block; }
    .responsive-table .processing-cell { min-width: 0; }
    .login-card-body { padding: 24px 20px 28px; }
    .login-brand-panel { padding: 24px 28px 20px; }
}

@media (max-width: 420px) {
    .summary-grid { grid-template-columns: 1fr; }
    .topbar { gap: 8px; }
    .role-chip { display: none; }
}
