/* ===================================================================
   Digital Doctors Solutions Ltd: Design System

   One palette, declared once here. Every component below is written
   against these variables and against nothing else, so the brand can be
   retargeted by editing this block and no other file. A colour that is
   hardcoded in a component rule is a bug: it cannot be themed, it goes
   stale the moment the brand moves, and it is invisible in review.
   =================================================================== */

:root {
    /* ---- Brand ----
       Purple is the accent, not the canvas. It is spent on the things
       that are actionable or selected, and withheld from the surfaces,
       so that a purple button means "do this" rather than "this is a
       box". */
    --color-primary: #7b2df0;
    --color-primary-light: #9b5cf6;
    --color-primary-dark: #5b16c9;
    --color-primary-50: #f8f5ff;
    --color-primary-100: #f3ecff;
    --color-primary-200: #e4d5fb;
    --color-primary-500: #7b2df0;
    --color-primary-600: #6a1fdb;
    --color-primary-700: #5b16c9;

    /* ---- Semantic ----
       Each has a light companion for badge and alert backgrounds. The
       text colour on those backgrounds is darker than the base hue, not
       the hue itself: #E5A000 on white fails contrast at small sizes,
       so warning text is the amber's own dark end. */
    --color-success: #22a06b;
    --color-success-light: #e6f6ef;
    --color-success-text: #157347;
    --color-warning: #e5a000;
    --color-warning-light: #fdf3dd;
    --color-warning-text: #8a6100;
    --color-danger: #d64545;
    --color-danger-light: #fbeaea;
    --color-danger-text: #a12c2c;
    --color-info: #3b82f6;
    --color-info-light: #e8f0fe;
    --color-info-text: #1a56c4;

    /* ---- Neutrals ----
       A warm off-white page with a faintly violet border. The page is
       #FAF9FC rather than a cool grey so the white cards on it read as
       raised rather than as a different temperature of the same colour. */
    --color-bg: #faf9fc;
    --color-bg-card: #ffffff;
    --color-bg-soft: #f8f5ff;
    --color-bg-hover: #f4f1f8;
    --color-border: #e9e4ef;
    --color-border-light: #f2eef7;
    --color-text: #25212b;
    --color-text-secondary: #77717f;
    --color-text-muted: #a49eab;
    --color-ink: #171321;
    --color-ink-2: #292333;

    /* ---- Sidebar ----
       Light, not dark. A dark rail beside a light page splits the screen
       into two visual halves and reads as two applications; a light rail
       with a hairline edge keeps one surface. */
    --sidebar-bg: #ffffff;
    --sidebar-hover: #f8f5ff;
    --sidebar-active: #f3ecff;
    --sidebar-text: #77717f;
    --sidebar-text-strong: #25212b;
    --sidebar-text-active: #5b16c9;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 72px;

    /* ---- Topbar ---- */
    --topbar-height: 72px;

    /* ---- Elevation ----
       Very soft. Depth here comes from borders and background layers;
       a shadow strong enough to see on a white card reads as a smudge
       on a light-grey page. */
    --shadow-sm: 0 1px 2px 0 rgb(37 33 43 / 0.04);
    --shadow: 0 2px 8px 0 rgb(37 33 43 / 0.05);
    --shadow-md: 0 8px 24px 0 rgb(37 33 43 / 0.06);
    --shadow-lg: 0 16px 40px 0 rgb(37 33 43 / 0.08);
    --shadow-focus: 0 0 0 3px var(--color-primary-100);

    /* ---- Radius ----
       One ladder, used everywhere. Cards sit at 20px because a 12px
       card next to a 20px one reads as two products. */
    --radius-sm: 8px;
    --radius: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-2xl: 24px;
    --input-radius: 14px;

    /* ---- Spacing ----
       A 4px scale, named by step rather than by pixel, so that a
       template can ask for a gap without knowing the arithmetic. */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;

    /* ---- Type ---- */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --text-xs: 12px;
    --text-sm: 13px;
    --text-base: 14px;
    --text-md: 15px;
    --text-lg: 16px;
    --text-xl: 18px;
    --text-2xl: 24px;
    --text-3xl: 32px;
    --text-4xl: 40px;

    /* ---- Motion ----
       150-250ms. Long enough to be legible as movement, short enough
       that a button never feels like it has swallowed the click. */
    --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    /* ---- Claymorphism Design System Tokens ----
       Soft, inflated 3D tactile surfaces with dual-layer lighting:
       outer diffused elevation plus inner rim highlights and depth bevels. */
    --clay-card-bg: #ffffff;
    --clay-card-border: #ede8f5;
    --clay-card-shadow: 0 14px 28px -4px rgb(37 33 43 / 0.07), 0 4px 10px -2px rgb(37 33 43 / 0.03), inset 1.5px 1.5px 2px rgb(255 255 255 / 0.95), inset -2px -2px 4px rgb(37 33 43 / 0.03);
    --clay-card-shadow-hover: 0 18px 36px -4px rgb(37 33 43 / 0.1), 0 6px 14px -2px rgb(37 33 43 / 0.04), inset 1.5px 1.5px 2px rgb(255 255 255 / 1), inset -2px -2px 4px rgb(37 33 43 / 0.04);

    --clay-input-bg: #f8f6fc;
    --clay-input-border: #e6e0f0;
    --clay-input-shadow: inset 2px 2px 4px rgb(37 33 43 / 0.06), inset -2px -2px 4px rgb(255 255 255 / 0.95), 0 1px 2px rgb(37 33 43 / 0.02);
    --clay-input-focus-bg: #ffffff;
    --clay-input-focus-border: var(--color-primary);
    --clay-input-focus-shadow: inset 1px 1px 2px rgb(123 45 240 / 0.1), 0 0 0 4px var(--color-primary-100), 0 8px 20px -3px rgb(123 45 240 / 0.2);

    --clay-btn-primary-bg: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-600) 100%);
    --clay-btn-primary-border: #6a1fdb;
    --clay-btn-primary-shadow: 0 8px 20px -2px rgb(123 45 240 / 0.38), inset 2px 2px 3px rgb(255 255 255 / 0.35), inset -2px -2px 4px rgb(91 22, 201 / 0.45);
    --clay-btn-primary-hover-shadow: 0 12px 26px -2px rgb(123 45 240 / 0.48), inset 2px 2px 4px rgb(255 255 255 / 0.45), inset -2px -2px 5px rgb(91 22, 201 / 0.5);
    --clay-btn-primary-active-shadow: 0 3px 8px -1px rgb(123 45 240 / 0.3), inset 2px 2px 4px rgb(37 33 43 / 0.35), inset -1px -1px 2px rgb(255 255 255 / 0.2);

    --clay-btn-secondary-bg: linear-gradient(135deg, #ffffff 0%, var(--color-bg-soft) 100%);
    --clay-btn-secondary-border: var(--color-border);
    --clay-btn-secondary-shadow: 0 4px 12px rgb(37 33 43 / 0.05), inset 1.5px 1.5px 2px rgb(255 255 255 / 1), inset -1.5px -1.5px 3px rgb(37 33 43 / 0.04);
    --clay-btn-secondary-hover-shadow: 0 8px 18px rgb(37 33 43 / 0.09), inset 1.5px 1.5px 2px rgb(255 255 255 / 1);

    --clay-step-shadow: 0 4px 10px rgb(123 45 240 / 0.3), inset 1.5px 1.5px 2px rgb(255 255 255 / 0.4), inset -1.5px -1.5px 2px rgb(91 22, 201 / 0.4);
    --clay-pill-shadow: 0 2px 6px rgb(37 33 43 / 0.04), inset 1.5px 1.5px 2px rgb(255 255 255 / 0.95), inset -1.5px -1.5px 2px rgb(37 33 43 / 0.03);
    --clay-pill-checked-shadow: 0 4px 12px rgb(123 45 240 / 0.18), inset 1.5px 1.5px 2px rgb(123 45 240 / 0.15);
    --clay-bottom-bar-shadow: 0 -8px 24px rgb(37 33 43 / 0.06), 0 -2px 6px rgb(37 33 43 / 0.02), inset 0 1px 2px rgb(255 255 255 / 0.9);
    --clay-track-bg: #f4f0fa;
    --clay-track-border: #ece4f7;
    --clay-toolbar-end-bg: #faf8fd;
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    margin: 0;
    min-height: 100vh;
    font-size: var(--text-base);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-dark); }

/* A keyboard user must be able to see where they are. :focus-visible draws
   the ring only for keyboard focus, so a mouse click does not leave a halo
   around whatever it just activated. */
:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: 4px;
}

/* A skip link is the first thing in the tab order but stays out of sight
   until a keyboard user reaches it. It is a navigation aid for keyboard and
   screen-reader users only, so a mouse user never sees it flash. */
.skip-link {
    position: fixed;
    top: 8px;
    left: 8px;
    z-index: 2000;
    transform: translateY(-160%);
    background: var(--color-primary);
    color: #fff;
    font-size: var(--text-sm);
    font-weight: 600;
    padding: 10px 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    transition: transform var(--transition-fast);
}
.skip-link:focus {
    transform: translateY(0);
    color: #fff;
}

/* The main region is a programmatic scroll target, not a control, so it
   must not draw a focus ring when the skip link lands on it. */
#main-content:focus { outline: none; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ---- Layout ---- */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ---- Sidebar ---- */
/* The rail is a light surface separated by a hairline, not a dark slab.
   Its own brand mark is the one saturated purple on the page. */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: width var(--transition), transform var(--transition);
    overflow: hidden;
    border-right: 1px solid var(--color-border);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px 20px;
    border-bottom: 1px solid var(--color-border-light);
    margin-bottom: 10px;
}

.sidebar-brand-icon {
    width: 38px;
    height: 38px;
    background: var(--color-primary);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
    box-shadow: 0 4px 12px -2px rgb(123 45 240 / 0.35);
}

