/* =========================================================================
   Notes dashboard — holy-grail shell, light and dark.
   Based on XFY Email dashboard design system (xfy-* classes).
   ========================================================================= */

:root {
    --xfy-nav-width: 272px;
    --xfy-nav-collapsed: 72px;
    --xfy-header-h: 60px;
    --xfy-radius: 1.125rem;
    --xfy-radius-sm: 0.65rem;

    /* Light palette — Notes green brand tokens. */
    --xfy-brand: #16a34a;
    --xfy-brand-dark: #15803d;
    --xfy-brand-soft: #f0fdf4;
    --xfy-accent: #16a34a;

    --xfy-bg: #f4f6f8;
    --xfy-surface: #ffffff;
    --xfy-card: #ffffff;
    --xfy-surface-2: #fafbfc;
    --xfy-border: #e3e6ea;
    --xfy-text: #14161a;
    --xfy-text-muted: #6b7280;

    --xfy-ok: #047857;
    --xfy-ok-bg: #ecfdf5;
    --xfy-warn: #b45309;
    --xfy-warn-bg: #fffbeb;
    --xfy-bad: #dc2626;
    --xfy-bad-bg: #fef2f2;

    --xfy-shadow: 0 14px 44px rgba(15, 23, 42, 0.18), 0 4px 14px rgba(15, 23, 42, 0.1);
    --xfy-shadow-sm: 0 3px 10px rgba(15, 23, 42, 0.14);
    --xfy-shadow-card: 0 10px 32px rgba(15, 23, 42, 0.14), 0 2px 8px rgba(15, 23, 42, 0.08);
}

html[data-bs-theme="dark"] {
    --xfy-brand: #4ade80;
    --xfy-brand-dark: #22c55e;
    --xfy-brand-soft: #14532d;
    --xfy-accent: #4ade80;

    --xfy-bg: #000000;
    --xfy-surface: #0d0d0d;
    --xfy-card: #2a2a2a;
    --xfy-surface-2: #1a1a1a;
    --xfy-border: #3a3a3a;
    --xfy-text: #f0f0f0;
    --xfy-text-muted: #a6a6a6;

    --xfy-ok: #6ee7b7;
    --xfy-ok-bg: rgba(6, 95, 70, 0.28);
    --xfy-warn: #fcd34d;
    --xfy-warn-bg: rgba(146, 64, 14, 0.28);
    --xfy-bad: #fca5a5;
    --xfy-bad-bg: rgba(153, 27, 27, 0.28);

    --xfy-shadow: 0 16px 48px rgba(0, 0, 0, 0.55), 0 4px 16px rgba(0, 0, 0, 0.35);
    --xfy-shadow-sm: 0 3px 12px rgba(0, 0, 0, 0.45);
    --xfy-shadow-card: 0 12px 36px rgba(0, 0, 0, 0.45), 0 2px 10px rgba(0, 0, 0, 0.3);

    color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    color: var(--xfy-text);
    background: var(--xfy-bg);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--xfy-accent); text-decoration: none; }
a:hover { text-decoration: none; color: var(--xfy-brand-dark); }

/* ---------------------------------------------------------------- topbar -- */

.xfy-topbar {
    height: var(--xfy-header-h);
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0 1rem;
    background: var(--xfy-surface);
    border-bottom: 1px solid var(--xfy-border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.xfy-brand {
    display: inline-flex;
    align-items: baseline;
    gap: 0.1rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    font-size: 1.02rem;
    color: var(--xfy-text);
}

.xfy-brand:hover { text-decoration: none; }
.xfy-brand span { color: var(--xfy-brand); }

.xfy-brand-sub {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--xfy-text-muted);
    padding-left: 0.5rem;
    border-left: 1px solid var(--xfy-border);
    margin-left: 0.35rem;
}

.xfy-topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.xfy-who {
    text-align: right;
    line-height: 1.25;
    min-width: 0;
}

.xfy-who-name {
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 15rem;
}

.xfy-who-role { font-size: 0.72rem; color: var(--xfy-text-muted); }

/* Icon buttons: theme toggle, mobile nav trigger, sign out. */
.xfy-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 1px solid var(--xfy-border);
    border-radius: 0.6rem;
    background: var(--xfy-surface-2);
    color: var(--xfy-text);
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.xfy-icon-btn:hover {
    background: var(--xfy-brand-soft);
    border-color: var(--xfy-brand);
    color: var(--xfy-brand);
    text-decoration: none;
}

.xfy-icon-btn--wide { width: auto; padding: 0 0.7rem; font-size: 0.82rem; font-weight: 600; }

/* The two glyphs swap by theme, so the button always shows the destination. */
.xfy-theme-toggle .xfy-theme-dark-icon { display: none; }
html[data-bs-theme="dark"] .xfy-theme-toggle .xfy-theme-dark-icon { display: inline; }
html[data-bs-theme="dark"] .xfy-theme-toggle .xfy-theme-light-icon { display: none; }

.xfy-mobile-nav-trigger { display: none; }

/* ----------------------------------------------------------------- shell -- */

.xfy-shell {
    display: flex;
    align-items: stretch;
    gap: 0.85rem;
    width: 100%;
    height: calc(100dvh - var(--xfy-header-h));
    max-height: calc(100dvh - var(--xfy-header-h));
    min-height: 0;
    overflow: hidden;
    padding: 0.6rem 0.85rem 0.75rem;
}

/* ------------------------------------------------------------- left nav -- */

.xfy-nav {
    flex: 0 0 var(--xfy-nav-width);
    width: var(--xfy-nav-width);
    min-width: var(--xfy-nav-width);
    align-self: stretch;
    height: 100%;
    max-height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--xfy-card);
    border: none;
    border-radius: var(--xfy-radius);
    box-shadow: var(--xfy-shadow);
    overflow: hidden;
    transition: width 0.22s ease, min-width 0.22s ease, flex-basis 0.22s ease;
    z-index: 5;
}

