/* Texas Draft Plan Scanner
   Brand: txdraft-brand-documents (Style Guide v1.0). White field, TX Draft Black structure,
   red as a ~10% accent only: header rule, section rules, CTAs, pull-stats, short bold labels. */

:root {
  --red: #C41200;
  --red-dark: #9E0E00;
  --black: #1A1A1A;
  --steel: #58595B;
  --cool: #E7E8E9;
  --white: #FFFFFF;
  --line: #D4D5D7;          /* thin rules between cool gray and steel */
  --head: "Arial Black", "Arial Bold", Gadget, Arial, sans-serif;
  --head-alt: Arial, "Helvetica Neue", Helvetica, sans-serif;
  --body: Calibri, Carlito, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --radius: 3px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }   /* .btn's display:inline-flex was overriding hidden */
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--white); color: var(--black);
  font-family: var(--body); font-size: 16px; line-height: 1.45;
  display: flex; flex-direction: column; min-height: 100vh;
}
main { flex: 1; padding-bottom: 48px; }
a { color: var(--black); text-decoration-color: var(--red); text-underline-offset: 3px; }
a:hover { color: var(--red-dark); }
img { max-width: 100%; }
.wrap { width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 24px; }

h1 { font-family: var(--head); font-weight: 900; font-size: 30px; line-height: 1.15; margin: 0 0 6px; letter-spacing: -0.2px; }
h2 { font-family: var(--head-alt); font-weight: 700; font-size: 20px; margin: 0 0 14px; padding-bottom: 6px; border-bottom: 2px solid var(--red); display: inline-block; }
h2 .count { font-family: var(--body); font-weight: 400; color: var(--steel); font-size: 16px; margin-left: 4px; }
h3 { font-family: var(--head-alt); font-size: 15px; font-weight: 700; margin: 0 0 10px; }
.h-sm { font-size: 16px; }
.muted { color: var(--steel); margin: 0; max-width: 780px; }
.fine { color: var(--steel); font-size: 13px; }
.sub { color: var(--steel); font-size: 13px; font-weight: 400; }
.nowrap { white-space: nowrap; }
.num { text-align: right; }
.sr, .visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; }

/* ------------------------------------------------ header / footer */
header.site { border-bottom: 3px solid var(--red); background: var(--white); }
.site-inner { display: flex; align-items: center; gap: 20px; min-height: 96px; }
.brand { display: block; padding: 12px 0; line-height: 0; }       /* clear space: 8% of 150px = 12px */
.brand img { width: 150px; height: auto; }
.app-name { font-family: var(--head-alt); font-weight: 700; font-size: 13px; letter-spacing: 1.6px; text-transform: uppercase; color: var(--steel); border-left: 1px solid var(--line); padding-left: 18px; }
.nav { margin-left: auto; display: flex; align-items: center; gap: 18px; font-family: var(--head-alt); font-size: 14px; }
.nav a { text-decoration: none; font-weight: 700; padding: 6px 0; border-bottom: 2px solid transparent; }
.nav a.active, .nav a:hover { border-bottom-color: var(--red); color: var(--black); }
.nav .nav-quiet { font-weight: 400; color: var(--steel); }
.nav-user { color: var(--steel); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-foot { border-top: 1px solid var(--cool); color: var(--steel); font-size: 12px; padding: 18px 0; }
form.inline { display: inline; margin: 0; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--black); text-decoration: underline; text-decoration-color: var(--red); text-underline-offset: 3px; cursor: pointer; }
.nav .linklike { font-weight: 700; text-decoration: none; }
.nav .linklike:hover { text-decoration: underline; }