.sidebar-brand-text {
    color: var(--color-text);
    font-weight: 700;
    font-size: 15px;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.sidebar-brand-text small {
    display: block;
    color: var(--color-text-muted);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px 12px;
    /* A thin scrollbar in the rail's own border colour, so a long menu
       does not introduce a grey bar the design never asked for. */
    scrollbar-width: thin;
    scrollbar-color: var(--color-border) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 3px;
}

.sidebar-section {
    margin-bottom: 10px;
}

.sidebar-section-title {
    color: var(--color-text-muted);
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    padding: 14px 12px 6px;
    white-space: nowrap;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    color: var(--sidebar-text);
    border-radius: var(--radius);
    transition: background var(--transition-fast), color var(--transition-fast);
    white-space: nowrap;
    font-size: var(--text-base);
    font-weight: 500;
    position: relative;
}

.sidebar-link:hover {
    background: var(--sidebar-hover);
    color: var(--color-text);
}

.sidebar-link.active {
    background: var(--sidebar-active);
    color: var(--sidebar-text-active);
    font-weight: 600;
}

/* A 3px bar on the inline edge of the active item, the one cue that still
   reads when the rail is scrolled or the label is truncated. */
.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--color-primary);
    border-radius: 0 3px 3px 0;
}

.sidebar-link svg,
.sidebar-link i {
    width: 19px;
    height: 19px;
    flex-shrink: 0;
    opacity: 0.75;
    transition: opacity var(--transition-fast);
}

.sidebar-link:hover svg,
.sidebar-link:hover i {
    opacity: 1;
}

.sidebar-link.active svg,
.sidebar-link.active i {
    opacity: 1;
}

.sidebar-badge {
    margin-left: auto;
    background: var(--color-danger);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 1px 7px;
    border-radius: 10px;
    line-height: 1.4;
}

.sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--color-border-light);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--sidebar-text);
    font-size: var(--text-sm);
}

.sidebar-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    /* The avatar is soft purple with purple text rather than solid purple:
       the rail already carries the mark, and a second solid block down
       here would compete with the brand for the eye. */
    background: var(--color-primary-100);
    color: var(--color-primary-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--text-sm);
    flex-shrink: 0;
    border: 1px solid var(--color-primary-200);
}

/* ---- Main Content Area ---- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ---- Topbar ----
   Sticky, white, and separated by a hairline. No shadow: a shadow here
   would darken the page as it scrolls underneath and put a grey band
   across the top of every long list. */
.topbar {
    height: var(--topbar-height);
    background: var(--color-bg-card);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-6);
    position: sticky;
    top: 0;
    z-index: 900;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    min-width: 0;
}

.topbar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--color-text-secondary);
    cursor: pointer;
    padding: 4px;
}

/* A soft, borderless well rather than a boxed input: it sits on white, so
   a border would draw a second line under the topbar's own. */
.topbar-search {
    position: relative;
    display: flex;
    align-items: center;
}

.topbar-search input {
    width: 340px;
    max-width: 100%;
    padding: 9px 14px 9px 38px;
    border: 1px solid transparent;
    border-radius: var(--radius-lg);
    font-size: var(--text-base);
    font-family: inherit;
    background: var(--color-bg);
    color: var(--color-text);
    transition: background var(--transition-fast), box-shadow var(--transition-fast);
}

.topbar-search input::placeholder { color: var(--color-text-muted); }

.topbar-search input:focus {
    outline: none;
    background: var(--color-bg-card);
    border-color: var(--color-primary-200);
    box-shadow: var(--shadow-focus);
}

.topbar-search svg {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--color-text-muted);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-btn {
    position: relative;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    border: none;
    background: none;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.topbar-btn:hover {
    background: var(--color-bg-hover);
    color: var(--color-text);
}

.topbar-btn .badge {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    background: var(--color-danger);
    border-radius: 50%;
    border: 2px solid var(--color-bg-card);
}

.topbar-tenant {
    padding: 6px 12px;
    background: var(--color-primary-50);
    color: var(--color-primary);
    border-radius: var(--radius);
    font-size: 12px;
    font-weight: 600;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
}

.topbar-user:hover {
    background: var(--color-bg-hover);
}

.topbar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: 12px;
}

.topbar-user-info {
    line-height: 1.3;
}

.topbar-user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
}

.topbar-user-role {
    font-size: 11px;
    color: var(--color-text-muted);
}

/* ---- Page Content ---- */
.page-content {
    flex: 1;
    padding: 24px;
}

/* ---- Page Header ----
   Context, then title, then supporting line, then the action on the right.
   The title is 32px because a page title is the loudest element on a page
   of white cards; at 24px it competed with the numbers it was labelling. */
.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-8);
    flex-wrap: wrap;
}

.page-header h1 {
    font-size: var(--text-3xl);
    font-weight: 700;
    color: var(--color-text);
    margin: 0;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.page-header-subtitle {
    font-size: var(--text-md);
    color: var(--color-text-secondary);
    margin-top: 6px;
    max-width: 62ch;
}

.page-header-actions {
    display: flex;
    gap: var(--space-2);
    flex-shrink: 0;
}

/* ---- Cards ----
   20px radius, a 1px violet-grey border, and a shadow so soft it is
   only noticeable as the absence of a hard edge. */
.card {
    background: var(--clay-card-bg);
    border: 1px solid var(--clay-card-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--clay-card-shadow);
    transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition);
}

.card:hover {
    box-shadow: var(--clay-card-shadow-hover);
    border-color: var(--color-primary-200);
}

.card-header {
    padding: var(--space-5) var(--space-6);
    border-bottom: 1px solid var(--color-border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
}

.card-header h5,
.card-header h6 {
    margin: 0;
    font-weight: 600;
    font-size: var(--text-lg);
    letter-spacing: -0.01em;
    color: var(--color-text);
}

.card-body {
    padding: var(--space-6);
}

/* ---- Stat Cards (Dashboard KPIs) ----
   The number is the design. Label above it in small muted type, trend
   below, and the icon pushed to the corner so the column of figures
   across the row lines up. */
.stat-card {
    background: var(--clay-card-bg);
    border: 1px solid var(--clay-card-border);
    border-radius: var(--radius-xl);
    padding: var(--space-5) var(--space-6);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
    box-shadow: var(--clay-card-shadow);
    transition: all var(--transition);
}

.stat-card:hover {
    box-shadow: var(--clay-card-shadow-hover);
    border-color: var(--color-primary-200);
    transform: translateY(-2px);
}

.stat-card-content {
    flex: 1;
    min-width: 0;
}

.stat-card-label {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: 6px;
    letter-spacing: 0.02em;
}

.stat-card-value {
    font-size: var(--text-3xl);
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.stat-card-change {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: var(--text-xs);
    font-weight: 600;
    margin-top: var(--space-2);
    padding: 3px 10px;
    border-radius: 20px;
}

/* A stat card can report an amount held in more than one currency. The first
   line keeps the card's own size, so a company that bills in a single currency
   sees what it has always seen; the rest step down, because a further currency
   is additional detail rather than a second headline. */
.money-totals-row + .money-totals-row {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text-muted);
}

/* The pill's text is the *-text token, not the base hue. #22A06B on its own
   pale green measures 2.3:1, which is below the 4.5:1 that small bold type
   needs; #157347 on the same green measures 5.1:1. The icon in the corner
   is a 24px graphic rather than text, so it keeps the base hue. */
.stat-card-change.positive {
    background: var(--color-success-light);
    color: var(--color-success-text);
}

.stat-card-change.negative {
    background: var(--color-danger-light);
    color: var(--color-danger-text);
}

.stat-card-icon {
    width: 46px;
    height: 46px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: inset 1.5px 1.5px 2.5px rgb(255 255 255 / 0.9), inset -1.5px -1.5px 3px rgb(37 33 43 / 0.05), 0 4px 10px rgb(37 33 43 / 0.04);
    border: 1px solid rgb(255 255 255 / 0.85);
}

.stat-card-icon.primary {
    background: var(--color-primary-100);
    color: var(--color-primary-dark);
}

.stat-card-icon.success {
    background: var(--color-success-light);
    color: var(--color-success-text);
}

.stat-card-icon.warning {
    background: var(--color-warning-light);
    color: var(--color-warning-text);
}

.stat-card-icon.danger {
    background: var(--color-danger-light);
    color: var(--color-danger-text);
}

.stat-card-icon.info {
    background: var(--color-info-light);
    color: var(--color-info);
}

/* ---- Buttons ----
   11px radius rather than the 20px cards use. A control and the surface
   that holds it should not share a shape, or the button reads as a hole
   cut in the card rather than a thing you press. */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 18px;
    font-size: var(--text-base);
    font-weight: 600;
    font-family: inherit;
    border-radius: 11px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast),
                color var(--transition-fast), box-shadow var(--transition-fast),
                transform var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}

.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn:active { transform: translateY(1px); }

.btn:disabled,
.btn.disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: var(--clay-btn-primary-bg);
    color: #fff;
    border-color: var(--clay-btn-primary-border);
    box-shadow: var(--clay-btn-primary-shadow);
}

.btn-primary:hover {
    background: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: var(--clay-btn-primary-hover-shadow);
}

.btn-primary:active {
    transform: translateY(1px);
    box-shadow: var(--clay-btn-primary-active-shadow);
}

.btn-secondary {
    background: var(--clay-btn-secondary-bg);
    color: var(--color-text);
    border-color: var(--clay-btn-secondary-border);
    box-shadow: var(--clay-btn-secondary-shadow);
}

.btn-secondary:hover {
    background: var(--color-bg-soft);
    border-color: var(--color-primary-200);
    color: var(--color-primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--clay-btn-secondary-hover-shadow);
}

.btn-secondary:active {
    transform: translateY(1px);
    box-shadow: var(--clay-pill-shadow);
}

.btn-success {
    background: var(--color-success);
    color: #fff;
}

.btn-danger {
    background: var(--color-danger);
    color: #fff;
}

.btn-outline-primary {
    background: transparent;
    color: var(--color-primary);
    border-color: var(--color-primary-200);
    box-shadow: var(--clay-pill-shadow);
}

.btn-outline-primary:hover {
    background: var(--color-primary-50);
    color: var(--color-primary-dark);
    border-color: var(--color-primary-light);
    transform: translateY(-2px);
    box-shadow: var(--clay-pill-checked-shadow);
}

.btn-outline-secondary {
    background: transparent;
    color: var(--color-text-secondary);
    border-color: var(--color-border);
}

.btn-outline-secondary:hover {
    background: var(--color-bg-hover);
    color: var(--color-text);
}

.btn-sm {
    padding: 6px 12px;
    font-size: var(--text-xs);
    border-radius: 9px;
}

.btn-lg {
    padding: 12px 24px;
    font-size: var(--text-md);
}

.btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 10px;
}

/* ---- Tables ---- */
.table-container {
    background: var(--clay-card-bg);
    border: 1px solid var(--clay-card-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--clay-card-shadow);
    overflow: hidden;
    transition: box-shadow var(--transition);
}