.xfy-nav-inner {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

.xfy-nav-header {
    flex-shrink: 0;
    text-align: center;
    padding: 1rem 0.75rem 0.5rem;
}

.xfy-avatar {
    width: 56px;
    height: 56px;
    margin: 0 auto 0.45rem;
    border-radius: 50%;
    border: 3px solid var(--xfy-brand-soft);
    background: var(--xfy-brand);
    color: #fff;
    font-weight: 700;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
}

.xfy-nav-header-text {
    font-weight: 700;
    color: var(--xfy-brand);
    font-size: 0.95rem;
    line-height: 1.25;
    word-break: break-word;
}

.xfy-nav-header-sub { font-size: 0.76rem; color: var(--xfy-text-muted); }

.xfy-nav-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.35rem 0 1.25rem;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}

.xfy-nav-section {
    padding: 0.55rem 1rem 0.25rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--xfy-text-muted);
}

.xfy-nav-list {
    list-style: none;
    margin: 0;
    padding: 0.15rem 0 0.5rem;
}

.xfy-nav-list a {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.62rem 1rem;
    color: var(--xfy-text);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.92rem;
    border-left: 3px solid transparent;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.xfy-nav-list a:hover,
.xfy-nav-list a.active {
    background: rgba(22, 163, 74, 0.12);
    color: var(--xfy-brand);
    border-left-color: var(--xfy-brand);
    text-decoration: none;
}

html[data-bs-theme="dark"] .xfy-nav-list a:hover,
html[data-bs-theme="dark"] .xfy-nav-list a.active {
    background: rgba(74, 222, 128, 0.18);
}

.xfy-nav-list a.is-danger { color: var(--xfy-bad); }

.xfy-nav-list a.is-danger:hover {
    background: var(--xfy-bad-bg);
    border-left-color: var(--xfy-bad);
    color: var(--xfy-bad);
}

.xfy-nav-ico {
    width: 1.15rem;
    flex-shrink: 0;
    text-align: center;
    opacity: 0.9;
}

.xfy-nav-label {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.xfy-nav-count {
    margin-left: auto;
    flex-shrink: 0;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
    background: var(--xfy-surface-2);
    color: var(--xfy-text-muted);
}

.xfy-nav-footer {
    flex-shrink: 0;
    margin-top: auto;
    padding: 0.6rem 0.75rem 0.85rem;
}

.xfy-nav-footer-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 0.5rem;
}

.xfy-nav-info-btn {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 999px;
    background: var(--xfy-brand-soft);
    color: var(--xfy-brand);
    font-size: 1.05rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.xfy-nav-info-btn:hover { background: rgba(22, 163, 74, 0.22); color: var(--xfy-brand-dark); }

html[data-bs-theme="dark"] .xfy-nav-info-btn {
    background: rgba(22, 163, 74, 0.25);
    color: #fed7aa;
}

.xfy-info-panel {
    position: fixed;
    z-index: 1200;
    left: calc(var(--xfy-nav-width) + 0.75rem);
    bottom: 1rem;
    max-width: min(22rem, calc(100vw - var(--xfy-nav-width) - 2rem));
}

.xfy-shell.is-sidebar-collapsed .xfy-info-panel {
    left: calc(var(--xfy-nav-collapsed) + 0.75rem);
    max-width: min(22rem, calc(100vw - var(--xfy-nav-collapsed) - 2rem));
}

.xfy-info-panel-inner {
    background: var(--xfy-card);
    border: 1px solid var(--xfy-border);
    border-radius: var(--xfy-radius-sm);
    box-shadow: var(--xfy-shadow);
    padding: 1rem 1.1rem;
}

.xfy-info-panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.65rem;
}

.xfy-info-panel-head h2 { margin: 0; font-size: 1rem; }

.xfy-info-panel-body { font-size: 0.88rem; line-height: 1.55; margin-bottom: 0.75rem; }

.xfy-info-panel-meta { margin: 0; font-size: 0.76rem; }

.xfy-info-panel-edit { margin: 0.65rem 0 0; font-size: 0.82rem; }

.xfy-snippet pre { margin: 0; padding: 0; background: transparent; border: none; }
.xfy-snippet code.hljs {
    display: block;
    padding: 0.65rem 0.75rem;
    max-height: 14rem;
    overflow: auto;
    border-radius: 0.45rem;
    font-size: 0.72rem;
    line-height: 1.45;
}

.xfy-key-flash-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 8px;
}

@media (max-width: 992px) {
    .xfy-info-panel {
        left: 0.75rem;
        max-width: calc(100vw - 1.5rem);
    }
}

