/*
  Customer 365 modern theme: skin for HTML that Sage CRM renders (entry blocks, list blocks, filter blocks,
  and ASP.NET GridViews that reuse Sage's class names). We do not control that markup, so everything here
  targets Sage's own classes: VIEWBOX, VIEWBOXCAPTION, EDIT, CONTENT, GRIDHEAD, ROW1, ROW2, TABLEHEAD,
  PANEREPEAT, WEBLINK, ButtonItem.
  Scoped to the content area of the modern theme. Colours come from the central tokens only.
*/

/* ---------- screens (entry blocks) ---------- */
.c365-modern .hd-content .VIEWBOXCAPTION {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .02em;
    color: var(--c365-muted);
    background: transparent;
}
.c365-modern .hd-content .VIEWBOX {
    color: var(--c365-ink);
    font-size: 14px;
    font-weight: 400 !important;
    background: transparent;
}
.c365-modern .hd-content td:has(> .VIEWBOXCAPTION) { padding: 6px 18px 10px 0; vertical-align: top; }
.c365-modern .hd-content .VIEWBOXCAPTION_hintWrapper { padding: 24px 16px; text-align: center; }
.c365-modern .hd-content .VIEWBOXCAPTION_hint { color: var(--c365-muted); font-size: 14px; }

/* panel headers Sage draws above a block */
.c365-modern .hd-content .TABLEHEAD,
.c365-modern .hd-content .PANEREPEAT,
.c365-modern .hd-content td.TABLEHEAD {
    background: transparent;
    background-image: none;
    border: 0;
    padding: 0 0 8px;
    color: var(--c365-ink);
    font-size: 15px;
    font-weight: 600;
}
.c365-modern .hd-content .TABLETOPBORDER,
.c365-modern .hd-content .TABLEBORDERLEFT,
.c365-modern .hd-content .TABLEBORDERRIGHT,
.c365-modern .hd-content .TABLEBORDERBOTTOM { background: transparent; background-image: none; border: 0; }

/* fields in edit mode: sizes and borders come from shell.css; Sage sets widths with size= / inline styles */
.c365-modern .hd-content .EDIT { max-width: 100%; }
.c365-modern .hd-content textarea.EDIT { width: 100%; }
.c365-modern .hd-content select.EDIT { min-width: 140px; }
.c365-modern .hd-content input.EDIT[readonly],
.c365-modern .hd-content input.EDIT[disabled] { background-color: var(--c365-surface-2); color: var(--c365-muted); }

/* links and buttons */
.c365-modern .hd-content a.WEBLINK,
.c365-modern .hd-content .WEBLINK { color: var(--c365-brand-text); text-decoration: none; font-weight: 600; }
.c365-modern .hd-content a.WEBLINK:hover { text-decoration: underline; }
.c365-modern .hd-content a.ButtonItem,
.c365-modern .hd-content .ButtonItem a,
.c365-modern .hd-content a.er_buttonItem {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 38px;
    padding: 8px 15px;
    border: 1px solid var(--c365-line-strong);
    border-radius: var(--c365-radius-sm);
    background: var(--c365-surface);
    color: var(--c365-ink);
    font-weight: 600;
    text-decoration: none;
}
.c365-modern .hd-content a.ButtonItem:hover,
.c365-modern .hd-content .ButtonItem a:hover,
.c365-modern .hd-content a.er_buttonItem:hover { background: var(--c365-surface-2); border-color: var(--c365-muted); }

/* ---------- lists (Sage list blocks and GridViews using Sage classes) ---------- */
.c365-modern .hd-content table.CONTENT {
    width: 100%;
    border: 1px solid var(--c365-line) !important;
    border-radius: var(--c365-radius);
    border-collapse: separate;
    border-spacing: 0;
    background: var(--c365-surface);
    overflow: hidden;
}
.c365-modern .hd-content .GRIDHEAD,
.c365-modern .hd-content tr.GRIDHEAD th,
.c365-modern .hd-content tr.GRIDHEAD td {
    padding: 10px 14px;
    background: var(--c365-surface-2);
    background-image: none;
    border: 0;
    border-bottom: 1px solid var(--c365-line);
    color: var(--c365-muted);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    text-align: left;
    white-space: nowrap;
}
.c365-modern .hd-content .GRIDHEAD a { color: inherit; text-decoration: none; }
.c365-modern .hd-content .ROW1,
.c365-modern .hd-content .ROW2,
.c365-modern .hd-content tr.ROW1 td,
.c365-modern .hd-content tr.ROW2 td {
    padding: 10px 14px;
    background: var(--c365-surface);
    border: 0;
    border-bottom: 1px solid var(--c365-line);
    color: var(--c365-ink);
    font-size: 14px;
    vertical-align: middle;
}
.c365-modern .hd-content tr.ROW1:hover td,
.c365-modern .hd-content tr.ROW2:hover td { background: var(--c365-surface-2); }
.c365-modern .hd-content table.CONTENT tr:last-child td { border-bottom: 0; }

/* a screen (entry block) is also a table.CONTENT, wrapped in a bare table: full width, no list frame */
.c365-modern .hd-content table:has(> tbody > tr > td > table.CONTENT) { width: 100%; }
.c365-modern .hd-content table.CONTENT:has(.VIEWBOXCAPTION) {
    border: 0 !important;
    border-radius: 0;
    background: transparent;
    overflow: visible;
}
.c365-modern .hd-content table.CONTENT:has(.VIEWBOXCAPTION) td { border-bottom: 0; }

/* ---------- phones ---------- */
@media (max-width: 767.98px) {
    /* a Sage screen is a table with several caption/value cells per row: stack them into one column */
    .c365-modern .hd-content table:has(> tbody > tr > td > .VIEWBOXCAPTION),
    .c365-modern .hd-content table:has(> tbody > tr > td > .VIEWBOXCAPTION) > tbody,
    .c365-modern .hd-content table:has(> tbody > tr > td > .VIEWBOXCAPTION) > tbody > tr,
    .c365-modern .hd-content table:has(> tbody > tr > td > .VIEWBOXCAPTION) > tbody > tr > td {
        display: block;
        width: 100% !important;
    }
    .c365-modern .hd-content td:has(> .VIEWBOXCAPTION) { padding: 6px 0 10px; }
    .c365-modern .hd-content td:has(> .VIEWBOXCAPTION):empty { display: none; }
    .c365-modern .hd-content .EDIT,
    .c365-modern .hd-content select.EDIT { width: 100% !important; }

    /* Sage lists keep their columns and scroll sideways inside their own box */
    .c365-modern .hd-content table.CONTENT:not(:has(.VIEWBOXCAPTION)) { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .c365-modern .hd-content .ROW1, .c365-modern .hd-content .ROW2,
    .c365-modern .hd-content tr.ROW1 td, .c365-modern .hd-content tr.ROW2 td { padding: 12px; }
}