.table-toolbar {
    padding: var(--space-4) var(--space-6);
    border-bottom: 1px solid var(--color-border-light);
    background: linear-gradient(180deg, #ffffff 0%, var(--clay-toolbar-end-bg) 100%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.table-toolbar-left {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

/* -- The search page's own box --
   The topbar and the table toolbars both style a single search input for
   their own width. The search page is the third place a reader types a query,
   and it is the only one where the box is the subject of the page rather than
   a control in someone else's toolbar, so it is wider and carries the icon
   inline instead of floating it. */
.search-page-form {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-6);
    max-width: 680px;
}

.search-page-form input {
    flex: 1;
    min-width: 0;
    padding: 12px 16px;
    border: 1px solid var(--color-border);
    border-radius: var(--input-radius);
    font-size: var(--text-md);
    font-family: inherit;
    background: var(--color-bg-card);
    color: var(--color-text);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-page-form input::placeholder { color: var(--color-text-muted); }

.search-page-form input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: var(--shadow-focus);
}

.table-search {
    position: relative;
    display: flex;
    align-items: center;
}

.table-search input {
    padding: 8px 12px 8px 34px;
    border: 1.5px solid var(--clay-input-border);
    border-radius: var(--input-radius);
    font-size: var(--text-sm);
    font-family: inherit;
    width: 250px;
    background: var(--clay-input-bg);
    color: var(--color-text);
    box-shadow: var(--clay-input-shadow);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

.table-search input::placeholder { color: var(--color-text-muted); }

.table-search input:focus {
    outline: none;
    border-color: var(--clay-input-focus-border);
    box-shadow: var(--clay-input-focus-shadow);
    background: var(--clay-input-focus-bg);
}

.table-search svg {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    color: var(--color-text-muted);
}

/* -- Filter row (a toolbar that filters on more than one thing) --
   .table-search covers the single search box: one input, a fixed width, an
   icon inside it. A toolbar that also filters by client or by a date range
   needs its controls sized to their own content so the row stays a row.
   Sizing them is the whole point of this class, because .form-control and the
   .form-field rules both set width:100%, which would stack them one per line.
   The date inputs are given a narrower floor than the text ones because
   "yyyy-mm-dd" is a fixed-length value. */
.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.filter-form input:not([type="checkbox"]):not([type="radio"]),
.filter-form select {
    width: auto;
    min-width: 150px;
    min-height: 38px;
    padding: 7px 12px;
    font-size: 13px;
    font-family: inherit;
    color: var(--color-text);
    background: var(--clay-input-bg);
    border: 1.5px solid var(--clay-input-border);
    border-radius: var(--radius);
    box-shadow: var(--clay-input-shadow);
    transition: all var(--transition);
}

.filter-form input[type="date"] {
    min-width: 140px;
}

.filter-form input:focus,
.filter-form select:focus {
    outline: none;
    border-color: var(--clay-input-focus-border);
    box-shadow: var(--clay-input-focus-shadow);
    background: var(--clay-input-focus-bg);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
}

/* Spacious rows, and a hairline separator rather than a grid: a table with
   vertical rules reads as a spreadsheet, which is the thing a CRM is not. */
.data-table th {
    padding: 14px 20px;
    font-size: 11px;
    font-weight: 700;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    text-align: left;
    white-space: nowrap;
}

.data-table td {
    padding: 14px 20px;
    font-size: var(--text-base);
    color: var(--color-text);
    border-bottom: 1px solid var(--color-border-light);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
    background: var(--color-primary-50);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* ---- Badges / Status Pills ----
   A soft fill with a same-hue dot and text at the *-text end of the ramp.
   Every colour below is a token: the whole set retargets by editing :root. */
.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 9999px;
    font-size: var(--text-xs);
    font-weight: 600;
    white-space: nowrap;
    box-shadow: inset 1px 1px 2px rgb(255 255 255 / 0.8), inset -1px -1px 2px rgb(37 33 43 / 0.04), 0 2px 4px rgb(37 33 43 / 0.03);
    border: 1px solid rgb(255 255 255 / 0.5);
}

.badge-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.badge-new, .badge-draft { background: var(--color-info-light); color: var(--color-info-text); }
.badge-new::before, .badge-draft::before { background: var(--color-info); }

.badge-qualified, .badge-in_progress, .badge-ongoing { background: var(--color-info-light); color: var(--color-info-text); }
.badge-qualified::before, .badge-in_progress::before, .badge-ongoing::before { background: var(--color-info); }

.badge-proposal_sent, .badge-proposal, .badge-sent { background: var(--color-warning-light); color: var(--color-warning-text); }
.badge-proposal_sent::before, .badge-proposal::before, .badge-sent::before { background: var(--color-warning); }

.badge-won, .badge-completed, .badge-accepted, .badge-paid, .badge-resolved, .badge-closed { background: var(--color-success-light); color: var(--color-success-text); }
.badge-won::before, .badge-completed::before, .badge-accepted::before, .badge-paid::before, .badge-resolved::before, .badge-closed::before { background: var(--color-success); }

.badge-lost, .badge-cancelled, .badge-rejected, .badge-overdue, .badge-critical { background: var(--color-danger-light); color: var(--color-danger-text); }
.badge-lost::before, .badge-cancelled::before, .badge-rejected::before, .badge-overdue::before, .badge-critical::before { background: var(--color-danger); }

.badge-on_hold, .badge-partially_paid, .badge-review, .badge-upcoming { background: var(--color-warning-light); color: var(--color-warning-text); }
.badge-on_hold::before, .badge-partially_paid::before, .badge-review::before, .badge-upcoming::before { background: var(--color-warning); }

.badge-todo, .badge-open, .badge-new-status { background: var(--color-bg-hover); color: var(--color-text-secondary); border: 1px solid var(--color-border); }
.badge-todo::before, .badge-open::before, .badge-new-status::before { background: var(--color-text-muted); }

/* Negotiation is the one status that is ours rather than a generic state, so
   it is the one that gets the brand. */
.badge-negotiation { background: var(--color-primary-100); color: var(--color-primary-dark); }
.badge-negotiation::before { background: var(--color-primary); }

.badge-enrolled { background: var(--color-info-light); color: var(--color-info-text); }
.badge-enrolled::before { background: var(--color-info); }

.badge-dropped { background: var(--color-danger-light); color: var(--color-danger-text); }
.badge-dropped::before { background: var(--color-danger); }

/* Priority badges */
.badge-priority-low { background: var(--color-bg-hover); color: var(--color-text-secondary); }
.badge-priority-medium { background: var(--color-warning-light); color: var(--color-warning-text); }
.badge-priority-high { background: var(--color-warning-light); color: var(--color-danger-text); }
.badge-priority-urgent { background: var(--color-danger-light); color: var(--color-danger-text); }

/* ---- Tabs ---- */
.nav-tabs-custom {
    display: flex;
    gap: 8px;
    padding: 6px;
    background: var(--clay-track-bg);
    border: 1.5px solid var(--clay-track-border);
    border-radius: 9999px;
    margin-bottom: 24px;
    overflow-x: auto;
    width: fit-content;
    max-width: 100%;
    box-shadow: inset 2px 2px 5px rgb(37 33 43 / 0.05), inset -2px -2px 5px rgb(255 255 255 / 0.95);
}

.nav-tab {
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-secondary);
    border-radius: 9999px;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    background: transparent;
    border: 1px solid transparent;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.nav-tab:hover {
    color: var(--color-primary-dark);
    background: rgb(255 255 255 / 0.65);
}

.nav-tab.active {
    background: #ffffff;
    color: var(--color-primary);
    border-color: var(--color-primary-100);
    box-shadow: 0 4px 12px -2px rgb(123 45 240 / 0.16), inset 1.5px 1.5px 2px rgb(255 255 255 / 1), inset -1.5px -1.5px 2px rgb(37 33 43 / 0.03);
    font-weight: 700;
}

.nav-tab .count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    margin-left: 4px;
    background: rgba(123, 45, 240, 0.08);
    color: var(--color-primary);
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 700;
    transition: all var(--transition);
}

.nav-tab.active .count {
    background: var(--clay-btn-primary-bg);
    color: #ffffff;
    box-shadow: 0 2px 6px rgb(123 45 240 / 0.35);
}

/* ---- Filter Tabs (for status filtering on list pages) ---- */
.filter-tabs {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px;
    background: var(--clay-track-bg);
    border-radius: 9999px;
    border: 1.5px solid var(--clay-track-border);
    width: fit-content;
    max-width: 100%;
    overflow-x: auto;
    box-shadow: inset 2px 2px 4px rgb(37 33 43 / 0.06), inset -2px -2px 4px rgb(255 255 255 / 0.95);
}

.filter-tab {
    padding: 7px 16px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--color-text-secondary);
    border-radius: 9999px;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    border: 1px solid transparent;
    background: transparent;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.filter-tab:hover {
    color: var(--color-primary);
    background: rgb(255 255 255 / 0.7);
}

.filter-tab.active {
    background: #ffffff;
    color: var(--color-primary);
    border-color: var(--color-primary-100);
    box-shadow: 0 4px 12px -2px rgb(123 45 240 / 0.16), inset 1.5px 1.5px 2px rgb(255 255 255 / 1), inset -1.5px -1.5px 2px rgb(37 33 43 / 0.03);
    font-weight: 700;
}

/* ---- Pagination ---- */
.pagination-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-top: 1px solid var(--color-border-light);
}

.pagination-info {
    font-size: 13px;
    color: var(--color-text-secondary);
}

.pagination {
    display: flex;
    gap: 4px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-secondary);
    border-radius: var(--radius);
    transition: all var(--transition);
    text-decoration: none;
}

.pagination a:hover {
    background: var(--color-bg-hover);
    color: var(--color-text);
}

.pagination .current {
    background: var(--color-primary);
    color: #fff;
}

.pagination .disabled {
    color: var(--color-text-muted);
    pointer-events: none;
}

/* ---- Forms ---- */
.form-card {
    background: var(--clay-card-bg);
    border: 1.5px solid var(--clay-card-border);
    border-radius: var(--radius-2xl);
    padding: 28px;
    box-shadow: var(--clay-card-shadow);
    transition: box-shadow var(--transition);
}

.form-card:hover {
    box-shadow: var(--clay-card-shadow-hover);
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 6px;
}

.form-group .help-text {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-top: 5px;
}