.xfy-nav-toggle {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    width: 2.25rem;
    height: 2.25rem;
    margin: 0 0 0.5rem 0;
    padding: 0;
    border: none;
    border-radius: 0.55rem;
    background: rgba(22, 163, 74, 0.10);
    color: var(--xfy-brand-dark);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.xfy-nav-toggle:hover { background: rgba(22, 163, 74, 0.2); color: var(--xfy-brand); }

html[data-bs-theme="dark"] .xfy-nav-toggle {
    background: rgba(74, 222, 128, 0.18);
    color: #fed7aa;
}

.xfy-nav-version {
    font-size: 0.7rem;
    color: var(--xfy-text-muted);
    text-align: left;
    padding-left: 0.15rem;
}

/* -------------------------------------------------------------- collapsed -- */

.xfy-shell.is-sidebar-collapsed .xfy-nav {
    flex-basis: var(--xfy-nav-collapsed);
    width: var(--xfy-nav-collapsed);
    min-width: var(--xfy-nav-collapsed);
}

.xfy-shell.is-sidebar-collapsed .xfy-nav-label,
.xfy-shell.is-sidebar-collapsed .xfy-nav-section,
.xfy-shell.is-sidebar-collapsed .xfy-nav-header-text,
.xfy-shell.is-sidebar-collapsed .xfy-nav-header-sub,
.xfy-shell.is-sidebar-collapsed .xfy-nav-count,
.xfy-shell.is-sidebar-collapsed .xfy-nav-toggle-label,
.xfy-shell.is-sidebar-collapsed .xfy-nav-version,
.xfy-shell.is-sidebar-collapsed .xfy-nav-info-btn {
    display: none !important;
}

.xfy-shell.is-sidebar-collapsed .xfy-nav-list a {
    justify-content: center;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

.xfy-shell.is-sidebar-collapsed .xfy-avatar { width: 40px; height: 40px; font-size: 1rem; }

.xfy-shell.is-sidebar-collapsed .xfy-nav-toggle {
    width: calc(100% - 0.9rem);
    margin-left: 0.45rem;
    margin-right: 0.45rem;
}

/* ----------------------------------------------------------- main column -- */

.xfy-main {
    flex: 1 1 auto;
    min-width: 0;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 100%;
    min-height: 0;
    overflow: hidden;
}

.xfy-main-inner {
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    max-height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 0.35rem 0.5rem 2.5rem 0.15rem;
}

/* ------------------------------------------------------------- typography -- */

.xfy-page-head { margin-bottom: 1.1rem; }

.xfy-page-head-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.xfy-page-head-row h1 { margin: 0; }

h1 { font-size: 1.4rem; margin: 0 0 0.2rem; letter-spacing: -0.02em; }
h2 { font-size: 1.02rem; margin: 1.6rem 0 0.6rem; }
h3 { font-size: 0.9rem; margin: 1.1rem 0 0.5rem; }

.xfy-sub { color: var(--xfy-text-muted); margin: 0; font-size: 0.88rem; }

code, .mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.8rem;
}

code {
    background: var(--xfy-surface-2);
    border: 1px solid var(--xfy-border);
    border-radius: 0.35rem;
    padding: 0.08rem 0.3rem;
}

/* ------------------------------------------------------------------ cards -- */

.xfy-card {
    background: var(--xfy-card);
    border: 1px solid var(--xfy-border);
    border-radius: var(--xfy-radius);
    padding: 1rem;
    box-shadow: var(--xfy-shadow-card);
}

html[data-bs-theme="dark"] .xfy-card { border-color: var(--xfy-border); }

.xfy-grid {
    display: grid;
    gap: 0.85rem;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.xfy-metric .n {
    font-size: 1.6rem;
    font-weight: 650;
    letter-spacing: -0.03em;
    line-height: 1.15;
}

a.xfy-metric-link {
    color: inherit;
    text-decoration: none;
}

a.xfy-metric-link:hover {
    color: var(--xfy-accent);
    text-decoration: underline;
}

.xfy-metric .l { color: var(--xfy-text-muted); font-size: 0.8rem; }

.xfy-delta { font-size: 0.74rem; }
.xfy-delta.up { color: var(--xfy-ok); }
.xfy-delta.down { color: var(--xfy-bad); }

.xfy-bars { display: flex; align-items: flex-end; gap: 2px; height: 90px; }

.xfy-bars div {
    flex: 1;
    background: var(--xfy-brand);
    border-radius: 2px 2px 0 0;
    min-height: 2px;
    opacity: 0.85;
}

.xfy-bars div.err { background: var(--xfy-bad); }

/* ----------------------------------------------------------------- tables -- */

.xfy-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--xfy-border);
    border-radius: var(--xfy-radius-sm);
    background: var(--xfy-card);
}

table.xfy-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--xfy-card);
    min-width: 34rem;
}

.xfy-table th,
.xfy-table td {
    text-align: left;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--xfy-border);
    font-size: 0.86rem;
    vertical-align: middle;
}

.xfy-table th {
    background: var(--xfy-surface-2);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--xfy-text-muted);
    white-space: nowrap;
}

.xfy-table tr:last-child td { border-bottom: none; }
.xfy-table tbody tr:hover td { background: var(--xfy-surface-2); }

.xfy-empty { color: var(--xfy-text-muted); padding: 1.75rem; text-align: center; }

/* ------------------------------------------------------------------ pills -- */

.xfy-pill {
    display: inline-block;
    padding: 0.12rem 0.5rem;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 600;
    white-space: nowrap;
}

.xfy-pill.ok { background: var(--xfy-ok-bg); color: var(--xfy-ok); }
.xfy-pill.warn { background: var(--xfy-warn-bg); color: var(--xfy-warn); }
.xfy-pill.bad { background: var(--xfy-bad-bg); color: var(--xfy-bad); }
.xfy-pill.neutral { background: var(--xfy-surface-2); color: var(--xfy-text-muted); }
.xfy-pill.accent { background: rgba(22, 163, 74, 0.14); color: var(--xfy-brand); }

/* ---------------------------------------------------------------- flashes -- */

.xfy-flash {
    padding: 0.7rem 0.9rem;
    border-radius: 0.55rem;
    margin-bottom: 1rem;
    font-size: 0.88rem;
}

.xfy-flash.err { background: var(--xfy-bad-bg); color: var(--xfy-bad); border: 1px solid var(--xfy-bad); }
.xfy-flash.ok { background: var(--xfy-ok-bg); color: var(--xfy-ok); border: 1px solid var(--xfy-ok); }
.xfy-flash.key { background: var(--xfy-warn-bg); color: var(--xfy-warn); border: 1px solid var(--xfy-warn); }

/* ------------------------------------------------------------------ forms -- */

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

label { display: block; font-size: 0.8rem; font-weight: 600; margin-bottom: 0.25rem; }

.xfy-hint { font-size: 0.76rem; color: var(--xfy-text-muted); font-weight: 400; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=search], input[type=url], input[type=tel], select, textarea {
    width: 100%;
    max-width: 26rem;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--xfy-border);
    border-radius: var(--xfy-radius-sm);
    background: var(--xfy-surface);
    color: var(--xfy-text);
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
    transition: border-color 0.15s, box-shadow 0.15s;
}

select,
.xfy-select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 2.25rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7280' d='M1.4.4 6 5l4.6-4.6L12 2.8 6 8.8 0 2.8z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 0.65rem;
    cursor: pointer;
}

html[data-bs-theme="dark"] select,
html[data-bs-theme="dark"] .xfy-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23a6a6a6' d='M1.4.4 6 5l4.6-4.6L12 2.8 6 8.8 0 2.8z'/%3E%3C/svg%3E");
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--xfy-brand);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--xfy-brand) 22%, transparent);
}

.xfy-field { margin-bottom: 0.9rem; }

