/* ClientReports -- HTL / GoHTL brand system.
   App-B (HTL corporate report) palette delivered through App-A (CarrierIQ)
   token architecture. Tuned for high contrast / low-vision: 16px base,
   strong text contrast, visible focus rings, labels ABOVE fields. */

:root {
  /* Brand */
  --brand: #c60000;          /* HTL red */
  --brand-dark: #a00000;
  --brand-bgtint: #fdf2f2;   /* red 5% -- active tab / selected row */

  /* Surfaces */
  --bg: #f2f2f2;             /* page */
  --surface: #ffffff;        /* cards */
  --surface-2: #f8f7f4;      /* subtle fills, table head */
  --slate: #4c5f71;

  /* Text */
  --t: #18181b;             /* primary */
  --ts: #4b5563;            /* secondary / labels */
  --tmute: #6b7280;         /* muted / helper text */

  /* Borders */
  --b: #d9d9d9;
  --b-strong: #b8b8b8;

  /* Semantic state triads (bg tint / text / border) */
  --info-bg: #eef4ff;  --info-t: #1d4ed8;  --info-b: #bfdbfe;
  --ok-bg: #edfaf3;    --ok-t: #15803d;    --ok-b: #bbf7d0;
  --warn-bg: #fffbf0;  --warn-t: #92400e;  --warn-b: #fde68a;
  --err-bg: #fef2f2;   --err-t: #b91c1c;   --err-b: #fecaca;

  --green: #2e7d32;

  /* Radius / shadow */
  --r: 6px;
  --rl: 10px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,.10), 0 2px 4px rgba(0,0,0,.05);

  --font-d: 'Montserrat', 'Helvetica Neue', Arial, sans-serif;
  --font-b: 'Open Sans', 'Helvetica Neue', Arial, sans-serif;

  --maxw: 1320px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--t);
  font-family: var(--font-b);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* -- Top chrome ---------------------------------------------------------- */

.topbar {
  height: 8px;
  background: var(--brand);
}

.app-header {
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--b);
  padding: 12px 24px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand:hover { text-decoration: none; }
.brand-logo { height: 38px; width: auto; display: block; }
.brand-name {
  font-family: var(--font-d);
  font-weight: 900;
  font-size: 22px;
  letter-spacing: -.01em;
  color: var(--t);
}

.header-title {
  font-family: var(--font-d);
  font-weight: 700;
  font-size: 18px;
  color: var(--slate);
  border-left: 1px solid var(--b);
  padding-left: 18px;
  line-height: 1.2;
}
.header-title small {
  display: block;
  font-family: var(--font-b);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--tmute);
}

.header-spacer { flex: 1; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}
.user-name { font-weight: 700; color: var(--t); }
.user-signout {
  font-family: var(--font-d);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--brand);
  border: 1px solid var(--b);
  border-radius: var(--r);
  padding: 6px 12px;
}
.user-signout:hover { background: var(--brand-bgtint); text-decoration: none; }

/* -- Tabs ---------------------------------------------------------------- */

.tabs {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border-bottom: 1px solid var(--b);
  padding: 0 24px;
}
.tab {
  font-family: var(--font-d);
  font-weight: 700;
  font-size: 14px;
  color: var(--ts);
  padding: 12px 16px;
  border-bottom: 3px solid transparent;
}
.tab:hover { color: var(--t); text-decoration: none; }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }

/* Header minimize toggle -- collapses the logo/title header to free vertical
   space for data entry (no scrolling). Persisted per user via localStorage. */
.hdr-toggle {
  margin-left: auto;
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--b);
  border-radius: var(--r);
  padding: 4px 10px;
  font-family: var(--font-d);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--ts);
  cursor: pointer;
}
.hdr-toggle:hover { background: var(--surface-2); }
.hdr-toggle svg { transition: transform .15s; }
.hdr-toggle .lbl-show { display: none; }