.form-control,
.form-select {
    width: 100%;
    padding: 10px 14px;
    font-size: 13px;
    color: var(--color-text);
    background: var(--clay-input-bg);
    border: 1.5px solid var(--clay-input-border);
    border-radius: var(--input-radius);
    box-shadow: var(--clay-input-shadow);
    transition: all var(--transition);
}

.form-control:hover,
.form-select:hover {
    border-color: var(--color-primary-light);
}

.form-control:focus,
.form-select:focus {
    outline: none;
    border-color: var(--clay-input-focus-border);
    background: var(--clay-input-focus-bg);
    box-shadow: var(--clay-input-focus-shadow);
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

/* ================================================================
   WORLD-CLASS FORM DESIGN SYSTEM
   ================================================================ */

/* -- Form Hero Banner -- */
.form-hero {
    background: linear-gradient(135deg, var(--color-primary-50) 0%, #fff 100%);
    border: 1.5px solid var(--clay-card-border);
    border-radius: var(--radius-2xl);
    padding: 26px 32px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 18px;
    box-shadow: var(--clay-card-shadow);
}
.form-hero-icon {
    width: 52px; height: 52px;
    background: var(--clay-btn-primary-bg);
    border-radius: var(--radius-lg);
    display: flex; align-items: center; justify-content: center;
    color: #fff; flex-shrink: 0;
    box-shadow: var(--clay-btn-primary-shadow);
}
.form-hero h1 { font-size: 20px; font-weight: 700; margin: 0 0 2px; color: var(--color-text); }
.form-hero p  { font-size: 13px; color: var(--color-text-secondary); margin: 0; }

/* -- Form Section (Card with step number) -- */
.form-section {
    background: var(--clay-card-bg);
    border: 1.5px solid var(--clay-card-border);
    border-radius: var(--radius-2xl);
    margin-bottom: 24px;
    overflow: hidden;
    box-shadow: var(--clay-card-shadow);
    transition: box-shadow var(--transition);
}
.form-section:hover {
    box-shadow: var(--clay-card-shadow-hover);
}
.form-section-header {
    display: flex; align-items: center; gap: 12px;
    padding: 18px 26px;
    border-bottom: 1px solid var(--color-border-light);
    background: linear-gradient(180deg, var(--color-bg-soft) 0%, var(--color-bg) 100%);
}
.form-section-header .form-step {
    width: 32px; height: 32px;
    background: var(--clay-btn-primary-bg);
    color: #fff; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; flex-shrink: 0;
    box-shadow: var(--clay-step-shadow);
}
.form-section-header h6 { margin: 0; font-size: 14px; font-weight: 600; }
.form-section-header .form-hint {
    font-size: 12px; color: var(--color-text-muted); margin-left: auto;
}
.form-section-body { padding: 26px; }

/* -- Form Grid Layouts -- */
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.form-grid-1 { display: grid; grid-template-columns: 1fr; gap: 20px; }
.form-span-2 { grid-column: span 2; }
.form-span-full { grid-column: 1 / -1; }

/* -- Field Group -- */
.form-field label {
    display: flex; align-items: center; gap: 6px;
    font-size: 13px; font-weight: 600; color: var(--color-text);
    margin-bottom: 6px;
}
.form-field label .required {
    color: var(--color-danger); font-size: 14px; line-height: 1;
}
.form-field .help-text {
    font-size: 12px; color: var(--color-text-muted);
    margin-top: 4px; display: flex; align-items: center; gap: 4px;
}
.form-field .help-text svg { width: 12px; height: 12px; flex-shrink: 0; opacity: 0.5; }
.form-field .invalid-feedback { font-size: 12px; margin-top: 4px; }
/* Validation message rendered next to a hand-written form field. */
.form-error { display: block; font-size: 12px; color: var(--color-danger); margin-top: 4px; }
/* Honeypot: off-screen but not display:none, so bots still fill it. */
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* -- Enhanced Inputs -- */
.form-field .form-control,
.form-field .form-select {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    color: var(--color-text);
    background: var(--clay-input-bg);
    border: 1.5px solid var(--clay-input-border);
    border-radius: var(--input-radius);
    box-shadow: var(--clay-input-shadow);
    transition: all 0.2s ease;
    line-height: 1.5;
}
.form-field .form-control:hover,
.form-field .form-select:hover {
    border-color: var(--color-primary-light);
}
.form-field .form-control:focus,
.form-field .form-select:focus {
    outline: none;
    border-color: var(--clay-input-focus-border);
    background: var(--clay-input-focus-bg);
    box-shadow: var(--clay-input-focus-shadow);
}
.form-field .form-control::placeholder {
    color: var(--color-text-muted);
    font-size: 13px;
}
.form-field textarea.form-control {
    min-height: 100px;
    resize: vertical;
    line-height: 1.6;
}
.form-field .form-control.is-invalid,
.form-field .form-select.is-invalid {
    border-color: var(--color-danger);
    box-shadow: inset 1px 1px 2px rgb(214 69 69 / 0.1), 0 0 0 3px var(--color-danger-light);
}

/* -- Checkbox / Radio Groups -- */
.form-check-group {
    display: flex; flex-wrap: wrap; gap: 12px;
}
.form-check-item {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 18px;
    border: 1.5px solid var(--clay-input-border);
    border-radius: var(--input-radius);
    background: var(--clay-card-bg);
    box-shadow: var(--clay-pill-shadow);
    cursor: pointer;
    transition: all 0.18s ease;
    font-size: 13px; font-weight: 500;
}
.form-check-item:hover {
    border-color: var(--color-primary-200);
    background: var(--color-primary-50);
    transform: translateY(-1px);
}
.form-check-item:has(input:checked) {
    border-color: var(--color-primary);
    background: var(--color-primary-50);
    color: var(--color-primary-700);
    box-shadow: var(--clay-pill-checked-shadow);
}
.form-check-item input[type="radio"],
.form-check-item input[type="checkbox"] {
    accent-color: var(--color-primary);
    width: 16px; height: 16px;
}

/* -- Toggle Switch -- */
.form-switch-wrap {
    display: flex; align-items: center; gap: 10px;
}
.form-switch-wrap label { margin-bottom: 0; }
.toggle-switch {
    position: relative; width: 46px; height: 26px; flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; inset: 0;
    background: var(--clay-input-bg);
    border: 1.5px solid var(--color-border);
    border-radius: 26px; cursor: pointer;
    box-shadow: inset 1px 1px 3px rgb(37 33 43 / 0.1), inset -1px -1px 2px rgb(255 255 255 / 0.8);
    transition: 0.25s ease;
}
.toggle-slider::before {
    content: '';
    position: absolute; width: 18px; height: 18px;
    left: 3px; bottom: 3px;
    background: #fff; border-radius: 50%;
    box-shadow: 0 2px 5px rgb(37 33 43 / 0.2), inset 1px 1px 1px rgb(255 255 255 / 1);
    transition: 0.25s ease;
}
.toggle-switch input:checked + .toggle-slider {
    background: var(--color-primary);
    border-color: var(--color-primary);
    box-shadow: inset 1px 1px 2px rgb(91 22, 201 / 0.3);
}
.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

/* -- File Upload -- */
.form-file-upload {
    border: 2px dashed var(--color-primary-200);
    border-radius: var(--radius-2xl);
    padding: 36px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--clay-input-bg);
    box-shadow: var(--clay-input-shadow);
}
.form-file-upload:hover {
    border-color: var(--color-primary);
    background: var(--color-primary-50);
    box-shadow: var(--clay-pill-checked-shadow);
}
.form-file-upload svg {
    width: 40px; height: 40px;
    color: var(--color-primary);
    margin-bottom: 12px;
}
.form-file-upload p {
    font-size: 13px; color: var(--color-text-secondary);
    margin: 0 0 4px;
}
.form-file-upload small {
    font-size: 12px; color: var(--color-text-muted);
}
.form-file-upload input[type="file"] {
    position: absolute; width: 1px; height: 1px;
    overflow: hidden; clip: rect(0,0,0,0);
}

/* -- Bottom Action Bar -- */
.form-bottom-bar {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--clay-card-bg);
    border: 1.5px solid var(--clay-card-border);
    border-radius: var(--radius-xl);
    padding: 16px 26px;
    position: sticky; bottom: 12px;
    box-shadow: var(--clay-bottom-bar-shadow);
    z-index: 10;
    margin-top: 20px;
}
.form-bottom-bar .form-actions { display: flex; gap: 8px; }
.form-bottom-bar .form-status {
    font-size: 13px; color: var(--color-text-muted);
}

/* -- Form Summary / Info Cards -- */
.form-info-card {
    background: var(--color-info-light);
    border: 1px solid var(--color-info);
    border-radius: var(--radius);
    padding: 12px 16px;
    display: flex; align-items: flex-start; gap: 10px;
    font-size: 13px; color: var(--color-info-text);
    margin-bottom: 16px;
}
.form-info-card svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }

/* -- Responsive -- */
@media (max-width: 900px) {
    .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
    .form-span-2 { grid-column: span 1; }
    .form-bottom-bar { flex-direction: column; gap: 12px; }
}
@media (max-width: 600px) {
    .form-section-body { padding: 16px; }
    .form-hero { padding: 16px; }
    .form-hero-icon { width: 40px; height: 40px; }
    .form-hero h1 { font-size: 17px; }
}

/* ================================================================
   FORM SYSTEM: REFINED ENTERPRISE ENHANCEMENTS
   Ensures EVERY native widget is polished, even when rendered bare
   via `{{ field }}` (no form-control/form-select classes required).
   Loaded after Bootstrap, so these token-driven rules win.
   ================================================================ */

/* -- Unified control look (bare elements inside any form container) -- */
/* A 44px control is a finger-sized target. A 1.5px border is thicker than
   the 1px on the cards around it, which is what makes a form read as a
   form rather than as more of the same white surfaces. These containers no
   longer declare --input-radius of their own: the root value is the value,
   so the input radius is changed in exactly one place. */
.form-field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]),
.form-field select,
.form-field textarea,
.form-group input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]),
.form-group select,
.form-group textarea,
.line-item-form input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.line-item-form select,
.line-item-form textarea,
.form-row .form-group input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.form-row .form-group select,
.form-row .form-group textarea {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--clay-input-bg);
    border: 1.5px solid var(--clay-input-border);
    border-radius: var(--input-radius);
    box-shadow: var(--clay-input-shadow);
    min-height: 44px;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
    font-family: inherit;
}
.form-field textarea,
.form-group textarea,
.line-item-form textarea {
    min-height: 92px;
    resize: vertical;
    line-height: 1.6;
    padding: 12px 14px;
}
/* A manifest row is a table row, not a form card, so its notes box is one line
   tall. A 92px textarea in a table cell makes the row three times the height of
   the four inputs beside it. */
