/* Page styles for the settings area (see site.css for the shared layout and button system). */


/* A label + its input stacked (used inside .form-grid / .tmpl-cols). */
.field-stack { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-stack > label { margin-top: 10px; }

/* ---- Settings hub: tiles in a grid, a bit tighter than the big landing tiles ---- */
.settings-group-title { margin: 18px 0 8px; }
.page-head + .settings-group-title { margin-top: 4px; }
.settings-tiles .mode-button { padding: 14px 18px; gap: 3px; }
.settings-tiles .mode-title { font-size: 17px; }
.settings-tiles .mode-description { font-size: 13px; line-height: 1.4; }
/* Settings and its group screens: one centred column, two tiles across (one on a phone). */
.settings-page { max-width: 1000px; margin: 0 auto; }
.settings-page .settings-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.settings-page .settings-find { max-width: none; }
@media (max-width: 640px) { .settings-page .settings-tiles { grid-template-columns: 1fr; } }

/* Find a setting (settings-find.js): the box over the groups, and the matches with their group's name above each title. */
.settings-find { margin: 4px 0 6px; max-width: 520px; }
.settings-find-input { width: 100%; height: 42px; padding: 0 14px; border-radius: 14px; border: 1px solid var(--input-border); background: var(--input-fill); color: var(--text-primary); font: inherit; font-size: 15px; box-sizing: border-box; }
.settings-find-input:focus { outline: none; border-color: var(--accent); background: var(--surface); }
#settings-home[hidden], .settings-results[hidden], .settings-results .settings-result[hidden], .settings-no-match[hidden] { display: none; }
.settings-results { margin-top: 14px; }
.settings-result-group { font-size: 11.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--accent); }
.settings-no-match { margin: 4px 0; color: var(--text-secondary); }
/* A group's own screen: one line saying what's in it, above its tiles. */
.settings-group-intro { margin: 0 0 14px; font-size: 14px; color: var(--text-secondary); max-width: 760px; }

/* ---- Settings sub pages: cards two per row where they're short ---- */
.entry-form.settings-form { gap: 0; }
.entry-form.settings-form > .card-section { margin-top: 0; margin-bottom: 16px; }
.entry-form.settings-form.settings-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(460px, 100%), 1fr));
    grid-auto-flow: row dense;
    gap: 16px;
    align-items: stretch;
}
.entry-form.settings-form.settings-cards > .card-section { margin: 0; min-width: 0; }
.entry-form.settings-form.settings-cards > :not(.card-section),
.entry-form.settings-form.settings-cards > .span-all { grid-column: 1 / -1; }
.entry-form.settings-form .form-actions { margin-top: 0; }
.settings-form .card-section h2 { margin: 0 0 4px; font-size: 18px; }
.settings-form .card-section > .settings-hint { margin-top: 0; }
.settings-lead { margin: 0 !important; }
.settings-reprint { margin-top: 20px; }
.card-section .form-grid .field-stack > label:first-child { margin-top: 6px; }

/* Long lists (Daysheet Lists, Quotes): the textareas fill their card. */
.entry-form.settings-form.settings-cards > .settings-tall { grid-row: span 2; }
.settings-cards .card-section textarea { flex: 1 1 auto; min-height: 120px; }

/* Rate table: inputs no wider than they need to be. */
.ewo-rates td input { max-width: 200px; }

/* Features: switches side by side. */
.feature-switches { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: 12px; margin-top: 0; }
.feature-switches .feature-switch { margin: 0; }

/* Safety topics: topic cards in a grid. */
#topic-rows { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(360px, 100%), 1fr)); gap: 12px; margin-bottom: 0; }
#topic-rows > .topic-row { margin: 0; }
.entry-form .topic-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.entry-form .topic-actions button { margin-top: 0; }
#safety-topics-form .form-actions { margin-top: 16px; }
.topic-add { margin-top: 0 !important; }