:root.hdr-min .topbar,
:root.hdr-min .app-header { display: none; }
:root.hdr-min .tabs { border-top: 6px solid var(--brand); }
:root.hdr-min .hdr-toggle svg { transform: rotate(180deg); }
:root.hdr-min .hdr-toggle .lbl-hide { display: none; }
:root.hdr-min .hdr-toggle .lbl-show { display: inline; }
:root.hdr-min .app-main { padding-top: 10px; }

/* -- Layout -------------------------------------------------------------- */

.app-main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 22px 24px 60px;
}

/* -- Flash --------------------------------------------------------------- */

.flash-wrap { max-width: var(--maxw); margin: 14px auto 0; padding: 0 24px; }
.flash {
  border: 1px solid var(--b);
  border-left: 5px solid var(--brand);
  border-radius: var(--r);
  padding: 10px 14px;
  margin-bottom: 8px;
  font-weight: 600;
  background: var(--surface);
}
.flash-alert, .flash-error { background: var(--err-bg); border-left-color: var(--err-t); color: var(--err-t); }
.flash-notice, .flash-success { background: var(--ok-bg); border-left-color: var(--ok-t); color: var(--ok-t); }

/* -- Cards --------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--b);
  border-left: 5px solid var(--brand);
  border-radius: var(--rl);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.card > h2, .card > h3 { margin-top: 0; }

.section-h {
  font-family: var(--font-d);
  font-weight: 900;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--t);
  border-bottom: 2px solid var(--brand);
  padding-bottom: 6px;
  margin: 0 0 14px;
}

/* -- Buttons ------------------------------------------------------------- */

.btn {
  font-family: var(--font-d);
  font-weight: 700;
  font-size: 14px;
  padding: 9px 16px;
  border-radius: var(--r);
  border: 1px solid var(--b-strong);
  background: var(--surface);
  color: var(--t);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1.1;
}
.btn:hover { background: var(--surface-2); }
.btn:focus-visible { outline: 3px solid var(--brand); outline-offset: 1px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.success { background: var(--ok-bg); color: var(--ok-t); border-color: var(--ok-b); }
.btn.danger { background: var(--err-bg); color: var(--err-t); border-color: var(--err-b); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ts); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* -- Forms (label ABOVE, helper BELOW -- never placeholder hint text) ---- */

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px 16px;
}
@media (max-width: 1100px) { .form-grid { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field.col-2 { grid-column: span 2; }
.field.col-full { grid-column: 1 / -1; }

.field label {
  font-family: var(--font-d);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ts);
}
.field .req { color: var(--brand); margin-left: 2px; }

.field input,
.field select,
.field textarea {
  font-family: var(--font-b);
  font-size: 15px;
  color: var(--t);
  background: var(--surface);
  border: 1px solid var(--b-strong);
  border-radius: var(--r);
  padding: 9px 10px;
  width: 100%;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 3px solid var(--brand);
  outline-offset: 0;
  border-color: var(--brand);
}
.field input:disabled,
.field select:disabled {
  background: var(--surface-2);
  color: var(--ts);
}
.field textarea { resize: vertical; min-height: 60px; }

.field .help {
  font-size: 12px;
  color: var(--tmute);
}
.field.invalid input,
.field.invalid select { border-color: var(--err-t); }
.field .err-msg { font-size: 12px; color: var(--err-t); font-weight: 600; }

/* -- Tables -------------------------------------------------------------- */

.table-scroll { overflow-x: auto; max-width: 100%; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table thead th {
  background: var(--surface-2);
  font-family: var(--font-d);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ts);
  text-align: left;
  padding: 9px 10px;
  border-bottom: 2px solid var(--b);
  white-space: nowrap;
}
.data-table tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--b);
  white-space: nowrap;
}
.data-table tbody tr:hover { background: var(--brand-bgtint); cursor: pointer; }
.data-table td.num, .data-table th.num { text-align: right; }

/* -- Badges / pills ------------------------------------------------------ */

.badge {
  display: inline-block;
  font-family: var(--font-d);
  font-weight: 700;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
}
.badge.ok { background: var(--ok-bg); color: var(--ok-t); }
.badge.err { background: var(--err-bg); color: var(--err-t); }
.badge.warn { background: var(--warn-bg); color: var(--warn-t); }
.badge.info { background: var(--info-bg); color: var(--info-t); }