.line-item-form.table td textarea {
    min-height: 38px;
    padding: 8px 12px;
    line-height: 1.5;
}
.form-field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):hover,
.form-field select:hover,
.form-field textarea:hover,
.form-group input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):hover,
.form-group select:hover,
.form-group textarea:hover,
.line-item-form input:hover,
.line-item-form select:hover,
.line-item-form textarea:hover {
    border-color: var(--color-primary-light);
}
.form-field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):focus,
.form-field select:focus,
.form-field textarea:focus,
.form-group input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):focus,
.form-group select:focus,
.form-group textarea:focus,
.line-item-form input:focus,
.line-item-form select:focus,
.line-item-form textarea:focus {
    outline: none;
    border-color: var(--clay-input-focus-border);
    box-shadow: var(--clay-input-focus-shadow);
    background: var(--clay-input-focus-bg);
}

/* -- File input --
   The rules above deliberately leave [type="file"] alone, because padding and a
   border on a file input shift the native button the browser draws. Left that
   way, though, an upload field rendered with {{ form.logo }} or {{ form.image }}
   shows the operating system's own grey "Choose File" box inside a form where
   every other field has a 1.5px border and 10px padding, so it reads as a
   different object from the two fields above it.

   Styling the ::file-selector-button rather than the input's own face keeps the
   button itself the browser's, so the click target and the file name beside it
   behave exactly as they should, and the field around them matches the rest of
   the form. */
.form-field input[type="file"],
.form-group input[type="file"] {
    width: 100%;
    min-height: 44px;
    padding: 8px 10px;
    font-size: 14px;
    font-family: inherit;
    color: var(--color-text);
    background: var(--clay-input-bg);
    border: 1.5px solid var(--clay-input-border);
    border-radius: var(--input-radius);
    box-shadow: var(--clay-input-shadow);
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
    cursor: pointer;
}
.form-field input[type="file"]:hover,
.form-group input[type="file"]:hover {
    border-color: var(--color-primary-light);
}
.form-field input[type="file"]:focus,
.form-group input[type="file"]:focus {
    outline: none;
    border-color: var(--clay-input-focus-border);
    box-shadow: var(--clay-input-focus-shadow);
}
.form-field input[type="file"]::file-selector-button,
.form-group input[type="file"]::file-selector-button {
    margin-right: 12px;
    padding: 6px 14px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
    background: var(--clay-btn-secondary-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    box-shadow: var(--clay-pill-shadow);
    cursor: pointer;
    transition: all var(--transition-fast);
}
.form-field input[type="file"]::file-selector-button:hover,
.form-group input[type="file"]::file-selector-button:hover {
    background: var(--color-primary-50);
    border-color: var(--color-primary-200);
    color: var(--color-primary);
}
/* The drop zone is a component of its own: it shows a styled box and reveals a
   hidden input on click, so the rules above must not give that hidden input a
   border. Naming both elements puts this at (0,3,1), above the (0,2,1) above
   it, which means the order of the two no longer decides the outcome. */
.form-field .form-file-upload input[type="file"],
.form-group .form-file-upload input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    min-height: 0;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
    border-radius: 0;
}

/* -- Placeholder -- */
.form-field ::placeholder,
.form-group ::placeholder,
.line-item-form ::placeholder {
    color: var(--color-text-muted);
    font-size: 13px;
}

/* -- Custom select chevron -- */
.form-field select,
.form-group select,
.line-item-form select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23788b9e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
}

/* -- Autofill (neutralize browser yellow) -- */
.form-field input:-webkit-autofill,
.form-group input:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 1000px #fff inset;
    -webkit-text-fill-color: var(--color-text);
    caret-color: var(--color-text);
    border-radius: 10px;
}

/* -- Number / date / time spinners and pickers -- */
.form-field input[type="number"],
.form-group input[type="number"] {
    font-variant-numeric: tabular-nums;
}
.form-field input[type="number"]::-webkit-inner-spin-button,
.form-group input[type="number"]::-webkit-inner-spin-button {
    opacity: 1;
}
.form-field input[type="date"],
.form-field input[type="time"],
.form-field input[type="datetime-local"],
.form-group input[type="date"],
.form-group input[type="time"],
.form-group input[type="datetime-local"] {
    min-height: 44px;
}

/* -- Plain checkbox / radio (native accent) -- */
.form-field input[type="checkbox"],
.form-field input[type="radio"],
.form-group input[type="checkbox"],
.form-group input[type="radio"],
.qf-total-row input,
.budget-row input,
.per-row input,
input[type="checkbox"],
input[type="radio"] {
    accent-color: var(--color-primary);
}

/* ================================================================
   WORLD-CLASS FORM COMPONENTS (shared partials)
   ================================================================ */

/* -- Form Hero (premium) -- */
/* A violet wash in one corner and an ink wash in the other, over the
   soft purple the page already uses. rgb() literals here because a
   gradient needs an alpha channel, and a token cannot hold one without
   giving up its name. */
.form-hero {
    position: relative;
    background:
        radial-gradient(1200px 300px at -10% -20%, rgb(123 45 240 / 0.09), transparent 60%),
        radial-gradient(900px 260px at 110% 0%, rgb(41 35 51 / 0.05), transparent 55%),
        linear-gradient(135deg, #ffffff 0%, var(--color-primary-50) 100%);
    border: 1px solid var(--color-primary-100);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.form-hero .form-hero-icon {
    box-shadow: 0 8px 20px -6px rgb(123 45 240 / 0.4);
}
.form-hero h1 {
    letter-spacing: -0.02em;
}

/* -- Section header (hero-form) -- */
.form-section {
    border-color: var(--color-border);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s ease;
}
.form-section:hover {
    box-shadow: var(--shadow-md);
}
.form-section-header {
    background: linear-gradient(180deg, #ffffff, var(--color-primary-50));
    padding: 18px 24px;
}
.form-section-header .form-step {
    width: 30px;
    height: 30px;
    font-size: 12px;
    box-shadow: 0 4px 10px -3px rgb(123 45 240 / 0.45);
}
.form-section-header h6 {
    font-size: 14.5px;
    letter-spacing: -0.01em;
}

/* -- Workspace (tenant subdomain) address preview -- */
.workspace-url-preview {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px 12px;
    padding: 12px 16px;
    margin-bottom: 18px;
    border: 1px dashed var(--color-primary-200);
    border-radius: 10px;
    background: var(--color-primary-50);
}
.workspace-url-preview .workspace-url-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--color-text-secondary);
}
.workspace-url-preview a {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-primary);
    word-break: break-all;
}

/* -- Colour picker: native swatch beside an editable hex value -- */
.color-input {
    display: flex;
    align-items: center;
    gap: 8px;
}
.color-input .color-swatch {
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    padding: 3px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
}
.color-input .color-swatch::-webkit-color-swatch-wrapper { padding: 0; }
.color-input .color-swatch::-webkit-color-swatch { border: none; border-radius: 5px; }
.color-input .color-swatch::-moz-color-swatch { border: none; border-radius: 5px; }
.color-input .form-control { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.color-field.is-invalid .color-swatch { border-color: var(--color-danger); }

/* -- Letterhead preview: what a customer sees at the top of a document -- */
.letterhead-preview {
    border: 1px solid var(--color-border);
    border-radius: 12px;
    overflow: hidden;
    background: var(--color-bg-card);
}
.letterhead-preview-bar {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 14px;
    background: var(--color-bg-soft);
    border-bottom: 1px solid var(--color-border);
}
.letterhead-preview-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--color-text-secondary);
}
.letterhead-preview-hint { font-size: 12px; color: var(--color-text-muted); }
.letterhead-preview-link {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-primary);
    text-decoration: none;
    white-space: nowrap;
}
.letterhead-preview-link:hover { text-decoration: underline; }
.letterhead-preview-sheet {
    padding: 26px 28px 22px;
    max-width: 560px;
}
.letterhead-preview-head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}
.letterhead-preview-logo {
    width: 52px;
    height: 52px;
    object-fit: contain;
    flex: 0 0 auto;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 3px;
    background: #fff;
}
.letterhead-preview-logo.is-placeholder {
    background: repeating-linear-gradient(45deg, var(--color-bg-hover) 0 6px, var(--color-border) 6px 12px);
}
.letterhead-preview-name { min-width: 0; }
.letterhead-preview-company {
    font-size: 15px;
    font-weight: 700;
    color: var(--color-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.letterhead-preview-meta {
    font-size: 12px;
    color: var(--color-text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.letterhead-preview-rule {
    height: 2px;
    border-radius: 2px;
    margin-bottom: 18px;
    background: #1e40af;
}
.letterhead-preview-recipient {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 18px;
}
.letterhead-preview-subject { font-size: 14px; font-weight: 700; color: var(--color-text); margin-bottom: 12px; }
.letterhead-preview-line {
    height: 7px;
    border-radius: 3px;
    background: var(--color-border);
    margin-bottom: 8px;
}
.letterhead-preview-line.is-short { width: 58%; }
.letterhead-preview-signoff {
    font-size: 12px;
    color: var(--color-text-secondary);
    margin-top: 26px;
    min-height: 17px;
}
.letterhead-preview-foot {
    margin-top: 26px;
    padding-top: 10px;
    border-top: 1px solid var(--color-border);
    font-size: 10px;
    color: var(--color-text-muted);
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media print {
    .letterhead-preview { display: none; }
}

/* -- Form info card -- */
.form-info-card {
    border-left: 4px solid var(--color-info);
    background: linear-gradient(90deg, var(--color-info-light), var(--color-info-light));
    box-shadow: var(--shadow-sm);
}

/* -- Bottom action bar (friendlier) -- */
.form-bottom-bar {
    border: 1px solid var(--color-border);
    padding: 16px 24px;
    backdrop-filter: saturate(1.2);
}

/* -- Buttons within forms (consistent height with inputs) -- */
.form-actions .btn {
    min-height: 44px;
    padding: 10px 20px;
    font-weight: 600;
    border-radius: 10px;
}

/* -- Labels: balanced, clear -- */
.form-field > label,
.form-group > label,
.form-group label,
.form-field label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--color-text);
    letter-spacing: 0.01em;
}
.form-field label .required,
.form-group label .required,
.form-field label .required,
span.required {
    color: var(--color-danger);
    font-weight: 700;
}

/* -- Error state on bare widgets -- */
.invalid-feedback {
    color: var(--color-danger);
    font-size: 12px;
    margin-top: 4px;
}
.form-field:has(.is-invalid),
.form-group:has(.is-invalid) {
    /* reserved hook */
}

/* ============================================================
   TABS / SEGMENTED FORMS (form sections via tabs)
   ============================================================ */
.ff-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 20px;
    padding: 6px;
    background: var(--color-bg-soft);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    max-width: 100%;
    overflow-x: auto;
}
.ff-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-secondary);
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    user-select: none;
    white-space: nowrap;
}
.ff-tab:hover { background: #fff; color: var(--color-text); border-color: var(--color-border); }
.ff-tab.is-active {
    background: #fff;
    color: var(--color-primary);
    border-color: var(--color-border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.form-tabpane { display: none; }
.form-tabpane.is-active { display: block; }

/* ---- Kanban Board ---- */
.kanban-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.kanban-column {
    background: var(--color-bg);
    border-radius: var(--radius-lg);
    padding: 12px;
    min-width: 240px;
}

.kanban-column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--color-border);
}

.kanban-column-title {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-text-secondary);
}