.xfy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 0.9rem;
    border-radius: 0.55rem;
    border: 1px solid var(--xfy-brand);
    background: var(--xfy-brand);
    color: #fff;
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    transition: filter 0.15s;
}

.xfy-btn:hover { filter: brightness(0.94); text-decoration: none; color: #fff; }

html[data-bs-theme="dark"] .xfy-btn { color: #fff; }
html[data-bs-theme="dark"] .xfy-btn:hover { color: #fff; }

.xfy-btn.ghost {
    background: var(--xfy-surface);
    color: var(--xfy-brand);
    border-color: rgba(22, 163, 74, 0.35);
}

.xfy-btn.ghost:hover { background: var(--xfy-brand-soft); color: var(--xfy-brand-dark); }

html[data-bs-theme="dark"] .xfy-btn.ghost {
    color: var(--xfy-brand);
    border-color: rgba(74, 222, 128, 0.45);
}

html[data-bs-theme="dark"] .xfy-btn.ghost:hover {
    color: #ffedd5;
    background: rgba(22, 163, 74, 0.18);
}

.xfy-btn.danger { background: #dc2626; border-color: #b91c1c; color: #fff; }
.xfy-btn.danger:hover { background: #b91c1c; filter: none; color: #fff; }
html[data-bs-theme="dark"] .xfy-btn.danger { background: #ef4444; border-color: #dc2626; color: #fff; }
html[data-bs-theme="dark"] .xfy-btn.danger:hover { background: #dc2626; color: #fff; }

.xfy-btn.sm { padding: 0.3rem 0.6rem; font-size: 0.78rem; }

.xfy-row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.xfy-row.end { justify-content: flex-end; }
.xfy-spacer { flex: 1 1 auto; }

.xfy-actions-inline {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.35rem;
    align-items: center;
    white-space: nowrap;
}

.xfy-actions-inline form { margin: 0; display: inline-flex; }

.xfy-form-grid {
    display: grid;
    gap: 0.85rem;
    margin-bottom: 0.9rem;
}

.xfy-form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.xfy-form-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.xfy-field-card {
    margin: 0;
    padding: 0.85rem 1rem;
    box-shadow: none;
}

.xfy-field-card label { margin-bottom: 0.35rem; }
.xfy-field-card input,
.xfy-field-card select { max-width: none; }

.xfy-snippet-grid {
    display: grid;
    gap: 0.85rem;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 1.5rem;
}

.xfy-snippet-card { padding: 0.75rem 0.85rem; }
.xfy-snippet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.xfy-snippet {
    margin: 0;
    padding: 0.65rem 0.75rem;
    max-height: 14rem;
    overflow: auto;
    background: var(--xfy-surface-2);
    border: 1px solid var(--xfy-border);
    border-radius: 0.45rem;
    font-size: 0.72rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

/* --------------------------------------------------- permission checklist -- */

.xfy-perm-group { margin-bottom: 1.1rem; }

.xfy-perm-group > h3 {
    margin: 0 0 0.5rem;
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--xfy-text-muted);
}

.xfy-perm-list { display: grid; gap: 0.5rem; }

.xfy-perm {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--xfy-border);
    border-radius: 0.55rem;
    background: var(--xfy-surface);
}

.xfy-perm input[type=checkbox] { width: auto; margin-top: 0.2rem; flex-shrink: 0; }
.xfy-perm-body { min-width: 0; }
.xfy-perm-name { font-size: 0.86rem; font-weight: 600; }
.xfy-perm-desc { font-size: 0.78rem; color: var(--xfy-text-muted); }
.xfy-perm-slug { font-size: 0.72rem; color: var(--xfy-text-muted); }

.xfy-perm.from-role { border-color: var(--xfy-brand); background: rgba(22, 163, 74, 0.06); }
.xfy-perm.is-denied { border-color: var(--xfy-bad); background: var(--xfy-bad-bg); }

.xfy-effect { display: flex; gap: 0.35rem; align-items: center; margin-left: auto; flex-shrink: 0; }

.xfy-effect select { max-width: 8rem; padding: 0.25rem 0.4rem; font-size: 0.78rem; }

/* ------------------------------------------------------------------ login -- */

.xfy-login-wrap {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: var(--xfy-bg);
}

.xfy-login {
    width: 100%;
    max-width: 23rem;
    background: var(--xfy-card);
    border: 1px solid var(--xfy-border);
    border-radius: var(--xfy-radius);
    box-shadow: var(--xfy-shadow);
    padding: 1.5rem;
}

.xfy-login h1 { font-size: 1.15rem; }
.xfy-login input { max-width: none; }
.xfy-login .xfy-btn { width: 100%; margin-top: 0.35rem; }

.xfy-login-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

/* --------------------------------------------------------------- forbidden -- */

.xfy-forbidden {
    max-width: 30rem;
    margin: 4rem auto;
    text-align: center;
    padding: 1.5rem;
}

.xfy-forbidden .xfy-code {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--xfy-text-muted);
    letter-spacing: -0.03em;
}

/* ---------------------------------------------------------------- responsive
   992px is the same breakpoint SHEFA uses, so the two products change shape at
   the same width. Below it the shell stops being a fixed-height two-pane layout
   and becomes an ordinary scrolling page with a collapsible nav drawer.        */

@media (min-width: 992px) and (max-width: 1199.98px) {
    :root { --xfy-nav-width: 248px; }
    .xfy-main-inner { padding-right: 0.35rem; }
}

@media (min-width: 1200px) and (max-width: 1399.98px) {
    :root { --xfy-nav-width: 260px; }
}

@media (max-width: 991.98px) {
    body { height: auto; }

    .xfy-shell {
        flex-direction: column;
        height: auto;
        max-height: none;
        overflow: visible;
        padding: 0.6rem 0.75rem 1.5rem;
    }

    .xfy-mobile-nav-trigger { display: inline-flex; }

    /* Collapsed on desktop must not leak into the mobile drawer. */
    .xfy-shell.is-sidebar-collapsed .xfy-nav {
        flex-basis: auto;
        width: 100%;
        min-width: 0;
    }

    .xfy-shell.is-sidebar-collapsed .xfy-nav-label,
    .xfy-shell.is-sidebar-collapsed .xfy-nav-section,
    .xfy-shell.is-sidebar-collapsed .xfy-nav-header-text,
    .xfy-shell.is-sidebar-collapsed .xfy-nav-header-sub,
    .xfy-shell.is-sidebar-collapsed .xfy-nav-count,
    .xfy-shell.is-sidebar-collapsed .xfy-nav-version {
        display: revert !important;
    }

    .xfy-shell.is-sidebar-collapsed .xfy-nav-list a {
        justify-content: flex-start;
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .xfy-nav {
        display: none;
        width: 100%;
        min-width: 0;
        flex: none;
        height: auto;
        max-height: none;
        margin-bottom: 0.75rem;
    }

    .xfy-shell.is-mobile-nav-open .xfy-nav { display: flex; }

    .xfy-nav-scroll { overflow: visible; max-height: none; }
    .xfy-nav-toggle { display: none; }

    .xfy-main,
    .xfy-main-inner {
        height: auto;
        max-height: none;
        overflow: visible;
        min-height: 0;
    }

    .xfy-main-inner { padding: 0 0 1.5rem; }

    .xfy-who { display: none; }
    .xfy-brand-sub { display: none; }

    h1 { font-size: 1.2rem; }
    .xfy-table th, .xfy-table td { padding: 0.5rem 0.6rem; }
    input[type=text], input[type=email], input[type=password], input[type=number],
    input[type=search], select, textarea { max-width: none; }
}

@media (max-width: 900px) {
    .xfy-form-grid-3,
    .xfy-form-grid-2,
    .xfy-snippet-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
    .xfy-topbar { padding: 0 0.7rem; gap: 0.5rem; }
    .xfy-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
    .xfy-metric .n { font-size: 1.35rem; }
    .xfy-effect { margin-left: 0; width: 100%; }
    .xfy-perm { flex-wrap: wrap; }
}

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

.xfy-user-menu { position: relative; }
.xfy-user-dropdown {
  position: absolute; right: 0; top: calc(100% + 0.35rem); min-width: 14rem;
  background: var(--xfy-card); border: 1px solid var(--xfy-border); border-radius: 0.65rem;
  box-shadow: var(--xfy-shadow); padding: 0.35rem 0; z-index: 30;
}
.xfy-user-dropdown[hidden] { display: none !important; }
.xfy-user-dropdown-head { padding: 0.65rem 0.85rem 0.5rem; border-bottom: 1px solid var(--xfy-border); margin-bottom: 0.25rem; }
.xfy-user-dropdown a, .xfy-user-dropdown-theme {
  display: flex; align-items: center; gap: 0.55rem; width: 100%;
  padding: 0.55rem 0.85rem; border: none; background: transparent; color: var(--xfy-text);
  font: inherit; text-align: left; cursor: pointer; text-decoration: none;
}
.xfy-user-dropdown a:hover, .xfy-user-dropdown-theme:hover { background: var(--xfy-brand-soft); color: var(--xfy-brand); }
.xfy-user-dropdown a.is-danger { color: var(--xfy-bad); }
.xfy-nav-toggle-icon { width: 2.25rem; height: 2.25rem; padding: 0; margin: 0 0 0.5rem 0; border-radius: 0.55rem; }
.xfy-nav-expand-icon { display: none; }
.xfy-shell.is-sidebar-collapsed .xfy-nav-collapse-icon { display: none; }
.xfy-shell.is-sidebar-collapsed .xfy-nav-expand-icon { display: inline; }

/* Printing a delivery or an audit view should not waste a page on the nav. */
@media print {
    .xfy-topbar, .xfy-nav { display: none !important; }
    .xfy-shell { display: block; height: auto; max-height: none; padding: 0; }
    .xfy-main, .xfy-main-inner { height: auto; max-height: none; overflow: visible; }
}

.xfy-segment { display: inline-flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0; }
.xfy-segment-btn {
    display: inline-flex;
    align-items: center;
    padding: 0.4rem 0.85rem;
    border-radius: 999px;
    border: 1px solid var(--xfy-border);
    background: var(--xfy-surface);
    color: var(--xfy-text);
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    box-shadow: var(--xfy-shadow-sm);
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.xfy-segment-btn:hover { background: var(--xfy-brand-soft); text-decoration: none; }
.xfy-segment-btn.is-active { background: var(--xfy-brand); border-color: var(--xfy-brand); color: #fff; }

.xfy-metric-static { cursor: default; }
.xfy-card-link { display: block; color: inherit; text-decoration: none; }
.xfy-card-link:hover { text-decoration: none; box-shadow: var(--xfy-shadow); border-color: var(--xfy-brand); }
.xfy-card-link-title { font-weight: 700; margin-bottom: 0.35rem; }

.xfy-chart-line svg { width: 100%; height: 120px; display: block; }
.xfy-chart-line-grid { stroke: var(--xfy-border); stroke-width: 1; }
.xfy-chart-line-total { stroke: var(--xfy-brand); stroke-width: 2.5; }
.xfy-chart-line-err { stroke: var(--xfy-bad); stroke-width: 1.5; stroke-dasharray: 4 3; }
.xfy-chart-legend { display: flex; flex-wrap: wrap; gap: 1rem; font-size: 0.8rem; color: var(--xfy-text-muted); margin-top: 0.65rem; }
.xfy-swatch { display: inline-block; width: 0.65rem; height: 0.65rem; border-radius: 2px; margin-right: 0.35rem; vertical-align: middle; }
.xfy-swatch-total { background: var(--xfy-brand); }
.xfy-swatch-err { background: var(--xfy-bad); }

.xfy-chart-donut-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 1.5rem; }
.xfy-chart-donut { position: relative; width: 140px; height: 140px; border-radius: 50%; }
.xfy-donut-hole {
    position: absolute; inset: 22%; border-radius: 50%; background: var(--xfy-card);
    display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
}
.xfy-donut-hole .n { font-weight: 800; font-size: 1.1rem; line-height: 1.1; }
.xfy-donut-hole .l { font-size: 0.65rem; color: var(--xfy-text-muted); text-transform: uppercase; }
.xfy-donut-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.45rem; font-size: 0.85rem; }
.xfy-donut-legend li { display: flex; align-items: center; gap: 0.35rem; }

select.xfy-enhance-select { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.xfy-select-wrap { position: relative; max-width: 420px; }
.xfy-select-trigger {
    display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; width: 100%;
    padding: 0.55rem 0.75rem; border: 1px solid var(--xfy-border); border-radius: var(--xfy-radius-sm);
    background: var(--xfy-surface); color: var(--xfy-text); font: inherit; cursor: pointer; text-align: left;
}
.xfy-select-menu {
    position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 25; max-height: 240px; overflow: auto;
    background: var(--xfy-card); border: 1px solid var(--xfy-border); border-radius: var(--xfy-radius-sm); box-shadow: var(--xfy-shadow); padding: 0.35rem 0;
}
.xfy-select-menu[hidden] { display: none !important; }
.xfy-select-option {
    display: block; width: 100%; padding: 0.5rem 0.75rem; border: none; background: transparent;
    color: var(--xfy-text); font: inherit; text-align: left; cursor: pointer;
}
.xfy-select-option:hover, .xfy-select-option.is-selected { background: var(--xfy-brand-soft); color: var(--xfy-brand); }

.xfy-check-grid { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; }
.xfy-check { font-weight: 400; display: inline-flex; align-items: center; gap: 0.45rem; cursor: pointer; user-select: none; }
.xfy-check input[type="checkbox"],
.xfy-check input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}
.xfy-check .xfy-check-icon,
.xfy-check .xfy-check-icon-on {
    font-size: 1.15rem;
    line-height: 1;
    color: var(--xfy-text-muted);
}
.xfy-check .xfy-check-icon-on { display: none; color: var(--xfy-brand); }
.xfy-check input:checked ~ .xfy-check-icon { display: none; }
.xfy-check input:checked ~ .xfy-check-icon-on { display: inline-block; }
.xfy-check:hover .xfy-check-icon,
.xfy-check:hover .xfy-check-icon-on { color: var(--xfy-brand); }

.xfy-segment-btn.is-active::before {
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    content: "\f058";
    margin-right: 0.35rem;
}

.xfy-modal[hidden] { display: none !important; }
.xfy-modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.xfy-modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.45); }
.xfy-modal-panel {
    position: relative; z-index: 1; width: min(420px, 100%); background: var(--xfy-card);
    border: 1px solid var(--xfy-border); border-radius: var(--xfy-radius); padding: 1.25rem; box-shadow: var(--xfy-shadow);
}
.xfy-modal-title { margin: 0 0 0.5rem; font-size: 1.1rem; }
.xfy-modal-body { margin: 0 0 1rem; color: var(--xfy-text-muted); }
.xfy-modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; }

.xfy-toast-tray {
  position: fixed; top: 4.5rem; right: 1rem; z-index: 60; display: flex; flex-direction: column; gap: 0.5rem;
  max-width: min(360px, calc(100vw - 2rem)); pointer-events: none;
}
.xfy-toast {
  pointer-events: auto; padding: 0.75rem 1rem; border-radius: var(--xfy-radius-sm);
  background: var(--xfy-card); border: 1px solid var(--xfy-border); box-shadow: var(--xfy-shadow);
  font-size: 0.88rem; animation: xfy-toast-in 0.2s ease;
}
.xfy-toast.ok { border-color: #16a34a; }
.xfy-toast.err { border-color: #dc2626; }
.xfy-toast.warn { border-color: #16a34a; }
@keyframes xfy-toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.xfy-notify-trigger { position: relative; }
.xfy-notify-badge {
  position: absolute; top: 2px; right: 2px; min-width: 1rem; height: 1rem; padding: 0 0.25rem;
  border-radius: 999px; background: var(--xfy-brand); color: #fff; font-size: 0.65rem;
  display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.xfy-notify-panel {
  position: fixed; top: 3.25rem; right: 1rem; z-index: 55; width: min(320px, calc(100vw - 2rem));
  background: var(--xfy-card); border: 1px solid var(--xfy-border); border-radius: var(--xfy-radius);
  box-shadow: var(--xfy-shadow); max-height: 360px; overflow: auto;
}
.xfy-notify-panel-head { padding: 0.75rem 1rem; border-bottom: 1px solid var(--xfy-border); }
.xfy-notify-list { list-style: none; margin: 0; padding: 0.5rem 0; }
.xfy-notify-list li { padding: 0.5rem 1rem; font-size: 0.85rem; border-bottom: 1px solid var(--xfy-border); color: var(--xfy-text-muted); }
.xfy-notify-list li:last-child { border-bottom: none; }

.xfy-plan-card-clickable { cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s; }
.xfy-plan-card-clickable:hover { border-color: var(--xfy-brand); box-shadow: 0 0 0 1px var(--xfy-brand); }
.xfy-plan-card-btn { cursor: pointer; }

.xfy-search-bar-form { display: flex; flex-wrap: wrap; align-items: stretch; gap: 0.65rem; }
.xfy-search-bar-main {
    flex: 1 1 220px; display: flex; align-items: center; gap: 0.5rem;
    border: 1px solid var(--xfy-border); border-radius: var(--xfy-radius-sm); padding: 0 0.65rem;
    background: var(--xfy-surface);
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
}
.notes-search-bar {
    width: 100%;
    max-width: none;
    padding: 0.35rem 0.35rem 0.35rem 0.65rem;
}
.notes-search-bar .xfy-btn {
    flex-shrink: 0;
    border-radius: calc(var(--xfy-radius-sm) - 0.1rem);
}
.xfy-search-bar-icon { color: var(--xfy-text-muted); }
.xfy-search-input, input.xfy-enhance-search {
    flex: 1; border: none; background: transparent; padding: 0.55rem 0; font: inherit; color: var(--xfy-text);
    min-width: 0;
}
.xfy-search-input:focus, input.xfy-enhance-search:focus { outline: none; }

.xfy-glossary-title { font-size: 1rem; margin: 0 0 0.5rem; }
.xfy-glossary-list { margin: 0; padding-left: 1.15rem; color: var(--xfy-text-muted); font-size: 0.9rem; }

.xfy-filter-backdrop {
    position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,0.35);
    opacity: 0; transition: opacity 0.18s; pointer-events: none;
}
.xfy-filter-backdrop.is-open { opacity: 1; pointer-events: auto; }
.xfy-filter-panel {
    position: fixed; z-index: 45; width: min(320px, calc(100vw - 16px));
    background: var(--xfy-card); border: 1px solid var(--xfy-border); border-radius: var(--xfy-radius);
    box-shadow: var(--xfy-shadow); opacity: 0; transform: translateY(6px); transition: opacity 0.18s, transform 0.18s;
}
.xfy-filter-panel.is-open { opacity: 1; transform: translateY(0); }
.xfy-filter-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 0.75rem 1rem; border-bottom: 1px solid var(--xfy-border); }
.xfy-filter-panel-title { margin: 0; font-size: 1rem; }
.xfy-filter-panel-close { border: none; background: transparent; color: var(--xfy-text-muted); cursor: pointer; font-size: 1.1rem; }
.xfy-filter-panel-body { padding: 1rem; max-height: min(50vh, 320px); overflow: auto; }
.xfy-filter-panel-foot { display: flex; justify-content: flex-end; gap: 0.5rem; padding: 0.75rem 1rem; border-top: 1px solid var(--xfy-border); }

/* =========================================================================
   Notes — desktop app frame + mobile native shell
   ========================================================================= */

.notes-app-body {
    overscroll-behavior: none;
}

.notes-mobile-tabbar {
    display: none;
}

.notes-auth-body {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.notes-auth-frame {
    width: min(420px, calc(100vw - 2rem));
}

.notes-login {
    width: 100%;
}

/* Desktop: full-width app shell */
@media (min-width: 992px) {
    .notes-app-body {
        background: var(--xfy-bg);
        padding: 0;
    }

    html[data-bs-theme="dark"] .notes-app-body {
        background: #000;
    }

    .notes-app-frame {
        width: 100%;
        max-width: none;
        margin: 0;
        height: 100dvh;
        max-height: 100dvh;
        border: none;
        border-radius: 0;
        box-shadow: none;
        overflow: hidden;
        background: var(--xfy-surface);
        display: flex;
        flex-direction: column;
    }

    .notes-topbar {
        border-radius: 0;
        flex-shrink: 0;
    }

    .notes-shell {
        flex: 1;
        min-height: 0;
        padding: 0.6rem 0.85rem 0.75rem;
    }

    .notes-main .xfy-main-inner {
        padding-bottom: 0.5rem;
    }
}

@media (max-width: 991.98px) {
    .notes-app-body {
        background: var(--xfy-bg);
        padding-bottom: calc(4.5rem + env(safe-area-inset-bottom));
    }

    .notes-app-frame {
        min-height: 100dvh;
    }

    .notes-topbar {
        padding-top: max(0px, env(safe-area-inset-top));
    }

    .notes-desktop-new,
    .notes-page-action {
        display: none !important;
    }

    .notes-mobile-tabbar {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 40;
        align-items: stretch;
        justify-content: space-around;
        gap: 0.15rem;
        padding: 0.35rem 0.5rem calc(0.45rem + env(safe-area-inset-bottom));
        background: color-mix(in srgb, var(--xfy-surface) 92%, transparent);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border-top: 1px solid var(--xfy-border);
        box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.06);
    }

    .notes-tab-item {
        flex: 1 1 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.15rem;
        min-height: 3rem;
        padding: 0.25rem 0.15rem;
        border-radius: 0.75rem;
        color: var(--xfy-text-muted);
        font-size: 0.68rem;
        font-weight: 600;
        text-decoration: none;
        transition: color 0.15s, background 0.15s;
    }

    .notes-tab-item i {
        font-size: 1.05rem;
    }

    .notes-tab-item.is-active {
        color: var(--xfy-brand);
        background: var(--xfy-brand-soft);
    }

    .notes-tab-item.is-fab {
        color: #fff;
        background: var(--xfy-brand);
        max-width: 4.25rem;
        border-radius: 999px;
        margin-top: -0.85rem;
        box-shadow: 0 8px 20px rgba(22, 163, 74, 0.35);
    }

    .notes-tab-item.is-fab.is-active {
        color: #fff;
        background: var(--xfy-brand-dark);
    }

    .notes-shell {
        padding-bottom: 0.25rem;
    }
}

.notes-theme-topbar { display: inline-flex; }

@media (max-width: 991.98px) {
    .notes-theme-topbar { display: none; }
}

/* Notes-specific components */
.notes-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0.85rem;
}

.notes-note-card {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    min-height: 9rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

a.notes-note-card:hover {
    text-decoration: none;
    border-color: var(--xfy-brand);
    box-shadow: var(--xfy-shadow);
}

.notes-note-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
}

.notes-note-title {
    color: var(--xfy-text);
    font-weight: 700;
    text-decoration: none;
}

.notes-note-title:hover {
    color: var(--xfy-brand);
}

.notes-note-excerpt {
    margin: 0;
    color: var(--xfy-text-muted);
    font-size: 0.88rem;
    line-height: 1.45;
    flex: 1;
}

.notes-note-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: auto;
}

.notes-inline-actions {
    display: flex;
    gap: 0.25rem;
}

.notes-inline-form {
    display: inline;
    margin: 0;
}

.notes-search-form {
    margin-bottom: 0.25rem;
}

.notes-tag-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.85rem;
}

.notes-detail-body {
    min-height: 12rem;
}

.notes-markdown {
    white-space: pre-wrap;
    line-height: 1.65;
    font-size: 0.95rem;
}

.notes-detail-actions,
.notes-page-actions,
.notes-editor-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.85rem;
}

.notes-editor-form textarea {
    min-height: 16rem;
    resize: vertical;
    font-family: inherit;
    line-height: 1.55;
}

.notes-quick-new {
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-style: dashed;
}

@media (max-width: 560px) {
    .notes-card-grid {
        grid-template-columns: 1fr;
    }

    .notes-detail-actions .xfy-btn,
    .notes-editor-actions .xfy-btn {
        flex: 1 1 calc(50% - 0.25rem);
    }

    .notes-layout-with-sidebar {
        flex-direction: column;
    }
}

/* Notes page — stacked card layout */
.notes-page-stack {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.notes-panel {
    padding: 1rem 1.1rem;
}

.notes-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.85rem;
}

.notes-panel-title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.notes-folder-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.notes-folder-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--xfy-border);
    background: var(--xfy-surface-2);
    color: var(--xfy-text);
    text-decoration: none;
    font-size: 0.84rem;
    font-weight: 500;
    margin-left: calc(var(--chip-depth, 0) * 0.5rem);
    box-shadow: var(--xfy-shadow-sm);
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.notes-folder-chip:hover {
    border-color: color-mix(in srgb, var(--xfy-brand) 45%, var(--xfy-border));
    background: var(--xfy-brand-soft);
    text-decoration: none;
    color: var(--xfy-brand-dark);
}