/* -- Status panel (validation readiness) --------------------------------- */

.status-panel {
  border-radius: var(--r);
  padding: 10px 14px;
  font-weight: 700;
  border: 1px solid var(--b);
}
.status-panel.ready { background: var(--ok-bg); color: var(--ok-t); border-color: var(--ok-b); }
.status-panel.blocked { background: var(--err-bg); color: var(--err-t); border-color: var(--err-b); }

/* Fields auto-filled by an active PRESET -- amber tint so they read as prefilled. */
.preset-field { background: #fff5d6 !important; }

/* Pro number masked (dots) while the save-confirm modal is open, so the value
   can't be read behind the dialog and copied into the re-type box. */
.pro-masked { -webkit-text-security: disc; text-security: disc; }

/* -- Autocomplete dropdown (replaces EasyUI combogrid) ------------------- */

.ac-wrap { position: relative; }
.ac-list {
  position: absolute;
  z-index: 40;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--b-strong);
  border-radius: var(--r);
  box-shadow: var(--shadow-md);
  max-height: 280px;
  overflow-y: auto;
  margin-top: 2px;
}
.ac-item { padding: 8px 10px; font-size: 14px; cursor: pointer; }
.ac-item:hover, .ac-item.active { background: var(--brand-bgtint); }
.ac-item .ac-sub { color: var(--tmute); font-size: 12px; }
.ac-empty { padding: 8px 10px; color: var(--tmute); font-size: 13px; }
.ac-section {
  padding: 6px 10px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--tmute);
  background: var(--bg-soft, #f3f4f6);
  border-top: 1px solid var(--b);
  cursor: default;
}
.readonly-display { background: var(--bg-soft, #f3f4f6); color: var(--ts); cursor: default; }
/* Expense1 "client has GL codes" flash (ports CTS flashExpenseListItemColor). */
@keyframes expense-flash-kf {
  0% { background: #fde047; }
  100% { background: inherit; }
}
.expense-flash { animation: expense-flash-kf 1s ease-out; }
/* Hard per-field error (ports CTS errorPro red-bg / white-text). */
.field-error, .field-error:focus {
  background: #b91c1c !important;
  color: #fff !important;
  border-color: #7f1d1d !important;
  box-shadow: 0 0 0 2px rgba(185,28,28,.35) !important;
}

/* -- Footer -------------------------------------------------------------- */

.site-footer {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 22px 24px 40px;
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--tmute);
  font-size: 13px;
  border-top: 1px solid var(--b);
}
.ft-logo { height: 22px; width: auto; opacity: .85; }

/* -- Login --------------------------------------------------------------- */

.login-wrap {
  max-width: 420px;
  margin: 8vh auto 0;
  padding: 0 20px;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--b);
  border-top: 6px solid var(--brand);
  border-radius: var(--rl);
  box-shadow: var(--shadow-md);
  padding: 28px 26px;
}
.login-card h1 {
  font-family: var(--font-d);
  font-weight: 900;
  font-size: 22px;
  margin: 0 0 4px;
}
.login-card .sub { color: var(--tmute); margin: 0 0 22px; font-size: 14px; }
.login-card .field { margin-bottom: 16px; }
.login-card .btn.primary { width: 100%; justify-content: center; padding: 11px; font-size: 15px; }

/* -- Data Entry layout --------------------------------------------------- */

.de-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 20px;
  align-items: start;
}
@media (max-width: 1100px) { .de-layout { grid-template-columns: 1fr; } }

.de-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.de-toolbar .spacer { flex: 1; }
.de-status-text { font-weight: 700; color: var(--ts); }

.de-side .card { margin-bottom: 14px; }
.de-side .btn { width: 100%; justify-content: center; margin-bottom: 8px; }

.money-wrap { position: relative; }
.money-wrap::before {
  content: "$";
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--tmute); font-size: 14px; pointer-events: none;
}
.money-wrap input { padding-left: 18px; }