.kanban-column-count {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-muted);
    background: var(--color-bg-card);
    padding: 2px 8px;
    border-radius: 10px;
}

.kanban-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all var(--transition);
}

.kanban-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.kanban-card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 6px;
}

.kanban-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--color-text-muted);
}

.kanban-card-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--color-primary-100);
    color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
}

/* ---- Empty States ----
   An empty list is a dead end unless it offers the next move, so the
   markup puts an action in here and the styling gives it somewhere to
   sit. The icon sits in a soft purple well rather than floating grey. */
.empty-state {
    text-align: center;
    padding: 72px 24px;
    color: var(--color-text-secondary);
    background: var(--color-bg-card);
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-xl);
}

.empty-state svg {
    width: 40px;
    height: 40px;
    color: var(--color-primary);
    margin-bottom: var(--space-5);
    padding: 14px;
    box-sizing: content-box;
    background: var(--color-primary-100);
    border-radius: var(--radius-xl);
}

.empty-state h4 {
    font-size: var(--text-xl);
    font-weight: 600;
    color: var(--color-text);
    margin: 0 0 var(--space-2);
    letter-spacing: -0.01em;
}

.empty-state p {
    font-size: var(--text-md);
    max-width: 44ch;
    margin: 0 auto var(--space-5);
    line-height: 1.6;
}

/* ---- Activity Feed / Timeline ---- */
.activity-timeline {
    list-style: none;
    padding: 0;
    margin: 0;
}

.activity-item {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--color-border-light);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-primary);
    margin-top: 5px;
    flex-shrink: 0;
}

.activity-content {
    flex: 1;
}

.activity-content strong {
    font-size: 13px;
}

.activity-content p {
    margin: 2px 0 0;
    font-size: 13px;
    color: var(--color-text-secondary);
}

.activity-time {
    font-size: 12px;
    color: var(--color-text-muted);
    white-space: nowrap;
}

/* ---- Toast Notifications ---- */
.toast-container {
    position: fixed;
    top: 80px;
    right: 24px;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 14px 18px;
    border-radius: var(--radius-lg);
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-lg);
    font-size: var(--text-sm);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 300px;
    animation: slideIn var(--transition) ease;
}

.toast.success { border-left: 4px solid var(--color-success); }
.toast.error { border-left: 4px solid var(--color-danger); }
.toast.warning { border-left: 4px solid var(--color-warning); }
.toast.info { border-left: 4px solid var(--color-info); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ================================================================
   SKELETON LOADERS

   A skeleton that matches the shape of the content that is coming beats
   a spinner: the reader sees the page arriving rather than seeing the
   platform admit it has nothing yet. The pulse is a single 1.5s cycle
   and is disabled wholesale under prefers-reduced-motion, above.
   ================================================================ */
.skeleton {
    display: block;
    background: linear-gradient(
        90deg,
        var(--color-bg-hover) 25%,
        var(--color-border-light) 37%,
        var(--color-bg-hover) 63%
    );
    background-size: 400% 100%;
    border-radius: var(--radius-sm);
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}

.skeleton-text {
    height: 12px;
    margin-bottom: 8px;
}

.skeleton-text.short { width: 40%; }
.skeleton-text.medium { width: 65%; }
.skeleton-text.full { width: 100%; }

.skeleton-title { height: 22px; width: 45%; margin-bottom: 14px; }
.skeleton-avatar { width: 40px; height: 40px; border-radius: 50%; }
.skeleton-card { height: 108px; border-radius: var(--radius-xl); }

@keyframes skeleton-pulse {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

/* ================================================================
   AVATARS

   Initial-based, tinted from a fixed set of soft fills. The colour is
   chosen by the template, not derived from the name, so the same person
   is the same colour on every page.
   ================================================================ */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-sm);
    font-weight: 700;
    flex-shrink: 0;
    user-select: none;
    letter-spacing: 0.01em;
}

.avatar-sm { width: 32px; height: 32px; font-size: var(--text-xs); }
.avatar-lg { width: 64px; height: 64px; font-size: var(--text-xl); }

.avatar.tone-purple { background: var(--color-primary-100); color: var(--color-primary-dark); }
.avatar.tone-blue   { background: var(--color-info-light); color: var(--color-info-text); }
.avatar.tone-green  { background: var(--color-success-light); color: var(--color-success-text); }
.avatar.tone-amber  { background: var(--color-warning-light); color: var(--color-warning-text); }
.avatar.tone-red    { background: var(--color-danger-light); color: var(--color-danger-text); }
.avatar.tone-grey   { background: var(--color-bg-hover); color: var(--color-text-secondary); }

/* ================================================================
   PAGE TRANSITION

   Content rises 6px and fades in on the way to a new page. Short enough
   not to be felt as a wait, and cut to nothing by the reduced-motion
   rule near the top of this file.
   ================================================================ */
@keyframes page-enter {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.page-content > * {
    animation: page-enter var(--transition) ease both;
}

@media (prefers-reduced-motion: reduce) {
    .page-content > * { animation: none; }
    .skeleton { animation: none; }
}

/* ================================================================
   DARK FEATURE PANEL

   The one place the interface goes dark. A banded near-black section
   with a purple glow reads as depth against the off-white page, and is
   what keeps the brand from being purple on every single surface.
   ================================================================ */
.feature-panel {
    background:
        radial-gradient(900px 400px at 15% 0%, rgb(123 45 240 / 0.22), transparent 60%),
        linear-gradient(160deg, var(--color-ink) 0%, var(--color-ink-2) 100%);
    color: #fff;
    border-radius: var(--radius-2xl);
    padding: var(--space-10);
}

.feature-panel h2,
.feature-panel h3 { color: #fff; letter-spacing: -0.02em; }

.feature-panel p { color: rgb(255 255 255 / 0.72); }

.feature-panel .feature-panel-muted { color: rgb(255 255 255 / 0.55); }

/* ---- Detail Page Sections ---- */
.detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
}

.detail-meta {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.detail-meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--color-text-secondary);
}

.detail-meta-item svg {
    width: 14px;
    height: 14px;
    color: var(--color-text-muted);
}

.detail-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

.detail-sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ---- Charts Container ---- */
.chart-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.chart-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chart-card-header h6 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

.chart-card-body {
    padding: 20px;
}

.chart-card-body canvas {
    max-height: 300px;
}

/* ---- Utility Classes ---- */
.text-primary { color: var(--color-primary) !important; }
.text-success { color: var(--color-success) !important; }
.text-warning { color: var(--color-warning) !important; }
.text-danger { color: var(--color-danger) !important; }
.text-info { color: var(--color-info) !important; }
.text-muted { color: var(--color-text-muted) !important; }
.text-secondary { color: var(--color-text-secondary) !important; }

.bg-primary-subtle { background: var(--color-primary-50) !important; }
.bg-success-subtle { background: var(--color-success-light) !important; }
.bg-warning-subtle { background: var(--color-warning-light) !important; }
.bg-danger-subtle { background: var(--color-danger-light) !important; }

.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 4px !important; }
.mb-2 { margin-bottom: 8px !important; }
.mb-3 { margin-bottom: 16px !important; }
.mb-4 { margin-bottom: 24px !important; }

.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 4px !important; }
.mt-2 { margin-top: 8px !important; }
.mt-3 { margin-top: 16px !important; }
.mt-4 { margin-top: 24px !important; }

.gap-2 { gap: 8px !important; }
.gap-3 { gap: 16px !important; }

.d-flex { display: flex !important; }
.align-items-center { align-items: center !important; }
.justify-content-between { justify-content: space-between !important; }
.flex-wrap { flex-wrap: wrap !important; }

/* ================================================================
   NOTIFICATION SYSTEM: WORLD-CLASS UI
   ================================================================ */

/* -- Channel Status Overview Cards -- */
.notif-channels-overview {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.notif-channel-status-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
}

.notif-channel-status-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.notif-channel-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.notif-channel-icon.whatsapp {
    background: #dcf8c6;
    color: #25D366;
}

.notif-channel-icon.email {
    background: var(--color-primary-50);
    color: var(--color-primary);
}

.notif-channel-icon.sms {
    background: var(--color-info-light);
    color: var(--color-info);
}

.notif-channel-icon.bell {
    background: var(--color-info-light);
    color: var(--color-info);
}

.notif-channel-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.notif-channel-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
}

.notif-channel-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-muted);
}

.notif-channel-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.notif-channel-dot.green {
    background: var(--color-success);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.notif-channel-dot.gray {
    background: var(--color-text-muted);
}

.notif-channel-badge.active {
    color: var(--color-success);
    font-weight: 600;
}

/* -- Toggle Switch (Enhanced) -- */
.notif-toggle-label {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    cursor: pointer;
    padding: 4px 0;
}

.notif-toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
    margin-top: 2px;
}

.notif-toggle-switch.small {
    width: 36px;
    height: 20px;
}

.notif-toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.notif-toggle-track {
    position: absolute;
    inset: 0;
    background: var(--color-border);
    border-radius: 24px;
    cursor: pointer;
    transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.notif-toggle-track::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.notif-toggle-switch.small .notif-toggle-track::before {
    width: 14px;
    height: 14px;
    left: 3px;
    bottom: 3px;
}

.notif-toggle-switch input:checked + .notif-toggle-track {
    background: var(--color-primary);
}

.notif-toggle-switch input:checked + .notif-toggle-track::before {
    transform: translateX(20px);
}

.notif-toggle-switch.small input:checked + .notif-toggle-track::before {
    transform: translateX(16px);
}

.notif-toggle-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.notif-toggle-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
}