.notes-folder-chip.is-active {
    background: var(--xfy-brand);
    border-color: var(--xfy-brand);
    color: #fff;
}

.notes-toolbar-panel .notes-search-form {
    margin-bottom: 0.85rem;
}

.notes-filter-segment {
    margin: 0;
}

.notes-results-panel {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

/* Legacy sidebar layout — kept for mobile fallback if referenced */
.notes-layout-with-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.notes-main-column {
    flex: 1;
    min-width: 0;
}

.notes-folder-sidebar {
    width: 100%;
    flex-shrink: 0;
    padding: 1rem 1.1rem;
}

.notes-folder-sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.65rem;
}

.notes-folder-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.notes-folder-list a {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--xfy-border);
    background: var(--xfy-surface-2);
    color: var(--xfy-text);
    text-decoration: none;
    font-size: 0.84rem;
}

.notes-folder-list a.is-active,
.notes-folder-list a:hover {
    background: var(--xfy-brand-soft);
    border-color: color-mix(in srgb, var(--xfy-brand) 40%, var(--xfy-border));
}

.notes-folder-label {
    margin: 0 0 0.35rem;
    font-size: 0.82rem;
}

.notes-folder-tree,
.notes-folder-tree-children {
    list-style: none;
    margin: 0;
    padding: 0;
}