/* Safety Documents & Topics: the MSDS and Code of Safe Practices forms above the topics, each file a small card. */
.safety-docs-form { margin-bottom: 20px; }
.safety-docs-form h2, .safety-topics-title { margin: 8px 0 6px; font-size: 18px; line-height: 1.3; }
.safety-docs-form > .settings-hint { margin: 0 0 12px; }
.safety-doc-rows { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(360px, 100%), 1fr)); gap: 12px; }
.safety-doc-rows:empty { display: none; }
.safety-doc-rows > .safety-doc-row { margin: 0; }
.entry-form .safety-doc-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.entry-form .safety-doc-actions .btn { margin-top: 0; }
.safety-doc-add { margin-top: 12px !important; }

/* Equipment types: Save sits under the fields; the Up / Down / Remove row (.equip-type-actions) is in project-tools.css. */
.equip-types { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(400px, 100%), 1fr)); gap: 10px 12px; align-items: start; margin-bottom: 12px; }
.equip-types > .detail-section { margin: 0; }
.equip-types > .detail-section[open] { grid-column: 1 / -1; }

/* ---- Document Templates: one tab's section at a time, full width ---- */
.tmpl-tabs { margin: 4px 0 12px; }
.tmpl-tabbed .tmpl-hidden { display: none; }
.tmpl-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 0 0 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border-color); }
.tmpl-head > .settings-hint { flex: 1 1 320px; margin: 0; }
.tmpl-head .tmpl-csv { margin: 0; gap: 6px; flex-wrap: wrap; }
.tmpl-head .tmpl-csv .inline-form { display: inline-flex; align-items: center; gap: 6px; margin: 0; flex-wrap: wrap; }
.tmpl-head .tmpl-csv input[type=file] { max-width: 220px; font-size: 12px; }
/* Bidding's lists: each heading with its Import / Export menu (Download CSV, Upload). */
.tmpl-intro { margin: 0 0 4px; }
.tmpl-list-head { display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; }
.tmpl-list-head .dir-h { margin-right: auto; }
.tmpl-io { position: relative; }
.tmpl-io > summary { list-style: none; cursor: pointer; margin: 0; }
.tmpl-io > summary::-webkit-details-marker { display: none; }
.tmpl-io > summary::after { content: " ▾"; }
/* The section headers' chevron and hover (.detail-section summary) aren't for this button. */
.detail-section .tmpl-io > summary::before { content: none; }
.detail-section .tmpl-io > summary:hover { background: var(--input-border); }
.tmpl-io-menu {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: min(320px, 86vw); padding: 10px 12px; display: flex; flex-direction: column; gap: 6px;
    background: var(--surface, #fff); border: 1px solid var(--border-color); border-radius: 12px; box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
}
/* Solid in dark mode, like the Email menu (the surface colour is a little see-through over the list). */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .tmpl-io-menu { background: #222638; }
}
:root[data-theme="dark"] .tmpl-io-menu { background: #222638; }
.tmpl-io-item { font-weight: 600; font-size: 14px; }
.tmpl-io-label { font-size: 13px; color: var(--text-secondary); margin: 4px 0 0; }
.tmpl-io-upload { display: flex; align-items: center; gap: 6px; }
.tmpl-io-upload input[type=file] { flex: 1 1 auto; min-width: 0; font-size: 12px; }
.tmpl-io-upload .btn { flex: none; margin: 0; }
.tmpl-io-hint { margin: 0; font-size: 12px; color: var(--text-secondary); }
.detail-section .entry-form.entry-form-wide { padding: 0; background: none; border: 0; box-shadow: none; }
.tmpl-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); gap: 4px 24px; align-items: start; }
.tmpl-cols .dir-h { margin-top: 16px; }
.tmpl-terms { margin-top: 4px; }
.tmpl-add-row { margin: 6px 0 0; }
.tmpl-table td { padding-top: 3px; padding-bottom: 3px; }
.tmpl-cols .dir-h + .settings-hint { margin: 0 0 6px; }
.entry-form .tmpl-add-row button { margin-top: 0; }