.notif-toggle-desc {
    font-size: 12px;
    color: var(--color-text-muted);
    line-height: 1.4;
}

/* -- Divider -- */
.notif-divider {
    height: 1px;
    background: var(--color-border-light);
    margin: 24px 0;
}

/* -- Section Label -- */
.notif-section-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* -- Credentials Grid -- */
.notif-credentials-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* -- Password Toggle -- */
.notif-password-wrap {
    position: relative;
}

.notif-password-wrap .form-control {
    padding-right: 40px;
}

.notif-password-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.notif-password-toggle:hover {
    color: var(--color-text);
    background: var(--color-bg-hover);
}

/* -- Backend Select Cards -- */
.notif-backend-select {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.notif-backend-option {
    cursor: pointer;
}

.notif-backend-option input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.notif-backend-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius);
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-secondary);
}

.notif-backend-option:hover .notif-backend-card {
    border-color: var(--color-primary-200);
    background: var(--color-primary-50);
    color: var(--color-primary);
}

.notif-backend-option.active .notif-backend-card,
.notif-backend-option input:checked + .notif-backend-card {
    border-color: var(--color-primary);
    background: var(--color-primary-50);
    color: var(--color-primary-700);
    font-weight: 600;
}

/* -- Event Preference Groups -- */
.notif-event-group {
    margin-bottom: 20px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.notif-event-group:last-child {
    margin-bottom: 0;
}

.notif-event-group-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border-light);
}

.notif-event-group-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* One hue per app, so a reader can tell which queue a line came from
   before reading it. Support takes the brand purple; the rest take a
   semantic hue. Every one is a token pair, not a literal. */
.notif-event-group-icon.crm { background: var(--color-info-light); color: var(--color-info-text); }
.notif-event-group-icon.billing { background: var(--color-warning-light); color: var(--color-warning-text); }
.notif-event-group-icon.support { background: var(--color-primary-100); color: var(--color-primary-dark); }
.notif-event-group-icon.finance { background: var(--color-success-light); color: var(--color-success-text); }
.notif-event-group-icon.hr { background: var(--color-danger-light); color: var(--color-danger-text); }

.notif-event-group-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
}

.notif-event-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

.notif-event-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    cursor: pointer;
    transition: background var(--transition);
    border-bottom: 1px solid var(--color-border-light);
    border-right: 1px solid var(--color-border-light);
}

.notif-event-item:nth-child(2n) {
    border-right: none;
}

.notif-event-item:last-child,
.notif-event-item:nth-last-child(2):nth-child(odd) {
    border-bottom: none;
}

.notif-event-item:hover {
    background: var(--color-bg-hover);
}

.notif-event-item input[type="checkbox"] {
    display: none;
}

.notif-event-content {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.notif-event-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.notif-event-dot.green { background: var(--color-success); }
.notif-event-dot.blue { background: var(--color-info); }
.notif-event-dot.red { background: var(--color-danger); }
.notif-event-dot.amber { background: var(--color-warning); }

.notif-event-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text);
    display: block;
}

.notif-event-desc {
    font-size: 11px;
    color: var(--color-text-muted);
    display: block;
    margin-top: 1px;
}

.notif-event-item:has(input:checked) {
    background: var(--color-primary-50);
}

.notif-event-item:has(input:checked) .notif-event-dot {
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

/* -- Test Cards -- */
.notif-test-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.notif-test-card {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all var(--transition);
}

.notif-test-card:hover {
    box-shadow: var(--shadow-md);
}

.notif-test-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border-light);
}

.notif-test-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.notif-test-icon.whatsapp {
    background: #dcf8c6;
    color: #25D366;
}

.notif-test-icon.email {
    background: var(--color-primary-50);
    color: var(--color-primary);
}

.notif-test-icon.sms {
    background: var(--color-info-light);
    color: var(--color-info);
}

.notif-test-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
    display: block;
}

.notif-test-desc {
    font-size: 12px;
    color: var(--color-text-muted);
    display: block;
}

.notif-test-body {
    padding: 20px;
}

.notif-test-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--color-info-light);
    border-radius: var(--radius);
    font-size: 12px;
    color: var(--color-info-text);
    margin-bottom: 16px;
}

/* ================================================================
   NOTIFICATION LOG: WORLD-CLASS UI
   ================================================================ */

/* -- Log Stats -- */
.notif-log-stats {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.notif-log-stat-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
}

.notif-log-stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.notif-log-stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.notif-log-stat-icon.primary { background: var(--color-primary-50); color: var(--color-primary); }
.notif-log-stat-icon.success { background: var(--color-success-light); color: var(--color-success); }
.notif-log-stat-icon.whatsapp { background: #dcf8c6; color: #25D366; }
.notif-log-stat-icon.email { background: var(--color-info-light); color: var(--color-info-text); }
.notif-log-stat-icon.danger { background: var(--color-danger-light); color: var(--color-danger); }

.notif-log-stat-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.notif-log-stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.1;
}

.notif-log-stat-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-muted);
}

/* -- Log Filters -- */
.notif-log-filters {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.notif-filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.notif-filter-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

/* -- Log Table Row Enhancements -- */
.notif-log-row {
    transition: all var(--transition);
}

.notif-log-row:hover {
    background: var(--color-bg-hover) !important;
}

.notif-log-channel-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.notif-log-channel-dot.whatsapp { background: #25D366; }
.notif-log-channel-dot.email { background: var(--color-info); }
.notif-log-channel-dot.inapp { background: var(--color-text-muted); }

.notif-log-channel-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.notif-log-channel-badge.whatsapp {
    background: #dcf8c6;
    color: var(--color-info-text);
}

.notif-log-channel-badge.email {
    background: var(--color-info-light);
    color: var(--color-info-text);
}

.notif-log-channel-badge.inapp {
    background: var(--color-bg);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
}

.notif-log-event-badge {
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-secondary);
    padding: 3px 10px;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

.notif-log-recipient {
    display: flex;
    align-items: center;
    gap: 10px;
}

.notif-log-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--color-primary-100);
    color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    flex-shrink: 0;
}

.notif-log-recipient-info {
    display: flex;
    flex-direction: column;
}

.notif-log-recipient-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text);
}

.notif-log-recipient-detail {
    font-size: 11px;
    color: var(--color-text-muted);
}

.notif-log-subject {
    font-size: 13px;
    color: var(--color-text-secondary);
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

.notif-log-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.notif-log-status-badge.sent {
    background: var(--color-success-light);
    color: var(--color-success-text);
}

.notif-log-status-badge.failed {
    background: var(--color-danger-light);
    color: var(--color-danger-text);
    cursor: help;
}

.notif-log-status-badge.pending {
    background: var(--color-warning-light);
    color: var(--color-warning-text);
}

.notif-log-time {
    display: flex;
    flex-direction: column;
    gap: 1px;
    white-space: nowrap;
}

.notif-log-date {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text);
}

.notif-log-clock {
    font-size: 11px;
    color: var(--color-text-muted);
}

/* -- Empty State (Enhanced) -- */
.notif-log-empty {
    text-align: center;
    padding: 60px 20px;
}

.notif-log-empty-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--color-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    color: var(--color-text-muted);
}

.notif-log-empty h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 8px;
}

.notif-log-empty p {
    font-size: 13px;
    color: var(--color-text-secondary);
    max-width: 400px;
    margin: 0 auto;
    line-height: 1.6;
}

/* -- Topbar Notification Bell -- */
.notif-bell-btn {
    position: relative;
}

.notif-bell-count {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    background: var(--color-danger);
    color: #fff;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--color-bg-card);
    animation: notifPulse 2s infinite;
}

.notif-bell-count:empty,
.notif-bell-count[data-count="0"] {
    display: none;
}

@keyframes notifPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* -- Notification Dropdown Panel -- */
.notif-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 380px;
    max-height: 480px;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    z-index: 1000;
    display: none;
    animation: notifSlideDown 0.2s ease;
}

.notif-dropdown.show {
    display: block;
}

@keyframes notifSlideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.notif-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--color-border-light);
}

.notif-dropdown-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
}

.notif-dropdown-link {
    font-size: 12px;
    font-weight: 500;
    color: var(--color-primary);
}

.notif-dropdown-body {
    max-height: 360px;
    overflow-y: auto;
}

.notif-dropdown-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border-light);
    transition: background var(--transition);
    cursor: default;
}

.notif-dropdown-item:hover {
    background: var(--color-bg-hover);
}

.notif-dropdown-item:last-child {
    border-bottom: none;
}

.notif-dropdown-item-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.notif-dropdown-item-icon.whatsapp { background: #dcf8c6; color: #25D366; }
.notif-dropdown-item-icon.email { background: var(--color-primary-50); color: var(--color-primary); }

.notif-dropdown-item-text {
    flex: 1;
    min-width: 0;
}

.notif-dropdown-item-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text);
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notif-dropdown-item-meta {
    font-size: 11px;
    color: var(--color-text-muted);
    display: block;
    margin-top: 2px;
}

.notif-dropdown-empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--color-text-muted);
    font-size: 13px;
}

.notif-dropdown-empty svg {
    width: 32px;
    height: 32px;
    margin-bottom: 8px;
    opacity: 0.4;
}

/* -- Responsive -- */
@media (max-width: 1200px) {
    .notif-log-stats {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 900px) {
    .notif-channels-overview {
        grid-template-columns: 1fr;
    }
    .notif-event-grid {
        grid-template-columns: 1fr;
    }
    .notif-test-grid {
        grid-template-columns: 1fr;
    }
    .notif-credentials-grid {
        grid-template-columns: 1fr;
    }
    .notif-log-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    .notif-log-filters {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 600px) {
    .notif-log-stats {
        grid-template-columns: 1fr;
    }
    .notif-dropdown {
        width: 100%;
        right: -60px;
    }
}

/* ---- Login Page ---- */
/* The sign-in page is the one screen a visitor sees before they are in,
   so it carries the brand at full strength: near-black ink with a violet
   glow, rather than the pale page the rest of the app sits on. */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(1000px 520px at 20% 10%, rgb(123 45 240 / 0.35), transparent 60%),
        radial-gradient(800px 460px at 90% 90%, rgb(91 22 201 / 0.3), transparent 55%),
        linear-gradient(150deg, var(--color-ink) 0%, var(--color-ink-2) 100%);
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--clay-card-bg);
    border: 1.5px solid var(--clay-card-border);
    border-radius: var(--radius-2xl);
    padding: 40px;
    box-shadow: var(--clay-card-shadow);
    transition: box-shadow var(--transition);
}