.notes-folder-tree-item {
    margin: 0.25rem 0;
}

.notes-folder-tree-row {
    padding-left: calc(var(--depth, 0) * 0.85rem);
}

.notes-folder-manage-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.notes-folder-manage-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.notes-folder-manage-row input[type="text"] {
    flex: 1 1 10rem;
}

.notes-users-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.notes-user-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.notes-user-main {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.notes-folder-access-grid {
    display: grid;
    gap: 0.35rem;
    margin: 0.5rem 0;
}

.notes-folder-access-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.88rem;
}

.notes-card-title {
    margin: 0 0 0.85rem;
    font-size: 1rem;
}

.notes-move-select {
    min-width: 10rem;
    max-width: none;
}

/* Quill editor + rich text rounded backgrounds */
.notes-editor-form .xfy-field:has(.notes-quill-toolbar) {
    overflow: visible;
}

.notes-quill-stack {
    position: relative;
    isolation: isolate;
}

.notes-quill-toolbar {
    border: 1px solid var(--xfy-border);
    border-bottom: none;
    border-radius: var(--xfy-radius-sm) var(--xfy-radius-sm) 0 0;
    background: var(--xfy-surface-2);
    overflow: visible;
    position: relative;
    z-index: 5;
}

.notes-quill-toolbar.ql-toolbar.ql-snow {
    padding: 0.5rem 0.65rem;
}

