:root {
    --orange: #FF6500;
    --orange-dark: #e65a00;
    --orange-soft: #fff1e8;
    --black: #050505;
    --bg: #f4f5f7;
    --white: #ffffff;
    --text: #0f172a;
    --muted: #6b7280;
    --line: #eceef2;
    --red: #dc2626;
    --border: var(--line);      /* alias used by the search + notification dropdowns */

    --sidebar-w: 260px;
    --topbar-h: 66px;
    --content-max: 1680px;      /* keeps ultra-wide monitors tidy */

    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 10px;
    --radius-card: 14px;

    --control-h: 38px;          /* every input / select / md button */
    --control-h-sm: 30px;       /* small buttons / pagers / footer select */
    --gutter: 32px;             /* page side padding */

    --surface: #f7f8fa;         /* table headers, soft boxes */
    --orange-line: #ffd9c2;     /* soft orange borders */
    --green: #15803d;
    --green-soft: #e8f7ee;
    --red-soft: #fef2f2;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .05);
    --shadow-md: 0 8px 24px rgba(15, 23, 42, .10);
    --shadow-lg: 0 24px 64px rgba(15, 23, 42, .22);
    --ease: cubic-bezier(.2, .8, .2, 1);
}

/* ===== 2. Base / reset ===== */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html {
    /* Reserve scrollbar space so layout never jumps between short/long pages */
    overflow-y: scroll;
    scrollbar-gutter: stable;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
img { max-width: 100%; height: auto; }

svg {
    width: 18px; height: 18px; flex-shrink: 0;
    fill: none; stroke: currentColor; stroke-width: 1.7;
    stroke-linecap: round; stroke-linejoin: round;
}

[hidden] { display: none !important; }
body.modal-open { overflow: hidden; }

:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }

/* Soft-red validation warnings shown through Toastr. */
#toast-container > .toast-success { background-color: var(--orange); border: 1px solid #ff873e; box-shadow: 0 14px 34px rgba(230, 90, 0, .24); opacity: 1; }
#toast-container > .toast-warning { background-color: #fff1f2; color: #991b1b; border: 1px solid #fecdd3; box-shadow: 0 14px 34px rgba(136, 19, 55, .14); opacity: 1; }
#toast-container > .toast-warning .toast-title { color: #881337; }
#toast-container > .toast-warning .toast-progress { background-color: #fb7185; opacity: .72; }
#toast-container > .toast-warning .toast-message { white-space: pre-line; }

/* ===== 3. Sidebar ===== */
.sidebar {
    position: fixed; inset: 0 auto 0 0;
    width: var(--sidebar-w);
    height: 100vh; height: 100dvh;
    background: var(--black);
    color: #cfd2d8;
    display: flex; flex-direction: column;
    padding: 28px 16px 20px;
    z-index: 40;
    transition: transform .25s ease;
}