.login-card:hover {
    box-shadow: var(--clay-card-shadow-hover);
}

.login-card .login-brand {
    text-align: center;
    margin-bottom: 32px;
}

.login-card .login-brand-icon {
    width: 60px;
    height: 60px;
    background: var(--clay-btn-primary-bg);
    border-radius: var(--radius-xl);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 22px;
    margin-bottom: 16px;
    box-shadow: var(--clay-btn-primary-shadow);
}

.login-card .login-brand h2 {
    font-size: 20px;
    font-weight: 700;
    margin: 0;
}

.login-card .login-brand p {
    font-size: 13px;
    color: var(--color-text-secondary);
    margin: 4px 0 0;
}

/* ---- Responsive ---- */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .topbar-toggle {
        display: flex;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 999;
    }

    .sidebar-overlay.show {
        display: block;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .kanban-board {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .topbar-search input {
        width: 180px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .page-header-actions {
        width: 100%;
    }

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

    .kanban-board {
        grid-template-columns: 1fr;
    }

    .stat-card {
        flex-direction: row-reverse;
    }

    .topbar-tenant,
    .topbar-user-info {
        display: none;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .filter-tabs {
        overflow-x: auto;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .page-content {
        padding: 16px;
    }

    .topbar {
        padding: 0 12px;
    }

    .topbar-search input {
        width: 140px;
    }
}

/* ---------------------------------------------------------------------------
   Currency
   The switcher is a reading preference, so it sits with the other topbar
   controls rather than in Company Settings where a company sets the currency
   its records are actually kept in.
   --------------------------------------------------------------------------- */
.topbar-currency {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
}

.topbar-currency-label {
    font-size: 11px;
    color: var(--color-text-muted);
    white-space: nowrap;
    margin: 0;
}

.topbar-currency-select {
    height: 32px;
    max-width: 190px;
    padding: 0 24px 0 9px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

.topbar-currency-select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

.fx-notice {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    padding: 9px 13px;
    margin-bottom: 18px;
    background: var(--color-info-light);
    border: 1px solid var(--color-info);
    border-radius: 6px;
    color: var(--color-info-text);
    font-size: 12px;
    line-height: 1.6;
}

.fx-notice svg {
    flex-shrink: 0;
    margin-top: 1px;
}

@media (max-width: 900px) {
    .topbar-currency-label {
        display: none;
    }

    .topbar-currency-select {
        max-width: 108px;
    }
}
/* The currency an amount input expects. A form is never converted, so this is
   the only place a form mentions a currency -- it exists to stop a converted
   number being typed into a field that stores the real one. */
.form-field label .field-currency,
.form-group label .field-currency {
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    background: var(--color-bg-hover);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: 1px 5px;
}

/* ==================================================================
   MOBILE

   One block, written last, because most of what a phone gets wrong here
   is written as an inline style on a div and cannot be reached by any
   selector short of `!important`. Those are handled in one place below
   rather than by editing the seventy-odd templates that carry them, so
   there is a single place to look when a page still does not fit.

   The rule followed throughout: a phone shows fewer things, not smaller
   ones. Columns that cannot be read are stacked, tables that cannot be
   squeezed are scrolled, and controls that cannot be hit are made tall
   enough to hit. Nothing is hidden that a user came to the page to see.
   ================================================================== */

/* -- Any inline two-or-three column grid collapses to one column -- */
@media (max-width: 900px) {
    [style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }

    /* ...except the ones that already adapt on their own. Forcing them to
       one column would undo `auto-fit`, which is doing the right thing
       already and can fit two narrow cards where one would waste the width. */
    [style*="grid-template-columns"][style*="auto-fit"],
    [style*="grid-template-columns"][style*="auto-fill"],
    [style*="grid-template-columns"][style*="minmax"] {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)) !important;
    }
}

@media (max-width: 768px) {
    /* -- Tables: scroll sideways rather than crush.
       An invoice has eight columns. At phone width they cannot be shown
       legibly, and squeezing them produces overlapping figures that look
       like data rather than like a layout that gave up. Scrolling keeps
       every column readable and keeps the row a single object. -- */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table-container .data-table {
        min-width: 640px;
    }

    .card > .card-body:has(> .data-table:only-child),
    .card-body:has(> .data-table:only-child) {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .data-table th,
    .data-table td {
        padding: 10px 12px;
    }

    /* A sticky header on a scrolling table is the difference between
       reading a row and knowing which row you are reading. */
    .table-container .data-table thead th {
        position: sticky;
        top: 0;
        background: var(--color-bg);
        z-index: 1;
    }
}

@media (max-width: 900px) {
    /* -- Multi-column stat rows -- */
    .notif-log-stats,
    .notif-channels-overview {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 640px) {
    /* -- Topbar: the search box is the first thing to go.
       It sits beside the currency switcher, the alert bell and the
       account, and at this width those four cannot share a row. The
       search is the least of them: it is a convenience over filters
       that every list page already carries underneath. -- */
    .topbar-search {
        display: none;
    }

    .topbar {
        gap: 8px;
    }

    .topbar-right {
        gap: 6px;
    }

    .topbar-currency-select {
        max-width: 92px;
    }

    /* -- Page title and actions stack, and the actions go full width so
       a button is a target rather than a sliver. -- */
    .page-header h1 {
        font-size: 20px;
    }

    .page-header-actions {
        flex-wrap: wrap;
    }

    .page-header-actions .btn {
        flex: 1;
        justify-content: center;
    }

    /* -- Cards breathe less -- */
    .card-header,
    .card-body {
        padding: 14px;
    }

    .stat-card {
        padding: 14px;
    }

    /* -- Filters scroll rather than wrap into a tall unusable stack -- */
    .filter-tabs {
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .filter-tabs::-webkit-scrollbar {
        display: none;
    }

    .filter-tab {
        white-space: nowrap;
    }

    /* -- The sticky form action bar cannot be sticky if it is taller
       than the space left for the field above it, so it becomes a
       normal bar at the end of the form. -- */
    .form-bottom-bar {
        position: static;
        padding: 12px 14px;
    }

    .form-bottom-bar .form-actions {
        flex-wrap: wrap;
        width: 100%;
    }

    .form-bottom-bar .form-actions .btn {
        flex: 1;
        min-width: 120px;
    }

    /* -- Login -- */
    .login-card {
        padding: 24px 20px;
        margin: 16px;
    }

    /* -- Any button meant to be pressed with a thumb -- */
    .btn {
        min-height: 40px;
    }

    .topbar-btn {
        min-height: 36px;
        min-width: 36px;
    }

    /* -- Wide grids of small cards: two columns is still readable, and
       one column of a 90px card is just a lot of scrolling. -- */
    .notif-log-stats,
    .notif-channels-overview {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px;
    }
}

@media (max-width: 420px) {
    .page-content {
        padding: 12px;
    }

    .notif-log-stats,
    .notif-channels-overview {
        grid-template-columns: 1fr !important;
    }

    .page-header-actions .btn {
        flex-basis: 100%;
    }
}

/* -- Pointer-precise pointers only.
   A hover rule that survives on a phone means a sticky hover state left
   behind by a tap, so the row stays highlighted long after the finger is
   gone. -- */
@media (hover: none) {
    .data-table tbody tr:hover {
        background: transparent;
    }

    .card:hover {
        box-shadow: var(--shadow-sm);
    }

    .stat-card:hover {
        transform: none;
    }
}

/* -- Respect a stated preference for less motion. -- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}


/* ===================================================================
   Digital Doctors HR Dedicated Sidebar (Active for user.role.code == 'hr')
   =================================================================== */
.hr-brand-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 18px 16px;
    border-bottom: 1px solid var(--color-border);
}

.hr-brand-badge {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: #2563eb;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.28);
    flex-shrink: 0;
}

.hr-nav-list {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 14px 12px 24px;
}

.hr-nav-item {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 10px 14px;
    border-radius: 12px !important;
    color: #475569;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.16s ease;
    border: none;
    position: relative;
}

.hr-nav-item:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.hr-nav-item.active {
    background: #2563eb !important;
    color: #ffffff !important;
    font-weight: 600;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.25);
}

.hr-nav-item.active::before {
    display: none !important;
}

.hr-nav-item svg {
    width: 19px;
    height: 19px;
    flex-shrink: 0;
    stroke: currentColor;
    opacity: 0.85;
}

.hr-nav-item.active svg {
    opacity: 1;
    stroke: #ffffff;
}

/* Upgrade to Pro Card */
.hr-pro-card {
    margin: 24px 2px 10px 2px;
    padding: 18px 14px;
    background: linear-gradient(180deg, #f0f7ff 0%, #e0f2fe 100%);
    border: 1px solid #bae6fd;
    border-radius: 16px;
    text-align: center;
}

.hr-pro-badge {
    width: 44px;
    height: 44px;
    margin: 0 auto 10px;
    background: #ffffff;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
}

.hr-pro-title {
    font-size: 14.5px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 4px;
}

.hr-pro-desc {
    font-size: 12px;
    color: #475569;
    line-height: 1.4;
    margin: 0 0 12px 0;
}

.hr-pro-btn {
    display: block;
    width: 100%;
    padding: 9px 0;
    background: #2563eb;
    color: #ffffff !important;
    font-size: 13px;
    font-weight: 600;
    border-radius: 9px;
    text-align: center;
    text-decoration: none;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
    transition: background 0.15s ease;
}

.hr-pro-btn:hover {
    background: #1d4ed8;
}

/* Dark mode adjustments */
[data-theme="dark"] .hr-brand-header {
    border-color: #334155;
}

[data-theme="dark"] .hr-nav-item {
    color: #94a3b8;
}

[data-theme="dark"] .hr-nav-item:hover {
    background: #1e293b;
    color: #f8fafc;
}

[data-theme="dark"] .hr-nav-item.active {
    background: #2563eb !important;
    color: #ffffff !important;
}

[data-theme="dark"] .hr-pro-card {
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    border-color: #334155;
}

[data-theme="dark"] .hr-pro-badge {
    background: #1e293b;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .hr-pro-title {
    color: #f8fafc;
}

[data-theme="dark"] .hr-pro-desc {
    color: #94a3b8;
}