.notes-quill-toolbar .ql-picker {
    position: relative;
}

.notes-quill-toolbar .ql-picker.ql-expanded .ql-picker-options {
    z-index: 100;
    display: block;
}
    border-radius: var(--xfy-radius-sm);
    box-shadow: var(--xfy-shadow);
    border: 1px solid var(--xfy-border);
    background: var(--xfy-card);
    max-height: 220px;
    overflow-y: auto;
}

.notes-quill-toolbar .ql-color-picker .ql-picker-options {
    padding: 0.35rem;
    width: auto;
}

.notes-quill-editor {
    min-height: 16rem;
    border: 1px solid var(--xfy-border);
    border-radius: 0 0 var(--xfy-radius-sm) var(--xfy-radius-sm);
    background: var(--xfy-surface);
    overflow: visible;
    position: relative;
    z-index: 1;
}

.notes-quill-editor .ql-editor {
    min-height: 14rem;
    max-height: 28rem;
    overflow-y: auto;
    font-size: 0.95rem;
    line-height: 1.6;
    padding: 0.85rem 1rem;
}

.notes-rich-body.ql-snow,
.notes-quill-editor.ql-snow {
    border: none;
}

.notes-rich-body .ql-editor,
.notes-quill-editor .ql-editor {
    padding: 0;
    font-size: 0.95rem;
    line-height: 1.65;
}

.notes-rich-body .ql-editor span[style*="background"],
.notes-quill-editor .ql-editor span[style*="background"] {
    border-radius: 0.35rem;
    padding: 0.05rem 0.2rem;
}

.notes-rich-body .ql-editor blockquote,
.notes-quill-editor .ql-editor blockquote {
    border-left: 3px solid var(--xfy-brand);
    border-radius: 0 var(--xfy-radius-sm) var(--xfy-radius-sm) 0;
    background: var(--xfy-surface-2);
    padding: 0.65rem 0.85rem;
    margin: 0.65rem 0;
}

.notes-rich-body .ql-editor pre,
.notes-quill-editor .ql-editor pre {
    border-radius: var(--xfy-radius-sm);
    background: var(--xfy-surface-2);
    padding: 0.75rem;
}

.notes-rich-body .ql-editor ul,
.notes-rich-body .ql-editor ol,
.notes-quill-editor .ql-editor ul,
.notes-quill-editor .ql-editor ol {
    padding-left: 1.25rem;
}