.sidebar__brand { padding: 0 10px 34px; }
.sidebar__brand img { max-width: 100%; height: auto; display: block; }
.sidebar__wordmark { font-size: 26px; font-weight: 700; color: #fff; letter-spacing: 1px; }

.sidebar__nav { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }

.sidebar__label {
    font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
    color: #8a8f98; margin: 20px 10px 10px;
}
.sidebar__label:first-child { margin-top: 0; }

.nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; margin-bottom: 6px;
    border-radius: var(--radius-lg); color: #cfd2d8; font-size: 13px;
    transition: background .15s, color .15s;
}
.nav-link:hover { background: #161616; color: #fff; }
.nav-link.is-active { background: var(--orange); color: #fff; font-weight: 500; }

.nav-badge {
    margin-left: auto; font-style: normal; font-size: 11px;
    background: #2a2a2a; color: #fff; border-radius: var(--radius-sm); padding: 1px 7px;
}
.nav-chevron { width: 14px; height: 14px; color: #8a8f98; }

/* Count badges in the sidebar (e.g. Approvals) are hidden: they were inaccurate.
   To hide them only while that page is open, replace this selector with:
   .nav-link.is-active .nav-badge */
.nav-badge { display: none; }

.nav-sub { margin: -2px 0 6px 14px; }
.nav-sublink {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 14px; border-radius: var(--radius-lg);
    color: #cfd2d8; font-size: 12px;
}
.nav-sublink svg { width: 14px; height: 14px; }
.nav-sublink:hover { background: #161616; color: #fff; }
.nav-sublink.is-active { background: var(--orange); color: #fff; font-weight: 500; }
.nav-sublink.is-active:hover { background: var(--orange-dark); }

.sidebar__footer {
    display: flex; align-items: center; gap: 12px;
    padding: 16px 10px 0; border-top: 1px solid #1f1f1f;
}
.sidebar__footer strong { display: block; font-size: 12px; color: #fff; font-weight: 500; }
.sidebar__footer small { font-size: 11px; color: #8a8f98; }
.sidebar__footer-icon {
    width: 34px; height: 34px; border-radius: var(--radius); background: #161616;
    display: grid; place-items: center; color: #9ca3af;
}

.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 30; }

/* ===== 4. Main + top bar ===== */
.main {
    margin-left: var(--sidebar-w);
    min-height: 100vh; min-height: 100dvh;
    min-width: 0;
    display: flex; flex-direction: column;
}

.topbar {
    position: sticky; top: 0; z-index: 20;
    height: var(--topbar-h); background: var(--white);
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: 16px; padding: 0 var(--gutter);
}
.topbar__menu { display: none; }

.breadcrumb { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 12.5px; min-width: 0; }
.breadcrumb svg { width: 15px; height: 15px; }
.breadcrumb strong { color: var(--text); font-weight: 500; }

.topbar__right { margin-left: auto; display: flex; align-items: center; gap: 14px; }

.search {
    display: flex; align-items: center; gap: 8px;
    background: var(--bg); border-radius: var(--radius-lg);
    padding: 0 12px; height: var(--control-h); width: 280px; color: var(--muted); position: relative;
}
.search svg { width: 16px; height: 16px; }
.search input {
    border: 0; background: transparent; outline: 0; width: 100%;
    font: inherit; font-size: 12.5px; color: var(--text);
}
.global-search-results {
    position: absolute; z-index: 50; top: calc(100% + 8px); left: 0; width: 360px;
    max-height: 360px; overflow-y: auto; padding: 6px; background: #fff;
    border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: 0 12px 30px rgba(23, 38, 61, .16);
}
.global-search-result { display: block; padding: 10px 12px; border-radius: 8px; color: var(--text); text-decoration: none; }
.global-search-result:hover, .global-search-result:focus { background: var(--bg); outline: 0; }
.global-search-result strong, .global-search-result small { display: block; }
.global-search-result strong { font-size: 12.5px; }
.global-search-result small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.global-search-results__empty { margin: 0; padding: 10px 12px; color: var(--muted); font-size: 12px; }

.icon-btn {
    position: relative; width: var(--control-h); height: var(--control-h);
    border: 0; border-radius: var(--radius-lg);
    background: transparent; color: var(--muted); cursor: pointer;
    display: grid; place-items: center;
}
.icon-btn:hover { background: var(--bg); }
.icon-btn--dot::after {
    content: ''; position: absolute; top: 9px; right: 10px;
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--orange); border: 1.5px solid var(--white);
}
/* Notifications dropdown */
.notifications { position: relative; }
.notifications__panel {
    position: absolute; z-index: 50; top: calc(100% + 8px); right: 0; width: 350px; max-width: calc(100vw - 24px);
    max-height: 420px; overflow-y: auto; background: #fff;
    border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: 0 12px 30px rgba(23, 38, 61, .16);
}
.notifications__head { display: flex; align-items: center; justify-content: space-between; padding: 13px 14px; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.notifications__head button { border: 0; background: transparent; color: var(--orange); font: inherit; font-size: 11px; cursor: pointer; }
.notification { display: block; padding: 11px 14px; color: var(--text); text-decoration: none; border-bottom: 1px solid var(--line); }
.notification:hover { background: var(--bg); }
.notification--unread { background: #fff8f0; }
.notification strong, .notification span, .notification small { display: block; }
.notification strong { font-size: 12px; }
.notification span { margin-top: 2px; font-size: 11px; color: var(--muted); }
.notification small { margin-top: 4px; font-size: 10px; color: var(--orange); }
.notifications__empty { margin: 0; padding: 18px 14px; color: var(--muted); font-size: 12px; }
.icon-btn--sm { width: var(--control-h-sm); height: var(--control-h-sm); font-size: 16px; letter-spacing: 1px; line-height: 1; }

.user { display: flex; align-items: center; gap: 10px; padding-left: 16px; border-left: 1px solid var(--line); }
.user__avatar {
    width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
    background: var(--orange-soft); color: var(--orange);
    display: grid; place-items: center; font-size: 12px; font-weight: 600;
}
.user__meta strong { display: block; font-size: 12.5px; font-weight: 500; }
.user__meta small { font-size: 11px; color: var(--muted); }
.user__chevron { width: 14px; height: 14px; color: var(--muted); }

/* Workspace: same padding on every page, centered on huge screens */
.workspace {
    flex: 1; min-width: 0;
    width: 100%; max-width: var(--content-max);
    margin-inline: auto;
    padding: 28px var(--gutter) 40px;
}

/* ===== 5. Page header ===== */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 22px; }
.page-head h1 { font-size: 22px; font-weight: 600; line-height: 1.3; }
.page-head p { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.page-head__actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

.date-pill {
    display: flex; align-items: center; gap: 8px;
    background: var(--white); border: 1px solid var(--line);
    border-radius: var(--radius-lg); padding: 9px 14px; font-size: 12.5px; white-space: nowrap;
}
.date-pill svg { width: 16px; height: 16px; color: var(--muted); }

.back-link { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.back-link svg { width: 14px; height: 14px; }
.back-link:hover { color: var(--orange); }

/* ===== 6. Cards + stat cards ===== */
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-card); box-shadow: var(--shadow-sm); }

.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.cards--3 { grid-template-columns: repeat(3, 1fr); }

.stat { padding: 18px 20px; min-width: 0; }
.stat__top { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 12.5px; }
.stat__icon { width: 30px; height: 30px; border-radius: var(--radius); display: grid; place-items: center; font-style: normal; }
.stat__icon svg { width: 16px; height: 16px; }
.stat__icon--gray   { background: #f1f2f4; color: #6b7280; }
.stat__icon--green  { background: #e8f7ee; color: #16a34a; }
.stat__icon--purple { background: #f1ecff; color: #7c4dff; }
.stat__icon--orange { background: var(--orange-soft); color: var(--orange); }
.stat__value { font-size: 30px; font-weight: 700; margin: 12px 0 6px; line-height: 1.1; }
.stat__note { font-size: 11.5px; color: var(--muted); }

/* ===== 7. Panels ===== */
.panel { padding: 22px 0 10px; margin-bottom: 22px; }
.panel--pad { padding: 22px 28px 14px; overflow: hidden; }
.panel__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 0 28px 16px; }
.panel__head h2 { font-size: 15px; font-weight: 600; }
.panel__head p { font-size: 12px; color: var(--muted); margin-top: 3px; }

.link-orange { color: var(--text); font-size: 12.5px; white-space: nowrap; }
.link-orange span { color: var(--orange); }
.link-orange:hover { color: var(--orange); }

.meta-row { display: flex; justify-content: space-between; font-size: 11.5px; margin-bottom: 14px; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 22px; }

/* ===== 8. Filters + form fields (one size everywhere) ===== */
.filters { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 22px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 170px; }
.field--grow { flex: 1; min-width: 240px; }
.field label { font-size: 11.5px; color: var(--muted); }
.field small { font-size: 11px; color: var(--muted); }

.field select,
.field input,
.input-icon input,
.table-foot select,
.eval-input {
    height: var(--control-h); border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--white); color: var(--text);
    font: inherit; font-size: 12.5px; padding: 0 12px; outline: 0; max-width: 100%;
}
.field select:focus,
.field input:focus,
.input-icon input:focus,
.eval-input:focus,
.eval-text:focus,
.modal__body textarea:focus {
    border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-soft);
}

.input-icon { position: relative; }
.input-icon svg {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    width: 15px; height: 15px; color: var(--muted);
}
.input-icon input { width: 100%; padding-left: 36px; }

.eval-text {
    width: 100%; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px;
    font: inherit; font-size: 12.5px; outline: 0; background: var(--white); resize: vertical;
}
.eval-input { width: 100%; }

/* ----- Modern select (dropdown): every <select> in the app ----- */
select:not([multiple]) {
    -webkit-appearance: none; -moz-appearance: none; appearance: none;
    padding-right: 36px; cursor: pointer; text-overflow: ellipsis;
    background: var(--white) right 12px center / 16px 16px no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    transition: border-color .15s, box-shadow .15s;
}
select:not([multiple]):hover:not(:disabled) { border-color: #d3d7de; }
select:not([multiple]):focus {
    border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-soft);
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px 16px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23FF6500' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
select:not([multiple]):disabled { background-color: #f1f2f4; color: var(--muted); cursor: not-allowed; opacity: .8; }
/* Placeholder option (empty value) shown in muted color */
select:not([multiple]):has(option[value=""]:checked) { color: var(--muted); }
select option { color: var(--text); }

/* ----- Custom dropdown list (Tom Select) ----- */
/* the real <select> stays in the page for form submit, but is hidden */
select.ts-hidden-accessible,
.field select.ts-hidden-accessible,
.form-grid .field select.ts-hidden-accessible {
    position: absolute !important; width: 1px !important; height: 1px !important;
    min-height: 0 !important; padding: 0 !important; margin: -1px !important; border: 0 !important;
    overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; opacity: 0 !important;
    background: none !important; box-shadow: none !important; pointer-events: none !important;
}

/* closed box */
.ts-wrapper { width: 100%; font-family: inherit; }
.ts-wrapper .ts-control {
    min-height: var(--control-h); height: var(--control-h);
    display: flex; flex-wrap: nowrap; align-items: center;
    padding: 0 40px 0 12px; font-size: 12.5px; line-height: 1.2; color: var(--text);
    background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: none; cursor: pointer; transition: border-color .15s, box-shadow .15s;
}
.ts-wrapper .ts-control:hover { border-color: #d3d7de; }
.ts-wrapper .ts-control .item {
    max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text);
}
.ts-wrapper .ts-control .item[data-value=""] { color: var(--muted); }
.ts-wrapper.focus .ts-control,
.ts-wrapper.dropdown-active .ts-control {
    border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-soft);
}
.ts-wrapper.disabled .ts-control { background: #f1f2f4; color: var(--muted); cursor: not-allowed; opacity: 1; }

/* chevron (replaces Tom Select's default triangle) */
.ts-wrapper.single .ts-control:not(.rtl)::after {
    content: '' !important; display: block; position: absolute; top: 50% !important; right: 12px !important;
    width: 16px !important; height: 16px !important; margin: -8px 0 0 !important;
    border: 0 !important; transition: transform .2s ease;
    background: center / 16px 16px no-repeat
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
.ts-wrapper.single.dropdown-active .ts-control:not(.rtl)::after {
    transform: rotate(180deg); margin: -8px 0 0 !important; border: 0 !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23FF6500' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

/* open list */
.ts-dropdown {
    z-index: 95; margin-top: 6px; padding: 6px;
    background: var(--white); color: var(--text);
    border: 1px solid var(--line); border-radius: 12px;
    box-shadow: 0 16px 40px rgba(15, 23, 42, .16);
    font-family: inherit; font-size: 12.5px;
}
.ts-dropdown .ts-dropdown-content { max-height: 240px; padding: 0; scrollbar-width: thin; scrollbar-color: #d3d7de transparent; }
.ts-dropdown .option,
.ts-dropdown .no-results {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 9px 12px; margin: 1px 0; border-radius: var(--radius); color: var(--text); cursor: pointer;
}
.ts-dropdown .option[data-value=""] { color: var(--muted); }
.ts-dropdown .option.active { background: var(--bg); color: var(--text); }
.ts-dropdown .option.selected { background: var(--orange-soft); color: var(--orange); font-weight: 500; }
.ts-dropdown .option.selected::after {
    content: ''; flex-shrink: 0; width: 14px; height: 14px;
    background: center / 14px 14px no-repeat
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23FF6500' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
}
.ts-dropdown .option.selected.active { background: #ffe6d6; }
.ts-dropdown .no-results { color: var(--muted); cursor: default; }

/* ----- Modern checkbox ----- */
html { accent-color: var(--orange); color-scheme: light; }

input[type="checkbox"],
.field input[type="checkbox"],
.form-grid .field input[type="checkbox"] {
    -webkit-appearance: none; appearance: none;
    display: inline-grid; place-content: center; flex-shrink: 0;
    width: 18px; height: 18px; min-width: 18px; padding: 0; margin: 0;
    border: 1.5px solid #cbd5e1; border-radius: 5px; background: var(--white);
    cursor: pointer;
    transition: background .15s, border-color .15s, box-shadow .15s;
}
input[type="checkbox"]::before {
    content: ''; width: 10px; height: 10px; background: #fff;
    clip-path: polygon(14% 44%, 0 62%, 40% 100%, 100% 20%, 82% 4%, 39% 66%);
    transform: scale(0); transition: transform .12s ease-out;
}
input[type="checkbox"]:hover { border-color: var(--orange); }
input[type="checkbox"]:checked { background: var(--orange); border-color: var(--orange); }
input[type="checkbox"]:checked::before { transform: scale(1); }
input[type="checkbox"]:focus-visible { outline: 0; box-shadow: 0 0 0 3px var(--orange-soft); border-color: var(--orange); }
input[type="checkbox"]:disabled { opacity: .5; cursor: not-allowed; background: #f1f2f4; }

/* Label that wraps / sits beside a checkbox */
label.check,
.field label:has(> input[type="checkbox"]) {
    display: inline-flex; align-items: center; gap: 10px;
    font-size: 12.5px; color: var(--text); cursor: pointer;
}

/* ----- Modern date picker field ----- */
input[type="date"],
input[type="datetime-local"],
input[type="month"] {
    cursor: pointer; min-width: 0;
}
input[type="date"]::-webkit-datetime-edit,
input[type="datetime-local"]::-webkit-datetime-edit { padding: 0; }
input[type="date"]::-webkit-datetime-edit-fields-wrapper { padding: 0; }
input[type="date"]::-webkit-datetime-edit-text { color: var(--muted); padding: 0 2px; }
input[type="date"]::-webkit-datetime-edit-month-field:focus,
input[type="date"]::-webkit-datetime-edit-day-field:focus,
input[type="date"]::-webkit-datetime-edit-year-field:focus {
    background: var(--orange-soft); color: var(--orange); border-radius: 4px; outline: 0;
}
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator {
    width: 26px; height: 26px; margin: 0 -4px 0 4px; padding: 0;
    border-radius: var(--radius-sm); cursor: pointer; opacity: 1;
    background: transparent center / 16px 16px no-repeat
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='3'/%3E%3Cpath d='M16 2v4M8 2v4M3 10h18'/%3E%3C/svg%3E");
    transition: background-color .15s;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover,
input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover,
input[type="month"]::-webkit-calendar-picker-indicator:hover {
    background-color: var(--orange-soft);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23FF6500' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='3'/%3E%3Cpath d='M16 2v4M8 2v4M3 10h18'/%3E%3C/svg%3E");
}
input[type="date"]:disabled::-webkit-calendar-picker-indicator,
input[type="date"][readonly]::-webkit-calendar-picker-indicator { opacity: .4; cursor: not-allowed; }

/* ----- Flatpickr: field (the visible input it creates) ----- */
.field input.flatpickr-alt,
.form-grid .field input.flatpickr-alt {
    width: 100%; cursor: pointer; padding-right: 40px;
    background-color: var(--white); color: var(--text);
}

/* Calendar icon sitting inside the date box (added by datepicker.js) */
.date-input { position: relative; width: 100%; }
.date-input__icon {
    position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
    width: 18px; height: 18px; display: grid; place-items: center;
    color: var(--muted); pointer-events: none; transition: color .15s;
}
.date-input__icon svg { width: 18px; height: 18px; }
.date-input:hover .date-input__icon,
.date-input:focus-within .date-input__icon { color: var(--orange); }
.date-input:has(input:disabled) .date-input__icon { opacity: .4; }
/* Flatpickr marks its input read-only; keep it looking editable */
.form-grid .field input.flatpickr-alt[readonly]:not(:disabled),
.field input.flatpickr-alt[readonly]:not(:disabled) { background-color: var(--white); color: var(--text); }
.field input.flatpickr-alt.active,
.field input.flatpickr-alt:focus { border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-soft); }
.form-grid .field input.flatpickr-alt:disabled { background-color: #f1f2f4; color: var(--muted); cursor: not-allowed; }

/* ----- Flatpickr: popup calendar ----- */
.flatpickr-calendar {
    font-family: inherit; font-size: 13px; color: var(--text);
    background: var(--white); border: 1px solid var(--line); border-radius: var(--radius-card);
    box-shadow: 0 16px 40px rgba(15, 23, 42, .16); padding: 8px 6px 6px;
}
.flatpickr-calendar::before, .flatpickr-calendar::after { display: none; }
.flatpickr-calendar.open { z-index: 95; }   /* above every modal */

.flatpickr-months { align-items: center; padding: 4px 4px 6px; }
.flatpickr-months .flatpickr-month { height: 34px; color: var(--text); fill: var(--text); }
.flatpickr-current-month { font-size: 13.5px; font-weight: 600; padding-top: 6px; height: 34px; }
.flatpickr-current-month .flatpickr-monthDropdown-months,
.flatpickr-current-month input.cur-year { font: inherit; font-weight: 600; color: var(--text); }
.flatpickr-current-month .flatpickr-monthDropdown-months:hover,
.flatpickr-current-month .numInputWrapper:hover { background: var(--bg); }
.flatpickr-monthDropdown-months { border-radius: var(--radius-sm); }
.numInputWrapper span:hover { background: var(--orange-soft); }
.numInputWrapper span.arrowUp::after   { border-bottom-color: var(--orange); }
.numInputWrapper span.arrowDown::after { border-top-color: var(--orange); }

.flatpickr-months .flatpickr-prev-month,
.flatpickr-months .flatpickr-next-month {
    width: 30px; height: 30px; top: 6px; padding: 0; border-radius: var(--radius);
    display: grid; place-items: center; color: var(--muted); fill: var(--muted);
}
.flatpickr-months .flatpickr-prev-month { left: 8px; }
.flatpickr-months .flatpickr-next-month { right: 8px; }
.flatpickr-months .flatpickr-prev-month svg,
.flatpickr-months .flatpickr-next-month svg { width: 11px; height: 11px; fill: currentColor; stroke: none; }
.flatpickr-months .flatpickr-prev-month:hover,
.flatpickr-months .flatpickr-next-month:hover { background: var(--orange-soft); color: var(--orange); }
.flatpickr-months .flatpickr-prev-month:hover svg,
.flatpickr-months .flatpickr-next-month:hover svg { fill: var(--orange); }

.flatpickr-weekdays { height: 30px; }
span.flatpickr-weekday { font-size: 11.5px; font-weight: 500; color: var(--muted); background: transparent; }

.flatpickr-day {
    border-radius: var(--radius); border-color: transparent; color: var(--text); font-weight: 400;
    height: 38px; line-height: 38px; max-width: 38px; margin: 1px 0;
}
.flatpickr-day:hover, .flatpickr-day:focus { background: var(--bg); border-color: var(--bg); }
.flatpickr-day.today { border-color: var(--orange); color: var(--orange); background: transparent; font-weight: 500; }
.flatpickr-day.today:hover { background: var(--orange-soft); border-color: var(--orange); color: var(--orange); }
.flatpickr-day.selected, .flatpickr-day.selected:hover, .flatpickr-day.selected:focus,
.flatpickr-day.startRange, .flatpickr-day.endRange {
    background: var(--orange); border-color: var(--orange); color: #fff; font-weight: 500;
}
.flatpickr-day.inRange {
    background: var(--orange-soft); border-color: var(--orange-soft); box-shadow: none; color: var(--text);
}
.flatpickr-day.prevMonthDay, .flatpickr-day.nextMonthDay { color: #cbd5e1; }
.flatpickr-day.flatpickr-disabled, .flatpickr-day.flatpickr-disabled:hover { color: #d1d5db; background: transparent; cursor: not-allowed; }

/* ===== 9. Tables ===== */
.table-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.table-head h2 { font-size: 14px; font-weight: 600; }
.table-head .count { color: var(--muted); font-weight: 400; }
.table-head p { font-size: 11.5px; }
.table-head--top { align-items: flex-start; margin-bottom: 16px; }

/* Tables scroll inside their own card, never the whole page */
.table-wrap { overflow-x: auto; padding: 0 20px; max-width: 100%; -webkit-overflow-scrolling: touch; }
.table-wrap--flush { padding: 0; }

.table { width: 100%; border-collapse: collapse; min-width: 760px; }
.table--wide { min-width: 1020px; }
.table th {
    text-align: left; font-size: 11.5px; font-weight: 500; color: var(--muted);
    background: #f7f8fa; padding: 12px 16px; white-space: nowrap;
}
.table th:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.table th:last-child  { border-radius: 0 var(--radius) var(--radius) 0; }
.table td { padding: 15px 16px; border-bottom: 1px solid var(--line); font-size: 12.5px; white-space: nowrap; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fcfcfd; }
.muted { color: var(--muted); }

.person { display: flex; align-items: center; gap: 10px; }
.person strong { font-weight: 500; }
.person__avatar {
    width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
    background: #f1f2f4; color: #374151;
    display: grid; place-items: center; font-size: 9.5px; font-weight: 600;
}

.stack { display: flex; flex-direction: column; gap: 2px; }
.stack small { color: var(--muted); font-size: 11px; }

.table-foot {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    flex-wrap: wrap; padding: 14px 0 4px; font-size: 11.5px;
}
.table-foot__right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.table-foot select { height: var(--control-h-sm); padding: 0 28px 0 10px; background-position: right 8px center; background-size: 14px 14px; }
.pager {
    width: var(--control-h-sm); height: var(--control-h-sm); border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--white); color: var(--text); display: grid; place-items: center; cursor: pointer;
}
.pager svg { width: 14px; height: 14px; }
.pager:disabled { color: #cbd5e1; cursor: not-allowed; }
.pagination-wrap { padding: 14px 28px 8px; }

/* Empty state */
.empty { text-align: center; padding: 44px 16px; color: var(--muted); white-space: normal; }
.empty svg { width: 34px; height: 34px; margin-bottom: 10px; color: #cbd5e1; }
.empty strong { display: block; color: var(--text); margin-bottom: 4px; font-weight: 500; }
.empty--sm { padding: 20px 8px; }

/* ===== 10. Badges, pills, tags, chips ===== */
.badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px; border-radius: var(--radius-sm); font-size: 11px; font-weight: 500; white-space: nowrap;
}
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge--deploy   { background: #fff6dd; color: #b7791f; }
.badge--pending  { background: #f1ecff; color: #6d3fe0; }
.badge--expiring { background: #fff1e0; color: #c2570c; }
.badge--active   { background: #e8f7ee; color: #15803d; }
.badge--draft    { background: #f1f2f4; color: #4b5563; }
.badge--returned { background: #fff1e0; color: #c2570c; }
.badge--overdue  { background: #fdecec; color: #c62828; }

.pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px; border-radius: var(--radius-sm); font-size: 11px; font-weight: 500;
}
.pill svg { width: 12px; height: 12px; stroke-width: 2.2; }
.pill--complete   { background: var(--orange); color: #fff; }
.pill--incomplete { background: var(--white); color: var(--muted); border: 1px solid var(--line); }

.days-pill { display: inline-block; padding: 2px 8px; border-radius: var(--radius-sm); font-size: 10.5px; font-weight: 500; }
.days-pill--expiring { background: #fff4e0; color: #b45309; }
.days-pill--overdue  { background: #fdecec; color: #c62828; }

.tag { background: var(--bg); color: var(--muted); border-radius: var(--radius-sm); padding: 5px 10px; font-size: 11.5px; white-space: nowrap; }
.tag--orange { background: var(--orange-soft); color: var(--orange); }

.rating-chip { display: inline-block; padding: 4px 10px; border-radius: var(--radius-sm); font-size: 11.5px; font-weight: 500; background: #f1f2f4; color: #4b5563; }
.rating-chip--1 { background: #fff1e0; color: #c2570c; }
.rating-chip--3 { background: #e8f7ee; color: #15803d; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.chip {
    border: 1px solid var(--line); background: var(--white); color: var(--muted);
    border-radius: var(--radius); padding: 7px 14px; font-size: 12px;
}
.chip:hover { border-color: var(--orange); color: var(--orange); }
.chip.is-active { background: var(--orange-soft); border-color: var(--orange); color: var(--orange); font-weight: 500; }

/* ===== 11. Buttons (one consistent scale) ===== */
.btn,
.btn-ghost,
.btn-outline-red,
.btn-outline-orange {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: var(--control-h); padding: 0 20px;
    border-radius: var(--radius); font: inherit; font-size: 12.5px; font-weight: 500;
    line-height: 1.2; cursor: pointer; white-space: nowrap; text-align: center;
    transition: background .15s, border-color .15s, color .15s;
}
.btn { background: var(--orange); color: #fff; border: 1px solid var(--orange); }
.btn:hover { background: var(--orange-dark); border-color: var(--orange-dark); }
.btn-ghost { background: var(--white); color: var(--text); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--bg); }
.btn-outline-red { background: var(--white); color: var(--red); border: 1px solid var(--red); }
.btn-outline-red:hover { background: #fef2f2; }
.btn-outline-orange { background: var(--white); color: var(--orange); border: 1px solid var(--orange); }
.btn-outline-orange:hover { background: var(--orange-soft); }

.btn--md { min-height: var(--control-h); padding: 0 18px; font-size: 12.5px; border-radius: var(--radius); }
.btn--sm { min-height: var(--control-h-sm); padding: 0 12px; font-size: 11.5px; border-radius: var(--radius-sm); }

.btn:disabled, .btn-ghost:disabled { opacity: .55; cursor: not-allowed; }
.btn.is-disabled { background: #e5e7eb; border-color: #e5e7eb; color: #9ca3af; cursor: not-allowed; pointer-events: none; }

/* Row action icons */
.actions { display: flex; gap: 8px; }
.actions form { display: contents; }
.act {
    width: 28px; height: 28px; padding: 0; border-radius: var(--radius-sm); background: var(--white);
    border: 1px solid var(--line); display: grid; place-items: center;
    font: inherit; cursor: pointer; transition: background .15s;
}
.act svg { width: 14px; height: 14px; }
.act--view   { color: #374151; border-color: #374151; }
.act--edit   { color: var(--orange); border-color: var(--orange); }
.act--delete { color: var(--red); border-color: var(--red); }
.act--ok     { color: #16a34a; border-color: #86d7a3; background: #f0fbf4; }
.act--no     { color: var(--red); border-color: #fca5a5; background: #fef2f2; }
.act:hover   { background: var(--bg); }
.act--ok:hover { background: #e3f6ea; }
.act--no:hover { background: #fde4e4; }
.act.is-disabled,
.act--ok.is-disabled,
.act--no.is-disabled { color: #cbd5e1; border-color: var(--line); background: #f7f8fa; cursor: not-allowed; }
.act.is-disabled:hover { background: #f7f8fa; }

/* ===== 12. Create / edit contract form ===== */
.create-grid {
    display: grid; gap: 22px; align-items: start;
    grid-template-columns: minmax(0, 1fr) clamp(340px, 28vw, 440px);
}
.form-card { padding: 22px 24px; margin-bottom: 18px; }
.form-card h2 { font-size: 14px; font-weight: 600; }
.form-card > .muted { font-size: 11.5px; margin: 3px 0 18px; }

.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px 18px; }
.form-grid--2 { grid-template-columns: repeat(2, 1fr); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: 1 / -1; }
.span-1-2 { grid-column: span 1; }

.form-grid .field { min-width: 0; }
.form-grid .field input,
.form-grid .field select { width: 100%; }
.form-grid .field input:disabled { background: #f1f2f4; color: var(--muted); cursor: not-allowed; }
.form-grid .field input[readonly] { background: #f7f8fa; color: var(--muted); }

.summary { position: sticky; top: calc(var(--topbar-h) + 20px); }
.summary dd { word-break: break-word; }
.summary .dl--stack { grid-template-columns: 1fr 1fr; gap: 10px 18px; margin-top: 0; }
.summary .dl--stack > .wide { grid-column: 1 / -1; }
.summary-split { margin: 12px 0 8px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 12px; }
.summary-line { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--muted); }

.form-actions {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 18px; margin-top: 6px;
}
.form-actions__right { display: flex; align-items: center; gap: 12px; font-size: 11.5px; flex-wrap: wrap; }

/* Form feedback */
.notice--info    { background: #f3f4f6; border: 1px solid var(--line); color: var(--muted); }
.notice--success { background: #e8f7ee; border: 1px solid #86d7a3; color: #15803d; }
.notice--error   { background: #fef2f2; border: 1px solid #fca5a5; color: #b91c1c; }
.notice--error ul { margin: 6px 0 0 18px; }

/* ===== 13. Details / review pages ===== */
.details-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.details-grid .panel { margin-bottom: 22px; }
.details-grid .table-head h2 { font-size: 14px; }

.dl { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 24px; }
.dl dt { font-size: 11.5px; color: var(--muted); margin-bottom: 3px; }
.dl dd { font-size: 13px; font-weight: 500; }
.dl--stack { grid-template-columns: 1fr; gap: 12px; margin-top: 4px; }
.dl--3 { grid-template-columns: repeat(3, 1fr); margin-top: 14px; }
.dl--4 { grid-template-columns: repeat(4, 1fr); }

.doc-row {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 12.5px;
}
.doc-row:last-child { border-bottom: 0; }
.doc-row svg { color: var(--muted); }

.step { display: flex; gap: 12px; padding: 8px 0; }
.step__dot { width: 10px; height: 10px; border-radius: 50%; background: var(--orange); margin-top: 5px; flex-shrink: 0; }
.step__dot--muted { background: #cbd5e1; }
.step strong { display: block; font-size: 12.5px; font-weight: 500; }
.step small { color: var(--muted); font-size: 11.5px; }

.num {
    display: inline-grid; place-items: center; width: 18px; height: 18px; margin-right: 8px;
    border-radius: 5px; background: #f1f2f4; color: var(--muted); font-size: 10.5px; font-weight: 500;
}

/* ===== 14. Employee evaluation ===== */
.crit-row {
    display: grid; grid-template-columns: 200px minmax(0, 1.6fr) minmax(0, 1fr);
    gap: 14px; align-items: center; padding: 14px 0; border-top: 1px solid var(--line);
}
.crit-row--read { grid-template-columns: 200px 180px minmax(0, 1fr); }
.crit-rates { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.rec-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 4px; }

.rate { position: relative; display: block; }
.rate input { position: absolute; opacity: 0; pointer-events: none; }
.rate span {
    display: flex; align-items: center; gap: 8px; padding: 9px 10px; font-size: 12px;
    border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); cursor: pointer;
}
.rate span::before {
    content: ''; width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; border: 1.5px solid #cbd5e1;
}
.rate input:checked + span { border-color: var(--orange); background: var(--orange-soft); }
.rate input:checked + span::before {
    border-color: var(--orange); background: radial-gradient(circle, var(--orange) 45%, transparent 50%);
}
.rate input:focus-visible + span { box-shadow: 0 0 0 3px var(--orange-soft); }

/* ===== 15. Contract conversion / modals ===== */
.modal {
    position: fixed; inset: 0; z-index: 60; padding: 16px;
    background: rgba(15, 23, 42, .55); display: flex; align-items: center; justify-content: center;
}
.modal[hidden] { display: none; }
.modal__box {
    background: var(--white); border-radius: var(--radius-card); width: 100%; max-width: 520px;
    max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto;
    box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
}
.modal__box--wide { max-width: 720px; }
.modal__head { display: flex; gap: 12px; padding: 22px 24px 14px; }
.modal__head h3 { font-size: 15px; font-weight: 600; }
.modal__head p { font-size: 12px; color: var(--muted); margin-top: 3px; }
.modal__who {
    display: flex; align-items: center; gap: 12px; margin: 0 24px 16px; padding: 12px 14px;
    background: #f7f8fa; border-radius: var(--radius-lg);
}
.modal__who > div { flex: 1; min-width: 0; }
.modal__who strong { display: block; font-size: 13px; }
.modal__who small { color: var(--muted); font-size: 11px; }
.modal__body { padding: 0 24px 6px; }
.modal__body label { display: block; font-size: 12px; margin-bottom: 6px; }
.modal__body textarea {
    width: 100%; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px;
    font: inherit; font-size: 12.5px; resize: vertical; outline: 0;
}
.modal__body textarea.is-invalid { border-color: var(--red); }
.modal__err { color: var(--red); font-size: 11.5px; margin: 6px 0; }
.modal__foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--line); margin-top: 14px; }

.soft-box { background: #f7f8fa; border-radius: var(--radius-lg); padding: 14px 16px; margin: 14px 0; }
.ext-summary {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    background: var(--orange-soft); border-radius: var(--radius-lg); padding: 12px 14px; margin-top: 16px; font-size: 12px;
}
.ext-summary small { color: var(--muted); font-size: 11px; margin-top: 3px; }

/* =====================================================================
   16. NEWER PAGES — shared building blocks
   (used by Approval Matrix, Audit Logs, Templates, Users & Roles)
   ===================================================================== */

/* ----- Small helper chips / eyebrow lines ----- */
.matrix-eyebrow { color: var(--muted); font-size: 12px !important; margin: 0 0 6px !important; }
.matrix-eyebrow span { padding: 0 7px; color: #b0b7c3; }
.matrix-eyebrow strong { color: var(--orange); font-weight: 500; }

.audit-page-crumb { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; color: var(--muted); font-size: 12px; }
.audit-page-crumb b { color: #b0b7c3; font-weight: 400; }
.audit-page-crumb > strong { color: var(--orange); font-weight: 500; }
.audit-authorized { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; color: var(--muted); font-size: 12px; }

.matrix-access, .audit-readonly {
    display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px;
    border: 1px solid var(--line); border-radius: 999px; background: var(--white);
    color: var(--muted); font-size: 12px; white-space: nowrap;
}
.matrix-access svg, .audit-readonly svg, .audit-authorized svg { width: 13px; height: 13px; }

.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; }

/* ----- Page heads ----- */
.approval-matrix-head, .templates-head, .users-settings-head { align-items: center; margin-bottom: 20px; }
.approval-matrix-head h1, .templates-head h1, .users-settings-head h1 { margin-top: 6px; }

.audit-page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.audit-page-head h1 { font-size: 22px; font-weight: 600; line-height: 1.3; }
.audit-page-head p { margin-top: 4px; color: var(--muted); font-size: 12.5px; }

/* ----- Big cards with a header row ----- */
.matrix-card, .templates-card, .users-settings-card { min-width: 0; overflow: hidden; padding: 20px 0 0; }
.audit-panel { overflow: hidden; padding: 0; }
.audit-event-card, .audit-changes-card, .contract-template-preview { overflow: hidden; padding: 0; }

.matrix-card__head, .templates-card__head, .users-settings-card__head,
.audit-panel__head, .contract-template-preview__head, .audit-changes-card__head {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 0 24px 16px;
}
.audit-panel__head, .contract-template-preview__head, .audit-changes-card__head { padding-top: 20px; }
.matrix-card__head h2, .templates-card__head h2, .users-settings-card__head h2,
.audit-panel__head h2, .contract-template-preview__head h2, .audit-changes-card__head h2 { font-size: 15px; font-weight: 600; line-height: 1.35; }
.matrix-card__head p, .templates-card__head p, .users-settings-card__head p,
.audit-panel__head p, .contract-template-preview__head p, .audit-changes-card__head p { margin-top: 3px; color: var(--muted); font-size: 12px; }

.matrix-add, .matrix-apply, .templates-upload, .users-settings-card__head > .btn { gap: 8px; white-space: nowrap; }
.btn svg { width: 15px; height: 15px; }

.audit-count-tag, .audit-event-result, .audit-changes-card__head > span, .template-preview-badge {
    padding: 5px 10px; border-radius: var(--radius-sm); background: #f3f5f8; color: var(--muted); font-size: 11.5px; white-space: nowrap;
}
.template-preview-badge { border-radius: 999px; background: var(--green-soft); color: var(--green); }

/* ----- Toolbar controls (search / date / selects) ----- */
.matrix-search, .matrix-date, .matrix-filters select,
.template-search, .templates-toolbar select,
.audit-search, .audit-filter select, .audit-filter--date > div {
    height: var(--control-h); border: 1px solid var(--line); border-radius: var(--radius);
    background-color: var(--white); color: var(--text); font: inherit; font-size: 12.5px;
    transition: border-color .15s, box-shadow .15s;
}
.matrix-search, .matrix-date, .template-search, .audit-search, .audit-filter--date > div {
    display: flex; align-items: center; gap: 8px; min-width: 0; padding: 0 12px;
}
.matrix-search:focus-within, .matrix-date:focus-within, .template-search:focus-within,
.audit-search:focus-within, .audit-filter--date > div:focus-within {
    border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-soft);
}
.matrix-search svg, .template-search svg, .audit-search svg { width: 15px; height: 15px; color: #94a3b8; }
.matrix-search input, .matrix-date input, .template-search input, .audit-search input, .audit-filter--date input {
    width: 100%; min-width: 0; border: 0; outline: 0; box-shadow: none; background: transparent;
    color: var(--text); font: inherit; font-size: 12.5px;
}
.matrix-search input::placeholder, .template-search input::placeholder, .audit-search input::placeholder { color: #94a3b8; }
.matrix-filters select, .templates-toolbar select, .audit-filter select { padding: 0 34px 0 12px; }
/* date pickers inside toolbars: icon sits at the far right of the box */
.matrix-date .date-input, .audit-filter--date .date-input { flex: 1; min-width: 0; }
.matrix-date .date-input__icon, .audit-filter--date .date-input__icon { right: 0; }
.matrix-date input.flatpickr-alt, .audit-filter--date input.flatpickr-alt { padding-right: 24px; cursor: pointer; }

/* ----- Buttons for secondary actions ----- */
.matrix-reset, .template-cancel, .role-cancel-button {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: var(--control-h); padding: 0 16px; border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--white); color: var(--text); font: inherit; font-size: 12.5px; font-weight: 500;
    white-space: nowrap; cursor: pointer; transition: background .15s, border-color .15s;
}
.matrix-reset:hover, .template-cancel:hover, .role-cancel-button:hover { background: var(--bg); }
.role-cancel-button { min-height: var(--control-h-sm); padding: 0 12px; margin: 10px 0 0 6px; font-size: 12px; }

.user-save, .template-edit, .template-delete, .user-delete, .role-edit-button {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: var(--control-h-sm); padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--white); color: var(--text); font: inherit; font-size: 12px; font-weight: 500;
    white-space: nowrap; cursor: pointer; transition: background .15s, border-color .15s, color .15s;
}
.user-save, .template-edit { border-color: var(--orange-line); background: #fff8f3; color: var(--orange-dark); }
.user-save:hover, .template-edit:hover { background: var(--orange-soft); }
.user-delete, .template-delete { border-color: #fecaca; background: var(--red-soft); color: var(--red); }
.user-delete:hover, .template-delete:hover { background: #fde4e4; }
.user-delete:disabled { opacity: .45; cursor: not-allowed; }
.role-edit-button:hover { background: var(--bg); }

.matrix-delete-confirm {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: var(--control-h); padding: 0 18px; border: 0; border-radius: var(--radius);
    background: var(--red); color: #fff; font: inherit; font-size: 12.5px; font-weight: 500;
    white-space: nowrap; cursor: pointer; transition: background .15s;
}
.matrix-delete-confirm:hover { background: #b91c1c; }
.matrix-delete-confirm svg { width: 14px; height: 14px; }

/* ----- Tables on the newer pages (same look as .table) ----- */
.matrix-table-wrap, .templates-table-wrap, .users-settings-table-wrap, .audit-table-wrap, .audit-changes-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.matrix-table, .templates-table, .users-settings-table, .audit-table, .audit-changes-table { width: 100%; border-collapse: collapse; }
.templates-table, .users-settings-table { min-width: 760px; }
.audit-table { min-width: 820px; }
.audit-changes-table { min-width: 520px; }

.matrix-table th, .templates-table th, .users-settings-table th, .audit-table th, .audit-changes-table th {
    padding: 12px 16px; background: var(--surface); color: var(--muted);
    text-align: left; font-size: 11.5px; font-weight: 500; white-space: nowrap;
}
.matrix-table td, .templates-table td, .users-settings-table td, .audit-table td, .audit-changes-table td {
    padding: 15px 16px; border-bottom: 1px solid var(--line); color: var(--text);
    font-size: 12.5px; white-space: nowrap; vertical-align: middle;
}
.matrix-table tbody tr:last-child td, .templates-table tbody tr:last-child td,
.users-settings-table tbody tr:last-child td, .audit-table tbody tr:last-child td,
.audit-changes-table tbody tr:last-child td { border-bottom: 0; }
.matrix-table tbody tr, .templates-table tbody tr, .users-settings-table tbody tr, .audit-table tbody tr { transition: background .12s; }
.matrix-table tbody tr:hover, .templates-table tbody tr:hover { background: #fff8f3; }
.users-settings-table tbody tr:hover, .audit-table tbody tr:hover { background: #fcfcfd; }
.audit-table td small { display: block; margin-top: 3px; color: var(--muted); font-size: 11.5px; }

.matrix-empty td, .template-empty, .audit-empty, .audit-changes-empty { padding: 32px 16px !important; color: var(--muted) !important; text-align: center; white-space: normal !important; }
.matrix-table-foot, .audit-table-foot, .templates-foot {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 14px 24px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px;
}
.templates-foot strong { color: var(--text); font-weight: 500; }

/* ----- Shared modals ----- */
.modal, .template-editor-backdrop {
    background: rgba(15, 23, 42, .55); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.matrix-modal, .matrix-details-modal, .matrix-delete-modal, .matrix-edit-modal {
    position: fixed; inset: 0; display: grid; place-items: center; padding: 18px;
}
.matrix-modal { z-index: 70; }
.matrix-details-modal { z-index: 75; }
.matrix-edit-modal { z-index: 78; }
.matrix-delete-modal { z-index: 80; }
.template-editor-backdrop { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 24px; }

.matrix-modal__backdrop, .matrix-details-modal__backdrop, .matrix-delete-modal__backdrop, .matrix-edit-modal__backdrop {
    position: absolute; inset: 0; background: rgba(15, 23, 42, .55);
    -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}

.modal__box, .matrix-modal__panel, .matrix-details-modal__panel, .matrix-delete-modal__panel,
.matrix-edit-modal__panel, .template-editor-modal, .new-user-modal {
    background: var(--white); border-radius: 16px; box-shadow: var(--shadow-lg);
    animation: modal-in .22s var(--ease);
}
.matrix-modal__panel, .matrix-details-modal__panel, .matrix-delete-modal__panel, .matrix-edit-modal__panel {
    position: relative; width: min(100%, 620px);
    max-height: calc(100vh - 36px); max-height: calc(100dvh - 36px); overflow: auto;
}
.matrix-details-modal__panel { display: flex; flex-direction: column; }
@keyframes modal-in {
    from { opacity: 0; transform: translateY(12px) scale(.98); }
    to   { opacity: 1; transform: none; }
}

.matrix-modal__head, .matrix-details-modal__header, .matrix-edit-modal__header, .template-editor-header, .new-user-modal > header {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
    padding: 20px 24px 16px; border-bottom: 1px solid var(--line); background: var(--white);
}
.matrix-modal__head h2, .matrix-details-modal__header h2, .matrix-edit-modal__header h2,
.template-editor-header h2, .new-user-modal > header h2, .matrix-delete-modal__body h2 {
    color: var(--text); font-size: 18px; font-weight: 600; line-height: 1.3;
}
.template-editor-header h2, .new-user-modal > header h2 { margin-top: 4px; }
.template-editor-header p, .new-user-modal > header p { color: var(--muted); font-size: 12px; }

.matrix-modal__close, .matrix-details-modal__x, .matrix-edit-modal__x, .matrix-delete-modal__x,
.template-editor-close, .new-user-modal > header button {
    display: grid; place-items: center; flex: 0 0 auto; width: 32px; height: 32px; padding: 0;
    border: 0; border-radius: var(--radius); background: transparent; color: var(--muted);
    font-size: 22px; line-height: 1; cursor: pointer; transition: background .15s, color .15s;
}
.matrix-modal__close:hover, .matrix-details-modal__x:hover, .matrix-edit-modal__x:hover, .matrix-delete-modal__x:hover,
.template-editor-close:hover, .new-user-modal > header button:hover { background: #eef0f4; color: var(--text); }

.matrix-modal__foot, .matrix-details-modal__footer, .matrix-delete-modal__footer, .matrix-edit-modal__footer, .template-editor-footer {
    position: sticky; bottom: 0; z-index: 1;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 16px 24px; border-top: 1px solid var(--line); background: #fbfbfc;
}
.matrix-modal__foot > div, .matrix-edit-modal__footer > div, .matrix-delete-modal__footer > div, .template-editor-footer > div {
    display: flex; align-items: center; gap: 8px;
}
.matrix-modal__state, .matrix-authorized, .matrix-delete-authorized, .matrix-edit-authorized {
    display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; white-space: nowrap;
}
.matrix-modal__state svg, .matrix-authorized svg, .matrix-delete-authorized svg, .matrix-edit-authorized svg { width: 13px; height: 13px; }

/* ----- Shared form fields inside modals ----- */
.matrix-org-fields select, .matrix-approver select, .matrix-edit-org__fields select, .matrix-edit-approver select,
.template-editor-fields input, .template-editor-fields select,
.new-user-modal input, .new-user-modal select, .add-role-form input {
    width: 100%; min-width: 0; height: var(--control-h); padding: 0 12px;
    border: 1px solid var(--line); border-radius: var(--radius); background-color: var(--white);
    color: var(--text); font: inherit; font-size: 12.5px; outline: 0;
    transition: border-color .15s, box-shadow .15s;
}
.matrix-org-fields select, .matrix-approver select, .matrix-edit-org__fields select, .matrix-edit-approver select,
.template-editor-fields select, .new-user-modal select { padding-right: 36px; }
.matrix-org-fields input:focus, .template-editor-fields input:focus, .new-user-modal input:focus, .add-role-form input:focus {
    border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-soft);
}
.matrix-org-fields select.is-placeholder, .matrix-approver select.is-placeholder, .matrix-approver select:invalid { color: #a7b0bd; }
.matrix-org-fields select.has-value, .matrix-approver select.has-value { color: var(--text); }
.matrix-org-fields select option[value=""], .matrix-approver select option[value=""] { color: #a7b0bd; }

.matrix-org-fields label, .matrix-edit-org__fields label, .template-editor-fields label, .new-user-modal label, .add-role-form label {
    display: flex; flex-direction: column; gap: 6px; color: #334155; font-size: 12px; font-weight: 500;
}
.matrix-required { color: var(--orange); font-weight: 600; }

/* =====================================================================
   17. APPROVAL MATRIX
   ===================================================================== */
.matrix-filters {
    display: grid; align-items: center; gap: 10px; padding: 0 24px 16px;
    grid-template-columns: minmax(200px, 1.7fr) repeat(3, minmax(130px, .8fr)) auto auto;
}

.matrix-table td.matrix-unit { color: var(--orange-dark); font-weight: 600; }
.matrix-table td.muted { color: #a5adba; }

.matrix-actions { display: flex; align-items: center; gap: 6px; }
.matrix-action {
    display: grid; place-items: center; width: 28px; height: 28px; padding: 0;
    border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--white); cursor: pointer;
    transition: transform .15s, box-shadow .15s, background .15s;
}
.matrix-action svg { width: 14px; height: 14px; }
.matrix-action--view   { color: #64748b; }
.matrix-action--edit   { color: var(--orange); border-color: var(--orange-line); background: #fff8f3; }
.matrix-action--delete { color: var(--red); border-color: #fecaca; background: #fff6f6; }
.matrix-action:hover { transform: translateY(-1px); box-shadow: 0 3px 8px rgba(15, 23, 42, .1); }

.matrix-disclaimer { display: flex; align-items: flex-start; gap: 8px; margin-top: 16px; color: var(--muted); font-size: 12px; }
.matrix-disclaimer svg { width: 14px; height: 14px; flex: 0 0 14px; margin-top: 2px; }

/* Add / edit modals */
.matrix-modal__body, .matrix-edit-modal__body { padding: 0 24px 10px; }
.matrix-section-head, .matrix-edit-section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.matrix-section-head h3, .matrix-edit-section-head h3 { color: var(--orange); font-size: 14px; font-weight: 600; }
.matrix-section-head > span { color: var(--muted); font-size: 12px; }
.matrix-edit-section-head > span, .matrix-one-level {
    padding: 4px 9px; border: 1px solid var(--orange-line); border-radius: var(--radius-sm);
    background: #fff9f5; color: #bd4d08 !important; font-size: 11.5px !important; white-space: nowrap;
}

.matrix-org-section, .matrix-edit-org, .matrix-approver-section, .matrix-edit-approvers { padding: 16px 0; border-bottom: 1px solid var(--line); }
.matrix-org-fields, .matrix-edit-org__fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.matrix-approver-list, .matrix-edit-approver-list { display: grid; gap: 14px; }
.matrix-approver, .matrix-edit-approver { display: grid; gap: 6px; }

.matrix-approver__label, .matrix-edit-approver__label { display: flex; align-items: center; gap: 6px; color: #334155; font-size: 12px; font-weight: 500; }
.matrix-approver__label svg, .matrix-edit-approver__label svg { width: 13px; height: 13px; color: var(--muted); }
.matrix-approver__label b, .matrix-edit-approver__label b { color: var(--orange); }
.matrix-approver__label span, .matrix-edit-approver__label span { color: #a7b0bd; font-weight: 400; }

.matrix-approver__control, .matrix-edit-approver__control { display: flex; align-items: center; gap: 8px; }
.matrix-approver__control select, .matrix-edit-approver__control select { flex: 1; min-width: 0; }
.matrix-approver__control select.is-invalid, .matrix-edit-approver select.is-invalid {
    border-color: var(--red); box-shadow: 0 0 0 3px rgba(220, 38, 38, .12);
}
.matrix-approver__clear, .matrix-edit-approver__clear {
    display: grid; place-items: center; flex: 0 0 var(--control-h); width: var(--control-h); height: var(--control-h);
    border: 0; border-radius: var(--radius); background: var(--red-soft); color: var(--red);
    cursor: pointer; transition: background .15s;
}
.matrix-approver__clear svg, .matrix-edit-approver__clear svg { width: 15px; height: 15px; }
.matrix-approver__clear:hover, .matrix-edit-approver__clear:hover { background: #fde4e4; }
.matrix-approver__clear:disabled { opacity: .5; cursor: default; }
.matrix-approver__error, .matrix-edit-approver__error { color: var(--red); font-size: 12px; }

.matrix-policy-note, .matrix-edit-policy {
    display: flex; align-items: flex-start; gap: 10px; margin-top: 16px; padding: 12px 14px;
    border: 1px solid var(--orange-line); border-radius: var(--radius-lg); background: #fffaf7; color: var(--muted);
}
.matrix-policy-note svg, .matrix-edit-policy > svg { width: 15px; height: 15px; flex: 0 0 15px; margin-top: 1px; color: var(--orange-dark); }
.matrix-policy-note strong, .matrix-edit-policy strong { display: block; margin-bottom: 3px; color: var(--text); font-size: 12.5px; }
.matrix-policy-note p, .matrix-edit-policy p { font-size: 12px; line-height: 1.5; }

/* View details modal */
.matrix-details-modal__body { padding: 18px 24px; }
.matrix-details-card { padding: 18px; border: 1px solid var(--line); border-radius: var(--radius-card); }
.matrix-details-card__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.matrix-details-card__head h3, .matrix-details-approvers-head h3 { font-size: 14px; font-weight: 600; }
.matrix-details-card__head p, .matrix-details-approvers-head p { margin-top: 4px; color: var(--muted); font-size: 12px; }
.matrix-readonly { display: inline-flex; align-items: center; gap: 5px; padding: 5px 9px; border-radius: var(--radius-sm); background: #f3f5f8; color: #718096; font-size: 11.5px; white-space: nowrap; }
.matrix-readonly svg { width: 12px; height: 12px; }

.matrix-details-org { display: grid; grid-template-columns: 1.1fr 1.1fr .55fr; gap: 14px; margin-top: 18px; }
.matrix-details-org > div { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 0; }
.matrix-details-org > div > span { color: var(--muted); font-size: 12px; }
.matrix-details-org strong { color: var(--text); font-size: 13px; font-weight: 500; }
.matrix-details-org .matrix-status-active, .matrix-status-active {
    display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--radius-sm);
    background: var(--green-soft); color: var(--green); font-size: 12px; font-weight: 500;
}
.matrix-status-active i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

.matrix-details-divider { height: 1px; margin: 18px 0; background: var(--line); }
.matrix-details-approvers-head { margin-bottom: 12px; }
.matrix-details-approvers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.matrix-person-card { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: #fafbfc; }
.matrix-person-card__tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.matrix-role-tag, .matrix-level-tag { padding: 3px 8px; border-radius: var(--radius-sm); background: var(--orange-soft); color: #c65100; font-size: 11px; font-weight: 600; text-transform: uppercase; }
.matrix-level-tag { background: #eef2ff; color: #4963ce; font-weight: 500; text-transform: none; }
.matrix-level-tag.is-required { background: var(--green-soft); color: var(--green); }
.matrix-person-card__person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.matrix-person-avatar { display: grid; place-items: center; width: 28px; height: 28px; flex: 0 0 28px; border-radius: 50%; background: var(--orange-soft); color: #c65100; font-size: 11px; font-weight: 600; }
.matrix-person-card__person > div { min-width: 0; }
.matrix-person-card__person strong { display: block; overflow: hidden; color: var(--text); font-size: 12.5px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.matrix-person-card__person small { display: block; overflow: hidden; margin-top: 2px; color: var(--muted); font-size: 11.5px; text-overflow: ellipsis; white-space: nowrap; }
.matrix-details-note { margin-top: 14px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.matrix-details-close { padding: 0 18px; }

/* Delete confirmation modal */
.matrix-delete-modal__header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 0; }
.matrix-delete-modal__icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-lg); background: #fff2f1; color: var(--red); }
.matrix-delete-modal__icon svg { width: 18px; height: 18px; }
.matrix-delete-modal__body { padding: 14px 24px 20px; }
.matrix-delete-modal__description { margin-top: 8px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.matrix-delete-record { margin-top: 16px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: #f8fafc; }
.matrix-delete-record__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.matrix-delete-record__head strong { display: block; color: var(--text); font-size: 13px; font-weight: 600; }
.matrix-delete-record__head small { display: block; margin-top: 3px; color: var(--muted); font-size: 11.5px; }
.matrix-delete-record__head > span { padding: 4px 8px; border-radius: var(--radius-sm); background: var(--orange-soft); color: #c65100; font-size: 11.5px; white-space: nowrap; }
.matrix-delete-record__divider { height: 1px; margin: 12px 0; background: var(--line); }
.matrix-delete-record h3 { margin-bottom: 8px; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.matrix-delete-record dl { display: grid; gap: 6px; }
.matrix-delete-record dl > div { display: flex; align-items: center; gap: 8px; min-width: 0; }
.matrix-delete-record dt { padding: 3px 7px; border-radius: var(--radius-sm); background: #eef2f6; color: #64748b; font-size: 11.5px; }
.matrix-delete-record dd { overflow: hidden; color: var(--text); font-size: 12.5px; text-overflow: ellipsis; white-space: nowrap; }
.matrix-delete-warning { display: flex; align-items: flex-start; gap: 10px; margin-top: 14px; padding: 12px 14px; border: 1px solid #fecaca; border-radius: var(--radius-lg); background: #fff8f7; color: var(--muted); }
.matrix-delete-warning > svg { width: 15px; height: 15px; flex: 0 0 15px; margin-top: 1px; color: var(--red); }
.matrix-delete-warning strong { display: block; margin-bottom: 3px; color: var(--text); font-size: 12.5px; }
.matrix-delete-warning p { font-size: 12px; line-height: 1.5; }

/* =====================================================================
   18. AUDIT LOGS
   ===================================================================== */
.audit-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.audit-stat { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; min-width: 0; padding: 18px 20px; }
.audit-stat > div { display: flex; flex-direction: column; min-width: 0; }
.audit-stat > div > span { color: #718096; font-size: 12px; }
.audit-stat > div > strong { margin-top: 2px; color: #151923; font-size: 25px; font-weight: 600; line-height: 1.2; }
.audit-stat > div > small { margin-top: 3px; color: #8490a0; font-size: 11px; white-space: nowrap; }
.audit-stat__icon { display: grid; place-items: center; width: 25px; height: 25px; flex: 0 0 25px; border-radius: 7px; font-style: normal; }
.audit-stat__icon svg { width: 14px; height: 14px; }
.audit-stat__icon--orange { background: #fff1e8; color: var(--orange); }
.audit-stats-note { margin: 7px 0 16px; color: #8490a0; font-size: 11.5px; }
.audit-panel { overflow: hidden; padding: 0; }
.audit-panel__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 16px 9px; }
.audit-panel__head h2 { font-size: 17px; font-weight: 600; }
.audit-panel__head p { margin-top: 3px; color: #718096; font-size: 12px; }
.audit-count-tag { padding: 6px 8px; border-radius: 5px; background: #f5f7fa; color: #8490a0; font-size: 11px; white-space: nowrap; }
.audit-filters { padding: 0 16px 12px; }
.audit-search-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.audit-search-row > span { color: #8490a0; font-size: 11px; }
.audit-search { display: flex; align-items: center; gap: 7px; width: min(100%, 390px); height: 38px; padding: 0 9px; border: 1px solid #e7eaf0; border-radius: 7px; color: #8490a0; }
.audit-search svg { width: 13px; height: 13px; }
.audit-search input { width: 100%; border: 0; outline: 0; background: transparent; color: #26364a; font: inherit; font-size: 12px; }
.audit-search input::placeholder { color: #9aa5b4; }
.audit-filter-row { display: grid; grid-template-columns: minmax(250px, 1.7fr) .95fr .95fr 1.1fr .95fr auto; align-items: end; gap: 8px; }
.audit-filter { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.audit-filter > span { color: #718096; font-size: 11px; }
.audit-filter select, .audit-filter--date > div { width: 100%; height: 37px; border: 1px solid #e7eaf0; border-radius: 7px; background-color: #fff; color: #26364a; font: inherit; font-size: 11.5px; }
.audit-filter select { padding: 0 8px; }
.audit-filter--date > div { display: flex; align-items: center; gap: 4px; padding: 0 7px; }
.audit-filter--date > div > .date-input { width: auto; min-width: 0; flex: 1 1 0; }
.audit-filter--date input { width: 100%; min-width: 0; flex: 1 1 0; border: 0; outline: 0; background: transparent; color: #26364a; color-scheme: light; font: inherit; font-size: 12px; }
.audit-stat > div > span { color: var(--muted); font-size: 12.5px; }
.audit-stat > div > strong { margin-top: 10px; color: var(--text); font-size: 28px; font-weight: 700; line-height: 1.1; }
.audit-stat > div > small { margin-top: 6px; color: var(--muted); font-size: 11.5px; }
.audit-stat__icon { display: grid; place-items: center; width: 30px; height: 30px; flex: 0 0 30px; border-radius: var(--radius); background: #f1f2f4; color: var(--muted); font-style: normal; }
.audit-stat__icon svg { width: 16px; height: 16px; }
.audit-stat__icon--orange { background: var(--orange-soft); color: var(--orange); }
.audit-stats-note { margin: 10px 0 18px; color: var(--muted); font-size: 12px; }

.audit-filters { padding: 0 24px 16px; }
.audit-search-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.audit-search-row > span { color: var(--muted); font-size: 12px; }
.audit-search { width: min(100%, 400px); }
.audit-filter-row { display: grid; grid-template-columns: 1.35fr .95fr .95fr 1.1fr .95fr auto; align-items: end; gap: 10px; }
.audit-filter { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.audit-filter > span { color: var(--muted); font-size: 11.5px; }
.audit-filter select { width: 100%; }
.audit-filter--date > div { width: 100%; gap: 6px; padding: 0 10px; }
.audit-filter--date input { flex: 1; width: 0; font-size: 12px; }
.audit-filter--date b { color: #9aa5b4; font-weight: 400; }
.audit-clear { display: inline-flex; align-items: center; gap: 5px; height: var(--control-h); padding: 0 6px; border: 0; background: transparent; color: var(--orange); font: inherit; font-size: 12px; font-weight: 500; white-space: nowrap; cursor: pointer; }
.audit-clear:hover { color: var(--orange-dark); }
.audit-clear svg { width: 13px; height: 13px; }

.audit-primary { color: var(--text); }
.audit-date { display: block; }
.audit-result { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: var(--radius-sm); font-size: 11.5px; font-weight: 500; }
.audit-result svg { width: 11px; height: 11px; }
.audit-result--success { background: var(--green-soft); color: var(--green); }
.audit-result--failed { background: #fdecec; color: #c62828; }
.audit-view { display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 1px solid #cbd5e1; border-radius: var(--radius-sm); background: var(--white); color: #64748b; cursor: pointer; transition: background .15s, color .15s, border-color .15s; }
.audit-view svg { width: 14px; height: 14px; }
.audit-view:hover { background: var(--orange-soft); border-color: var(--orange); color: var(--orange); }

.audit-pagination { display: flex; align-items: center; gap: 6px; }
.audit-pagination button { min-width: 30px; height: 30px; padding: 0 8px; border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent; color: #64748b; font: inherit; font-size: 12px; cursor: pointer; }
.audit-pagination button:hover:not(:disabled):not(.is-current) { background: var(--bg); }
.audit-pagination button.is-current { background: var(--orange-soft); color: var(--orange); font-weight: 500; }
.audit-pagination button:disabled { color: #c3cad5; cursor: default; }
.audit-no-pages { padding: 0 4px; color: var(--muted); font-size: 12px; }

.audit-page-note, .audit-demo-note, .audit-detail-empty-note { color: var(--muted); font-size: 12px; }
.audit-page-note { display: flex; align-items: center; gap: 6px; margin-top: 16px; }
.audit-page-note svg { width: 14px; height: 14px; }
.audit-demo-note { margin-top: 8px; }
.audit-detail-empty-note { margin: 2px 0 16px; }

/* Event details page */
.audit-event-card { margin-bottom: 18px; }
.audit-event-card__summary { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.audit-event-icon { display: grid; place-items: center; width: 34px; height: 34px; flex: 0 0 34px; border-radius: var(--radius-lg); background: var(--orange-soft); color: var(--orange); }
.audit-event-icon svg { width: 17px; height: 17px; }
.audit-event-card__title { min-width: 0; flex: 1; }
.audit-event-card__title h2 { color: var(--text); font-size: 17px; font-weight: 600; }
.audit-event-card__title p { margin-top: 3px; color: var(--muted); font-size: 12.5px; }
.audit-event-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px 24px; padding: 18px 20px; }
.audit-event-meta > div { min-width: 0; }
.audit-event-meta dt { margin-bottom: 4px; color: var(--muted); font-size: 12px; }
.audit-event-meta dd { color: var(--text); font-size: 13px; overflow-wrap: anywhere; }
.audit-event-meta dd small { display: block; margin-top: 4px; color: var(--muted); font-size: 11.5px; }
.audit-changes-card__head { padding-bottom: 14px; }
.audit-changes-card__head h2 { font-size: 16px; }
.audit-changed-tag { display: inline-block; margin-left: 6px; padding: 3px 7px; border-radius: 5px; background: var(--orange-soft); color: #c65100; font-size: 11px; }
.audit-change-note { display: flex; align-items: center; gap: 6px; padding: 12px 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11.5px; }
.audit-change-note svg { width: 13px; height: 13px; flex: 0 0 13px; }
.audit-back-link {
    display: inline-flex; align-items: center; gap: 8px; min-height: var(--control-h); margin-top: 16px; padding: 0 18px;
    border-radius: var(--radius); background: var(--orange); color: #fff; font-size: 12.5px; font-weight: 500; transition: background .15s;
}
.audit-back-link:hover { background: var(--orange-dark); }
.audit-back-link svg { width: 15px; height: 15px; }

/* =====================================================================
   19. CONTRACT TEMPLATES
   ===================================================================== */
.template-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.template-stat { display: flex; align-items: center; gap: 14px; min-height: 80px; padding: 16px 20px; }
.template-stat__icon { display: grid; place-items: center; width: 40px; height: 40px; flex: 0 0 40px; border-radius: var(--radius-lg); background: var(--orange-soft); color: var(--orange-dark); }
.template-stat__icon svg { width: 19px; height: 19px; }
.template-stat__icon--green { background: var(--green-soft); color: var(--green); }
.template-stat__icon--amber { background: #fff6dd; color: #b7791f; }
.template-stat small, .template-stat strong { display: block; }
.template-stat small { color: var(--muted); font-size: 12px; }
.template-stat strong { margin-top: 2px; font-size: 22px; font-weight: 700; }

.templates-toolbar { display: flex; align-items: center; gap: 10px; padding: 0 24px 16px; }
.template-search { width: min(340px, 100%); }
.template-results { margin-left: auto; color: var(--muted); font-size: 12px; }

.template-name { display: flex; align-items: center; gap: 12px; min-width: 260px; }
.template-file-icon { display: grid; place-items: center; width: 36px; height: 40px; flex: 0 0 36px; border: 1px solid var(--orange-line); border-radius: var(--radius); background: #fff7f1; color: var(--orange-dark); }
.template-file-icon svg { width: 18px; height: 18px; }
.template-name strong, .template-name small { display: block; }
.template-name strong { color: var(--text); font-size: 13px; font-weight: 500; }
.template-name small { margin-top: 3px; color: var(--muted); font-size: 11.5px; }
.template-version { display: inline-block; padding: 3px 8px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--white); color: #596579; font-size: 11.5px; }
.template-status { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 500; white-space: nowrap; }
.template-status i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.template-status--active   { background: var(--green-soft); color: var(--green); }
.template-status--draft    { background: #fff6dd; color: #b7791f; }
.template-status--archived { background: #f1f2f4; color: #667085; }
.template-row-actions { display: flex; align-items: center; gap: 8px; }
.template-row-actions form { margin: 0; }

.template-toast {
    position: fixed; right: 24px; bottom: 24px; z-index: 100; max-width: min(440px, calc(100vw - 32px));
    padding: 12px 16px; border: 1px solid var(--line); border-left: 3px solid var(--orange); border-radius: var(--radius-lg);
    background: var(--white); box-shadow: var(--shadow-md); color: #344054; font-size: 12.5px;
    opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .2s ease, transform .2s ease;
}
.template-toast.is-visible { opacity: 1; transform: translateY(0); }

/* Template editor */
.template-editor-modal { display: flex; flex-direction: column; width: min(100%, 1000px); max-height: min(94vh, 1000px); overflow: hidden; background: var(--bg); }
.template-editor-modal form { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.template-editor-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 16px 24px 12px; background: var(--white); }
.template-status-field { grid-column: 1 / -1; max-width: 220px; }

.template-placeholder-row {
    display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 10px 24px;
    border-top: 1px solid var(--line); background: var(--white); color: #475467; font-size: 12px;
}
.template-placeholder-row select, .template-word-toolbar select {
    height: 32px; padding: 0 28px 0 10px; border: 1px solid var(--line); border-radius: var(--radius-sm);
    background-color: var(--white); background-position: right 8px center; background-size: 14px 14px;
    color: #344054; font: inherit; font-size: 12px;
}
.template-placeholder-row button {
    height: 32px; padding: 0 12px; border: 1px solid var(--orange-line); border-radius: var(--radius-sm);
    background: #fff8f3; color: var(--orange-dark); font: inherit; font-size: 12px; font-weight: 500; cursor: pointer;
}
.template-placeholder-row button:hover { background: var(--orange-soft); }
.template-placeholder-row code { color: var(--orange-dark); }
.template-placeholder-row small { color: var(--muted); }
.template-placeholder-row #templateImportStatus { color: var(--green); }
.template-import-divider { width: 1px; height: 22px; margin: 0 4px; background: var(--line); }

.template-word-toolbar { display: flex; align-items: center; gap: 6px; min-height: 50px; padding: 8px 24px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--white); }
.template-word-toolbar button { min-width: 34px; height: 32px; padding: 0 9px; border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent; color: #344054; font: inherit; font-size: 12.5px; cursor: pointer; transition: background .15s, border-color .15s; }
.template-word-toolbar button:hover { border-color: var(--line); background: var(--surface); }
.template-word-toolbar > span { width: 1px; height: 22px; margin: 0 4px; background: var(--line); }

.template-editor-paper-wrap { flex: 1; min-height: 0; overflow: auto; padding: 24px; }
.template-editor-paper {
    width: 216mm; min-height: 340mm; flex: 0 0 auto; margin: 0 auto; padding: 64px 1in 64px 1.5in; outline: none;
    background: var(--white); box-shadow: 0 2px 14px rgba(15, 23, 42, .08); color: #202733;
    font-family: Arial, sans-serif; font-size: 14px; line-height: 1.75;
}
.template-editor-paper:focus { box-shadow: 0 2px 18px rgba(15, 23, 42, .14); }
.template-editor-paper h2 { margin: 0 0 28px; text-align: center; font-size: 20px; }
.template-editor-paper h3 { margin: 22px 0 6px; font-size: 14px; }
.template-editor-paper p { margin: 0 0 12px; }
.template-editor-footer { color: var(--muted); font-size: 12px; }
.template-editor-footer .templates-upload { padding: 0 16px; }

/* Template preview on the create-contract page */
.create-side { min-width: 0; }
.contract-template-preview__head { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.contract-template-preview__paper {
    max-height: 500px; overflow: auto; margin: 14px; padding: 24px 20px; border: 1px solid var(--line);
    border-radius: var(--radius); background: var(--white); color: #202733; font-family: Arial, sans-serif; font-size: 12px; line-height: 1.65;
}
.contract-template-preview__paper h1, .contract-template-preview__paper h2 { margin: 12px 0; text-align: center; font-size: 17px; }
.contract-template-preview__paper h3, .contract-template-preview__paper h4 { margin: 14px 0 5px; font-size: 12px; }
.contract-template-preview__paper p { margin: 0 0 9px; }
.contract-template-preview__paper ul, .contract-template-preview__paper ol { padding-left: 22px; margin: 6px 0 10px; }

.contract-saved-document {
    width: 216mm; min-height: 340mm; margin: 12px auto; padding: 64px 1in 64px 1.5in;
    border: 1px solid var(--line); background: var(--white); color: #202733;
    font-family: Arial, sans-serif; font-size: 14px; line-height: 1.7;
}
.contract-saved-document h1, .contract-saved-document h2 { margin: 14px 0; text-align: center; }
.contract-saved-document h3, .contract-saved-document h4 { margin: 18px 0 6px; }
.contract-saved-document p { margin: 0 0 12px; }
.contract-saved-document ul, .contract-saved-document ol { padding-left: 24px; margin: 8px 0 14px; }

/* =====================================================================
   20. USERS & ROLES
   ===================================================================== */
.badge--info { background: #e8f0fe; color: #1d4ed8; }

.users-settings-grid { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(300px, .8fr); align-items: start; gap: 18px; }
.users-settings-table td strong { font-weight: 500; }
.users-settings-table select {
    max-width: 160px; height: 32px; padding: 0 30px 0 10px; border: 1px solid var(--line); border-radius: var(--radius-sm);
    background-color: var(--white); background-position: right 8px center; background-size: 14px 14px;
    color: #344054; font: inherit; font-size: 12.5px;
}
.user-row-actions, .role-row-actions { display: flex; align-items: center; gap: 6px; }
.users-self-label { margin-left: 6px; padding: 2px 8px; border-radius: 999px; background: #eff8ff; color: #175cd3; font-size: 11px; }

.roles-list { max-height: 420px; overflow-y: auto; padding: 0 20px; }
.role-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.role-row__icon { display: grid; place-items: center; width: 34px; height: 34px; flex: 0 0 34px; border-radius: var(--radius-lg); background: var(--orange-soft); color: var(--orange-dark); }
.role-row__icon svg { width: 17px; height: 17px; }
.role-row > div { flex: 1; min-width: 0; }
.role-row strong, .role-row small { display: block; }
.role-row strong { font-size: 13px; font-weight: 500; }
.role-row small { margin-top: 2px; color: var(--muted); font-size: 11.5px; }
.role-row-actions { margin-left: auto; }
.role-system-tag { padding: 3px 8px; border-radius: 999px; background: #f1f2f4; color: #667085; font-size: 11px; }

.role-permission-row { flex-wrap: wrap; align-items: flex-start; padding: 14px 0; }
.role-permission-row > div { padding-top: 3px; }
.role-permission-form { flex: 0 0 100%; margin: 10px 0 2px 46px; }
.role-permission-head, .role-permission-item { display: grid; grid-template-columns: minmax(0, 1fr) 60px 70px; align-items: center; gap: 8px; }
.role-permission-head { padding: 8px 12px; border-radius: var(--radius) var(--radius) 0 0; background: var(--surface); color: var(--muted); font-size: 11.5px; font-weight: 600; text-align: center; }
.role-permission-head span:first-child, .role-permission-item > span { text-align: left; }
.role-permission-item { min-height: 36px; padding: 4px 12px; border-bottom: 1px solid var(--line); color: #475264; font-size: 12.5px; }
.role-permission-item label { display: grid; place-items: center; cursor: pointer; }
.role-permission-form .user-save { margin-top: 10px; }
.role-permission-note { flex: 0 0 100%; margin: 8px 0 0 46px; color: var(--muted); font-size: 12px; }

.add-role-form { display: grid; gap: 10px; margin-top: 12px; padding: 18px 20px 20px; border-top: 1px solid var(--line); }
.add-role-form h3 { margin-bottom: 2px; font-size: 14px; font-weight: 600; }
.add-role-form .btn { justify-self: start; }

.new-user-modal { width: min(100%, 520px); overflow: hidden; }
.new-user-modal > form { display: grid; gap: 14px; padding: 20px 24px; }
.new-user-password-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.new-user-modal footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

/* Logout button next to the user avatar */
.user { gap: 10px; }
.user-logout {
    min-height: var(--control-h-sm); padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--white); color: var(--muted); font: inherit; font-size: 12px; cursor: pointer;
    transition: color .15s, border-color .15s, background .15s;
}
.user-logout:hover { border-color: #fca5a5; background: var(--red-soft); color: var(--red); }

/* =====================================================================
   21. LOGIN  (body.login-page > main.login-shell: dark promo + sign-in form)
   Everything inside the card is sized from ONE variable (--w = card width),
   so the orange sphere, rings and text keep the same proportions on every
   screen and never collide.
   ===================================================================== */
/* the login page has no scrolling, so don't reserve an empty scrollbar track */
html:has(.login-page) { overflow-y: auto; scrollbar-gutter: auto; }

.login-page {
    min-height: 100vh; min-height: 100dvh; display: grid; place-items: center;
    padding: 32px; background: #555;
}
.login-shell {
    --w: clamp(600px, 72vw, 900px);
    width: var(--w); height: clamp(430px, 62vh, 540px);
    display: grid; grid-template-columns: 55% 45%;
    background: #fff; overflow: hidden; box-shadow: 0 24px 56px rgba(0, 0, 0, .22);
}

/* ----- Left: promo panel ----- */
.login-promo {
    --sd: calc(var(--w) * .31);                 /* sphere diameter */
    position: relative; isolation: isolate; overflow: hidden;
    display: flex; flex-direction: column;
    padding: clamp(24px, 4vw, 36px); color: #fff; background: #08090b;
}
/* orange sphere, anchored to the bottom-right corner */
.login-promo::before {
    content: ''; position: absolute; z-index: -1;
    width: var(--sd); height: var(--sd);
    right: calc(var(--w) * -.10); bottom: calc(var(--w) * -.13);
    border-radius: 50%; background: radial-gradient(circle at 37% 37%, #ffad56 0, #ff852d 30%, #ff5c00 67%);
}
/* soft rings around the sphere (same centre as the sphere) */
.login-promo::after {
    content: ''; position: absolute; z-index: -1;
    width: calc(var(--sd) * 1.04); height: calc(var(--sd) * 1.04);
    right: calc(var(--w) * -.10 - var(--sd) * .02); bottom: calc(var(--w) * -.13 - var(--sd) * .02);
    border: 1px solid rgba(255, 101, 0, .15); border-radius: 50%;
    box-shadow:
        0 0 0 calc(var(--sd) * .0625) rgba(255, 101, 0, .09),
        0 0 0 calc(var(--sd) * .125)  rgba(255, 101, 0, .06),
        0 0 0 calc(var(--sd) * .1875) rgba(255, 101, 0, .035);
}
.login-promo__logo {
    align-self: flex-start; width: clamp(90px, 12vw, 140px); max-height: 62px;
    object-fit: contain; object-position: left top; filter: brightness(0) invert(1);
}
.login-promo__content { margin-top: clamp(20px, 4vh, 52px); }
.login-promo__eyebrow { color: #ff7a1a; font-size: clamp(6px, .65vw, 10px); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.login-promo h1 {
    margin-top: 14px; font-size: clamp(24px, min(3vw, 5vh), 42px);
    font-weight: 700; letter-spacing: -.03em; line-height: 1.2;
}
.login-promo__copy { margin-top: 13px; color: #aaa8a8; font-size: clamp(8px, .9vw, 13px); line-height: 1.45; }
.login-promo__pill {
    display: flex; align-items: center; gap: 8px; width: fit-content; margin-top: clamp(20px, 4vh, 40px);
    padding: 7px 12px; border: 1px solid rgba(255, 255, 255, .12); border-radius: 999px;
    background: rgba(255, 255, 255, .06); color: #d6d1cc; font-size: clamp(6px, .65vw, 10.5px);
}
.login-promo__pill i { color: #f58242; font-style: normal; }
.login-promo__footer { margin-top: auto; padding-top: 16px; color: #969393; font-size: clamp(6px, .6vw, 10px); letter-spacing: .04em; }

/* ----- Right: sign-in panel ----- */
.login-panel { display: grid; place-items: center; padding: clamp(24px, 4vw, 42px); background: #fdfcfb; }
.login-panel__inner { position: relative; width: min(100%, 312px); height: 100%; display: flex; flex-direction: column; }
.login-panel__brand { color: #1a1818; font-size: clamp(7px, .75vw, 11px); font-weight: 700; letter-spacing: .02em; }

.login-heading { margin-top: clamp(28px, 6vh, 64px); }
.login-heading > span { display: block; width: 24px; height: 3px; margin-bottom: 14px; border-radius: 2px; background: var(--orange); }
.login-heading h2 { color: #171515; font-size: clamp(18px, 2.1vw, 26px); font-weight: 700; letter-spacing: -.025em; line-height: 1.2; }
.login-heading p { margin-top: 8px; color: #7d7976; font-size: clamp(7px, .75vw, 11px); line-height: 1.45; }

.login-form { display: grid; gap: 6px; margin-top: clamp(23px, 4vh, 35px); }
.login-form > label { margin-top: 0; color: #383330; font-size: clamp(7px, .75vw, 11px); font-weight: 700; }
.login-form > label:nth-of-type(2) { margin-top: 8px; }
.login-form > input, .login-password input {
    width: 100%; height: clamp(31px, 4vw, 40px); padding: 0 12px; border: 1px solid #e1dfdd; border-radius: 6px;
    background: #fff; outline: 0; color: #282421; font: inherit; font-size: clamp(7px, .75vw, 11px);
    transition: border-color .15s, box-shadow .15s;
}
.login-form > input::placeholder, .login-password input::placeholder { color: #aaa6a3; }
.login-form > input:focus, .login-password input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-soft); }

.login-password { position: relative; }
.login-password input { padding-right: 40px; }
.login-password__toggle {
    position: absolute; right: 0; top: 0; display: grid; place-items: center;
    width: clamp(31px, 4vw, 40px); height: clamp(31px, 4vw, 40px); padding: 0;
    border: 0; background: transparent; color: #898581; cursor: pointer; transition: color .15s;
}
.login-password__toggle:hover, .login-password__toggle[aria-pressed="true"] { color: var(--orange); }
.login-password__toggle svg { width: 14px; height: 14px; }

/* Sign in: label centred, arrow pinned to the right edge */
.login-submit {
    position: relative; display: flex; justify-content: center; align-items: center;
    width: 100%; height: clamp(31px, 4vw, 40px); min-height: 0; margin-top: 10px; padding: 0 36px;
    border: 0; border-radius: 6px; background: var(--orange); color: #fff;
    font: inherit; font-size: clamp(7px, .75vw, 11px); font-weight: 700; letter-spacing: .01em; cursor: pointer;
    transition: background .15s, transform .15s;
}
.login-submit:hover { background: var(--orange-dark); }
.login-submit:active { transform: translateY(1px); }
.login-submit svg {
    position: absolute; right: clamp(12px, 1.6vw, 16px); top: 50%; width: 14px; height: 14px;
    transform: translateY(-50%); transition: transform .15s;
}
.login-submit:hover svg { transform: translateY(-50%) translateX(3px); }

.login-help { display: flex; justify-content: space-between; align-items: center; margin-top: clamp(16px, 3vh, 24px); color: #96918e; font-size: clamp(6px, .6vw, 10px); }
.login-help a { color: #c3500a; font-weight: 700; }
.login-help a:hover { text-decoration: underline; }
.login-panel__copyright { margin-top: auto; padding-top: 14px; color: #aaa6a3; font-size: clamp(5px, .55vw, 9px); }
.login-page .notice { margin-top: 14px; padding: 9px 12px; border-radius: 6px; font-size: 10px; line-height: 1.4; }

/* ----- Narrow windows and phones: full-screen sign-in form with readable text ----- */
@media (max-width: 700px) {
    .login-page { padding: 0; background: #fdfcfb; }
    .login-shell { width: 100%; height: auto; min-height: 100vh; min-height: 100dvh; grid-template-columns: 1fr; box-shadow: none; }
    .login-promo { display: none; }
    .login-panel { min-height: 100vh; min-height: 100dvh; padding: 36px 28px; }
    .login-panel__inner { width: min(100%, 360px); min-height: min(520px, calc(100dvh - 72px)); }
    .login-panel__brand { font-size: 12px; }
    .login-heading { margin-top: 56px; }
    .login-heading h2 { font-size: 26px; }
    .login-heading p, .login-form > label { font-size: 12.5px; }
    .login-form { margin-top: 28px; gap: 8px; }
    .login-form > input, .login-password input { height: 44px; padding: 0 14px; font-size: 13px; }
    .login-password input { padding-right: 46px; }
    .login-password__toggle { width: 44px; height: 44px; }
    .login-password__toggle svg, .login-submit svg { width: 16px; height: 16px; }
    .login-submit { height: 44px; padding: 0 44px; font-size: 13px; }
    .login-submit svg { right: 16px; }
    .login-help { margin-top: 22px; font-size: 11.5px; }
    .login-panel__copyright { margin-top: 32px; font-size: 10.5px; }
    .login-page .notice { font-size: 12px; }
}

/* =====================================================================
   22. NEWER PAGES — responsive (same breakpoints as the rest of the app)
   ===================================================================== */
@media (max-width: 1199px) {
    .matrix-filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .matrix-search { grid-column: 1 / -1; }
    .audit-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .audit-filter-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .audit-filter--date { grid-column: span 2; }
}

@media (max-width: 991px) {
    .users-settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .contract-saved-document { width: min(216mm, 100%); padding-right: min(1in, 8vw); padding-left: min(1.5in, 12vw); }
}

@media (max-width: 767px) {
    .matrix-access { display: none; }
    .matrix-card__head, .templates-card__head, .users-settings-card__head { flex-direction: column; }
    .matrix-filters { grid-template-columns: 1fr 1fr; padding: 0 16px 14px; }
    .matrix-card__head, .templates-card__head, .users-settings-card__head, .templates-toolbar, .audit-filters, .audit-panel__head,
    .matrix-table-foot, .audit-table-foot, .templates-foot { padding-right: 16px; padding-left: 16px; }

    .matrix-org-fields, .matrix-edit-org__fields { grid-template-columns: 1fr; }
    .matrix-modal__head, .matrix-details-modal__header, .matrix-edit-modal__header, .template-editor-header, .new-user-modal > header,
    .matrix-modal__foot, .matrix-details-modal__footer, .matrix-delete-modal__footer, .matrix-edit-modal__footer, .template-editor-footer { padding-right: 16px; padding-left: 16px; }
    .matrix-modal__body, .matrix-edit-modal__body, .matrix-delete-modal__body { padding-right: 16px; padding-left: 16px; }
    .matrix-details-modal__body { padding: 12px; }
    .matrix-details-card { padding: 14px; }
    .matrix-details-approvers { grid-template-columns: 1fr; }
    .matrix-details-org { grid-template-columns: 1fr 1fr; }
    .matrix-details-org > div:last-child { grid-column: 1 / -1; }
    .matrix-delete-modal__header { padding: 16px 16px 0; }
    .matrix-delete-modal__footer, .matrix-edit-modal__footer, .matrix-modal__foot, .template-editor-footer { flex-wrap: wrap; }
    .matrix-delete-modal__footer > div, .matrix-edit-modal__footer > div { margin-left: auto; }

    .audit-page-crumb { flex-wrap: wrap; }
    .audit-authorized { width: 100%; margin-left: 0; }
    .audit-page-head { flex-direction: column; }
    .audit-stat > div > small { white-space: normal; }
    .audit-filter-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .audit-search-row { flex-direction: column; align-items: stretch; }
    .audit-search { width: 100%; }
    .audit-table-foot { align-items: flex-start; flex-direction: column; }
    .audit-event-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }

    .template-summary { grid-template-columns: 1fr; }
    .templates-toolbar { flex-wrap: wrap; }
    .template-search { flex: 1 1 100%; width: 100%; }
    .templates-foot { flex-direction: column; align-items: flex-start; }
    .template-editor-backdrop { padding: 8px; }
    .template-editor-modal { max-height: 98vh; }
    .template-editor-fields { grid-template-columns: 1fr; padding-right: 16px; padding-left: 16px; }
    .template-placeholder-row { padding-right: 12px; padding-left: 12px; }
    .template-placeholder-row small { flex-basis: 100%; }
    .template-word-toolbar { flex-wrap: wrap; padding-right: 12px; padding-left: 12px; }
    .template-editor-paper-wrap { padding: 10px; }
    .template-editor-paper { min-height: 340mm; padding: 36px 1in 36px 1.5in; }

    .new-user-modal > form { padding: 16px; }
}

@media (max-width: 575px) {
    .new-user-password-grid { grid-template-columns: 1fr; }
    .audit-stats { grid-template-columns: 1fr; }
    .matrix-filters, .audit-filter-row { grid-template-columns: 1fr; }
    .audit-filter--date { grid-column: auto; }
}

/* Keep the Roles & Permissions card from acquiring its own horizontal scrollbar. */
.roles-settings-card,
.roles-settings-card .roles-list {
    box-sizing: border-box;
    min-width: 0;
    max-width: 100%;
    overflow-x: hidden;
}
.roles-settings-card .roles-list { overflow-y: auto; }
.roles-settings-card .role-row { min-width: 0; }
.roles-settings-card .role-permission-note { min-width: 0; margin-left: 0; padding-left: 41px; }
.roles-settings-card .role-permission-form { box-sizing: border-box; min-width: 0; width: 100%; margin-left: 0; }
.roles-settings-card .role-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 10px; }
.roles-settings-card .role-row__identity { display: flex; align-items: center; gap: 10px; min-width: 0; grid-column: 1; }
.roles-settings-card .role-row__identity > div { flex: 1; min-width: 0; }
.roles-settings-card .role-system-tag, .roles-settings-card .role-row-actions { grid-column: 2; justify-self: end; }
.roles-settings-card .role-permission-note { grid-column: 1 / -1; margin: 0; padding: 0 0 0 41px; }

/* Keep the role editor dialog compact on wide screens and usable on phones. */
.role-permission-modal .role-permission-form {
    box-sizing: border-box;
    justify-self: center;
    width: min(820px, calc(100vw - 32px)) !important;
    max-height: min(82vh, 680px);
}
.user-employee-name { color: #344054; font-size: 12.5px; }
.new-user-modal label > span { display: block; }
.new-user-modal label > span strong { color: #b42318; }

@media (prefers-reduced-motion: reduce) {
    .modal__box, .matrix-modal__panel, .matrix-details-modal__panel, .matrix-delete-modal__panel,
    .matrix-edit-modal__panel, .template-editor-modal, .new-user-modal { animation: none; }
}


/* =====================================================================
   RESPONSIVE — one set of breakpoints for the whole app
   ===================================================================== */

/* Large laptops: form switches to 2 columns, summary stays on the right */
@media (max-width: 1599px) {
    .create-main .form-grid { grid-template-columns: repeat(2, 1fr); }
    .create-main .span-3 { grid-column: 1 / -1; }
    .create-main .span-2 { grid-column: span 2; }
}

/* Small laptops */
@media (max-width: 1279px) {
    .create-grid { grid-template-columns: 1fr; }
    .summary { position: static; }
}

@media (max-width: 1199px) {
    .cards { grid-template-columns: repeat(2, 1fr); }
    .cards--3 { grid-template-columns: repeat(3, 1fr); }
}

/* Tablet: sidebar becomes a drawer */
@media (max-width: 991px) {
    :root { --gutter: 16px; }

    .sidebar { transform: translateX(-100%); }
    .sidebar-open .sidebar { transform: translateX(0); }
    .sidebar-open .overlay { display: block; }

    .main { margin-left: 0; }
    .topbar { padding: 0 var(--gutter); }
    .topbar__menu { display: grid; }
    .search { display: none; }
    .user__meta, .user__chevron { display: none; }
    .user { padding-left: 8px; }

    .workspace { padding: 20px var(--gutter) 32px; }
    .panel__head { padding: 0 16px 14px; }
    .table-wrap { padding: 0 8px; }

    .details-grid, .grid-2 { grid-template-columns: 1fr; }
    .crit-row, .crit-row--read { grid-template-columns: 1fr; }
    .crit-rates, .rec-grid { grid-template-columns: 1fr; }

    .filters { gap: 12px; }
    .filters .field { flex: 1 1 200px; min-width: 0; }
    .filters .field--grow { flex: 1 1 100%; }
}

/* Large phones / small tablets */
@media (max-width: 767px) {
    .cards--3 { grid-template-columns: 1fr; }
    .form-grid, .form-grid--2,
    .create-main .form-grid { grid-template-columns: 1fr; }
    .span-2, .span-3,
    .create-main .span-2, .create-main .span-3 { grid-column: auto; }
    .dl--3, .dl--4 { grid-template-columns: 1fr; }

    .panel--pad { padding: 18px 16px 12px; }
    .table-head { flex-direction: column; align-items: flex-start; }

    .page-head { flex-direction: column; align-items: stretch; }
    .page-head__actions { justify-content: flex-start; }
    .page-head__actions .btn { flex: 1 1 auto; }

    .filters .field { flex: 1 1 100%; }
    .filters .btn-ghost { width: 100%; }

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

    .stat__value { font-size: 26px; }
    .summary .dl--stack { grid-template-columns: 1fr; }
}

/* Phones */
@media (max-width: 575px) {
    .cards { grid-template-columns: 1fr; }
    .dl { grid-template-columns: 1fr; }
    .breadcrumb a, .breadcrumb span, .breadcrumb svg { display: none; }
}

@media (max-width: 480px) {
    :root { --gutter: 12px; }
    .workspace { padding: 16px var(--gutter) 28px; }
    .panel--pad { padding: 16px 12px 12px; }
    .table-head--top { flex-direction: column; gap: 8px; }
    .tag { align-self: flex-start; }
}

/* =====================================================================
   PAGE LOADING ANIMATION (works with loader.js)
   - Orange progress bar across the top while the next page loads
   - After ~0.35s a soft veil + spinner covers the content area only
   - New page fades in gently
   ===================================================================== */
.page-progress {
    position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 100;
    pointer-events: none; opacity: 0; transition: opacity .25s ease;
}
.page-progress.is-active { opacity: 1; }
.page-progress span {
    display: block; height: 100%; width: 0;
    background: linear-gradient(90deg, var(--orange), #ff9a52);
    border-radius: 0 3px 3px 0; box-shadow: 0 0 10px rgba(255, 101, 0, .55);
    transition: width .25s ease;
}

.page-veil {
    position: fixed; top: var(--topbar-h); left: var(--sidebar-w); right: 0; bottom: 0; z-index: 25;
    display: grid; place-items: center;
    background: rgba(244, 245, 247, .65); -webkit-backdrop-filter: blur(1.5px); backdrop-filter: blur(1.5px);
    opacity: 0; visibility: hidden; pointer-events: none;
    transition: opacity .2s ease, visibility .2s;
}
.page-veil.is-visible { opacity: 1; visibility: visible; pointer-events: auto; cursor: progress; }
.page-spinner {
    width: 38px; height: 38px; border-radius: 50%;
    border: 3.5px solid var(--orange-soft); border-top-color: var(--orange);
    animation: page-spin .75s linear infinite;
}
@keyframes page-spin { to { transform: rotate(360deg); } }

@keyframes page-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}
.workspace { animation: page-in .28s ease-out; }

@media (max-width: 991px) { .page-veil { left: 0; } }

/* Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}

.badge--info { background: #e8f0fe; color: #1d4ed8; }
.notice--info { background: #f3f4f6; border: 1px solid var(--line); color: var(--muted); }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(140deg, #111827, #202734 52%, #f4f5f7 52%); }
.login-card { width: min(100%, 430px); padding: 34px; border: 1px solid #e9ebef; border-radius: 16px; background: #fff; box-shadow: 0 24px 70px #05050530; }
.login-brand { display: flex; align-items: center; gap: 11px; }
.login-brand__mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 10px; color: #fff; background: var(--orange); font-size: 23px; font-weight: 700; }
.login-brand strong, .login-brand small { display: block; }
.login-brand strong { font-size: 15px; letter-spacing: .06em; }
.login-brand small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.login-heading { margin: 34px 0 22px; }
.login-heading > span { color: var(--orange); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.login-heading h1 { margin-top: 5px; font-size: 21px; font-weight: 600; }
.login-heading p { margin-top: 5px; color: var(--muted); font-size: 12px; }
.login-form { display: grid; gap: 9px; }
.login-form > label:not(.login-remember) { margin-top: 8px; color: #344054; font-size: 12px; font-weight: 500; }
.login-form > input { width: 100%; height: 42px; padding: 0 12px; border: 1px solid #dfe3e8; border-radius: 7px; outline: 0; font: inherit; font-size: 13px; }
.login-form > input:focus { border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-soft); }
.login-remember { display: flex; align-items: center; gap: 8px; margin: 8px 0; color: #596579; font-size: 11px; }
.login-remember input { accent-color: var(--orange); }
.login-submit { width: 100%; height: 42px; margin-top: 4px; font-size: 13px; }
.login-foot { margin-top: 24px; color: #98a1af; text-align: center; font-size: 10px; }
.users-settings-head { align-items: center; margin-bottom: 18px; }
.users-settings-head h1 { margin-top: 8px; font-size: 22px; }
.users-settings-head p { font-size: 14.5px; }
.users-settings-head .matrix-eyebrow { font-size: 13px !important; }
.users-settings-grid { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(280px, .8fr); align-items: start; gap: 16px; }
.users-settings-card { min-width: 0; overflow: hidden; padding: 18px 0 0; }
.users-settings-card__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; padding: 0 20px 15px; }
.users-settings-card__head h2 { font-size: 17px; font-weight: 600; }
.users-settings-card__head p { margin-top: 4px; color: var(--muted); font-size: 13px; }
.users-settings-card__head > .btn { padding: 8px 12px; white-space: nowrap; font-size: 13px; }
.users-settings-table-wrap { overflow-x: auto; }
.users-settings-table { min-width: 760px; }
.users-settings-table td, .users-settings-table th { padding: 12px 10px; }
.users-settings-table th { font-size: 13.5px; }
.users-settings-table td { font-size: 13px; }
.users-settings-table td strong { font-weight: 500; }
.users-settings-table select { max-width: 150px; height: 32px; padding: 0 30px 0 8px; border: 1px solid #e1e5eb; border-radius: 6px; background-color: #fff; background-position: right 8px center; background-size: 14px 14px; color: #344054; font: inherit; font-size: 12.5px; }
.user-save { padding: 6px 10px; border: 1px solid #f4d1b9; border-radius: 6px; color: #c24c00; background: #fff8f3; cursor: pointer; font: inherit; font-size: 12px; }
.user-row-actions, .role-row-actions { display: flex; align-items: center; gap: 6px; }
.user-delete { padding: 6px 10px; border: 1px solid #f2c7c7; border-radius: 6px; color: #b42318; background: #fff7f6; cursor: pointer; font: inherit; font-size: 12px; }
.user-delete:disabled { opacity: .45; cursor: not-allowed; }
.role-row-actions { margin-left: auto; }
.role-row-actions .role-edit-button { margin-left: 0; }
.users-self-label { margin-left: 6px; padding: 2px 5px; border-radius: 8px; color: #175cd3; background: #eff8ff; font-size: 11px; }
.roles-list { max-height: 420px; overflow-y: auto; padding: 0 18px; }
.role-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid #f0f1f3; }
.role-row__icon { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 8px; color: #d85a0a; background: #fff1e8; }
.role-row__icon svg { width: 16px; height: 16px; }
.role-row > div { min-width: 0; flex: 1; }
.role-row strong, .role-row small { display: block; }
.role-row strong { font-size: 13px; font-weight: 500; }
.role-row small { margin-top: 2px; color: #8490a0; font-size: 11.5px; }
.role-permission-row { align-items: flex-start; flex-wrap: wrap; padding: 14px 0; }
.role-permission-row > div { padding-top: 3px; }
.role-permission-form { flex: 0 0 100%; margin: 8px 0 2px 41px; }
.role-permission-form[hidden] { display: none; }
.role-permission-modal { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 18px; background: #10182880; }
.role-permission-modal[hidden] { display: none; }
.role-permission-modal .role-permission-form { display: block; width: min(900px, 100%); max-height: calc(100vh - 48px); overflow-y: auto; margin: 0; padding: 0 18px 14px; border-radius: 12px; background: #fff; box-shadow: 0 24px 64px #10182840; }
.role-permission-modal .role-permission-form[hidden] { display: none; }
.role-permission-modal__header { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 0 -18px 12px; padding: 16px 18px; border-bottom: 1px solid #eceef2; background: #fff; }
.role-permission-modal__header p { color: #8490a0; font-size: 11px; }
.role-permission-modal__header h2 { margin-top: 3px; color: #26364a; font-size: 18px; font-weight: 600; }
.role-permission-modal__header button { width: 30px; height: 30px; border: 0; border-radius: 6px; background: #f4f5f7; color: #667085; cursor: pointer; font-size: 21px; }
.role-permission-modal__footer { position: sticky; bottom: -14px; display: flex; justify-content: flex-end; gap: 8px; margin: 14px -18px -14px; padding: 12px 18px; border-top: 1px solid #eceef2; background: #fff; }
.role-permission-modal__footer .role-cancel-button, .role-permission-modal__footer .user-save { margin: 0; padding: 8px 12px; }
.role-permission-modal__footer .role-cancel-button { border: 1px solid #d9dee7; }
.role-edit-button, .role-cancel-button { padding: 6px 10px; border: 1px solid #e1e5eb; border-radius: 6px; color: #475467; background: #fff; cursor: pointer; font: inherit; font-size: 12px; }
.role-edit-button { margin-left: auto; }
.role-cancel-button { margin: 9px 0 0 6px; }
.role-permission-head, .role-permission-item { display: grid; grid-template-columns: minmax(0, 1fr) 54px 64px; align-items: center; gap: 8px; }
.role-permission-head { padding: 7px 9px; border-radius: 6px 6px 0 0; background: #f7f8fa; color: #707b8c; font-size: 11px; font-weight: 600; text-align: center; }
.role-permission-head span:first-child, .role-permission-item > span { text-align: left; }
.role-permission-item { min-height: 31px; padding: 4px 9px; border-bottom: 1px solid #f0f1f3; color: #475264; font-size: 12px; }
.role-permission-item label { display: grid; place-items: center; cursor: pointer; }
.role-permission-item input { width: 14px; height: 14px; accent-color: #df5b0b; }
.role-permission-form .user-save { margin-top: 9px; }
.role-permission-note { flex: 0 0 100%; margin: 7px 0 0 41px; color: #778294; font-size: 12px; }
.role-contract-scope { margin: 14px 0 18px; padding: 14px; border: 1px solid #e7eaf0; border-radius: 9px; background: #fff; }
.role-contract-scope h3 { margin: 0; color: #344054; font-size: 14px; }
.role-contract-scope > p { margin: 4px 0 12px; color: #778294; font-size: 12px; }
.role-scope-selectors { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.role-tag-picker { position: relative; min-width: 0; margin: 0; padding: 0; border: 0; }
.role-tag-picker legend { margin-bottom: 5px; color: #475264; font-size: 12px; font-weight: 600; }
.role-tag-picker__button { width: 100%; min-height: 36px; padding: 7px 10px; border: 1px solid #d9dee7; border-radius: 6px; background: #fff; color: #475264; font: inherit; font-size: 12px; text-align: left; cursor: pointer; }
.role-tag-picker__options { position: absolute; z-index: 5; top: 60px; left: 0; right: 0; max-height: 190px; overflow-y: auto; padding: 5px; border: 1px solid #d9dee7; border-radius: 6px; background: #fff; box-shadow: 0 8px 20px #10182820; }
.role-tag-picker__options[hidden] { display: none; }
.role-tag-picker__options label { display: flex; align-items: center; gap: 7px; padding: 6px; border-radius: 4px; color: #475264; font-size: 12px; cursor: pointer; }
.role-tag-picker__options label:hover { background: #f6f7f9; }
.role-tag-picker__options input { accent-color: #df5b0b; }
.role-selected-tags { display: flex; flex-wrap: nowrap; gap: 5px; margin-top: 6px; overflow-x: auto; }
.role-selected-tag { padding: 3px 8px; border-radius: 999px; background: #fff1e8; color: #a84408; font-size: 11px; white-space: nowrap; }
.role-contract-permission-rows { max-width: 100%; margin-top: 12px; overflow-x: auto; }
.role-contract-empty { margin: 0; padding: 12px; border-radius: 6px; background: #f8f9fb; color: #8791a1; font-size: 12px; text-align: center; }
.role-contract-permission-card { padding: 12px; border: 1px solid #e7eaf0; border-radius: 8px; background: #fff; box-shadow: 0 2px 5px #10182808; }
.role-contract-permission-card__scopes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding-bottom: 10px; border-bottom: 1px solid #eef0f3; }
.role-contract-permission-card__scope { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.role-contract-permission-card__scope > span { flex: 0 0 auto; color: #8490a0; font-size: 10px; }
.role-contract-permission-card__scope > strong { overflow: hidden; color: #344054; font-size: 11px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.role-contract-permission-card__actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; padding-top: 9px; }
.role-contract-permission-card__actions label { display: flex; align-items: center; gap: 5px; min-width: 0; padding: 5px 6px; border: 1px solid #edf0f3; border-radius: 5px; color: #475264; font-size: 10px; cursor: pointer; }
.role-contract-permission-card__actions input[type="checkbox"] { flex: 0 0 auto; width: 13px; height: 13px; margin: 0; accent-color: #df5b0b; }
.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; }
.role-system-tag { padding: 3px 6px; border-radius: 10px; color: #667085; background: #f1f2f4; font-size: 11px; }
.add-role-form { display: grid; gap: 8px; margin-top: 12px; padding: 15px 18px 18px; border-top: 1px solid #eceef2; }
.add-role-form h3 { margin-bottom: 2px; font-size: 14px; font-weight: 600; }
.add-role-form label, .new-user-modal label { display: grid; gap: 5px; color: #475467; font-size: 12.5px; font-weight: 500; }
.add-role-form input, .new-user-modal input, .new-user-modal select { height: 35px; padding: 0 9px; border: 1px solid #dfe3e8; border-radius: 6px; background-color: #fff; color: #344054; font: inherit; font-size: 13px; }
.add-role-form .btn { justify-self: start; padding: 8px 12px; font-size: 12.5px; }
.new-user-modal { width: min(100%, 520px); max-height: calc(100dvh - 32px); overflow: auto; border-radius: 13px; background: #fff; box-shadow: 0 24px 64px #10182840; }
.new-user-modal > header { display: flex; justify-content: space-between; align-items: flex-start; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.new-user-modal > header p { color: var(--muted); font-size: 12px; }
.new-user-modal > header h2 { margin-top: 4px; font-size: 19px; }
.new-user-modal > header button { width: 29px; height: 29px; border: 0; border-radius: 6px; color: #667085; background: #f5f6f7; cursor: pointer; font-size: 23px; }
.new-user-modal > form { display: grid; gap: 13px; padding: 20px 22px; }
.new-user-password-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.employee-link-control { position: relative; display: grid; gap: 8px; }
.employee-link-control > input[type="text"] { height: var(--control-h); padding: 0 36px 0 12px; border: 1px solid var(--line); border-radius: var(--radius); background-color: var(--white); color: var(--text); font: inherit; font-size: 12.5px; outline: 0; transition: border-color .15s, box-shadow .15s; }
.employee-link-control > input[type="text"]::placeholder { color: #a7b0bd; }
.employee-link-control > input[type="text"]:focus, .employee-link-control:has(input[aria-expanded="true"]) > input[type="text"] { border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-soft); }
.employee-link-control::after { position: absolute; top: calc(var(--control-h) / 2 - 2px); right: 14px; width: 7px; height: 7px; border-right: 1.5px solid #667085; border-bottom: 1.5px solid #667085; content: ""; pointer-events: none; transform: rotate(45deg); transition: transform .15s; }
.employee-link-control:has(input[aria-expanded="true"])::after { transform: translateY(3px) rotate(225deg); }
.employee-link-results { position: absolute; z-index: 30; top: calc(var(--control-h) + 5px); right: 0; left: 0; max-height: min(300px, 42vh); overflow-y: auto; padding: 4px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); box-shadow: var(--shadow-md); }
.employee-link-results[hidden] { display: none; }
.employee-link-option { display: block; width: 100%; padding: 8px 12px; border: 0; border-radius: calc(var(--radius) - 2px); color: var(--text); background: transparent; text-align: left; font: inherit; font-size: 12.5px; cursor: pointer; }
.employee-link-option:hover, .employee-link-option:focus-visible { outline: none; background: var(--orange-soft); }
.employee-link-empty { padding: 9px 12px; color: #667085; font-size: 12px; }
.employee-link-actions { display: flex; min-height: 20px; align-items: center; justify-content: space-between; gap: 8px; }
.employee-link-actions small { color: #667085; font-size: 11px; line-height: 1.45; }
.employee-link-actions button { padding: 4px 7px; border: 0; border-radius: 5px; color: #b54708; background: #fff6ed; font: inherit; font-size: 11px; font-weight: 600; cursor: pointer; }
.employee-link-actions button:hover { background: #ffead5; }
.employee-link-error { color: #b42318; font-size: 11px; }
.new-user-modal footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 5px; }
.new-user-modal footer button { padding: 8px 12px; font-size: 14px; }
.user { gap: 9px; }
.user-logout { padding: 6px 8px; border: 1px solid #353535; border-radius: 6px; color: #d1d5db; background: #151515; cursor: pointer; font: inherit; font-size: 10px; }
.user-logout:hover { color: #fff; border-color: #555; }
@media (max-width: 991px) { .users-settings-grid { grid-template-columns: 1fr; } }
@media (max-width: 575px) {
    .login-card { padding: 25px 21px; }
    .new-user-password-grid { grid-template-columns: 1fr; }
    .users-settings-card__head { flex-direction: column; }
    .workspace { animation: none; }
    .page-spinner { animation-duration: 1.6s; }
}

/* The role list scrolls vertically only; role content must fit the card width. */
.roles-settings-card { min-width: 0; overflow: hidden; }
.roles-settings-card .roles-list {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    overflow-x: hidden !important;
    overflow-y: auto;
}
.roles-settings-card .role-row { min-width: 0; }
.roles-settings-card .role-permission-note { min-width: 0; margin-left: 0; padding-left: 41px; }
.roles-settings-card .role-permission-form { box-sizing: border-box; min-width: 0; width: 100%; margin-left: 0; }