/* Data Entry compact density -- scoped to the form page only, to match the
   legacy CTS form's relative sizing and fit on one screen. Reports/Admin keep
   the normal (larger) sizing. */
.de-layout { font-size: 13px; }
.de-layout .card { padding: 12px 14px; margin-bottom: 12px; }
.de-layout .form-grid { gap: 7px 12px; }
.de-layout .field { gap: 2px; }
.de-layout .field label { font-size: 10px; letter-spacing: .03em; }
.de-layout .field input,
.de-layout .field select,
.de-layout .field textarea {
  font-size: 13px;
  padding: 5px 8px;
  border-radius: 4px;
}
.de-layout .field textarea { min-height: 40px; }
.de-layout .field .help { font-size: 10px; line-height: 1.2; }
.de-layout .money-wrap::before { left: 8px; font-size: 12px; }
.de-layout .money-wrap input { padding-left: 16px; }
.de-layout .section-h { font-size: 12px; margin-bottom: 8px; padding-bottom: 4px; }
.de-layout .status-panel { padding: 6px 10px; font-size: 12px; }
.de-layout .de-toolbar { margin-bottom: 8px; gap: 8px; }
.de-layout .btn { font-size: 12px; padding: 6px 12px; }
.de-side .btn { margin-bottom: 6px; }
.de-layout .toggle-state { font-size: 11px; }

.toggle-state { font-family: var(--font-d); font-weight: 900; font-size: 13px; }
.toggle-state.on { color: var(--green); }
.toggle-state.off { color: var(--brand); }

.batch-row { display: grid; grid-template-columns: 1fr 64px 32px; gap: 8px; margin-bottom: 6px; align-items: center; }
.batch-row input { min-width: 0; width: 100%; box-sizing: border-box; }
.batch-row .btn { margin: 0; padding: 6px 0; width: 100%; box-sizing: border-box; justify-content: center; text-align: center; }

/* extra class/weight/acc line rows (multi-line entry) */
.acc-line {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr 28px;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}
.acc-line .btn { margin: 0; padding: 4px 8px; }
#accLinesWrap > .btn { margin-top: 4px; }

/* Modal (search / corrections) via <dialog> */
dialog.de-modal {
  border: none; border-radius: var(--rl); padding: 0; width: min(1100px, 94vw);
  box-shadow: var(--shadow-md);
}
dialog.de-modal.de-modal-wide { width: min(1400px, 97vw); }
dialog.de-modal::backdrop { background: rgba(0,0,0,.45); }
#searchTable td, #searchTable th { white-space: nowrap; font-size: 13px; padding: 4px 8px; }
#searchTable tbody tr:hover { background: var(--hover, #f2f4f8); }
.de-modal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--b);
}
.de-modal-head h3 { margin: 0; font-family: var(--font-d); font-weight: 900; }
.de-modal-body { padding: 16px 18px; max-height: 70vh; overflow: auto; }

/* -- Tiles (landing / dashboard launchers) ------------------------------- */

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.tile {
  display: block;
  background: var(--surface);
  border: 1px solid var(--b);
  border-left: 5px solid var(--brand);
  border-radius: var(--rl);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  color: var(--t);
}
.tile:hover { text-decoration: none; box-shadow: var(--shadow-md); transform: translateY(-1px); }
.tile h3 {
  font-family: var(--font-d);
  font-weight: 900;
  font-size: 16px;
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.tile p { margin: 0; color: var(--tmute); font-size: 13px; }

/* Select-a-Client impersonation bar (internal users, Client Reports) */
.impersonate-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-b);
  border-radius: var(--r);
  padding: 10px 14px;
  margin-bottom: 16px;
}
.impersonate-bar .lbl {
  font-family: var(--font-d);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--warn-t);
}

/* -- Utility ------------------------------------------------------------- */

.row-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.muted { color: var(--tmute); }
.mono { font-family: 'DM Mono', ui-monospace, monospace; }
.hidden { display: none !important; }