/* ---- Transmittal Page Setup: live preview beside the settings on wide screens ---- */
.ts-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.ts-layout > .card-section, .ts-main > .card-section { margin: 0; }
.ts-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.ts-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(480px, 100%), 1fr)); gap: 16px; margin-top: 16px; align-items: start; }
.ts-pair > .card-section { margin: 0; }
@media (min-width: 1200px) {
    .ts-layout { grid-template-columns: minmax(0, 1fr) minmax(380px, 40%); align-items: start; }
    .ts-preview { grid-column: 2; grid-row: 1; position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; }
    .ts-main { grid-column: 1; grid-row: 1; }
}

/* ---- Users (Admin): Delete and Save side by side, small ---- */
.admin-users-table td.admin-user-buttons { display: table-cell; white-space: nowrap; text-align: right; }
.admin-user-buttons .inline-form { display: inline-flex; width: auto; margin: 0 0 0 6px; vertical-align: middle; }
.admin-user-buttons .inline-form button.btn { width: auto; }
.admin-add-user .entry-form { max-width: none; padding: 0; background: none; border: 0; box-shadow: none; }

/* ---- Assign Jobs ---- */
.assign-jobs .entry-form { max-width: none; padding: 0; background: none; border: 0; box-shadow: none; }

@media (max-width: 600px) {
    .settings-tiles .mode-button { padding: 12px 14px; }
    .settings-tiles .mode-title { font-size: 16px; }
}

/* ---- Settings → JHA / JSA: the hazard library, one collapsible card per hazard ---- */
.jha-library #jha-hazard-rows { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.jha-hazard-row { margin: 0; padding: 10px 14px; }
.jha-hazard-row > summary { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; cursor: pointer; }
.jha-hazard-row[open] > summary { margin-bottom: 8px; }

