/*
 * Rivercraft Workspace UI v1.6.5.2
 * Shared visual language for every Rivercraft application.
 * Additive/backward-compatible: does not change Core authority or routing.
 */
:root {
    --rc-control-h: 42px;
    --rc-control-h-sm: 34px;
    --rc-control-radius: 9px;
    --rc-card-radius: 13px;
    --rc-panel-pad: 16px;
    --rc-gap: 12px;
    --rc-gap-sm: 8px;
    --rc-surface-soft: #f8faf9;
    --rc-surface-muted: #f3f6f5;
    --rc-line-soft: #e9efee;
    --rc-shadow-xs: 0 1px 2px rgba(20,45,46,.025), 0 3px 10px rgba(20,45,46,.025);
}

body.rivercraft-shell .page-content .content {
    padding-bottom: 26px;
}

/* ---------- Shared panels/cards ---------- */
body.rivercraft-shell .rc-panel,
body.rivercraft-shell .grid.simple {
    border: 1px solid var(--rc-line, #e1e8e7);
    border-radius: var(--rc-card-radius);
    background: #fff;
    box-shadow: var(--rc-shadow-xs);
}

body.rivercraft-shell .grid.simple {
    overflow: visible;
}

body.rivercraft-shell .grid.simple .grid-title {
    min-height: 0;
    padding: 13px 15px 0;
    border: 0;
    background: transparent;
}

body.rivercraft-shell .grid.simple .grid-title h4,
body.rivercraft-shell .grid.simple .grid-title h3,
body.rivercraft-shell .grid.simple .grid-title h2 {
    margin: 0;
    color: var(--rc-ink-950);
    font-size: 15px;
    font-weight: 650;
    letter-spacing: -.015em;
}

body.rivercraft-shell .grid.simple .grid-body {
    padding: 14px 15px;
    border: 0;
    background: transparent;
}

body.rivercraft-shell .rc-panel {
    padding: var(--rc-panel-pad);
}

/* ---------- Universal button sizing ---------- */
body.rivercraft-shell .btn,
body.rivercraft-shell button.btn,
body.rivercraft-shell a.btn {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: var(--rc-control-h);
    height: var(--rc-control-h);
    margin: 0;
    padding: 0 13px;
    border-radius: var(--rc-control-radius);
    border-width: 1px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    box-shadow: none;
    white-space: nowrap;
}

body.rivercraft-shell .btn.btn-small,
body.rivercraft-shell .btn.btn-xs {
    min-height: var(--rc-control-h-sm);
    height: var(--rc-control-h-sm);
    padding: 0 10px;
    border-radius: 8px;
    font-size: 12px;
}

body.rivercraft-shell .btn .material-icons {
    margin: 0;
    font-size: 17px;
    line-height: 1;
}

body.rivercraft-shell .btn-primary,
body.rivercraft-shell .btn-success {
    border-color: var(--rc-river, #0e6f68);
    background: var(--rc-river, #0e6f68);
    color: #fff;
}

body.rivercraft-shell .btn-primary:hover,
body.rivercraft-shell .btn-primary:focus,
body.rivercraft-shell .btn-success:hover,
body.rivercraft-shell .btn-success:focus {
    border-color: var(--rc-river-dark, #0a514d);
    background: var(--rc-river-dark, #0a514d);
    color: #fff;
}

body.rivercraft-shell .btn-default,
body.rivercraft-shell .btn-white {
    border-color: var(--rc-line-strong, #d2dddb);
    background: #fff;
    color: var(--rc-ink-800, #294044);
}

body.rivercraft-shell .btn-default:hover,
body.rivercraft-shell .btn-white:hover {
    border-color: #bfcfcd;
    background: var(--rc-surface-soft);
    color: var(--rc-ink-950);
}

body.rivercraft-shell .btn-danger {
    border-color: #dfb8bb;
    background: #fff5f5;
    color: #a8343d;
}

body.rivercraft-shell .btn-danger:hover {
    border-color: #cf8f95;
    background: #fdebec;
    color: #922a32;
}

body.rivercraft-shell .rc-icon-button,
body.rivercraft-shell .inviu-icon-button {
    box-sizing: border-box;
    display: inline-grid;
    place-items: center;
    width: var(--rc-control-h);
    min-width: var(--rc-control-h);
    height: var(--rc-control-h);
    padding: 0;
    border: 1px solid var(--rc-line-strong);
    border-radius: var(--rc-control-radius);
    background: #fff;
    color: var(--rc-ink-600);
    box-shadow: none;
    cursor: pointer;
}

body.rivercraft-shell .rc-icon-button:hover,
body.rivercraft-shell .inviu-icon-button:hover {
    border-color: #bfcecc;
    background: var(--rc-surface-soft);
    color: var(--rc-ink-950);
}

body.rivercraft-shell .rc-icon-button .material-icons,
body.rivercraft-shell .inviu-icon-button .material-icons {
    font-size: 18px;
}

body.rivercraft-shell .rc-icon-button.is-danger,
body.rivercraft-shell .inviu-icon-button.is-danger {
    border-color: #eed5d7;
    color: #b33b44;
}

/* ---------- Inputs outside rc-field ---------- */
body.rivercraft-shell .form-control,
body.rivercraft-shell .rc-control,
body.rivercraft-shell .page-content input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]),
body.rivercraft-shell .page-content select,
body.rivercraft-shell .page-content textarea {
    box-sizing: border-box;
    border-color: var(--rc-line-strong, #d2dddb);
    border-radius: var(--rc-control-radius);
    box-shadow: none;
    outline: 0;
}

body.rivercraft-shell .page-content input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]),
body.rivercraft-shell .page-content select {
    min-height: var(--rc-control-h);
}

body.rivercraft-shell .page-content input:focus,
body.rivercraft-shell .page-content select:focus,
body.rivercraft-shell .page-content textarea:focus {
    border-color: #75aea8;
    box-shadow: 0 0 0 3px var(--rc-river-soft, #e8f4f2);
}

/* ---------- Compact toolbars ---------- */
.rc-page-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.rc-page-toolbar__title {
    min-width: 0;
}

.rc-page-toolbar__title small {
    display: block;
    margin-bottom: 2px;
    color: var(--rc-ink-500);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.rc-page-toolbar__title h2,
.rc-page-toolbar__title h3 {
    margin: 0;
    color: var(--rc-ink-950);
    font-size: 16px;
    font-weight: 650;
    letter-spacing: -.02em;
}

.rc-page-toolbar__actions {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
}

/* ---------- Compact statistics reusable by all apps ---------- */
.rc-stat-grid {
    display: grid;
    grid-template-columns: repeat(4,minmax(0,1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.rc-stat-card {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    min-height: 76px;
    padding: 12px 13px;
    border: 1px solid var(--rc-line);
    border-radius: 12px;
    background: #fff;
    box-shadow: var(--rc-shadow-xs);
}

.rc-stat-card__icon {
    display: grid;
    place-items: center;
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--rc-river-soft);
    color: var(--rc-river);
}

.rc-stat-card__icon .material-icons { font-size: 19px; }
.rc-stat-card__copy { min-width: 0; }
.rc-stat-card small { display: block; color: var(--rc-ink-500); font-size: 11px; }
.rc-stat-card strong { display: block; margin-top: 1px; color: var(--rc-ink-950); font-size: 18px; font-weight: 700; line-height: 1.15; }
.rc-stat-card em { display: block; margin-top: 2px; overflow: hidden; color: var(--rc-ink-500); font-size: 10px; font-style: normal; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Compact empty state ---------- */
body.rivercraft-shell .rc-empty-compact {
    display: grid;
    place-items: center;
    min-height: 110px;
    padding: 18px;
    text-align: center;
    color: var(--rc-ink-500);
}

body.rivercraft-shell .rc-empty-compact .material-icons { margin-bottom: 6px; font-size: 28px; color: #9ba8a6; }
body.rivercraft-shell .rc-empty-compact strong { display: block; color: var(--rc-ink-800); }
body.rivercraft-shell .rc-empty-compact span { display: block; margin-top: 3px; font-size: 12px; }

/* ---------- Rivercraft modal / form-dialog ---------- */
body.rc-modal-open {
    overflow: hidden !important;
}

.rc-modal[hidden] { display: none !important; }
.rc-modal {
    position: fixed;
    z-index: 5000;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 18px;
}

.rc-modal__backdrop {
    position: absolute;
    inset: 0;
    border: 0;
    background: rgba(13,27,29,.46);
    backdrop-filter: blur(2px);
}

.rc-modal__dialog {
    position: relative;
    z-index: 1;
    display: flex;
    width: min(620px,100%);
    max-height: min(86dvh,820px);
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(215,225,223,.96);
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 24px 70px rgba(15,35,36,.24);
}

.rc-modal__dialog.is-lg { width: min(820px,100%); }
.rc-modal__dialog.is-xl { width: min(1040px,100%); }

.rc-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex: 0 0 auto;
    min-height: 62px;
    padding: 12px 14px 12px 16px;
    border-bottom: 1px solid var(--rc-line-soft);
    background: #fff;
}

.rc-modal__title { min-width: 0; }
.rc-modal__title small { display: block; margin-bottom: 1px; color: var(--rc-ink-500); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.rc-modal__title h2,
.rc-modal__title h3 { margin: 0; overflow: hidden; color: var(--rc-ink-950); font-size: 18px; font-weight: 680; letter-spacing: -.025em; text-overflow: ellipsis; white-space: nowrap; }

.rc-modal__body {
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    padding: 16px;
    background: #fff;
}

.rc-modal__footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex: 0 0 auto;
    min-height: 62px;
    padding: 10px 16px;
    border-top: 1px solid var(--rc-line-soft);
    background: #fff;
}

.rc-modal__footer .btn { min-width: 98px; }
.rc-modal__close {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--rc-ink-500);
    cursor: pointer;
}
.rc-modal__close:hover { background: var(--rc-surface-muted); color: var(--rc-ink-950); }
.rc-modal__close .material-icons { font-size: 20px; }

.rc-modal__form { display: contents; }
.rc-modal__iframe { width: 100%; min-height: 62dvh; border: 0; background: #fff; }

/* ---------- Reduced App Center cards on narrow screens ---------- */
@media (max-width: 1024px) {
    body.rivercraft-shell .rc-application-card {
        min-height: 198px;
        padding: 16px;
    }
    body.rivercraft-shell .rc-card-body { padding-top: 15px; }
    body.rivercraft-shell .rc-app-icon { width: 42px; height: 42px; border-radius: 12px; }
    body.rivercraft-shell .rc-app-icon .material-icons { font-size: 23px; }
}

@media (max-width: 767px) {
    :root {
        --rc-control-h: 46px;
        --rc-control-h-sm: 40px;
        --rc-panel-pad: 12px;
        --rc-gap: 10px;
    }

    body.rivercraft-shell .page-content .content { padding-bottom: 18px; }
    body.rivercraft-shell .rc-panel,
    body.rivercraft-shell .grid.simple { border-radius: 12px; }
    body.rivercraft-shell .grid.simple .grid-title { padding: 11px 12px 0; }
    body.rivercraft-shell .grid.simple .grid-body { padding: 12px; }

    body.rivercraft-shell .btn,
    body.rivercraft-shell button.btn,
    body.rivercraft-shell a.btn {
        min-height: var(--rc-control-h);
        height: var(--rc-control-h);
        padding: 0 13px;
        font-size: 16px;
    }

    body.rivercraft-shell .btn.btn-small,
    body.rivercraft-shell .btn.btn-xs {
        min-height: var(--rc-control-h-sm);
        height: var(--rc-control-h-sm);
        font-size: 14px;
    }

    body.rivercraft-shell .rc-icon-button,
    body.rivercraft-shell .inviu-icon-button {
        width: var(--rc-control-h);
        min-width: var(--rc-control-h);
        height: var(--rc-control-h);
    }

    .rc-page-toolbar { align-items: stretch; flex-direction: column; }
    .rc-page-toolbar__actions { width: 100%; }
    .rc-page-toolbar__actions .btn { flex: 1 1 auto; }

    .rc-stat-grid {
        grid-template-columns: repeat(2,minmax(0,1fr));
        gap: 8px;
    }
    .rc-stat-card {
        min-height: 68px;
        padding: 9px 10px;
        gap: 8px;
    }
    .rc-stat-card__icon {
        flex-basis: 32px;
        width: 32px;
        height: 32px;
        border-radius: 9px;
    }
    .rc-stat-card__icon .material-icons { font-size: 17px; }
    .rc-stat-card small { font-size: 11px; }
    .rc-stat-card strong { font-size: 18px; }
    .rc-stat-card em { display: none; }

    body.rivercraft-shell .rc-application-card {
        min-height: 166px;
        padding: 14px;
        border-radius: 14px;
    }
    body.rivercraft-shell .rc-card-body { padding-top: 12px; }
    body.rivercraft-shell .rc-card-body > span {
        display: -webkit-box;
        overflow: hidden;
        margin-top: 6px;
        font-size: 13px;
        line-height: 1.45;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
    }
    body.rivercraft-shell .rc-card-foot { padding-top: 10px; }

    .rc-modal {
        align-items: end;
        padding: 8px;
    }
    .rc-modal__dialog,
    .rc-modal__dialog.is-lg,
    .rc-modal__dialog.is-xl {
        width: 100%;
        max-height: calc(100dvh - 16px);
        border-radius: 16px;
    }
    .rc-modal__header {
        min-height: 58px;
        padding: 10px 10px 10px 14px;
    }
    .rc-modal__body { padding: 13px; }
    .rc-modal__footer {
        min-height: 64px;
        padding: 9px 12px;
        padding-bottom: max(9px,env(safe-area-inset-bottom));
    }
    .rc-modal__footer .btn { flex: 1 1 auto; }
    .rc-modal__iframe { min-height: 72dvh; }
}

/* ========================================================================== */
/* Rivercraft Workspace UI v1.6.5.2 — Compact Professional Refresh          */
/* Shared density refinements for every application.                          */
/* ========================================================================== */

:root {
    --rc-panel-pad: 14px;
    --rc-gap: 10px;
    --rc-gap-sm: 6px;
    --rc-card-radius: 12px;
    --rc-shadow-xs: 0 1px 2px rgba(20,45,46,.018), 0 3px 8px rgba(20,45,46,.018);
}

/* Clear visual boundaries without heavy boxes. */
body.rivercraft-shell .rc-panel,
body.rivercraft-shell .grid.simple {
    border-color: #e4ebe9;
    box-shadow: var(--rc-shadow-xs);
}

body.rivercraft-shell .grid.simple .grid-title {
    padding: 11px 13px 0;
}

body.rivercraft-shell .grid.simple .grid-body {
    padding: 12px 13px 13px;
}

/* Search field is a global Rivercraft component, not page-specific. */
body.rivercraft-shell .rc-search-field {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    min-width: 0;
    width: 100%;
    height: var(--rc-control-h);
    margin: 0;
    padding: 0 10px;
    border: 1px solid var(--rc-line-strong, #d2dddb);
    border-radius: var(--rc-control-radius);
    background: #fff;
    transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}

body.rivercraft-shell .rc-search-field:focus-within {
    border-color: #75aea8;
    box-shadow: 0 0 0 3px var(--rc-river-soft, #e8f4f2);
}

body.rivercraft-shell .rc-search-field > .material-icons,
body.rivercraft-shell .rc-search-field > i {
    flex: 0 0 auto;
    margin: 0;
    color: var(--rc-ink-500, #718083);
    font-size: 18px;
    line-height: 1;
}

body.rivercraft-shell .rc-search-field input[type="search"],
body.rivercraft-shell .rc-search-field input[type="text"] {
    min-width: 0 !important;
    width: 100% !important;
    min-height: 0 !important;
    height: calc(var(--rc-control-h) - 2px) !important;
    margin: 0 !important;
    padding: 0 7px !important;
    border: 0 !important;
    border-radius: 0 !important;
    outline: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}

/* Compact stats: information first, card second. */
.rc-stat-grid {
    gap: 8px;
    margin-bottom: 10px;
}

.rc-stat-card {
    min-height: 66px;
    padding: 9px 11px;
    gap: 9px;
    border-radius: 11px;
}

.rc-stat-card__icon {
    flex-basis: 32px;
    width: 32px;
    height: 32px;
    border-radius: 9px;
}

.rc-stat-card__icon .material-icons { font-size: 17px; }
.rc-stat-card small { font-size: 10px; }
.rc-stat-card strong { font-size: 17px; }
.rc-stat-card em { margin-top: 1px; font-size: 9px; }

/* Empty states must not dominate an operational page. */
body.rivercraft-shell .rc-empty-compact {
    min-height: 76px;
    padding: 11px 14px;
}

body.rivercraft-shell .rc-empty-compact .material-icons {
    margin-bottom: 3px;
    font-size: 22px;
}

body.rivercraft-shell .rc-empty-compact strong {
    font-size: 12px;
    line-height: 1.25;
}

body.rivercraft-shell .rc-empty-compact span {
    margin-top: 2px;
    font-size: 10px;
    line-height: 1.35;
}

/* Toolbars stay on one professional baseline when space permits. */
.rc-page-toolbar {
    gap: 8px;
    margin-bottom: 9px;
}

.rc-page-toolbar__actions { gap: 6px; }

/* Form-dialog: less chrome, more usable form area. */
.rc-modal { padding: 14px; }

.rc-modal__dialog {
    width: min(580px,100%);
    max-height: min(88dvh,780px);
    border-radius: 14px;
    box-shadow: 0 18px 50px rgba(15,35,36,.20);
}

.rc-modal__dialog.is-lg { width: min(760px,100%); }
.rc-modal__dialog.is-xl { width: min(980px,100%); }

.rc-modal__header {
    min-height: 54px;
    padding: 9px 10px 9px 14px;
}

.rc-modal__title small { font-size: 9px; }
.rc-modal__title h2,
.rc-modal__title h3 { font-size: 16px; }

.rc-modal__body { padding: 13px 14px; }

.rc-modal__footer {
    min-height: 54px;
    padding: 8px 14px;
    gap: 7px;
}

.rc-modal__footer .btn { min-width: 88px; }

.rc-modal__close {
    width: 34px;
    height: 34px;
    border-radius: 9px;
}

.rc-modal__close .material-icons { font-size: 18px; }

/* Native checkbox/radio baseline for modern Rivercraft forms. */
body.rivercraft-shell .rc-check-input,
body.rivercraft-shell .inviu-permission-checks input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    box-sizing: border-box;
    display: inline-grid;
    place-content: center;
    flex: 0 0 18px;
    width: 18px !important;
    min-width: 18px !important;
    height: 18px !important;
    min-height: 18px !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 1.5px solid #b9c7c5 !important;
    border-radius: 5px !important;
    background: #fff !important;
    box-shadow: none !important;
    cursor: pointer;
}

body.rivercraft-shell .rc-check-input::before,
body.rivercraft-shell .inviu-permission-checks input[type="checkbox"]::before {
    content: "";
    width: 9px;
    height: 5px;
    transform: rotate(-45deg) scale(0);
    transform-origin: center;
    border-bottom: 2px solid #fff;
    border-left: 2px solid #fff;
    transition: transform .12s ease;
}

body.rivercraft-shell .rc-check-input:checked,
body.rivercraft-shell .inviu-permission-checks input[type="checkbox"]:checked {
    border-color: var(--rc-river, #0e6f68) !important;
    background: var(--rc-river, #0e6f68) !important;
}

body.rivercraft-shell .rc-check-input:checked::before,
body.rivercraft-shell .inviu-permission-checks input[type="checkbox"]:checked::before {
    transform: rotate(-45deg) scale(1);
}

body.rivercraft-shell .rc-check-input:disabled,
body.rivercraft-shell .inviu-permission-checks input[type="checkbox"]:disabled {
    cursor: not-allowed;
    opacity: .58;
}

@media (max-width: 1024px) {
    .rc-stat-card { min-height: 62px; }
}

@media (max-width: 767px) {
    :root {
        --rc-panel-pad: 11px;
        --rc-gap: 8px;
    }

    body.rivercraft-shell .grid.simple .grid-title { padding: 10px 11px 0; }
    body.rivercraft-shell .grid.simple .grid-body { padding: 10px 11px 11px; }

    .rc-stat-grid { gap: 6px; margin-bottom: 8px; }
    .rc-stat-card {
        min-height: 58px;
        padding: 7px 8px;
        gap: 7px;
    }
    .rc-stat-card__icon {
        flex-basis: 29px;
        width: 29px;
        height: 29px;
        border-radius: 8px;
    }
    .rc-stat-card__icon .material-icons { font-size: 16px; }
    .rc-stat-card small { font-size: 10px; }
    .rc-stat-card strong { font-size: 16px; }

    body.rivercraft-shell .rc-empty-compact {
        min-height: 66px;
        padding: 10px;
    }
    body.rivercraft-shell .rc-empty-compact .material-icons { font-size: 20px; }
    body.rivercraft-shell .rc-empty-compact span { font-size: 11px; }

    .rc-page-toolbar { margin-bottom: 8px; }

    .rc-modal {
        align-items: end;
        padding: 6px;
    }
    .rc-modal__dialog,
    .rc-modal__dialog.is-lg,
    .rc-modal__dialog.is-xl {
        max-height: calc(100dvh - 12px);
        border-radius: 14px;
    }
    .rc-modal__header {
        min-height: 52px;
        padding: 8px 8px 8px 12px;
    }
    .rc-modal__body { padding: 11px 12px; }
    .rc-modal__footer {
        min-height: 58px;
        padding: 7px 10px;
        padding-bottom: max(7px,env(safe-area-inset-bottom));
    }
}
