/* ============================================================================
 * Medici skin. Loaded after style.css and dark.css.
 *
 * The shell follows QuickBooks Online: a dark navigation column the height of
 * the window, a white header over the page with Create, search and the gear,
 * and green primary actions. style.css keeps layout and behaviour; this file
 * changes tokens, type, shape and the shell's composition.
 * ============================================================================ */

@media screen {

/* ---- Tokens: both themes --------------------------------------------------- */
:root {
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI Variable Text', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: ui-monospace, 'SF Mono', 'Cascadia Mono', Consolas, 'Courier New', monospace;

    --text-2xs: 10px;
    --text-xs: 11px;
    --text-sm: 12px;
    --text-md: 13px;
    --text-base: 14px;
    --text-lg: 15px;
    --text-xl: 20px;
    --text-2xl: 26px;

    --radius-control: 6px;
    --radius-badge: 4px;
    --radius-panel: 10px;

    --topbar-height: 56px;

    /* the navigation column is dark in both themes */

    /* filled controls: white on these is 5.4:1 and 7.2:1 */
    --primary-bg: #0f7a3d;
    --primary-bg-hover: #0b6431;

    --shadow-1: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow-2: 0 8px 24px rgba(16, 24, 40, 0.12), 0 2px 6px rgba(16, 24, 40, 0.06);
    --shadow-3: 0 24px 64px rgba(16, 24, 40, 0.28);
}

/* ---- Tokens: light --------------------------------------------------------- */
:root:not([data-theme="dark"]) {
    --qb-navy:        #14261c;   /* headings and figures: ink with a green cast */
    --qb-navy-dark:   #0c1811;
    --qb-navy-mid:    #0b6431;   /* primary, pressed and hovered */
    --qb-blue:        #0f7a3d;   /* primary: white on it is 5.4:1 */
    --qb-blue-light:  #0f7a3d;
    --qb-blue-accent: #1f9d57;
    --text-link:      #0b6431;
    --input-focus:    #0f7a3d;
    --input-border:   #8b94a1;

    --toolbar-bg:     #f4f5f7;
    --toolbar-border: #dfe3e8;
    --content-bg:     #f4f5f7;
    --panel-bg:       #ffffff;
    --panel-border:   #dfe3e8;
    --form-bg:        #fafbfc;
    --invoice-bg:     #ffffff;
    --estimate-bg:    #ffffff;
    --primary-light:  #e9f5ee;

    --text-primary:   #15191e;
    --text-secondary: #454d59;
    --text-muted:     #5d6572;
    --text-light:     #646c79;

    --head-bg:        #f7f8fa;
}

/* ---- Tokens: dark ---------------------------------------------------------- */
[data-theme="dark"] {

    /* filled controls: white on these is 4.9:1 and 6.2:1 */
    --primary-bg: #1f8048;
    --primary-bg-hover: #1a6e3e;
}

/* ---- Base ------------------------------------------------------------------ */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.45;
    letter-spacing: -0.003em;
}
::selection { background: rgba(31, 157, 87, 0.25); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(120, 128, 140, 0.45);
    border: 2px solid transparent;
    background-clip: padding-box;
    border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(120, 128, 140, 0.7); background-clip: padding-box; border: 2px solid transparent; }

/* ---- Shell: navigation column the height of the window ---------------------- */
#app {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
}
#main-area { display: contents; }
#sidebar-host { grid-column: 1; grid-row: 1 / -1; }
#content { grid-column: 2; grid-row: 2; min-width: 0; }
body.sidebar-hidden #sidebar-host { display: none; }
body.sidebar-hidden #content { grid-column: 1 / -1; }
/* the column carries the wordmark */

/* A narrow page (app.js App.fitShell: 700px and under in the page's own
   pixels, so a 900px window at 150% counts): the column is put away and the
   toggle opens it over the page, with the rest of the window dimmed. */
html.shell-narrow #content { grid-column: 1 / -1; }
/* Header presentation is owned by the Ghostly package. */

/* ---- Page ------------------------------------------------------------------- */
#content { --content-pad-b: 40px; padding: 24px 32px var(--content-pad-b); }
/* Settings' Save bar holds to the bottom of the page's box and covers the
   padding under it (style.css gives it 16px of cover) */
.settings-panel #settings-savebar::after { height: var(--content-pad-b); }
#page-content { max-width: 1240px; margin: 0 auto; }

.page-header,
[data-theme="dark"] .page-header {
    background: transparent;
    border: 0;
    border-radius: 0;
    padding: 0 0 4px;
    margin-bottom: 16px;
    box-shadow: none;
}
.page-header h2 {
    font-size: var(--text-2xl);
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text-primary);
}