/* ------------------------------------------------ buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-family: var(--head-alt); font-weight: 700; font-size: 14px; line-height: 1; padding: 11px 18px; border-radius: var(--radius); border: 2px solid transparent; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--red); color: var(--white); }
.btn-primary:hover:not(:disabled) { background: var(--red-dark); color: var(--white); }
.btn-secondary { background: var(--white); color: var(--black); border-color: var(--black); }
.btn-secondary:hover:not(:disabled) { background: var(--black); color: var(--white); }
.btn-danger { background: var(--white); color: var(--black); border-color: var(--steel); }
.btn-danger:hover { border-color: var(--red); color: var(--red-dark); }
.btn-quiet { background: none; color: var(--steel); border: 0; text-decoration: underline; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-block { width: 100%; margin-top: 18px; padding: 13px; }

label { display: block; font-family: var(--head-alt); font-weight: 700; font-size: 13px; margin: 14px 0 6px; }
label .opt { font-family: var(--body); font-weight: 400; color: var(--steel); }
label.check { display: flex; align-items: center; gap: 8px; font-family: var(--body); font-weight: 400; font-size: 15px; margin: 12px 0; cursor: pointer; }
input[type=text], input[type=email], input[type=password], input[type=search], select {
  width: 100%; font: inherit; font-size: 16px; color: var(--black); background: var(--white);
  border: 1px solid #B9BABC; border-radius: var(--radius); padding: 10px 12px;
}
input:focus, select:focus, .dropzone:focus, .btn:focus-visible { outline: 2px solid var(--black); outline-offset: 2px; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--black); }
.hint { color: var(--steel); font-size: 13px; margin: 6px 0 0; }

/* ------------------------------------------------ flashes */
.flash { margin: 22px 0 0; padding: 12px 16px; border-left: 4px solid var(--black); background: var(--cool); }
.flash-error { border-left-color: var(--red); background: var(--white); border-top: 1px solid var(--cool); border-right: 1px solid var(--cool); border-bottom: 1px solid var(--cool); font-weight: 700; }
.flash-ok { border-left-color: var(--black); }
.flash-secret { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; border-left-color: var(--red); background: var(--white); border: 1px solid var(--line); border-left: 4px solid var(--red); }
.flash-secret p { margin: 2px 0 0; color: var(--steel); font-size: 14px; }
.secret-row { display: flex; gap: 10px; align-items: center; }
.secret-row code { font-size: 18px; background: var(--cool); padding: 8px 12px; border-radius: var(--radius); user-select: all; }

/* ------------------------------------------------ layout pieces */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin: 30px 0 20px; flex-wrap: wrap; }
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.crumbs { margin-top: 22px; font-size: 14px; color: var(--steel); }
.crumbs a { color: var(--steel); }
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; background: var(--white); margin-bottom: 22px; }
.empty { text-align: center; padding: 48px 0; color: var(--steel); }
.empty h1 { color: var(--black); }

/* ------------------------------------------------ auth */
.page-auth main { display: flex; align-items: flex-start; justify-content: center; }
.auth-card { width: 100%; max-width: 420px; margin: 56px 0; padding: 32px; border: 1px solid var(--line); border-top: 4px solid var(--black); border-radius: var(--radius); }
.auth-card h1 { font-size: 26px; }
.auth-card .fine { margin: 16px 0 0; text-align: center; }

/* ------------------------------------------------ upload */
.upload-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 26px; }
.dropzone { border: 2px dashed var(--steel); border-radius: var(--radius); min-height: 230px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; cursor: pointer; color: var(--steel); transition: background .12s, border-color .12s; }
.dropzone:hover, .dropzone.over { background: var(--cool); border-color: var(--black); color: var(--black); }
.dz-title { font-family: var(--head); font-size: 20px; color: var(--black); margin: 10px 0 4px; }
.dz-sub { font-size: 14px; }
.upload-side label:first-child { margin-top: 0; }
.file-list { list-style: none; margin: 8px 0 0; padding: 0; }
.file-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 9px 0; border-bottom: 1px solid var(--cool); font-size: 14px; }
.file-list .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.file-list .fsize { color: var(--steel); }
.bar { grid-column: 1 / -1; height: 4px; background: var(--cool); border-radius: 2px; overflow: hidden; }
.bar > span { display: block; height: 100%; width: 0; background: var(--black); transition: width .2s; }
.file-list li.done .bar > span { background: var(--black); }
.upload-actions { display: flex; gap: 10px; align-items: center; margin-top: 16px; }
.upload-error { margin-top: 12px; color: var(--black); font-weight: 700; border-left: 4px solid var(--red); padding: 6px 10px; }

