:root {
    --cd-primary: #1e6fd9;
    --cd-header-bg: #ffffff;
    --cd-nav-bg: #17324d;
    --cd-nav-fg: #e8eef5;
    --cd-nav-hover: #22476d;
    --cd-page-bg: #f3f5f8;
    --cd-border: #dde3ea;
    --cd-header-h: 56px;
    --cd-nav-h: 44px;
    --cd-side-w: 240px;
}

html, body { height: 100%; }
[hidden] { display: none !important; }   /* flex/grid display rules must never un-hide hidden elements */
body { background: var(--cd-page-bg); font-size: .925rem; }

/* ---- login / two-step ---- */
body.cd-auth { display: flex; align-items: center; justify-content: center; padding: 16px; }
.cd-auth-card { background: #fff; width: 100%; max-width: 380px; padding: 28px; border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.08); }
.cd-auth-card .cd-brand { font-size: 1.4rem; font-weight: 600; color: var(--cd-primary); }
.cd-auth-sub { color: #6b7785; margin-bottom: 18px; }

/* ---- fields: one control height everywhere, caption UNDER the control (legacy layout) ----
   Markup: <div class="cd-field"> control </label for=…>Caption</label></div>. Widget helpers add the
   caption themselves when the markup has none. */
:root { --cd-control-h: 36px; }
.cd-field { display: flex; flex-direction: column; margin-bottom: 14px; min-width: 0; }
.cd-field > label, .cd-caption {
    order: 2; margin: 4px 0 0 2px; font-size: .75rem; font-weight: 500; color: #5b6775; line-height: 1.2;
}
.form-control:not(textarea), .form-select { height: var(--cd-control-h); padding-top: 0; padding-bottom: 0; }
textarea.form-control { min-height: calc(var(--cd-control-h) * 2); }
/* EJ2 inputs (DropDownList, DatePicker, MultiSelect, …) to the same height and full width */
.e-input-group, .e-input-group.e-control-wrapper, .e-float-input.e-control-wrapper {
    min-height: var(--cd-control-h) !important; width: 100% !important; margin: 0 !important; align-items: center;
}
.e-input-group:not(.e-multiselect) { height: var(--cd-control-h) !important; }
.e-input-group input.e-input, .e-input-group.e-control-wrapper input.e-input { height: calc(var(--cd-control-h) - 2px) !important; min-height: 0 !important; }
.e-multiselect.e-input-group .e-multi-select-wrapper { min-height: calc(var(--cd-control-h) - 2px); display: flex; align-items: center; }
/* Switches keep their natural size, centred in a control-height slot so their captions line up with the others */
.cd-field > .e-switch-wrapper { align-self: flex-start; margin-block: calc((var(--cd-control-h) - 20px) / 2); }
/* A form row is ONE visual line. Fields share the line by weight (cd-span-N = weight N); switches have a fixed
   width. Switches that END a row of other fields form a trailing "switch zone": every row in the same form reserves
   that zone (--cd-switch-slots, set by CD.alignForms in cleverdocs.js), so the fields of every row start and end on
   the same lines — a row only uses the zone when it also ends in switches. Rows of only switches sit left-aligned. */
:root { --cd-switch-w: 150px; --cd-gap: 16px; }
.cd-form-row {
    display: flex; flex-wrap: nowrap; align-items: flex-start; column-gap: var(--cd-gap);
    padding-right: calc(var(--cd-switch-slots, 0) * (var(--cd-switch-w) + var(--cd-gap)));
}
.cd-form-row > * { flex: 1 1 0; min-width: 0; }
.cd-span-2 { flex-grow: 2; } .cd-span-3 { flex-grow: 3; } .cd-span-4 { flex-grow: 4; }
.cd-span-5 { flex-grow: 5; } .cd-span-6 { flex-grow: 6; } .cd-span-12 { flex-grow: 12; }
.cd-form-row > .cd-switch-field { flex: 0 0 var(--cd-switch-w); }
/* An optional field marked cd-keep-slot keeps its space (invisible) while hidden, so the column lines don't move. */
.cd-form-row > .cd-keep-slot[hidden] { display: flex !important; visibility: hidden; }
.cd-form-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; border-top: 1px solid var(--cd-border); margin-top: 4px; padding-top: 12px; }
@media (max-width: 900px) { .cd-form-row { flex-wrap: wrap; padding-right: 0; } .cd-form-row > *, .cd-form-row > .cd-switch-field { flex: 1 1 100%; } }

/* ---- shell ---- */
.cd-header {
    position: fixed; inset: 0 0 auto 0; height: var(--cd-header-h); z-index: 1030;
    display: flex; align-items: center; gap: 16px; padding: 0 16px;
    background: var(--cd-header-bg); border-bottom: 1px solid var(--cd-border);
}
.cd-header .cd-brand { background: none; border: 0; font-size: 1.2rem; font-weight: 600; color: var(--cd-primary); padding: 0; }
/* Client (staff: switcher dropdown) sits on the right, next to the user menu — not full width. The global
   EJ2 rule makes the dropdown fill its box, so the box carries the width. */
.cd-client { margin-left: auto; color: #44515f; display: flex; align-items: center; gap: 6px; min-width: 0; }
.cd-client:has(.e-ddl) { width: 300px; max-width: 45vw; }

/* Grid headers that wrap (CD.runsTable): break between words only, never inside one ("Uploade/d"). */
.e-grid .e-headercell .e-headercelldiv, .e-grid .e-headercell .e-headertext {
    word-break: normal !important; overflow-wrap: normal !important; white-space: normal;
}
.cd-user-btn { border: 1px solid var(--cd-border); }

.cd-nav { position: fixed; z-index: 1020; background: var(--cd-nav-bg); color: var(--cd-nav-fg); }
.cd-nav button { background: none; border: 0; color: inherit; }
.cd-nav-item { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 7px 12px; border-radius: 6px; }
.cd-nav-item:hover:not(:disabled), .cd-nav-item.active { background: var(--cd-nav-hover); }
.cd-nav-item:disabled { opacity: .45; cursor: not-allowed; }
.cd-nav-icon { width: 18px; text-align: center; }
.cd-nav-group-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; opacity: .7; padding: 8px 12px 2px; }

/* Style 1 — menu bar with drop-down panels (MenuCollapsed = false) */
.cd-menu-bar .cd-nav { inset: var(--cd-header-h) 0 auto 0; height: var(--cd-nav-h); display: flex; padding: 0 8px; }
.cd-menu-bar .cd-nav-tab { position: relative; }
.cd-menu-bar .cd-nav-tab-btn { height: var(--cd-nav-h); padding: 0 14px; }
.cd-menu-bar .cd-nav-tab-btn:hover, .cd-menu-bar .cd-nav-tab.open .cd-nav-tab-btn { background: var(--cd-nav-hover); }
.cd-menu-bar .cd-nav-panel {
    display: none; position: absolute; top: var(--cd-nav-h); left: 0; min-width: 240px; padding: 6px;
    background: var(--cd-nav-bg); border-radius: 0 0 8px 8px; box-shadow: 0 8px 20px rgba(0,0,0,.2);
}
.cd-menu-bar .cd-nav-tab.open .cd-nav-panel { display: block; }
.cd-menu-bar .cd-content { margin-top: calc(var(--cd-header-h) + var(--cd-nav-h)); }

/* Style 2 — big-button side menu, all items visible (MenuCollapsed = true, legacy "button bar") */
.cd-menu-buttons .cd-nav { inset: var(--cd-header-h) auto 0 0; width: var(--cd-side-w); overflow-y: auto; padding: 8px; }
.cd-menu-buttons .cd-nav-tab-btn { width: 100%; text-align: left; font-weight: 600; padding: 10px 12px 4px; cursor: default; }
.cd-menu-buttons .cd-nav-tab-btn .fa-caret-down { display: none; }
.cd-menu-buttons .cd-nav-item { padding: 9px 12px; font-size: .95rem; }
.cd-menu-buttons .cd-content { margin-top: var(--cd-header-h); margin-left: var(--cd-side-w); }

.cd-content { padding: 18px; min-height: calc(100vh - var(--cd-header-h)); }
.cd-loader { position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,.45); }
.cd-loader[hidden] { display: none; }
.cd-duplicate { max-width: 520px; margin: 18vh auto; background: #fff; padding: 28px; border-radius: 10px; text-align: center; }

/* ---- pages ---- */
.cd-page { background: #fff; border: 1px solid var(--cd-border); border-radius: 10px; padding: 18px; }
.cd-page-title { font-size: 1.25rem; font-weight: 600; margin-bottom: 14px; }
.cd-section-title { font-size: 1rem; font-weight: 600; margin: 18px 0 10px; text-align: center; }
.cd-notice { max-width: 640px; }
.cd-readonly::before { content: "Read-only access"; display: inline-block; font-size: .75rem; background: #fff3cd; color: #7a5b00; border-radius: 4px; padding: 2px 8px; margin-bottom: 8px; }
.cd-split { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.cd-split-list { flex: 0 0 300px; max-width: 100%; border: 1px solid var(--cd-border); border-radius: 8px; overflow: hidden; }
.cd-split-detail { flex: 1 1 480px; }
.cd-modal { padding: 4px; }

.cd-tile-group h2 { font-size: 1rem; font-weight: 600; margin: 16px 0 8px; }
.cd-tile-row { display: flex; flex-wrap: wrap; gap: 10px; }
.cd-tile {
    width: 150px; min-height: 96px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
    background: #fff; border: 1px solid var(--cd-border); border-radius: 10px; padding: 10px; color: #23384d;
}
.cd-tile span:first-child { font-size: 1.6rem; color: var(--cd-primary); }
.cd-tile:hover:not(:disabled) { border-color: var(--cd-primary); box-shadow: 0 2px 10px rgba(30,111,217,.15); }
.cd-tile:disabled { opacity: .45; }

@media (max-width: 768px) {
    .cd-menu-buttons .cd-nav { position: static; width: auto; margin-top: var(--cd-header-h); }
    .cd-menu-buttons .cd-content { margin: 0; }
    .cd-menu-bar .cd-nav { overflow-x: auto; }
}

.cd-home { display: flex; gap: 18px; flex-wrap: wrap; align-items: flex-start; }
.cd-home-tiles { flex: 1 1 360px; }
.cd-home-dashboard { flex: 3 1 560px; min-height: 70vh; }
.cd-dashboard { width: 100%; min-height: 70vh; }

.cd-subtitle { font-weight: 600; text-decoration: underline; margin-bottom: 8px; }
.cd-placeholders { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.cd-placeholder { border: 1px dashed var(--cd-primary); background: #eef4fd; color: #1b4f91; border-radius: 6px; padding: 4px 8px; font-size: .8rem; cursor: grab; }
.cd-placeholder:hover { background: #dce9fb; }

/* ---- breadcrumb trail (above every page) ---- */
.cd-breadcrumb ol { display: flex; flex-wrap: wrap; align-items: center; list-style: none; margin: 0 0 12px; padding: 0; font-size: .85rem; }
.cd-breadcrumb li { display: flex; align-items: center; }
.cd-breadcrumb li + li::before { content: "\203A"; margin: 0 8px; color: #8a96a3; }
.cd-breadcrumb button { background: none; border: 0; padding: 2px 4px; color: var(--cd-primary); border-radius: 4px; }
.cd-breadcrumb button:hover { background: #e7eefb; text-decoration: underline; }
.cd-breadcrumb [aria-current="page"] { color: #2b3a4a; font-weight: 600; padding: 2px 4px; }