/* ---- Buttons ---------------------------------------------------------------- */
.btn,
[data-theme="dark"] .btn {
    padding: 7px 14px;
    font-size: var(--text-md);
    font-weight: 600;
    font-family: var(--font);
    line-height: 1.25;
    border-radius: var(--radius-control);
    border: 1px solid var(--input-border);
    background: var(--panel-bg);
    color: var(--text-primary);
    text-shadow: none;
    transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}
/* A shadow of the skin's own is never on a control the keyboard is on: the
   ring's halo is a box-shadow too, and counts for nothing against a rule
   here (style.css "Links, buttons, checkboxes"). */
.btn:not(:focus-visible) { box-shadow: var(--shadow-1); }
.btn-sm:not(:focus-visible),
.btn:active:not(:disabled):not(:focus-visible) { box-shadow: none; }
.btn:hover:not(:disabled),
[data-theme="dark"] .btn:hover:not(:disabled) { background: var(--primary-light); border-color: var(--text-muted); }
.btn:active:not(:disabled),
[data-theme="dark"] .btn:active:not(:disabled) { background: var(--primary-light); }
.btn-primary,
[data-theme="dark"] .btn-primary {
    background: var(--primary-bg);
    border-color: var(--primary-bg);
    color: #ffffff;
}
.btn-primary:hover:not(:disabled),
[data-theme="dark"] .btn-primary:hover:not(:disabled) { background: var(--primary-bg-hover); border-color: var(--primary-bg-hover); color: #ffffff; }
.btn-primary:active:not(:disabled),
[data-theme="dark"] .btn-primary:active:not(:disabled) { background: var(--primary-bg-hover); }
.btn-secondary,
[data-theme="dark"] .btn-secondary { background: var(--panel-bg); color: var(--text-primary); }
.btn-secondary:hover:not(:disabled),
[data-theme="dark"] .btn-secondary:hover:not(:disabled) { background: var(--primary-light); }
.btn-danger,
[data-theme="dark"] .btn-danger { background: #c62f2f; border-color: #c62f2f; color: #ffffff; }
.btn-danger:hover:not(:disabled),
[data-theme="dark"] .btn-danger:hover:not(:disabled) { background: #a82424; border-color: #a82424; color: #ffffff; }
.btn-sm { padding: 4px 10px; font-size: var(--text-sm); font-weight: 550; }

/* ---- Cards and panels -------------------------------------------------------- */
.card,
.analytics-card,
.analytics-kpi {
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-panel);
    box-shadow: var(--shadow-1);
}
.card { padding: 18px 20px; }
.card-header,
.dashboard-section h3 {
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 0;
    padding-bottom: 0;
    margin-bottom: 10px;
}
.card-value {
    font-family: var(--font);
    font-variant-numeric: tabular-nums;
    font-size: 28px;
    font-weight: 650;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}
.dashboard-section,
.table-container,
.toolbar {
    border-radius: var(--radius-panel);
}
.table-container {
    border: 1px solid var(--panel-border);
    box-shadow: var(--shadow-1);
}
:root:not([data-theme="dark"]) .table-container { background: var(--panel-bg); }
.toolbar,
[data-theme="dark"] .toolbar {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    padding: 10px 12px;
    gap: 10px;
    box-shadow: var(--shadow-1);
}

/* ---- Tables -----------------------------------------------------------------
   Lists and documents. The frozen grids (budgets, pivots, pay runs) keep
   style.css's own cells: their sticky headers and columns are measured. */
thead th,
.line-items-table th { font-weight: 700; letter-spacing: 0.05em; }
:root:not([data-theme="dark"]) thead th,
:root:not([data-theme="dark"]) .line-items-table th {
    background: var(--head-bg);
    color: var(--text-muted);
    font-weight: 700;
    letter-spacing: 0.05em;
}
thead th.sortable:hover,
thead th.sort-active,
[data-theme="dark"] thead th.sortable:hover,
[data-theme="dark"] thead th.sort-active { background: var(--primary-light); color: var(--text-primary); }
:where(table:not(.table--frozen):not(.pivot-grid):not(.pay-run-table):not(.line-items-table)) > thead > tr > th {
    font-size: var(--text-xs);
    padding: 10px 12px;
    border-right: 0;
    border-bottom: 1px solid var(--panel-border);
}
:where(table:not(.table--frozen):not(.pivot-grid):not(.pay-run-table):not(.line-items-table)) > tbody > tr > td {
    padding: 10px 12px;
    font-size: var(--text-md);
    border-right: 0;
    border-bottom: 1px solid var(--panel-border);
}
:where(table:not(.table--frozen):not(.pivot-grid):not(.pay-run-table):not(.line-items-table)) > tbody > tr:last-child > td { border-bottom: 0; }
:where(table:not(.table--frozen):not(.pivot-grid):not(.pay-run-table):not(.line-items-table)) > tfoot > tr > td { padding: 10px 12px; font-size: var(--text-md); }
td.amount, th.amount, .total-row .value {
    font-family: var(--font);
    font-variant-numeric: tabular-nums;
}
td.actions .btn + .btn { margin-left: 4px; }
/* A stop in the pivot grid keeps a pixel more than its halo's 8px: the wide
   dialog is a fraction of the window (96vw) and the grid's edge falls between
   pixels, where 8px left the halo most of a pixel past it */
.grid-scroll :where(a, button) { scroll-margin: 9px; }

/* ---- Forms ------------------------------------------------------------------ */
.form-group label,
.iif-date-range label {
    font-size: var(--text-sm);
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.form-group input:not([type="checkbox"], [type="radio"], [type="file"], [type="range"], [type="color"], [type="hidden"], [type="submit"], [type="button"], [type="reset"], [type="image"]),
.form-group select,
.form-group textarea,
:where(#page-content, #modal) :is(input:not([type="checkbox"], [type="radio"], [type="file"], [type="range"], [type="color"], [type="hidden"], [type="submit"], [type="button"], [type="reset"], [type="image"]), select, textarea),
.toolbar input:not([type="checkbox"], [type="radio"], [type="file"], [type="range"], [type="color"], [type="hidden"], [type="submit"], [type="button"], [type="reset"], [type="image"]),
.toolbar select,
.iif-date-range input,
.cbx-input {
    font-family: var(--font);
    font-size: var(--text-md);
    padding: 7px 10px;
    border-radius: var(--radius-control);
    border: 1px solid var(--input-border);
    box-shadow: none;
    min-height: 34px;
}
:root:not([data-theme="dark"]) .form-group :is(input:not([type="checkbox"], [type="radio"], [type="file"], [type="range"], [type="color"], [type="hidden"], [type="submit"], [type="button"], [type="reset"], [type="image"]), select, textarea),
:root:not([data-theme="dark"]) :where(#page-content, #modal) :is(input:not([type="checkbox"], [type="radio"], [type="file"], [type="range"], [type="color"], [type="hidden"], [type="submit"], [type="button"], [type="reset"], [type="image"]), select, textarea),
:root:not([data-theme="dark"]) .toolbar :is(input:not([type="checkbox"], [type="radio"], [type="file"], [type="range"], [type="color"], [type="hidden"], [type="submit"], [type="button"], [type="reset"], [type="image"]), select) {
    background-color: #ffffff;
    background-image: none;
}
.line-items-table input:not([type="checkbox"], [type="radio"], [type="file"], [type="range"], [type="color"], [type="hidden"], [type="submit"], [type="button"], [type="reset"], [type="image"]),
.line-items-table select,
.line-items-table .cbx-input {
    min-height: 30px;
    padding: 5px 8px;
    font-size: var(--text-md);
    border-radius: var(--radius-control);
    box-shadow: none;
}
.form-group input:not([type="checkbox"], [type="radio"], [type="file"], [type="range"], [type="color"], [type="hidden"], [type="submit"], [type="button"], [type="reset"], [type="image"]):focus,
.form-group select:focus,
.form-group textarea:focus,
:where(#page-content, #modal) :is(input:not([type="checkbox"], [type="radio"], [type="file"], [type="range"], [type="color"], [type="hidden"], [type="submit"], [type="button"], [type="reset"], [type="image"]), select, textarea):focus,
.toolbar :is(input:not([type="checkbox"], [type="radio"], [type="file"], [type="range"], [type="color"], [type="hidden"], [type="submit"], [type="button"], [type="reset"], [type="image"]), select):focus,
.cbx-input:focus {
    border-color: var(--input-focus);
    box-shadow: none;
    outline: none;
}
:root:not([data-theme="dark"]) .form-group :is(input:not([type="checkbox"], [type="radio"], [type="file"], [type="range"], [type="color"], [type="hidden"], [type="submit"], [type="button"], [type="reset"], [type="image"]), select, textarea):focus,
:root:not([data-theme="dark"]) :where(#page-content, #modal) :is(input:not([type="checkbox"], [type="radio"], [type="file"], [type="range"], [type="color"], [type="hidden"], [type="submit"], [type="button"], [type="reset"], [type="image"]), select, textarea):focus { background-color: #ffffff; }
/* An employee's opening quarters: seven boxes share a 644px row, so they
   keep style.css's close padding, and Remove stays inside its column */
#modal .opening-states input:not([type="checkbox"]) { padding: 4px 3px; min-height: 28px; }
.opening-states .btn,
[data-theme="dark"] .opening-states .btn { padding: 4px 6px; }
.form-actions { border-top: 1px solid var(--panel-border); padding-top: 14px; margin-top: 16px; gap: 8px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary-bg); }
.cbx-popup, .qmath {
    border-radius: var(--radius-panel);
    border: 1px solid var(--panel-border);
    box-shadow: var(--shadow-2);
}

/* ---- Badges ----------------------------------------------------------------- */
.badge, .badge-control {
    padding: 3px 8px;
    border-radius: 999px;
    font-size: var(--text-2xs);
    font-weight: 700;
    letter-spacing: 0.04em;
}

/* ---- Dialogs ---------------------------------------------------------------- */
.modal-overlay { background: rgba(15, 18, 22, 0.5); }
/* A field the keyboard moves to comes into view clear of the dialog's title
   bar and its buttons, both taller here than style.css allows for */

.toast { border-radius: var(--radius-panel); box-shadow: var(--shadow-2); font-size: var(--text-md); }
.notice { border-radius: var(--radius-control); }

/* ---- Document totals -------------------------------------------------------- */
.invoice-totals { border-radius: var(--radius-panel); }

/* ---- Settings tabs, report tiles and other rounded surfaces ------------------ */
.iif-dropzone { border-radius: var(--radius-panel); }
.iif-section,
.settings-section,
.settings-nav { border-radius: var(--radius-panel); }
.iif-results { border-radius: var(--radius-control); }
.settings-tab { border-radius: var(--radius-control); }
/* Interoperability: its export and its two imports side by side left an
   import's result a column too narrow for the sentence that accounts for the
   file's blocks; under a wide window they are one column */
@media (max-width: 1500px) {
    .iif-sections { grid-template-columns: minmax(0, 1fr); }
}

/* ---- Splash / About --------------------------------------------------------- */
.splash-box {
    background: #15181c;
    border: 1px solid #2b3037;
    border-radius: 16px;
    box-shadow: var(--shadow-3);
}
.splash-box::before { background: linear-gradient(90deg, #0f7a3d, #3ecf7a, #0f7a3d); border-radius: 16px 16px 0 0; }
.splash-divider { background: linear-gradient(90deg, transparent, #3ecf7a, transparent); }
.splash-subtitle { color: #3ecf7a; }
.splash-btn,
[data-theme="dark"] .splash-btn {
    background: #0f7a3d;
    border: 1px solid #0f7a3d;
    color: #ffffff;
    border-radius: 999px;
    font-weight: 650;
    text-shadow: none;
}
.splash-btn:hover,
[data-theme="dark"] .splash-btn:hover { background: #0b6431; color: #ffffff; }

/* ---- Narrow windows --------------------------------------------------------- */
@media (max-width: 1000px) {
    #content { --content-pad-b: 32px; padding: 20px 20px var(--content-pad-b); }
}
@media (max-width: 700px) {
    :root { --topbar-height: 52px; }
    #content { --content-pad-b: 28px; padding: 16px 14px var(--content-pad-b); }
    .page-header h2 { font-size: var(--text-xl); }
}

/* A short page (app.js App.fitShell: 520px and under in the page's own
   pixels, a 600px window at 150% among them): the bars and the page's
   heading give their height to the page. */
html.shell-short { --topbar-height: 44px; }
html.shell-short #content { --content-pad-b: 12px; padding: 10px 16px var(--content-pad-b); }
html.shell-short .page-header { margin-bottom: 8px; padding-bottom: 0; }
html.shell-short .page-header h2 { font-size: var(--text-xl); }
html.shell-short #page-content .form-actions { margin-top: 8px; padding-top: 8px; }

/* High-contrast colours: a focused field draws the system's highlight */
@media (forced-colors: active) {
    .form-group input:not([type="checkbox"], [type="radio"], [type="file"], [type="range"], [type="color"], [type="hidden"], [type="submit"], [type="button"], [type="reset"], [type="image"]):focus,
    .form-group select:focus,
    .form-group textarea:focus,
    :where(#page-content, #modal) :is(input:not([type="checkbox"], [type="radio"], [type="file"], [type="range"], [type="color"], [type="hidden"], [type="submit"], [type="button"], [type="reset"], [type="image"]), select, textarea):focus,
    .toolbar :is(input:not([type="checkbox"], [type="radio"], [type="file"], [type="range"], [type="color"], [type="hidden"], [type="submit"], [type="button"], [type="reset"], [type="image"]), select):focus,
    .cbx-input:focus { outline: 2px solid Highlight; }
}

}
