/*
 * Southtown shared look for the tool pages (lists, edit forms, reports):
 * a light page with white cards, the Inter font, a sticky header with the
 * logo, page title and its links, quiet list headings, soft buttons.
 * Loaded on every non-Xara page by includes/security.php; ste-theme.js
 * builds the header and marks lists, forms and buttons. A page that draws
 * its own layout opts out with data-ste-own on <html> (main_reqs.php uses
 * the same tokens by hand).
 */

html.ste {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #0f172a;
  --text: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-soft: #eef2f6;
  --brand: #1d4ed8;
  --brand-dark: #1e3a8a;
  --brand-soft: #e8efff;
  --aqua: #14b8c4;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 16px rgba(15, 23, 42, 0.06);
  -webkit-text-size-adjust: 100%;
  background: var(--bg) !important;
}
html.ste body {
  margin: 0 !important;
  padding: 0 !important;
  background: var(--bg) !important;
  color: var(--text) !important;
  font: 15px/1.55 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif !important;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
html.ste body * { font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif !important; box-sizing: border-box; }

/* The old pages' own backgrounds go (status colours come back as tints, see ste-theme.js). */
html.ste-reset body :is(table, thead, tbody, tr, td, th, div, p, span, font, center, form, ul, ol, li, b, strong, i, em, h1, h2, h3, h4, h5, h6, label, fieldset) {
  background-color: transparent !important;
  background-image: none !important;
}
html.ste-reset [bgcolor] { background-color: transparent !important; }
/* Hidden for the moment it takes ste-theme.js to lay the page out (a timer in the page shows it regardless). */
html.ste:not(.ste-ready) body { visibility: hidden; }

/* ---- Header ---- */
html.ste .ste-top {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.92) !important;
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.02);
}
html.ste .ste-top::after {
  content: "";
  display: block;
  height: 3px;
  background: linear-gradient(90deg, var(--aqua), var(--brand));
}
html.ste .ste-top .ste-in {
  max-width: 1280px;
  margin: 0 auto;
  padding: 10px 28px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 22px;
}
html.ste .ste-top img.ste-logo { height: 44px; width: auto; max-width: none; mix-blend-mode: multiply; }
html.ste .ste-top h1 {
  margin: 0;
  padding-left: 22px;
  border-left: 1px solid var(--line);
  flex: 1 1 240px;
  font-size: 21px !important;
  line-height: 1.25;
  font-weight: 700 !important;
  letter-spacing: -0.01em;
  color: var(--ink) !important;
}
html.ste .ste-top nav { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }

/* ---- Page body: content sits on a white card ---- */
html.ste .ste-main {
  position: relative;
  max-width: 1280px;
  margin: 28px auto 40px;
  padding: 28px 32px 36px;
  background: var(--card) !important;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
html.ste .ste-foot {
  max-width: 1280px;
  margin: 0 auto;
  padding: 8px 28px 32px;
  text-align: center;
  color: var(--muted) !important;
  font-size: 13px !important;
  background: transparent !important;
}
html.ste .ste-hidden { display: none !important; }

/* ---- Text ---- */
html.ste a { color: var(--brand); text-decoration: none; }
html.ste a:hover { text-decoration: underline; }
html.ste .ste-main :is(h1, h2, h3, h4) { color: var(--ink) !important; font-weight: 700 !important; letter-spacing: -0.01em; }
html.ste img, html.ste input[type="image"] { max-width: 100%; height: auto; }
html.ste hr { border: 0; border-top: 1px solid var(--line); }

/* ---- Buttons ---- */
html.ste .ste-btn, html.ste input[type="submit"]:not(.btn), html.ste input[type="button"]:not(.btn),
html.ste input[type="reset"]:not(.btn), html.ste button:not(.btn), html.ste .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 16px;
  border: 1px solid transparent !important;
  border-radius: 10px !important;
  background: var(--brand) !important;
  color: #fff !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  line-height: 1.2;
  text-decoration: none !important;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
  transition: background-color 0.15s, box-shadow 0.15s, transform 0.05s;
}
html.ste :is(.ste-btn, input[type="submit"], input[type="button"], button, .btn):hover { background: var(--brand-dark) !important; text-decoration: none !important; }
html.ste :is(.ste-btn, input[type="submit"], input[type="button"], button, .btn):active { transform: translateY(1px); }
/* Edit / view style actions inside lists: soft blue. */
html.ste .ste-btn.ste-soft { background: var(--brand-soft) !important; color: var(--brand) !important; box-shadow: none; }
html.ste .ste-btn.ste-soft:hover { background: #d6e2ff !important; }
html.ste .ste-btn.ste-home { background: var(--ink) !important; color: #fff !important; }
html.ste .ste-btn.ste-home:hover { background: #000 !important; }
html.ste :is(.ste-btn, input).ste-del { background: var(--danger-soft) !important; color: var(--danger) !important; box-shadow: none; }
html.ste :is(.ste-btn, input).ste-del:hover { background: #fbd5d5 !important; }
html.ste :is(.ste-btn, input).ste-plain {
  background: #fff !important;
  border-color: var(--line) !important;
  color: var(--text) !important;
}
html.ste :is(.ste-btn, input).ste-plain:hover { background: var(--bg) !important; }

/* ---- Fields ---- */
html.ste :is(input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="number"],
  input[type="tel"], input[type="search"], input:not([type]), select, textarea) {
  max-width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid #cbd5e1 !important;
  border-radius: 10px !important;
  background: #fff !important;
  color: var(--ink) !important;
  font-size: 15px !important;
  box-shadow: inset 0 1px 1px rgba(15, 23, 42, 0.03);
  transition: border-color 0.15s, box-shadow 0.15s;
}
html.ste textarea { min-height: 100px; width: 100%; max-width: 640px; }
html.ste :is(input, select, textarea):focus {
  outline: none;
  border-color: var(--brand) !important;
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.18);
}

/* ---- Lists ---- */
html.ste .ste-scroll {
  max-width: 100%;
  overflow-x: auto;
  margin: 16px 0 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
}
html.ste table.ste-data {
  width: 100% !important;
  border-collapse: collapse !important;
  border: 0 !important;
  background: #fff !important;
}
html.ste table.ste-data > * > tr > :is(td, th) {
  padding: 12px 14px !important;
  border: 0 !important;
  border-top: 1px solid var(--line-soft) !important;
  vertical-align: middle;
  text-align: left !important;
  font-size: 14px !important;
}
html.ste table.ste-data > * > tr > :is(td, th) > div { text-align: left !important; }
html.ste table.ste-data > * > tr.ste-head > :is(td, th) {
  background: #f8fafc !important;
  color: var(--muted) !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  border-top: 0 !important;
  border-bottom: 1px solid var(--line) !important;
}
html.ste table.ste-data > * > tr.ste-head > :is(td, th) * { color: var(--muted) !important; }
html.ste table.ste-data > * > tr:not(.ste-head):hover > td { background: #f8fbff !important; }
html.ste table.ste-data td.ste-act { white-space: nowrap; width: 1%; }
html.ste table.ste-data td.ste-act .ste-btn { min-height: 32px; padding: 6px 12px; margin-right: 4px; }

html.ste table.ste-data td.ste-nw { white-space: nowrap; }

/* Pieces the old page pinned at fixed spots, set in a row above the content. */
html.ste .ste-pinned { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px 24px; margin: 0 0 16px; }
html.ste .ste-pinned > * { margin: 0 !important; }

/* A table that was only a row of links, shown as a row of buttons. */
html.ste table.ste-linkbar { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px auto 16px; border: 0 !important; width: auto !important; }
html.ste table.ste-linkbar :is(tbody, tr) { display: contents; }
html.ste table.ste-linkbar :is(td, th) { display: block; padding: 0 !important; border: 0 !important; width: auto !important; }
html.ste table.ste-linkbar :is(td, th):empty { display: none; }

/* ---- Forms: label / field rows ---- */
html.ste table.ste-form {
  margin: 8px auto 24px;
  border-collapse: separate !important;
  border-spacing: 0 4px !important;
  border: 0 !important;
  background: transparent !important;
}
html.ste table.ste-form > * > tr > td { padding: 6px 10px !important; border: 0 !important; vertical-align: middle; }
html.ste table.ste-form > * > tr > td:first-child {
  font-size: 14px !important;
  font-weight: 600;
  color: var(--muted) !important;
  text-align: right !important;
  white-space: nowrap;
  padding-right: 16px !important;
}

/* Label / value tables (details pages). */
html.ste table.ste-kv {
  margin: 8px auto 24px;
  border-collapse: separate !important;
  border-spacing: 0;
  border: 1px solid var(--line) !important;
  border-radius: 12px;
  overflow: hidden;
  min-width: min(420px, 100%);
}
html.ste table.ste-kv > * > tr > td { padding: 10px 14px !important; border: 0 !important; border-top: 1px solid var(--line-soft) !important; }
html.ste table.ste-kv > * > tr:first-child > td { border-top: 0 !important; }
html.ste table.ste-kv > * > tr > td:first-child { width: 40%; font-size: 13px !important; font-weight: 600; color: var(--muted) !important; background: #f8fafc !important; }

/* Any other table: plain, no fixed widths, no old borders. */
html.ste table { max-width: 100%; border-color: var(--line) !important; }
html.ste table[width], html.ste :is(td, th)[width] { width: auto; }
html.ste div[style*="width"] { max-width: 100%; }

/* Bootstrap pages (login, sign up, passwords): a centred card. */
html.ste .wrapper { margin: 0 auto; max-width: 100%; }

/* ---- Phone ---- */
@media (max-width: 760px) {
  html.ste .ste-top .ste-in { padding: 8px 14px; gap: 8px 12px; }
  html.ste .ste-top img.ste-logo { height: 34px; }
  html.ste .ste-top h1 { font-size: 17px !important; padding-left: 12px; flex-basis: 140px; }
  html.ste .ste-top nav { width: 100%; justify-content: flex-start; }
  html.ste .ste-btn { padding: 8px 12px; }
  html.ste .ste-main { margin: 12px 10px 24px; padding: 16px 14px 22px; border-radius: 12px; }
  html.ste :is(input, select, textarea) { font-size: 16px !important; }
  html.ste :is(input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="number"],
    input[type="tel"], input[type="search"], input:not([type]), select, textarea, input[size]) { width: 100%; }

  /* Lists become one card per row, each value with its column name. */
  html.ste .ste-scroll { overflow: visible; border: 0; }
  html.ste table.ste-data, html.ste table.ste-data > tbody, html.ste table.ste-data > thead,
  html.ste table.ste-data > * > tr, html.ste table.ste-data > * > tr > :is(td, th) {
    display: block;
    width: auto !important;
  }
  html.ste table.ste-data { background: none !important; }
  html.ste table.ste-data > * > tr.ste-head { display: none; }
  html.ste table.ste-data > * > tr:not(.ste-head) {
    margin: 0 0 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  }
  html.ste table.ste-data > * > tr > td {
    display: flex;
    gap: 12px;
    justify-content: space-between;
    align-items: baseline;
    text-align: right !important;
    padding: 9px 14px !important;
  }
  html.ste table.ste-data > * > tr > td > div { text-align: right !important; }
  html.ste table.ste-data > * > tr > td[data-label]::before {
    content: attr(data-label);
    flex: 0 0 auto;
    max-width: 45%;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: var(--muted);
  }
  html.ste table.ste-data > * > tr > td.ste-empty { display: none; }
  html.ste table.ste-data > * > tr > td.ste-act { display: inline-flex; width: auto; border-top: 0 !important; padding: 12px 4px 10px 14px !important; }

  /* Forms stack: label above its field. */
  html.ste table.ste-form, html.ste table.ste-form > tbody, html.ste table.ste-form > * > tr,
  html.ste table.ste-form > * > tr > td { display: block; width: 100% !important; }
  html.ste table.ste-form > * > tr > td { text-align: left !important; padding: 2px 0 !important; white-space: normal; }
  html.ste table.ste-form > * > tr > td:first-child { padding-top: 12px !important; text-align: left !important; white-space: normal; }
  html.ste table.ste-kv { width: 100% !important; min-width: 0; }

  html.ste table:not(.ste-data):not(.ste-form):not(.ste-kv):not(.ste-linkbar) { width: 100% !important; }
}