/* ---- Subs, Suppliers & Vendors (Settings/Vendors, VendorEdit) ---- */
.vd-name a { font-weight: 600; }
.vd-trade { display: block; font-size: 12.5px; color: var(--text-secondary); }
.vd-pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.vd-pill.vd-supplier { background: rgba(52, 199, 89, 0.14); color: var(--success, #1a7a3a); }
.vd-pill.vd-vendor { background: rgba(255, 149, 0, 0.16); color: #b36200; }
.vd-actions { white-space: nowrap; text-align: right; }
.vd-actions .inline-form { display: inline; margin: 0; }
.vd-email { word-break: break-all; }
.vendor-form .vd-notes { margin-top: 14px; }
.vendor-form .vd-notes textarea { width: 100%; box-sizing: border-box; }
.ds-from-directory { margin: 6px 0 0 !important; font-size: 12.5px; }
@media (max-width: 700px) {
    /* Each company a small card instead of a sideways-scrolling table. */
    .data-table.card-table.vd-table { display: block; overflow: visible; background: none; border: 0; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
    .vd-table thead { display: none; }
    .vd-table tbody { display: flex; flex-direction: column; gap: 10px; }
    .vd-table tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 12px 14px; border-radius: 16px; background: var(--card-bg); border: 1px solid var(--border-color); box-shadow: var(--shadow); }
    .vd-table td { display: block; padding: 0 !important; border: 0 !important; font-size: 14px; }
    .vd-table td.vd-name { grid-column: 1; }
    .vd-table td.vd-type { grid-column: 2; grid-row: 1; text-align: right; }
    .vd-table td:not(.vd-name):not(.vd-type):not(.vd-actions) { grid-column: 1 / -1; color: var(--text-secondary); }
    .vd-table td.vd-blank { display: none; }
    .vd-table td.vd-actions { grid-column: 1 / -1; text-align: left; margin-top: 8px; display: flex; gap: 8px; }
    .vd-toolbar .equip-type-chips { display: flex; flex-wrap: wrap; gap: 6px; }
}

/* Document Templates → Directive: the Job Info board - the rows on the directive (one list, or a Left and a Right column)
   beside the ones that aren't. Each row: a drag handle, the name, and small buttons to move it. */
.jib { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin: 10px 0 8px; }
.jib[data-columns="1"] { grid-template-columns: 2fr 1fr; }
.jib[data-columns="1"] .jib-two, .jib[data-columns="2"] .jib-one { display: none; }
.jib-col { border: 1px solid var(--border-color); border-radius: 12px; padding: 8px 10px; min-width: 0; }
.jib-col-off { opacity: .85; }
.jib-h { font-size: 13px; font-weight: 600; margin: 0 0 6px; color: var(--text-secondary); }
.jib-list { list-style: none; margin: 0; padding: 0; min-height: 40px; display: flex; flex-direction: column; gap: 4px; }
.jib-item { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 9px; border: 1px solid var(--border-color); background: var(--card-bg); font-size: 14px; }
.jib-item.jib-dragging { opacity: .6; box-shadow: 0 4px 14px rgba(0, 0, 0, .18); }
.jib-drag { cursor: grab; touch-action: none; user-select: none; color: var(--text-secondary); font-size: 16px; line-height: 1; padding: 2px; }
.jib-name { flex: 1; min-width: 0; }
.jib-btns { display: flex; gap: 4px; flex-shrink: 0; }
.jib-btns .btn { min-width: 28px; padding-left: 6px; padding-right: 6px; }
.jib-list-off .jib-up, .jib-list-off .jib-down, .jib-list-off .jib-swap, .jib-list-off .jib-off { display: none; }
.jib-list:not(.jib-list-off) .jib-add { display: none; }
.jib[data-columns="1"] .jib-swap { display: none; }
@media (max-width: 760px) {
    .jib, .jib[data-columns="1"] { grid-template-columns: 1fr; }
}

/* ---- Company Info → Email from the app: On / Off, and a company sender that can't be used ---- */
.email-app-status { margin: 0; font-size: 14px; color: var(--text-primary); }
.email-app-status .email-app-on { color: var(--success); }
.email-app-warn { margin: 2px 0 0; padding: 8px 12px; border-radius: 12px; font-size: 13px; font-weight: 600; background: #FCE6D4; color: #A85A1D; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .email-app-warn { background: #4D3218; color: #FFC08A; }
}
:root[data-theme="dark"] .email-app-warn { background: #4D3218; color: #FFC08A; }
/* The email signature's live preview (Company Info) - as it'll read, filled in for whoever's signed in. */
.signature-preview { margin: 4px 0 0; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border-color); background: var(--glass-tint, transparent); }
.signature-preview[hidden] { display: none; }
.signature-preview-label { display: block; font-size: 11.5px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.02em; margin-bottom: 4px; }
.signature-preview-text { margin: 0; font: inherit; font-size: 14px; white-space: pre-wrap; color: var(--text-primary); }

/* ---- Settings → Email Log: filters, then one glass card whose table scrolls sideways inside it on a phone ---- */
.email-log-filter { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 12px; margin: 0 0 14px; }
.email-log-filter label { display: flex; flex-direction: column; gap: 4px; margin: 0; font-size: 13px; font-weight: 600; color: var(--text-secondary); min-width: 0; }
.email-log-filter select { height: 36px; max-width: min(320px, calc(100vw - 32px)); padding: 0 10px; border-radius: 10px; border: 1px solid var(--input-border); background: var(--input-fill); color: var(--text-primary); font: inherit; font-size: 14px; }
.email-log-card { max-width: 100%; overflow-x: auto; background: var(--card-bg); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); border: 1px solid var(--border-color); border-radius: 20px; box-shadow: var(--shadow); }
.email-log-table { min-width: 1000px; }
.email-log-table td { vertical-align: top; overflow-wrap: break-word; }
.email-log-when { white-space: nowrap; }
.email-log-by { min-width: 130px; }
.email-log-to { min-width: 190px; }
.email-log-subject { min-width: 220px; }
.email-log-what { min-width: 130px; }
.email-log-job { min-width: 140px; }
.email-log-status { min-width: 130px; }
.email-log-sub { display: block; font-size: 12px; color: var(--text-secondary); }
.email-log-cc { font-size: 12px; color: var(--text-secondary); white-space: nowrap; }
.email-log-error { display: block; max-width: 260px; margin-top: 4px; font-size: 12px; color: var(--error); }
.email-log-count { margin: 0 0 8px; }
.email-log-table .status-pill-grey { background: rgba(142, 142, 147, 0.18); color: var(--text-secondary); }