/* ------------------------------------------------ list */
.list-head { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 12px 20px; margin: 34px 0 12px; }
.list-head h2 { margin-bottom: 0; }
.search { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.search input[type=search] { width: 300px; max-width: 100%; }
.search .check { margin: 0; }
.pager { display: flex; gap: 14px; align-items: center; justify-content: center; margin: 20px 0; color: var(--steel); }

/* ------------------------------------------------ tables */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { background: var(--black); color: var(--white); font-family: var(--head-alt); font-weight: 700; font-size: 12.5px; letter-spacing: .3px; text-align: left; padding: 10px 12px; white-space: nowrap; }
.table td { padding: 10px 12px; vertical-align: top; border-bottom: 1px solid var(--cool); }
.table tbody tr:nth-child(even) td { background: var(--cool); }
.table tr.dim td { color: var(--steel); }
.table.scans td.proj a { font-weight: 700; }
.table.compact { font-size: 13.5px; }
.table.compact td, .table.compact th { padding: 7px 10px; }

/* ------------------------------------------------ status, badges, flags */
.status { display: inline-block; font-family: var(--head-alt); font-weight: 700; font-size: 11.5px; letter-spacing: .4px; text-transform: uppercase; padding: 4px 8px; border-radius: 2px; border: 1px solid var(--steel); color: var(--steel); white-space: nowrap; background: var(--white); }
.status-done { border-color: var(--black); color: var(--black); }
.status-running { background: var(--black); color: var(--white); border-color: var(--black); }
.status-failed { border-color: var(--red); color: var(--red); }
.badge { display: inline-block; font-family: var(--head-alt); font-weight: 700; font-size: 12px; padding: 4px 8px; border-radius: 2px; white-space: nowrap; }
.badge-opp { background: var(--black); color: var(--white); }
.badge-check { background: var(--white); color: var(--black); border: 1px solid var(--steel); }
.flag-competitor, .flag-ours, .label-red { font-family: var(--head-alt); font-weight: 700; font-size: 12px; letter-spacing: .5px; text-transform: uppercase; }
.flag-competitor { color: var(--red); margin-top: 4px; }
.flag-competitor.sm { font-size: 11px; margin-top: 2px; }
.flag-ours { color: var(--black); margin-top: 4px; }
.flag-ours::before { content: "★ "; color: var(--red); }
.label-red { color: var(--red); margin-bottom: 6px; }

/* ------------------------------------------------ scan page */
.scan-head h1 { max-width: 820px; }
.progress { display: flex; gap: 20px; align-items: center; }
.progress-title { font-family: var(--head-alt); font-weight: 700; font-size: 18px; }
.progress-stage { margin: 2px 0 6px; }
.spinner { width: 34px; height: 34px; border: 4px solid var(--cool); border-top-color: var(--red); border-radius: 50%; animation: spin .9s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
.alert-card { border-left: 4px solid var(--red); }
.notice-card { border-left: 4px solid var(--black); display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; }

.facts { padding: 0; }
.facts-key { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fact { padding: 20px 22px; border-right: 1px solid var(--cool); }
.fact:last-child { border-right: 0; }
.fact-label { font-family: var(--head-alt); font-weight: 700; font-size: 12px; letter-spacing: .6px; text-transform: uppercase; color: var(--steel); margin-bottom: 6px; }
.fact-value { font-family: var(--head-alt); font-weight: 700; font-size: 19px; line-height: 1.25; }
.fact-sub { color: var(--steel); font-size: 14px; margin-top: 4px; }
.fact-note { font-size: 13px; margin-top: 6px; border-left: 3px solid var(--red); padding-left: 8px; }
.facts-more { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 24px; margin: 0; padding: 16px 22px; background: var(--cool); }
.facts-more:empty { display: none; }
.facts-more dt { font-family: var(--head-alt); font-weight: 700; font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--steel); }
.facts-more dd { margin: 2px 0 0; }
.evidence { margin: 0; padding: 10px 22px 14px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 30px; }
.stat { padding: 16px 20px; border-right: 1px solid var(--cool); }
.stat:last-child { border-right: 0; }
.stats-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.sub-h { font-size: 18px; margin: 34px 0 6px; padding-bottom: 6px; border-bottom: 2px solid var(--black); display: inline-block; }
.items.plan .c-sheets { width: 190px; }
td.snippet { font-size: 12.5px; color: var(--steel); min-width: 320px; }
.stat-n { font-family: var(--head); font-size: 32px; line-height: 1; }
.stat-accent .stat-n { color: var(--red); }
.stat-l { color: var(--steel); font-size: 13px; margin-top: 6px; }

.rundown .headline { font-size: 18px; font-weight: 700; margin: 4px 0 20px; }
.area { margin-bottom: 22px; }
.area-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; padding: 8px 0; }
.area-code { font-family: var(--head); font-size: 15px; color: var(--red); }
.area-name { font-family: var(--head-alt); font-weight: 700; font-size: 17px; }
.area-meta { color: var(--steel); font-size: 13px; }
.table.items { table-layout: fixed; }
.items .c-tags { width: 150px; }
.items .c-sheet { width: 90px; white-space: nowrap; }
.items .c-fit { width: 120px; }
.items .c-note { width: 30%; }
.items .note { color: var(--black); font-size: 14px; }
.notes { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-top: 10px; }
.note-block { border-top: 2px solid var(--black); padding-top: 10px; }
.note-block ul { margin: 0; padding-left: 18px; }
.note-block li { margin-bottom: 4px; }
.note-block p { margin: 0; }
.note-block.next { border-top-color: var(--red); }

.details { margin: 30px 0 10px; }
details { border-top: 1px solid var(--line); padding: 12px 0; }
details:last-child { border-bottom: 1px solid var(--line); }
summary { cursor: pointer; font-family: var(--head-alt); font-weight: 700; font-size: 15px; }
details[open] summary { margin-bottom: 12px; }

.side-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 0 22px; margin-top: 30px; }
.side-actions .ai-note { grid-column: 1 / -1; margin: 0; }
ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li { padding: 6px 0; border-bottom: 1px solid var(--cool); overflow-wrap: anywhere; }
.form-inline { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.form-inline input, .form-inline select { flex: 1; min-width: 0; padding: 8px 10px; font-size: 15px; }

/* ------------------------------------------------ admin */
.add-user { display: grid; grid-template-columns: 1.3fr 1fr 1.2fr auto; gap: 14px; align-items: end; }
.add-user label { margin-top: 0; }
.table.users input[name=name] { padding: 6px 8px; font-size: 15px; font-weight: 700; max-width: 260px; }
.table.users select { padding: 6px 8px; font-size: 14px; width: auto; }
.table.users .actions-row { display: flex; gap: 6px; flex-wrap: wrap; }
.user-edit { margin: 0; }

/* ------------------------------------------------ small screens */
@media (max-width: 860px) {
  .upload-grid { grid-template-columns: 1fr; }
  .dropzone { min-height: 170px; }
  .facts-key { grid-template-columns: 1fr; }
  .fact { border-right: 0; border-bottom: 1px solid var(--cool); }
  .stats, .stats-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(2) { border-right: 0; }
  .stat:nth-child(-n+2) { border-bottom: 1px solid var(--cool); }
  .add-user { grid-template-columns: 1fr; }
  .app-name { display: none; }
}
@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  h1 { font-size: 24px; }
  .site-inner { flex-wrap: wrap; min-height: 0; gap: 4px 16px; padding-bottom: 8px; }
  .brand img { width: 130px; }
  .nav { margin-left: 0; width: 100%; gap: 14px; flex-wrap: wrap; font-size: 13px; }
  .nav-user { display: none; }
  .search input[type=search] { width: 100%; }
  .search { width: 100%; }
  .auth-card { padding: 24px 18px; margin: 28px 0; }
  .side-actions { grid-template-columns: 1fr; }
  /* rundown rows stack on phones */
  .table.items, .items tbody, .items tr, .items td { display: block; width: auto; }
  .items thead { display: none; }
  .items tr { padding: 10px 12px; border-bottom: 1px solid var(--cool); }
  .table.items tbody tr:nth-child(even) { background: var(--cool); }
  .table.items tbody tr td { background: transparent; border: 0; padding: 2px 0; }
  .items td.c-sheet, .items td.c-fit { display: inline-block; width: auto; margin: 4px 10px 0 0; }
  .items td.c-sheet::before { content: "Sheet "; color: var(--steel); }
  .items td.c-sheets { display: block; width: auto; margin-top: 4px; }
  .items td.c-sheets::before { content: "Sheets "; color: var(--steel); }
  .items td.note:empty { display: none; }
  .items td.note { margin-top: 4px; }
}
