/* Submission Management System — design system */

:root {
    --bg: #f6f7fb;
    --surface: #ffffff;
    --surface-2: #f9fafc;
    --surface-3: #f1f3f8;
    --border: #e4e7ef;
    --border-strong: #d3d8e3;
    --text: #151a2d;
    --text-2: #4a5268;
    --muted: #7c8499;

    --accent: #5145e5;
    --accent-hover: #4338ca;
    --accent-soft: #eeedfd;
    --accent-text: #4338ca;
    --on-accent: #ffffff;

    --sidebar: #0f1324;
    --sidebar-2: #181d33;
    --sidebar-text: #aab1c7;
    --sidebar-active: #ffffff;

    --st-draft: #6b7489;      --st-draft-bg: #eef0f4;
    --st-pending: #b45309;    --st-pending-bg: #fdf3e2;
    --st-approved: #047857;   --st-approved-bg: #e3f6ee;
    --st-rejected: #c2263d;   --st-rejected-bg: #fde8eb;
    --st-returned: #6d3fd1;   --st-returned-bg: #f0eafd;
    --st-withdrawn: #4b5563;  --st-withdrawn-bg: #eceef1;

    --danger: #c2263d;
    --danger-soft: #fde8eb;

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .06);
    --shadow-lg: 0 24px 64px rgba(15, 19, 36, .22);
    --ring: 0 0 0 4px rgba(81, 69, 229, .14);
    --sidebar-w: 256px;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0b0e19;
        --surface: #12162a;
        --surface-2: #161b31;
        --surface-3: #1c2240;
        --border: #262d4a;
        --border-strong: #343c5e;
        --text: #e8eaf3;
        --text-2: #b4bad0;
        --muted: #838aa4;
        --accent: #8b85ff;
        --accent-hover: #a29dff;
        --accent-soft: #24234a;
        --accent-text: #b1adff;
        --on-accent: #0b0e19;
        --sidebar: #080a14;
        --sidebar-2: #12162a;
        --st-draft: #a3abc0;      --st-draft-bg: #232a40;
        --st-pending: #f3b55a;    --st-pending-bg: #3a2c14;
        --st-approved: #4fd1a0;   --st-approved-bg: #123428;
        --st-rejected: #ff7d8f;   --st-rejected-bg: #3d1820;
        --st-returned: #b69bff;   --st-returned-bg: #2b2148;
        --st-withdrawn: #9aa3b5;  --st-withdrawn-bg: #232835;
        --danger: #ff7d8f;
        --danger-soft: #3d1820;
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
        --ring: 0 0 0 4px rgba(139, 133, 255, .22);
    }
}
:root[data-theme="dark"] {
    --bg: #0b0e19; --surface: #12162a; --surface-2: #161b31; --surface-3: #1c2240;
    --border: #262d4a; --border-strong: #343c5e; --text: #e8eaf3; --text-2: #b4bad0; --muted: #838aa4;
    --accent: #8b85ff; --accent-hover: #a29dff; --accent-soft: #24234a; --accent-text: #b1adff; --on-accent: #0b0e19;
    --sidebar: #080a14; --sidebar-2: #12162a;
    --st-draft: #a3abc0; --st-draft-bg: #232a40; --st-pending: #f3b55a; --st-pending-bg: #3a2c14;
    --st-approved: #4fd1a0; --st-approved-bg: #123428; --st-rejected: #ff7d8f; --st-rejected-bg: #3d1820;
    --st-returned: #b69bff; --st-returned-bg: #2b2148; --st-withdrawn: #9aa3b5; --st-withdrawn-bg: #232835;
    --danger: #ff7d8f; --danger-soft: #3d1820;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    --ring: 0 0 0 4px rgba(139, 133, 255, .22);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    font-feature-settings: "cv11", "ss01";
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
code { font-size: 12.5px; background: var(--surface-3); padding: 2px 6px; border-radius: 6px; }
[hidden] { display: none !important; }
svg { flex: none; }

/* ================= Shell ================= */

.app { display: flex; min-height: 100vh; }

.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 40;
    background: var(--sidebar); color: var(--sidebar-text);
    display: flex; flex-direction: column; padding: 18px 14px;
}
.sb-brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 22px; }
.logo {
    width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
    background: linear-gradient(135deg, #6d63ff, #3b82f6); color: #fff;
    box-shadow: 0 6px 18px rgba(99, 91, 255, .35);
}
.brand { color: #fff; font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.brand-sub { font-size: 12px; color: #737b94; }

.sb-nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.sb-section { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: #5d6580; padding: 18px 12px 8px; }
.sb-nav a {
    display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 9px;
    color: var(--sidebar-text); font-size: 14px; font-weight: 500; text-decoration: none;
    transition: background .15s, color .15s;
}
.sb-nav a svg { width: 18px; height: 18px; opacity: .85; }
.sb-nav a:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.sb-nav a.active { background: rgba(255, 255, 255, .09); color: var(--sidebar-active); }
.sb-nav a.active svg { color: #8f88ff; opacity: 1; }
.sb-nav .count {
    margin-left: auto; min-width: 22px; height: 20px; padding: 0 7px; border-radius: 10px;
    background: #6d63ff; color: #fff; font-size: 11.5px; font-weight: 600; display: inline-grid; place-items: center;
}

.sb-user {
    border-top: 1px solid rgba(255, 255, 255, .07); padding: 14px 6px 0; margin-top: 10px;
    display: flex; align-items: center; gap: 10px;
}
.sb-user .who { min-width: 0; flex: 1; }
.sb-user .name { color: #fff; font-weight: 500; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user .role { color: #737b94; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user .icon-btn { color: #8a92ab; }
.sb-user .icon-btn:hover { color: #fff; background: rgba(255, 255, 255, .07); }

.avatar {
    width: 34px; height: 34px; border-radius: 50%; flex: none;
    background: linear-gradient(135deg, #8b85ff, #5145e5); color: #fff;
    display: inline-grid; place-items: center; font-size: 12.5px; font-weight: 600;
}
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }

.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); }
.mobilebar { display: none; }
.scrim { display: none; }

body.is-auth .sidebar, body.is-auth .mobilebar { display: none; }
body.is-auth .main { margin-left: 0; }

.icon-btn {
    border: 0; background: none; cursor: pointer; padding: 7px; border-radius: 8px;
    color: var(--text-2); display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

/* ================= Page ================= */

.view { min-height: 100vh; }
.page-head {
    display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap;
    padding: 32px 40px 8px; max-width: 1320px;
}
.page-head h1 { font-size: 24px; font-weight: 650; letter-spacing: -0.02em; }
.page-head .sub { color: var(--muted); font-size: 14px; margin-top: 4px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-head .eyebrow { font-size: 13px; color: var(--muted); margin-bottom: 6px; display: block; }
.page-head .eyebrow a { color: var(--muted); }
.page-head .actions { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; }
.page-body { padding: 20px 40px 56px; max-width: 1320px; }

.loading { padding: 48px 40px; color: var(--muted); display: flex; gap: 10px; align-items: center; }
.spinner {
    width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--accent);
    border-radius: 50%; display: inline-block; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ================= Buttons ================= */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font: inherit; font-size: 14px; font-weight: 500; line-height: 1;
    height: 38px; padding: 0 16px; border-radius: 10px; cursor: pointer;
    border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
    box-shadow: var(--shadow-sm); text-decoration: none; white-space: nowrap;
    transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); box-shadow: 0 1px 2px rgba(81, 69, 229, .3), inset 0 1px 0 rgba(255, 255, 255, .12); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: transparent; }
.btn-warn { color: var(--st-returned); }
.btn-warn:hover { background: var(--st-returned-bg); border-color: transparent; }
.btn-success { background: var(--st-approved); border-color: var(--st-approved); color: #fff; }
.btn-success:hover { filter: brightness(1.05); background: var(--st-approved); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-link { border: 0; background: none; box-shadow: none; color: var(--text-2); }
.btn-link:hover { background: var(--surface-3); }
.btn-block { width: 100%; height: 42px; }

/* ================= Cards & panels ================= */

.panel {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 20px;
}
.panel h3 { font-size: 15px; font-weight: 600; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.panel h3 svg { width: 18px; height: 18px; color: var(--accent-text); }
.panel .panel-sub { color: var(--muted); font-size: 13px; margin: -10px 0 16px; }
.panel.act { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow); }
.section-title { font-size: 15px; font-weight: 600; margin: 0 0 14px; }

/* ================= Forms ================= */

.cform { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 24px; max-width: 920px; }
.cform > h3, .cform > .section-title, .cform > .notice, .cform > .modal-err, .cform > .form-actions, .cform > .frow.wide, .cform > .full { grid-column: 1 / -1; }
.frow { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.frow > label, .frow > .flabel { font-size: 13px; font-weight: 500; color: var(--text-2); }
.panel > .frow + .frow { margin-top: 16px; }
.req { color: var(--danger); margin-left: 3px; }
.help { color: var(--muted); font-size: 12.5px; margin-top: 6px; }

.input, select.input, textarea.input {
    width: 100%; height: 40px; padding: 0 12px;
    border: 1px solid var(--border-strong); border-radius: 10px;
    font: inherit; font-size: 14px; color: var(--text); background: var(--surface);
    transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
select.input {
    appearance: none; -webkit-appearance: none; padding-right: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%237c8499' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center;
}
.input::placeholder { color: var(--muted); }
.input:hover { border-color: color-mix(in srgb, var(--accent) 30%, var(--border-strong)); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.input[readonly], .input:disabled { background: var(--surface-3); color: var(--muted); }
.input.invalid { border-color: var(--danger); box-shadow: 0 0 0 4px var(--danger-soft); }

.choice-list { display: flex; flex-wrap: wrap; gap: 8px; }
.choice {
    display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 14px;
}
.choice-list .choice {
    border: 1px solid var(--border-strong); border-radius: 10px; padding: 0 14px; height: 40px; background: var(--surface);
    transition: border-color .15s, background .15s;
}
.choice-list .choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.choice input { margin: 0; width: 16px; height: 16px; accent-color: var(--accent); }
.frow > .choice-list { min-height: 40px; }
.other-text { margin-top: 8px; }
.other-text[hidden] { display: none; }

.form-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-top: 6px; }
.form-actions > span:empty { display: none; }
.form-actions .btns { display: flex; gap: 10px; flex-wrap: wrap; width: 100%; }

.form-card { max-width: 980px; padding: 0; overflow: hidden; }
.form-card .form-section { padding: 26px 28px; }
.form-card .form-section + .form-section { border-top: 1px solid var(--border); }
.form-card .form-section > h3 { margin-bottom: 4px; }
.form-card .form-section > .panel-sub { margin: 0 0 20px; }
.form-foot {
    position: sticky; bottom: 0; z-index: 5;
    display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
    padding: 16px 28px; background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(8px); border-top: 1px solid var(--border);
}
.form-foot .spacer { flex: 1; }

.meta-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.meta-tile { background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: 10px; padding: 10px 14px; }
.meta-tile .k { font-size: 11.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.meta-tile .v { font-weight: 600; font-size: 15px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.meta-tile .v.pending { color: var(--muted); font-weight: 500; font-size: 13.5px; }

/* Notifications bell & panel */
.sb-brand { position: relative; }
.sb-brand > div { min-width: 0; }
.sb-brand .brand, .sb-brand .brand-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bell {
    position: relative; margin-left: auto; width: 36px; height: 36px; border-radius: 10px; border: 0; cursor: pointer;
    display: grid; place-items: center; background: rgba(255, 255, 255, .06); color: #c3c9dc; flex: none;
}
.bell:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.bell.light { background: var(--surface-3); color: var(--text-2); margin-left: auto; }
.bell.has-unread svg { animation: ring 1.2s ease-in-out 1; transform-origin: 50% 10%; }
.bell-count {
    position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
    background: #ef4444; color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center;
    box-shadow: 0 0 0 2px var(--sidebar);
}
.bell.light .bell-count { box-shadow: 0 0 0 2px var(--surface); }
@keyframes ring { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(14deg); } 40% { transform: rotate(-12deg); } 60% { transform: rotate(8deg); } 80% { transform: rotate(-4deg); } }

.notif-panel {
    position: fixed; z-index: 90; top: 14px; left: calc(var(--sidebar-w) + 10px); width: 400px; max-height: calc(100vh - 28px);
    display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); animation: rise .16s ease-out;
}
.np-head { display: flex; align-items: center; gap: 6px; padding: 14px 14px 12px 18px; border-bottom: 1px solid var(--border); }
.np-head b { font-size: 15px; }
.np-head .spacer { flex: 1; }
.np-body { overflow-y: auto; padding: 6px; }
.notif {
    display: grid; grid-template-columns: 34px minmax(0, 1fr) 10px; gap: 12px; align-items: start;
    padding: 12px; border-radius: 10px; color: inherit; text-decoration: none;
}
.notif:hover { background: var(--surface-2); text-decoration: none; }
.notif.unread { background: var(--accent-soft); }
.notif.unread:hover { filter: brightness(.98); }
.notif .ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; }
.notif .ic svg { width: 17px; height: 17px; }
.notif .txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.notif .t { font-weight: 600; font-size: 13.5px; }
.notif .b { font-size: 13px; color: var(--text-2); overflow-wrap: anywhere; }
.notif .m { font-size: 12px; color: var(--muted); margin-top: 2px; }
.dot-unread { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); margin-top: 6px; }

.sb-nav .count.warn, .count.warn { background: #ef4444; color: #fff; }
.panel h3 .count { margin-left: 6px; min-width: 22px; height: 20px; padding: 0 7px; border-radius: 10px; font-size: 11.5px; display: inline-grid; place-items: center; }
.panel.attention { border-color: color-mix(in srgb, var(--st-returned) 45%, var(--border)); box-shadow: 0 0 0 4px var(--st-returned-bg), var(--shadow); }
.panel.attention h3 svg { color: var(--st-returned); }

@media (max-width: 900px) {
    .notif-panel { left: 8px; right: 8px; top: 64px; width: auto; max-height: calc(100vh - 80px); }
    .sb-brand .bell { display: none; }
}

.panel.note-panel { border-color: color-mix(in srgb, var(--st-pending) 40%, var(--border)); background: var(--st-pending-bg); }
.panel.note-panel h3 svg { color: var(--st-pending); }

/* Export buttons (joined) */
.export-group { display: inline-flex; }
.export-group .btn:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.export-group .btn:last-child { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px; }

/* Email templates */
.tpl-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.tpl { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; background: var(--surface-2); }
.tpl h4 { margin: 0 0 12px; font-size: 14px; font-weight: 600; }
.tpl .l { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--text-2); }
.tpl-body { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; }
.chip.ph { border: 1px dashed var(--border-strong); cursor: pointer; font-family: ui-monospace, Consolas, monospace; background: var(--surface); }
.chip.ph:hover { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent); }
.test-mail { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 16px; }
.test-mail .input { width: auto; min-width: 200px; height: 38px; }
@media (max-width: 900px) { .tpl-grid { grid-template-columns: 1fr; } }

/* Sidebar profile link */
.me-link { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; color: inherit; text-decoration: none; border-radius: 10px; padding: 4px; margin: -4px; }
.me-link:hover { background: rgba(255, 255, 255, .06); text-decoration: none; }

/* My profile */
.avatar.xl { width: 72px; height: 72px; font-size: 24px; box-shadow: 0 8px 24px rgba(81, 69, 229, .3); }
.profile-hero { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.profile-hero .who { flex: 1; min-width: 220px; }
.profile-hero h2 { font-size: 22px; letter-spacing: -0.02em; }
.profile-hero .chips { margin-top: 10px; }
.profile-hero .actions { display: flex; gap: 10px; flex-wrap: wrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
a.chip { text-decoration: none; }
a.chip:hover { background: var(--accent-soft); color: var(--accent-text); }
.chip svg { margin-right: 4px; }
.pstats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.pstat {
    display: flex; flex-direction: column; gap: 2px; padding: 16px 18px; color: inherit; text-decoration: none;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
a.pstat[href]:hover { border-color: var(--border-strong); text-decoration: none; }
.pstat .v { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; }
.pstat .k { font-size: 12.5px; color: var(--muted); }
.perm-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.perm-grid > div { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
@media (max-width: 900px) { .pstats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .perm-grid { grid-template-columns: 1fr; } .profile-hero { flex-direction: column; align-items: flex-start; } }

/* Module access matrix */
.matrix table.grid th.c, .matrix table.grid td.c { text-align: center; padding-left: 8px; padding-right: 8px; }
.matrix table.grid thead th { text-transform: none; letter-spacing: 0; font-size: 12px; white-space: normal; min-width: 68px; vertical-align: bottom; }
.matrix table.grid thead th.grp { text-transform: uppercase; letter-spacing: .05em; font-size: 11px; color: var(--muted); border-bottom: 1px solid var(--border); }
.matrix table.grid td.role-cell { min-width: 180px; }
.matrix input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }
.matrix input[type=checkbox]:disabled { cursor: not-allowed; opacity: .6; }
.matrix tbody tr:hover td { background: var(--surface-2); }

/* Password show/hide */
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 46px; }
.pw-toggle {
    position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
    width: 34px; height: 30px; border: 0; border-radius: 8px; background: none; cursor: pointer;
    display: grid; place-items: center; color: var(--muted);
}
.pw-toggle:hover { color: var(--text); background: var(--surface-3); }
.pw-toggle:focus-visible { outline: none; box-shadow: var(--ring); color: var(--text); }
.pw-toggle svg { width: 18px; height: 18px; }
/* Hide the browser's own reveal button so there is only one toggle */
input::-ms-reveal, input::-ms-clear { display: none; }

/* File attachments */
.files { display: flex; flex-direction: column; gap: 10px; }
.file-list { display: flex; flex-wrap: wrap; gap: 8px; }
.file-list:empty { display: none; }
.file-chip {
    display: inline-flex; align-items: center; gap: 8px; max-width: 100%; height: 36px; padding: 0 6px 0 12px;
    border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); font-size: 13px;
}
.file-chip > svg { width: 15px; height: 15px; color: var(--muted); }
.file-chip a, .file-chip > span:not(.muted) { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.file-chip .muted { font-size: 12px; padding-right: 6px; }
.file-chip .icon-btn { padding: 4px; }
.file-chip .icon-btn svg { width: 14px; height: 14px; }
.file-drop {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center;
    padding: 18px; border: 1.5px dashed var(--border-strong); border-radius: 12px; background: var(--surface-2);
    color: var(--text-2); cursor: pointer; transition: border-color .15s, background .15s;
}
.file-drop:hover { border-color: var(--accent); background: var(--accent-soft); }
.file-drop svg { width: 22px; height: 22px; color: var(--accent-text); }
.file-drop b { color: var(--accent-text); font-weight: 600; }
.file-status { display: flex; align-items: center; gap: 8px; }
.file-status:empty { display: none; }

.pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.pager .muted { margin-right: auto; }

/* Stacked form used in modals and auth */
.sform { display: grid; gap: 16px; }
.sform .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.sform label.l { display: block; font-size: 13px; font-weight: 500; margin-bottom: 7px; color: var(--text-2); }
.checks { display: flex; flex-wrap: wrap; gap: 12px 22px; }

/* ================= Status / chips ================= */

.status {
    display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px;
    font-size: 12px; font-weight: 600; border-radius: 999px; white-space: nowrap;
    color: var(--st-draft); background: var(--st-draft-bg);
}
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.Pending { color: var(--st-pending); background: var(--st-pending-bg); }
.status.Approved { color: var(--st-approved); background: var(--st-approved-bg); }
.status.Rejected { color: var(--st-rejected); background: var(--st-rejected-bg); }
.status.Returned { color: var(--st-returned); background: var(--st-returned-bg); }
.status.Withdrawn { color: var(--st-withdrawn); background: var(--st-withdrawn-bg); }

.chip {
    display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 7px;
    font-size: 12px; font-weight: 500; background: var(--surface-3); color: var(--text-2); margin: 2px 4px 2px 0;
}
.chip.green { background: var(--st-approved-bg); color: var(--st-approved); }
.chip.gray { background: var(--surface-3); color: var(--muted); }
.chip.red { background: var(--danger-soft); color: var(--danger); }
.chip.accent { background: var(--accent-soft); color: var(--accent-text); }
.badge {
    display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px;
    border-radius: 10px; font-size: 11.5px; font-weight: 600; background: var(--accent); color: var(--on-accent);
}
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.small { font-size: 12.5px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--st-draft); flex: none; }
.dot.Pending { background: var(--st-pending); }
.dot.Approved { background: var(--st-approved); }
.dot.Rejected { background: var(--st-rejected); }
.dot.Returned { background: var(--st-returned); }
.dot.Withdrawn { background: var(--st-withdrawn); }

/* ================= Toolbar / tables ================= */

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar .input { width: auto; min-width: 200px; height: 38px; }
.search { position: relative; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.search .input { padding-left: 36px; min-width: 260px; }
.toolbar .count { margin-left: auto; }

.seg { display: inline-flex; padding: 3px; background: var(--surface-3); border-radius: 10px; gap: 2px; }
.seg button {
    border: 0; background: none; height: 32px; padding: 0 14px; font: inherit; font-size: 13px; font-weight: 500;
    color: var(--text-2); border-radius: 8px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
table.grid { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.grid th, table.grid td { padding: 13px 16px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.grid th { font-weight: 600; font-size: 12px; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid tr.click { cursor: pointer; transition: background .12s; }
table.grid tr.click:hover td { background: var(--surface-2); }
table.grid td.actions { white-space: nowrap; text-align: right; }
table.grid td b { font-weight: 600; }
.empty { padding: 56px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 40px; height: 40px; color: var(--border-strong); display: block; margin: 0 auto 12px; }
.empty .t { color: var(--text); font-weight: 600; margin-bottom: 4px; }

/* ================= Dashboard ================= */

.hero { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; padding: 36px 40px 8px; max-width: 1320px; }
.hero .date { color: var(--muted); font-size: 13px; font-weight: 500; }
.hero h1 { font-size: 28px; font-weight: 650; letter-spacing: -0.025em; margin-top: 4px; }
.hero .actions { margin-left: auto; display: flex; gap: 10px; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi {
    position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 14px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 20px; box-shadow: var(--shadow); color: inherit; text-decoration: none;
    transition: transform .15s, box-shadow .15s, border-color .15s;
}
a.kpi:hover { transform: translateY(-2px); text-decoration: none; border-color: var(--border-strong); }
.kpi .ic { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; }
.kpi .ic svg { width: 19px; height: 19px; }
.kpi .k { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi .v { font-size: 32px; font-weight: 650; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi .row { display: flex; align-items: center; justify-content: space-between; }
.kpi.featured { background: linear-gradient(140deg, #5145e5 0%, #7c3aed 100%); border-color: transparent; color: #fff; box-shadow: 0 12px 32px rgba(81, 69, 229, .3); }
.kpi.featured .k { color: rgba(255, 255, 255, .8); }
.kpi.featured .ic { background: rgba(255, 255, 255, .16); color: #fff; }
.kpi.featured::after { content: ""; position: absolute; right: -40px; top: -40px; width: 140px; height: 140px; border-radius: 50%; background: rgba(255, 255, 255, .08); }
.ic.pending { background: var(--st-pending-bg); color: var(--st-pending); }
.ic.approved { background: var(--st-approved-bg); color: var(--st-approved); }
.ic.rejected { background: var(--st-rejected-bg); color: var(--st-rejected); }
.ic.accent { background: var(--accent-soft); color: var(--accent-text); }

.dist { display: flex; height: 10px; border-radius: 6px; overflow: hidden; background: var(--surface-3); gap: 2px; margin: 4px 0 16px; }
.dist span { display: block; height: 100%; }
.legend { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 16px; }
.legend a { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13px; text-decoration: none; }
.legend a:hover { color: var(--text); }
.legend b { margin-left: auto; color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

.two-col { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 20px; align-items: start; }

.activity { list-style: none; margin: 0; padding: 0; }
.activity li a {
    display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 14px; align-items: center;
    padding: 12px 10px; margin: 0 -10px; border-radius: 10px; color: inherit; text-decoration: none;
}
.activity li a:hover { background: var(--surface-2); }
.activity li + li { border-top: 1px solid var(--border); }
.activity .ic { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); }
.activity .ic svg { width: 18px; height: 18px; }
.activity .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.activity .m { color: var(--muted); font-size: 12.5px; }
.activity .r { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }

.bar-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; margin-bottom: 16px; font-size: 13.5px; }
.bar-row:last-child { margin-bottom: 0; }
.bar-row b { font-variant-numeric: tabular-nums; }
.bar { grid-column: 1 / -1; height: 8px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, #f59e0b, #f97316); border-radius: 4px; }

/* ================= Submission detail ================= */

.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.kv-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 28px; }
.kv { padding: 13px 0; border-bottom: 1px solid var(--border); min-width: 0; }
.kv .k { font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 3px; }
.kv .v { white-space: pre-wrap; word-break: break-word; font-weight: 500; }
.kv.wide { grid-column: 1 / -1; }
.cform .kv { padding: 0; border: 0; }

/* ================= Contracts ================= */

.contract-kpis .kpi { gap: 10px; }
.contract-kpis .kpi .v { font-size: 24px; }
table.grid th.r, table.grid td.r { text-align: right; font-variant-numeric: tabular-nums; }
.contract-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.contract-files { display: flex; flex-direction: column; gap: 12px; }
.contract-files .file-chip { max-width: 100%; }
a.file-chip { text-decoration: none; color: var(--accent-text); }
a.file-chip:hover { border-color: var(--accent); }

.stepper { display: flex; flex-direction: column; }
.step { display: grid; grid-template-columns: 30px 1fr; gap: 12px; position: relative; padding-bottom: 20px; }
.step:last-child { padding-bottom: 0; }
.step:not(:last-child)::before { content: ""; position: absolute; left: 14px; top: 32px; bottom: 2px; width: 2px; border-radius: 2px; background: var(--border); }
.step.done:not(:last-child)::before { background: var(--st-approved); }
.step .ic {
    width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
    border: 2px solid var(--border-strong); background: var(--surface); font-size: 12px; font-weight: 600; color: var(--muted);
    position: relative; z-index: 1;
}
.step.done .ic { background: var(--st-approved); border-color: var(--st-approved); color: #fff; }
.step.current .ic { border-color: var(--st-pending); color: var(--st-pending); box-shadow: 0 0 0 5px var(--st-pending-bg); }
.step.rejected .ic { background: var(--st-rejected); border-color: var(--st-rejected); color: #fff; }
.step.returned .ic { background: var(--st-returned); border-color: var(--st-returned); color: #fff; }
.step .t { font-weight: 600; font-size: 14px; padding-top: 4px; }
.step .s { font-size: 12.5px; color: var(--muted); }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: grid; grid-template-columns: 28px 1fr; gap: 12px; padding: 12px 0; font-size: 13.5px; }
.timeline li + li { border-top: 1px solid var(--border); }
.timeline .when { color: var(--muted); font-size: 12.5px; }
.timeline .comment { margin-top: 8px; background: var(--surface-2); border: 1px solid var(--border); padding: 9px 12px; border-radius: 10px; white-space: pre-wrap; color: var(--text-2); }

.notice { padding: 12px 16px; border-radius: 10px; background: var(--st-pending-bg); color: var(--st-pending); margin-bottom: 16px; font-size: 13.5px; font-weight: 500; }
.notice.info { background: var(--accent-soft); color: var(--accent-text); }
.notice.error { background: var(--danger-soft); color: var(--danger); }
.notice.ok { background: var(--st-approved-bg); color: var(--st-approved); }

.decision-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

/* ================= Workflow builder ================= */

.wf-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 16px; }
.wf-card .head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.wf-card .head h3 { font-size: 16px; }
.chain { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.chain .node { border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; font-size: 12.5px; background: var(--surface-2); color: var(--muted); }
.chain .node b { display: block; font-size: 13px; color: var(--text); font-weight: 600; }
.chain .node.start { background: var(--accent-soft); border-color: transparent; }
.chain .node.start b { color: var(--accent-text); }
.chain .node.end { background: var(--st-approved-bg); border-color: transparent; }
.chain .node.end b { color: var(--st-approved); }
.chain .arrow { color: var(--border-strong); }

.level { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; background: var(--surface-2); }
.level .lhead { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.level .num { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-weight: 600; font-size: 13px; flex: none; }
.level .lgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.level .lgrid label { font-size: 12.5px; font-weight: 500; color: var(--text-2); display: block; margin-bottom: 6px; }
.fieldmatrix { margin-top: 14px; max-height: 260px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.fieldmatrix table { width: 100%; border-collapse: collapse; font-size: 13px; }
.fieldmatrix th, .fieldmatrix td { padding: 8px 12px; border-bottom: 1px solid var(--border); text-align: left; }
.fieldmatrix th { position: sticky; top: 0; background: var(--surface-2); font-size: 12px; color: var(--muted); font-weight: 600; }
.fieldmatrix td.c, .fieldmatrix th.c { text-align: center; width: 90px; }
.fieldmatrix input { accent-color: var(--accent); width: 15px; height: 15px; }

/* ================= Calendar ================= */

.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.cal-head h2 { font-size: 20px; min-width: 190px; margin-left: 8px; }
.cal {
    display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
.cal .dow { font-weight: 600; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; padding: 10px 12px; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.cal .day { min-height: 116px; padding: 8px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); overflow: hidden; }
.cal .day:nth-child(7n) { border-right: 0; }
.cal .day:nth-last-child(-n+7) { border-bottom: 0; }
.cal .day.out { background: var(--surface-2); }
.cal .day.out .dn { color: var(--border-strong); }
.cal .dn { font-size: 12.5px; font-weight: 600; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; margin-bottom: 4px; color: var(--text-2); }
.cal .day.today .dn { background: var(--accent); color: var(--on-accent); }
.cal .ev {
    display: block; font-size: 12px; font-weight: 500; padding: 3px 8px; margin-bottom: 4px; border-radius: 6px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    color: var(--st-draft); background: var(--st-draft-bg); border-left: 3px solid currentColor;
}
.cal .ev:hover { text-decoration: none; filter: brightness(.97); }
.cal .ev.Pending { color: var(--st-pending); background: var(--st-pending-bg); }
.cal .ev.Approved { color: var(--st-approved); background: var(--st-approved-bg); }
.cal .ev.Rejected { color: var(--st-rejected); background: var(--st-rejected-bg); }
.cal .ev.Returned { color: var(--st-returned); background: var(--st-returned-bg); }
.cal .ev.Withdrawn { color: var(--st-withdrawn); background: var(--st-withdrawn-bg); }
.cal .more { font-size: 11.5px; color: var(--muted); padding-left: 4px; }
.legend-row { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 14px; font-size: 12.5px; color: var(--text-2); }
.legend-row span { display: inline-flex; align-items: center; gap: 7px; }

/* ================= Modal & toast ================= */

.modal-backdrop {
    position: fixed; inset: 0; z-index: 100; background: rgba(10, 13, 26, .5); backdrop-filter: blur(3px);
    display: flex; align-items: flex-start; justify-content: center; padding: 64px 16px; overflow-y: auto;
    animation: fade .15s ease-out;
}
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); width: 100%; max-width: 560px; box-shadow: var(--shadow-lg); animation: rise .18s ease-out; }
.modal.wide { max-width: 960px; }
.modal-head { display: flex; align-items: center; padding: 20px 24px 0; }
.modal-head h2 { font-size: 18px; }
.modal-head .icon-btn { margin-left: auto; font-size: 22px; line-height: 1; width: 34px; height: 34px; }
.modal-body { padding: 20px 24px; }
.modal-foot { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.modal-err { margin-bottom: 16px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(10px) scale(.98); opacity: 0; } }

.toast-root { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; max-width: calc(100vw - 32px); }
.toast {
    display: flex; align-items: center; gap: 10px; background: #151a2d; color: #fff; padding: 12px 16px; border-radius: 12px;
    box-shadow: var(--shadow-lg); font-size: 13.5px; font-weight: 500; animation: rise .2s ease-out;
}
.toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #8b85ff; flex: none; }
.toast.ok::before { background: #34d399; }
.toast.err::before { background: #fb7185; }

/* ================= Auth ================= */

.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.auth-art {
    position: relative; overflow: hidden; color: #fff; padding: 48px 56px; display: flex; flex-direction: column;
    background:
        radial-gradient(1200px 600px at -10% -10%, rgba(139, 133, 255, .55), transparent 60%),
        radial-gradient(800px 500px at 110% 110%, rgba(59, 130, 246, .45), transparent 60%),
        #0f1324;
}
.auth-art .sb-brand { padding: 0; }
.auth-art .quote { margin-top: auto; max-width: 460px; }
.auth-art .quote h2 { font-size: 34px; font-weight: 650; letter-spacing: -0.03em; line-height: 1.15; }
.auth-art .quote p { color: #aab1c7; font-size: 15px; margin: 14px 0 0; }
.auth-art .steps { display: flex; gap: 8px; margin-top: 36px; flex-wrap: wrap; }
.auth-art .steps span { font-size: 12.5px; padding: 6px 12px; border-radius: 999px; background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .1); }
.auth-form { display: grid; place-items: center; padding: 48px 24px; background: var(--surface); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 26px; font-weight: 650; letter-spacing: -0.025em; }
.auth-card .lead { color: var(--muted); margin: 8px 0 28px; }
.auth-card .foot { color: var(--muted); font-size: 13px; text-align: center; margin: 0; }

.center-card { max-width: 720px; margin: 64px auto; padding: 0 16px; }

/* ================= Form layout (rows of up to 3 fields) ================= */

.frows { display: flex; flex-direction: column; gap: 18px; max-width: 1080px; }
.form-row { display: grid; gap: 18px 24px; }
.form-row.cols-1 { grid-template-columns: minmax(0, 1fr); }
.form-row.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-row.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* ================= Form Builder ================= */

.page-body.fb-page { max-width: none; }
.fb { display: grid; grid-template-columns: 300px minmax(0, 1fr) 290px; gap: 20px; align-items: start; }
.fb-sticky { position: sticky; top: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 16px; box-shadow: var(--shadow); max-height: calc(100vh - 32px); overflow: auto; }
.fb-palette h4, .fb-hidden h4 { margin: 0 0 2px; font-size: 14px; }
.fb-palette > .fb-sticky > p { margin: 0 0 6px; font-size: 12px; }

/* palette: two-column tiles with an icon, like Creator's builder */
.fb-group { margin-top: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fb-gname { grid-column: 1 / -1; font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 0 2px; }
.fb-tool {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 70px; padding: 9px 8px;
    border: 1px dashed var(--border-strong); border-radius: 10px; background: var(--surface); color: var(--text-2);
    font: inherit; font-size: 13px; text-align: center; cursor: grab; transition: border-color .12s, background .12s, color .12s;
}
.fb-tool:hover { border-style: solid; border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.fb-tool:active { cursor: grabbing; }
.fb-tool .ic { display: grid; place-items: center; height: 26px; color: var(--text-2); }
.fb-tool:hover .ic { color: var(--accent); }
.fb-tool .ic svg { width: 23px; height: 23px; stroke-width: 1.5; }
.fb-num { font-weight: 700; font-size: 13px; letter-spacing: -0.02em; }
.fb-tool .fb-num { font-size: 15px; }

/* canvas: the form as a page */
.fb-form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 22px 22px 18px; }
.fb-formhead { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-bottom: 14px; margin-bottom: 4px; border-bottom: 1px solid var(--border); }
.fb-formhead h3 { margin: 0; font-size: 17px; letter-spacing: -0.01em; }
.fb-autos { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 12px 0 6px; }
.fb-autos .chip { cursor: pointer; border: 1px dashed var(--border-strong); background: var(--surface-2); font: inherit; font-size: 12px; color: var(--text-2); }
.fb-autos .chip.accent { border-style: solid; border-color: var(--accent); }
.fb-row { display: grid; gap: 12px; }
.fb-row.cols-1 { grid-template-columns: minmax(0, 1fr); }
.fb-row.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fb-row.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fb-row.drop-full { outline: 2px dashed var(--danger); outline-offset: 3px; border-radius: 12px; cursor: no-drop; }

/* gaps between rows: invisible until something is being dragged */
.fb-gap { height: 6px; position: relative; border-radius: 6px; transition: height .12s, background .12s; }
.fb-gap span { display: none; }
body.fb-dragging .fb-gap { height: 18px; }
body.fb-dragging .fb-gap::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 2px dashed var(--border-strong); }
.fb-gap.on { height: 40px !important; background: var(--accent-soft); outline: 2px dashed var(--accent); outline-offset: -2px; }
.fb-gap.on::after { display: none; }
.fb-gap.on span { display: grid; place-items: center; height: 100%; font-size: 12.5px; font-weight: 600; color: var(--accent-text); }

/* a field: compact outlined box (icon, label, * required); selected = dashed accent + delete button */
.fb-field {
    position: relative; min-width: 0; display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 12px 0 14px;
    border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); cursor: pointer;
    transition: border-color .12s, background .12s, box-shadow .12s;
}
.fb-field:hover { border-color: var(--accent); box-shadow: 0 1px 6px rgba(16, 24, 40, .06); }
.fb-field:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.fb-field.sel { border: 1px dashed var(--accent); background: var(--accent-soft); }
.fb-field.sel .fb-label { color: var(--accent-text); }
.fb-field.draft { border: 1px dashed var(--accent); background: var(--accent-soft); cursor: default; }
.fb-field.dragging { opacity: .35; }
.fb-field.drop-before::before, .fb-field.drop-after::after {
    content: ""; position: absolute; top: 2px; bottom: 2px; width: 4px; border-radius: 4px; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.fb-field.drop-before::before { left: -7px; }
.fb-field.drop-after::after { right: -7px; }
.fb-ticon { width: 20px; height: 20px; flex: none; display: grid; place-items: center; color: var(--muted); }
.fb-ticon svg { width: 17px; height: 17px; }
.fb-ticon .fb-num { font-size: 10.5px; }
.fb-field.sel .fb-ticon { color: var(--accent); }
.fb-label { flex: 1; min-width: 0; font-size: 13.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fb-label .req { color: var(--danger); margin-left: 4px; font-weight: 600; }
.fb-flagdots { display: flex; gap: 3px; flex: none; }
.fb-flagdots i { font-style: normal; font-size: 9.5px; font-weight: 700; width: 16px; height: 16px; border-radius: 4px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.fb-flagdots i.off { color: var(--danger); }
.fb-del { flex: none; margin-right: -6px; width: 34px; height: 34px; border: 0; border-left: 1px dashed var(--accent); background: transparent; color: var(--accent); display: grid; place-items: center; cursor: pointer; }
.fb-del:hover { color: var(--danger); }
.fb-del svg { width: 16px; height: 16px; }

.fb-empty { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 40px 12px; color: var(--muted); text-align: center; border: 2px dashed var(--border); border-radius: 12px; margin-top: 8px; }
.fb-empty svg { width: 28px; height: 28px; }
.fb-empty b { color: var(--text); }

.fb-hidden { margin-top: 18px; padding: 14px 16px; border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); background: var(--surface); }
.fb-hidden-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.fb-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); font-size: 13px; cursor: grab; }
.fb-chip.sel { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.fb-chip .grip { color: var(--muted); letter-spacing: -2px; font-size: 11px; }

/* properties panel */
.fb-props .sform { gap: 12px; }
.fb-ptitle { display: flex; align-items: center; gap: 8px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.fb-ptitle .fb-type { opacity: 1; margin-left: auto; font-size: 11px; font-weight: 600; color: var(--accent-text); background: var(--accent-soft); border-radius: 999px; padding: 2px 9px; }
.fb-checks { display: flex; flex-direction: column; gap: 8px; }
.fb-move { display: flex; flex-wrap: wrap; gap: 6px; }
.fb-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 4px; border-top: 1px solid var(--border); margin-top: 4px; padding-top: 12px; }
.fb-hint { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; }
.fb-hint svg { width: 22px; height: 22px; color: var(--accent); }
.fb-hint b { color: var(--text); font-size: 14px; }
.fb-hint ul { margin: 6px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.fb-status { margin-right: 6px; align-self: center; }
.fb-status.ok-text { color: var(--st-approved); }
.fb-status.err-text { color: var(--danger); }
input.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

@media (max-width: 1280px) {
    .fb { grid-template-columns: 260px minmax(0, 1fr) 260px; gap: 16px; }
}
@media (max-width: 1100px) {
    .fb { grid-template-columns: minmax(0, 1fr); }
    .fb-sticky { position: static; max-height: none; }
    .fb-palette .fb-sticky { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; }
    .fb-palette h4, .fb-palette > .fb-sticky > p { flex-basis: 100%; margin: 0; }
    .fb-group { margin: 0; display: flex; flex-wrap: wrap; }
    .fb-gname { flex-basis: 100%; }
    .fb-tool { min-height: 0; flex-direction: row; padding: 6px 10px; }
    .fb-tool .ic svg { width: 18px; height: 18px; }
}
@media (max-width: 700px) {
    .form-row.cols-2, .form-row.cols-3, .fb-row.cols-2, .fb-row.cols-3 { grid-template-columns: minmax(0, 1fr); }
}

/* ================= Responsive ================= */

@media (max-width: 1100px) {
    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .detail-grid, .two-col { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
    body.nav-open .sidebar { transform: none; }
    body.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(10, 13, 26, .45); }
    .main { margin-left: 0; }
    .mobilebar {
        display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 20;
        height: 56px; padding: 0 12px; background: color-mix(in srgb, var(--surface) 90%, transparent);
        backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
    }
    .mobile-title { font-weight: 600; }
    .auth { grid-template-columns: 1fr; }
    .auth-art { display: none; }
    .level .lgrid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .page-head, .hero { padding: 22px 16px 4px; }
    .page-body { padding: 16px 16px 40px; }
    .page-head .actions, .hero .actions { margin-left: 0; width: 100%; }
    .hero h1 { font-size: 23px; }
    .kpis { gap: 12px; }
    .kpi { padding: 16px; }
    .kpi .v { font-size: 26px; }
    .cform, .kv-grid { grid-template-columns: 1fr; }
    .form-card .form-section { padding: 20px 16px; }
    .form-foot { padding: 12px 16px; }
    .sform .row2 { grid-template-columns: 1fr; }
    .toolbar .input, .search .input { min-width: 0; width: 100%; }
    .search, .toolbar select.input { flex: 1 1 100%; }
    .toolbar .count { margin-left: 0; }
    .legend { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .cal .day { min-height: 64px; padding: 4px; }
    .cal .dow { padding: 8px 4px; text-align: center; }
    .cal .ev { font-size: 0; height: 6px; padding: 0; border-left: 0; background: currentColor; }
    .modal-backdrop { padding: 16px 10px; }
}

/* Form preview (opened from the Form Builder) */
.preview-note { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.preview-note svg { width: 15px; height: 15px; vertical-align: -2px; }

/* Email problems dialog */
.email-problems { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; }

.tpl-group { margin: 18px 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }

/* ================= Settings (section menu + one section at a time) ================= */

.set-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 24px; align-items: start; }
.set-nav { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 10px; box-shadow: var(--shadow); }
.set-group { display: flex; flex-direction: column; gap: 2px; }
.set-gname { font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); padding: 0 10px 6px; }
.set-link {
    position: relative; display: flex; align-items: center; gap: 11px; width: 100%; padding: 9px 10px; border: 0; border-radius: 10px;
    background: transparent; color: var(--text-2); font: inherit; text-align: left; cursor: pointer; transition: background .15s, color .15s;
}
.set-link:hover { background: var(--surface-2); color: var(--text); }
.set-link.on { background: var(--accent-soft); color: var(--accent-text); }
.set-link > svg { width: 18px; height: 18px; flex: none; }
.set-link span { display: flex; flex-direction: column; min-width: 0; }
.set-link b { font-size: 13.5px; font-weight: 600; }
.set-link small { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.set-link.on small { color: var(--accent-text); opacity: .8; }
.set-dot { position: absolute; right: 10px; top: 50%; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }

.set-main { min-width: 0; }
.set-main .panel { max-width: none !important; }
.set-panel { padding: 24px 26px; }
.set-title { margin: 0 0 8px; font-size: 18px; letter-spacing: -0.01em; }
.set-panel > .panel-sub { margin: 0 0 22px; }
.set-panel .tpl-editor .l { display: block; margin-bottom: 6px; }
.set-h3 { font-size: 14px; margin: 26px 0 10px; padding-top: 18px; border-top: 1px solid var(--border); }
.set-checks { display: flex; flex-direction: column; gap: 10px; }
.set-checks .choice { align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.set-checks .choice input { margin-top: 2px; }
.set-checks .choice b { display: block; font-weight: 600; }
.set-checks .choice span { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.set-note { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; font-size: 13px; color: var(--text-2); }
.set-note svg { width: 16px; height: 16px; flex: none; color: var(--st-approved); margin-top: 2px; }
.set-status { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 20px; }
.set-status > div { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; font-size: 13px; min-width: 0; }
.set-status > div span { display: flex; flex-direction: column; min-width: 0; word-break: break-word; }
.set-status > div b { font-weight: 600; color: var(--text); }
.set-status svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.set-status .ok { background: var(--st-approved-bg); color: var(--st-approved); }
.set-status .bad { background: var(--danger-soft); color: var(--danger); }
.set-save {
    position: sticky; bottom: 12px; z-index: 5; display: flex; align-items: center; gap: 12px; margin-top: 16px; padding: 12px 16px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow);
}
.set-save[hidden] { display: none; }
.set-save.dirty { border-color: var(--accent); }
.set-save.dirty #setDirty { color: var(--accent-text); font-weight: 600; }
.set-save .spacer { flex: 1; }

.tpl-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 20px; align-items: start; }
.tpl-list { display: flex; flex-direction: column; gap: 6px; }
.tpl-item {
    display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
    font: inherit; text-align: left; cursor: pointer; color: var(--text); transition: border-color .15s, background .15s;
}
.tpl-item:hover { border-color: var(--border-strong); }
.tpl-item.on { border-color: var(--accent); background: var(--accent-soft); }
.tpl-item b { font-size: 13.5px; }
.tpl-item span { font-size: 12px; color: var(--muted); }
.tpl-editor[hidden] { display: none; }
.tpl-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 12.5px; color: var(--muted); padding: 10px 12px; background: var(--surface-2); border-radius: 10px; margin-bottom: 14px; }
.tpl-meta b { color: var(--text-2); }
.tpl-editor .tpl-body { min-height: 260px; font-size: 13.5px; line-height: 1.55; }
.tpl-ph { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.tpl-ph .chip { cursor: pointer; border: 1px dashed var(--border-strong); background: var(--surface); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11.5px; }
.tpl-ph .chip:hover { border-color: var(--accent); color: var(--accent-text); }

@media (max-width: 1000px) {
    .set-layout { grid-template-columns: minmax(0, 1fr); }
    .set-nav { position: static; flex-direction: row; overflow-x: auto; gap: 12px; padding: 10px; }
    .set-group { flex-direction: row; align-items: center; gap: 4px; flex: none; }
    .set-gname { display: none; }
    .set-link { width: auto; white-space: nowrap; }
    .set-link small { display: none; }
    .set-dot { position: static; margin: 0; }
    .tpl-layout { grid-template-columns: minmax(0, 1fr); }
    .tpl-list { flex-direction: row; overflow-x: auto; }
    .tpl-item { flex: none; }
    .set-status { grid-template-columns: minmax(0, 1fr); }
}

/* ================= Profile photos ================= */
.avatar { background-size: cover; background-position: center; }
.avatar.has-photo { color: transparent; background-color: var(--surface-2); }
.user-cell { display: inline-flex; align-items: center; gap: 10px; }
.photo-edit { position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; flex: none; }
.photo-edit .photo-btn {
    position: absolute; top: 46px; left: 50%; margin-left: 14px; width: 30px; height: 30px; border-radius: 50%;
    display: grid; place-items: center; background: var(--surface); color: var(--accent); border: 1px solid var(--border-strong);
    box-shadow: var(--shadow); cursor: pointer; transition: transform .15s;
}
.photo-edit .photo-btn:hover { transform: scale(1.08); }
.photo-edit .photo-btn svg { width: 15px; height: 15px; }
.photo-actions { font-size: 12px; white-space: nowrap; }
.photo-actions .link { color: var(--accent-text); cursor: pointer; font-weight: 600; }
.photo-actions .link:hover { text-decoration: underline; }
.photo-edit.busy .avatar { opacity: .4; }
.photo-edit.busy::after { content: ""; position: absolute; top: 24px; left: 50%; margin-left: -12px; width: 24px; height: 24px; border-radius: 50%; border: 3px solid var(--accent-soft); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }

/* ================= USDA Agreement Report ================= */
.usda-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.usda-pill { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-2); font: inherit; font-size: 13px; cursor: pointer; }
.usda-pill b { font-variant-numeric: tabular-nums; color: var(--text); }
.usda-pill:hover { border-color: var(--border-strong); }
.usda-pill.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
/* six small segments in the list's Progress column */
.usda-mini { display: flex; gap: 3px; margin-bottom: 4px; }
.usda-mini span { width: 16px; height: 6px; border-radius: 3px; background: var(--border); }
.usda-mini span.on { background: var(--st-approved); }
.usda-mini span.rej { background: var(--st-rejected); }
.usda-progress { height: 8px; border-radius: 999px; background: var(--border); overflow: hidden; }
.usda-progress span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--st-approved)); }
.usda-tl-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.btn svg { width: 15px; height: 15px; }
/* USDA status colours not used elsewhere: Sent to USDA (blue) and Fully Executed (teal) */
.status.u-sent { color: #1d5fd6; background: #e6effe; }
.status.u-exec { color: #0f766e; background: #d9f4ef; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .status.u-sent { color: #8db4ff; background: #1a2a4a; }
    :root:not([data-theme="light"]) .status.u-exec { color: #5eead4; background: #12332f; }
}
:root[data-theme="dark"] .status.u-sent { color: #8db4ff; background: #1a2a4a; }
:root[data-theme="dark"] .status.u-exec { color: #5eead4; background: #12332f; }

/* thin scrollbar for the builder's side panels on short screens */
.fb-sticky { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.fb-sticky::-webkit-scrollbar { width: 6px; }
.fb-sticky::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; }

/* Print templates settings */
.color-in { width: 96px; height: 40px; padding: 4px; cursor: pointer; }
.psec { gap: 8px; }

/* Formatted text editor (print templates) */
.rt { border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); overflow: hidden; }
.rt:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.rt-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 5px 6px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.rt-btn { min-width: 30px; height: 28px; padding: 0 6px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--text-2); font: inherit; font-size: 13.5px; cursor: pointer; display: inline-grid; place-items: center; }
.rt-btn:hover { background: var(--surface); border-color: var(--border); color: var(--text); }
.rt-btn svg { width: 15px; height: 15px; }
.rt-sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }
.rt-size { height: 28px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text-2); font: inherit; font-size: 12.5px; padding: 0 4px; cursor: pointer; }
.rt-color { position: relative; width: 30px; height: 28px; display: inline-grid; place-items: center; border-radius: 6px; cursor: pointer; }
.rt-color:hover { background: var(--surface); }
.rt-color span { font-weight: 700; text-decoration: underline; text-decoration-thickness: 3px; text-decoration-color: var(--accent); }
.rt-color input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.rt-area { border: 0 !important; border-radius: 0 !important; box-shadow: none !important; height: auto; padding: 10px 12px; line-height: 1.5; overflow-wrap: anywhere; outline: none; }
.rt-area:empty::before { content: attr(data-placeholder); color: var(--muted); }
.rt-area ul { margin: 4px 0; padding-left: 20px; }

/* Dashboard: Draft / Sent to USDA / Approved by USDA row */
.kpis.kpis-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ic.draft { background: var(--st-draft-bg); color: var(--st-draft); }
.ic.usda { background: #e6effe; color: #1d5fd6; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ic.usda { background: #1a2a4a; color: #8db4ff; } }
:root[data-theme="dark"] .ic.usda { background: #1a2a4a; color: #8db4ff; }
@media (max-width: 1100px) { .kpis.kpis-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) { .kpis.kpis-3 { grid-template-columns: minmax(0, 1fr); } }

/* Dashboard: USDA pipeline strip (Draft → Sent to USDA → Approved by USDA) */
.pipe { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px 16px; margin-bottom: 20px; }
.pipe-head { display: flex; align-items: baseline; gap: 10px; margin: 0 4px 12px; }
.pipe-head b { font-size: 14px; font-weight: 600; }
.pipe-steps { display: grid; grid-template-columns: minmax(0, 1fr) 28px minmax(0, 1fr) 28px minmax(0, 1fr) 29px minmax(0, 1fr); align-items: center; }
/* Rejected is an outcome, not a next step: a divider instead of an arrow. */
.pipe-sep { justify-self: center; width: 1px; height: 40px; background: var(--border); }
@media (max-width: 1200px) and (min-width: 761px) {
    .pipe-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .pipe-arrow, .pipe-sep { display: none; }
}
.pipe-step { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid transparent; color: inherit; text-decoration: none; transition: border-color .15s, transform .15s; min-width: 0; }
a.pipe-step[href]:hover { border-color: var(--border-strong); transform: translateY(-1px); text-decoration: none; }
.pipe-step .ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.pipe-step .ic svg { width: 18px; height: 18px; }
.pipe-txt { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.pipe-txt .k { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pipe-txt .s { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pipe-step .v { font-size: 26px; font-weight: 650; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.pipe-arrow { justify-self: center; width: 9px; height: 9px; border-top: 2px solid var(--border-strong); border-right: 2px solid var(--border-strong); transform: rotate(45deg); }
@media (max-width: 760px) {
    .pipe-steps { grid-template-columns: minmax(0, 1fr); gap: 0; }
    .pipe-arrow { transform: rotate(135deg); margin: 6px 0; }
    .pipe-sep { width: 100%; height: 1px; margin: 10px 0; }
}

/* Form Builder: "fill in later" marker */
.fb-later { flex: none; font-size: 10.5px; font-weight: 600; color: var(--st-pending); background: var(--st-pending-bg); border-radius: 999px; padding: 1px 8px; }

/* File links inside list tables */
.list-file { display: inline-flex; align-items: center; gap: 5px; max-width: 190px; color: var(--accent); text-decoration: none; }
.list-file svg { width: 14px; height: 14px; flex: none; }
.list-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-file:hover span { text-decoration: underline; }

/* "Send for approval" popup: choose the approver */
.ap-list { display: flex; flex-direction: column; gap: 6px; max-height: 340px; overflow-y: auto; margin: 0 -2px; padding: 2px; }
.ap-item { position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; transition: border-color .15s, background .15s; }
.ap-item[hidden] { display: none; }
.ap-item:hover { border-color: var(--border-strong); background: var(--surface-2); }
.ap-item input { position: absolute; opacity: 0; pointer-events: none; }
.ap-txt { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ap-txt b { font-weight: 600; font-size: 14px; }
.ap-txt span { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ap-item > svg { width: 18px; height: 18px; color: var(--accent); visibility: hidden; flex: none; }
.ap-item:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.ap-item:has(input:checked) > svg { visibility: visible; }
.ap-item:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
