/* ============================================================
   Brigman Cabinets — Work Order System
   Shares the brand palette + fonts with brigmancabinets.com
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@500;600;700&family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --dark:        #1C1917;
  --primary:     #292524;
  --accent:      #C9963A;
  --accent-dark: #A87B2A;
  --light:       #FAFAF9;
  --white:       #FFFFFF;
  --muted:       #78716C;
  --border:      #E7E5E4;
  --section-alt: #F5F5F4;
  --danger:      #DC2626;
  --success:     #16A34A;

  --heading-font: 'Playfair Display', Georgia, serif;
  --body-font:    'Inter', system-ui, -apple-system, sans-serif;

  --radius:   8px;
  --radius-lg:14px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow-md: 0 4px 20px rgba(0,0,0,.10);
  --nav-h: 60px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--body-font);
  color: var(--dark);
  background: var(--light);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
ul { list-style: none; }
img { display: block; max-width: 100%; }
h1,h2,h3,h4 { font-family: var(--heading-font); line-height: 1.2; color: var(--dark); font-weight: 600; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }
small { color: var(--muted); }

/* ── Top bar ── */
.topbar { background: var(--dark); color: var(--light); position: sticky; top: 0; z-index: 50; box-shadow: var(--shadow-sm); }
.topbar__inner {
  display: flex; align-items: center; gap: 1.25rem; position: relative;
  max-width: 1360px; margin-inline: auto; padding: 0 1.25rem; height: var(--nav-h);
}
.navtoggle { display: none; }        /* hamburger — shown only on mobile */
.mainnav__user { display: none; }    /* user block inside the mobile menu */
.brand { display: flex; align-items: center; gap: .6rem; flex-shrink: 0; }
.brand__mark {
  width: 34px; height: 34px; border-radius: 7px; display: grid; place-items: center;
  background: var(--accent); color: var(--dark); font-family: var(--heading-font); font-weight: 700; font-size: 1.2rem;
}
.brand__text { font-family: var(--heading-font); font-size: 1.02rem; color: var(--white); line-height: 1.05; display: flex; flex-direction: column; }
.brand__text small { color: var(--accent); font-family: var(--body-font); font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; }
.mainnav { display: flex; gap: .25rem; margin-right: auto; overflow-x: auto; }
.mainnav a {
  padding: .5rem .8rem; border-radius: var(--radius); font-size: .9rem; font-weight: 500;
  color: #D6D3D1; white-space: nowrap; transition: background .15s, color .15s;
}
.mainnav a:hover { background: rgba(255,255,255,.08); color: var(--white); }
.mainnav a.is-active { background: var(--accent); color: var(--dark); font-weight: 600; }
.usermenu { display: flex; align-items: center; gap: .7rem; flex-shrink: 0; }
.usermenu__name { font-size: .85rem; color: #D6D3D1; }

/* ── Layout ── */
.wrap { max-width: 1360px; margin-inline: auto; padding: 1.5rem 1.25rem 4rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head .subtitle { color: var(--muted); font-size: .95rem; margin-top: .15rem; }
.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.grid { display: grid; gap: 1rem; }
.muted { color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .55rem 1.05rem; border-radius: var(--radius); border: 1.5px solid transparent;
  font-family: var(--body-font); font-size: .875rem; font-weight: 600; cursor: pointer;
  background: var(--accent); color: var(--dark); transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { background: var(--accent-dark); }
.btn--sm { padding: .35rem .7rem; font-size: .8rem; }
.btn--lg { padding: .7rem 1.5rem; font-size: .95rem; }
.btn--outline { background: transparent; border-color: var(--border); color: var(--dark); }
.btn--outline:hover { background: var(--section-alt); border-color: var(--muted); }
.btn--ghost { background: transparent; border-color: rgba(255,255,255,.25); color: #E7E5E4; }
.btn--ghost:hover { background: rgba(255,255,255,.1); }
.btn--danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn--danger:hover { background: var(--danger); color: var(--white); }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: default; }

/* ── Cards ── */
.card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card__body { padding: 1.15rem 1.25rem; }
.card__head { padding: .9rem 1.25rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.card__head h2, .card__head h3 { font-family: var(--body-font); font-size: .8rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }

/* ── Stat cards ── */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.stat { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.15rem 1.25rem; box-shadow: var(--shadow-sm); display: block; }
.stat__n { font-family: var(--heading-font); font-size: 2.1rem; font-weight: 700; line-height: 1; }
.stat__label { color: var(--muted); font-size: .82rem; margin-top: .35rem; text-transform: uppercase; letter-spacing: .05em; }
.stat--alert .stat__n { color: var(--danger); }
.stat--accent .stat__n { color: var(--accent-dark); }

/* ── Badges / pills ── */
.badge {
  display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .6rem; border-radius: 999px;
  font-size: .74rem; font-weight: 600; line-height: 1.4; white-space: nowrap;
  background: var(--section-alt); color: var(--primary);
}
.badge__dot { width: .55rem; height: .55rem; border-radius: 50%; background: currentColor; }
.badge--rush { background: #FEE2E2; color: #991B1B; }
.badge--overdue { background: #FEF2F2; color: var(--danger); border: 1px solid #FECACA; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: .6rem .75rem; border-bottom: 1px solid var(--border); }
table.data td { padding: .7rem .75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr:hover { background: var(--section-alt); }
table.data tr.is-overdue td { background: #FEF7F7; }
table.data .wo { font-weight: 600; font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--muted); padding: 2.5rem 1rem; }

/* ── Forms ── */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem 1.25rem; }
.field { display: flex; flex-direction: column; gap: .35rem; }
.field--full { grid-column: 1 / -1; }
.field label { font-size: .82rem; font-weight: 600; color: var(--primary); }
.field input, .field select, .field textarea {
  font-family: var(--body-font); font-size: .92rem; padding: .55rem .7rem;
  border: 1.5px solid var(--border); border-radius: var(--radius); background: var(--white); color: var(--dark); width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(201,150,58,.15); }
.field textarea { resize: vertical; min-height: 80px; }
.field .hint { font-size: .76rem; color: var(--muted); }
.form-actions { display: flex; gap: .6rem; margin-top: 1.25rem; align-items: center; }

/* ── Flash ── */
.flash { padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .9rem; font-weight: 500; }
.flash--success { background: #F0FDF4; color: #166534; border: 1px solid #BBF7D0; }
.flash--error { background: #FEF2F2; color: #991B1B; border: 1px solid #FECACA; }

/* ── Filters bar ── */
.filters { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1.15rem; }
.filters input, .filters select { padding: .45rem .65rem; border: 1.5px solid var(--border); border-radius: var(--radius); font-size: .85rem; font-family: var(--body-font); background: var(--white); }
.filters .chip { padding: .4rem .8rem; border: 1.5px solid var(--border); border-radius: 999px; font-size: .82rem; background: var(--white); }
.filters .chip.is-active { background: var(--dark); color: var(--white); border-color: var(--dark); }

/* ── Detail layout ── */
.detail-grid { display: grid; grid-template-columns: 1fr 320px; gap: 1.25rem; align-items: start; }
.deflist { display: grid; grid-template-columns: 130px 1fr; gap: .55rem .75rem; font-size: .9rem; }
.deflist dt { color: var(--muted); }
.deflist dd { font-weight: 500; }
.section-block { margin-top: 1.25rem; }
.section-block > h3 { font-family: var(--body-font); font-size: .8rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin-bottom: .6rem; }

/* status control */
.statusbar { display: flex; flex-wrap: wrap; gap: .4rem; }
.statusbar button { cursor: pointer; }
.status-pill { border: 1.5px solid var(--border); background: var(--white); padding: .35rem .7rem; border-radius: 999px; font-size: .8rem; font-weight: 600; color: var(--primary); }
.status-pill.is-current { color: var(--white); border-color: transparent; }

/* activity feed */
.feed { display: flex; flex-direction: column; gap: .1rem; }
.feed li { padding: .7rem 0; border-bottom: 1px solid var(--border); font-size: .88rem; }
.feed li:last-child { border-bottom: none; }
.feed .feed__meta { color: var(--muted); font-size: .76rem; margin-top: .2rem; }

/* inline add-row forms */
.inline-form { display: grid; gap: .5rem; grid-template-columns: repeat(6, 1fr); align-items: end; margin-top: .75rem; padding: .85rem; background: var(--section-alt); border-radius: var(--radius); }
.inline-form .field label { font-size: .72rem; }
.inline-form input, .inline-form select { padding: .4rem .55rem; font-size: .85rem; }

/* ── Kanban board ── */
.board { display: flex; gap: .85rem; overflow-x: auto; padding-bottom: 1rem; align-items: flex-start; }
.board__col { flex: 0 0 260px; background: var(--section-alt); border: 1px solid var(--border); border-radius: var(--radius-lg); display: flex; flex-direction: column; max-height: calc(100vh - 160px); }
.board__col-head { padding: .7rem .85rem; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); position: sticky; top: 0; }
.board__col-head .name { display: flex; align-items: center; gap: .45rem; font-size: .82rem; font-weight: 700; }
.board__col-head .count { font-size: .78rem; color: var(--muted); font-weight: 600; }
.board__list { padding: .6rem; display: flex; flex-direction: column; gap: .55rem; overflow-y: auto; min-height: 40px; }
.board__list.drag-over { background: rgba(201,150,58,.1); outline: 2px dashed var(--accent); outline-offset: -4px; border-radius: var(--radius); }
.jobcard { background: var(--white); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--radius); padding: .6rem .7rem; box-shadow: var(--shadow-sm); cursor: grab; }
.jobcard:active { cursor: grabbing; }
.jobcard.dragging { opacity: .5; }
.jobcard .jc-wo { font-size: .72rem; color: var(--muted); font-weight: 600; }
.jobcard .jc-title { font-size: .88rem; font-weight: 600; margin: .1rem 0 .3rem; }
.jobcard .jc-meta { display: flex; align-items: center; justify-content: space-between; gap: .4rem; font-size: .74rem; color: var(--muted); }
.jobcard.is-rush { border-left-color: var(--danger); }
.jobcard .jc-due.overdue { color: var(--danger); font-weight: 600; }

/* ── Field report ── */
.fieldreport { border-left: 4px solid var(--accent); }
.report-types { display: grid; grid-template-columns: repeat(4, 1fr); gap: .55rem; }
.report-opt { cursor: pointer; }
.report-opt input { position: absolute; opacity: 0; pointer-events: none; }
.report-opt__box {
  display: flex; flex-direction: column; align-items: center; gap: .3rem; text-align: center;
  padding: .8rem .5rem; border: 2px solid var(--border); border-radius: var(--radius);
  font-size: .82rem; font-weight: 600; color: var(--primary); background: var(--white);
  transition: border-color .12s, background .12s, box-shadow .12s; height: 100%;
}
.report-opt__icon { font-size: 1.4rem; line-height: 1; }
.report-opt:hover .report-opt__box { border-color: var(--muted); }
.report-opt input:checked + .report-opt__box {
  border-color: var(--rc); background: color-mix(in srgb, var(--rc) 10%, white);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--rc) 18%, transparent);
}
.report-opt input:focus-visible + .report-opt__box { outline: 2px solid var(--rc); outline-offset: 2px; }

/* ── Photo grid ── */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .7rem; }
.photo-grid--sm { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: .4rem; }
.photo { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--section-alt); }
.photo img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.photo-grid--sm a img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border: 1px solid var(--border); border-radius: 6px; }
.photo figcaption { padding: .4rem .55rem; font-size: .74rem; color: var(--muted); display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.photo-cap { color: var(--dark); font-weight: 600; width: 100%; }
.photo-del { margin-left: auto; border: none; background: transparent; color: var(--muted); cursor: pointer; font-size: .85rem; line-height: 1; padding: .1rem .25rem; border-radius: 4px; }
.photo-del:hover { background: #FEE2E2; color: var(--danger); }

@media (max-width: 560px) {
  .report-types { grid-template-columns: repeat(2, 1fr); }
}

/* ── Login ── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: var(--dark); padding: 1.5rem; }
.login-card { background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); width: 100%; max-width: 380px; padding: 2rem; }
.login-card .brand { justify-content: center; margin-bottom: 1.25rem; }
.login-card h1 { text-align: center; font-size: 1.35rem; margin-bottom: 1.25rem; }

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .detail-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .inline-form { grid-template-columns: repeat(2, 1fr); }
}

/* ── Mobile navigation (hamburger) ── */
@media (max-width: 820px) {
  .navtoggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 42px; height: 42px; margin-left: auto; flex-shrink: 0;
    background: transparent; border: 1px solid rgba(255,255,255,.22); border-radius: 8px; cursor: pointer;
  }
  .navtoggle__bars { position: relative; width: 20px; height: 14px; }
  .navtoggle__bars span { position: absolute; left: 0; width: 100%; height: 2px; background: var(--light); border-radius: 2px; transition: transform .2s, opacity .2s, top .2s; }
  .navtoggle__bars span:nth-child(1) { top: 0; }
  .navtoggle__bars span:nth-child(2) { top: 6px; }
  .navtoggle__bars span:nth-child(3) { top: 12px; }
  .topbar.nav-open .navtoggle__bars span:nth-child(1) { top: 6px; transform: rotate(45deg); }
  .topbar.nav-open .navtoggle__bars span:nth-child(2) { opacity: 0; }
  .topbar.nav-open .navtoggle__bars span:nth-child(3) { top: 6px; transform: rotate(-45deg); }

  .usermenu { display: none; }
  .mainnav {
    display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: 60;
    flex-direction: column; gap: .15rem; overflow-y: auto; max-height: calc(100vh - var(--nav-h));
    background: var(--dark); padding: .5rem; border-top: 1px solid rgba(255,255,255,.1); box-shadow: var(--shadow-md);
  }
  .topbar.nav-open .mainnav { display: flex; }
  .mainnav a { padding: .9rem 1rem; border-radius: 8px; font-size: 1.02rem; }
  .mainnav__user {
    display: flex; align-items: center; justify-content: space-between; gap: .75rem;
    padding: .9rem 1rem; margin-top: .35rem; border-top: 1px solid rgba(255,255,255,.1);
  }
  .mainnav__name { color: #D6D3D1; font-size: .95rem; }
}

/* ── Responsive tables → stacked cards on phones ── */
@media (max-width: 640px) {
  table.data.responsive thead { display: none; }
  table.data.responsive tr { display: block; border-bottom: 1px solid var(--border); padding: .45rem 0; }
  table.data.responsive tr:hover { background: transparent; }
  table.data.responsive tr.is-overdue td { background: transparent; }
  table.data.responsive td {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    border: none; padding: .3rem .85rem; text-align: right;
  }
  table.data.responsive td::before {
    content: attr(data-label); flex-shrink: 0; text-align: left;
    color: var(--muted); font-weight: 700; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
  }
  table.data.responsive td.hide-sm { display: none; }
  table.data.responsive td[data-label="WO#"], table.data.responsive td[data-label="Item"] { font-size: 1.02rem; }
  table.data.responsive td.empty { display: block; text-align: center; }
  table.data.responsive td.empty::before { content: none; }

  /* Tables that keep the grid layout (specs/materials with row forms): scroll, don't wrap */
  .card table.data:not(.responsive) th, .card table.data:not(.responsive) td { white-space: nowrap; }
}

/* ── General mobile polish ── */
.wo { white-space: nowrap; }
html, body { overflow-x: hidden; max-width: 100%; }
/* Let grid children shrink so their scroll containers (tables) don't force page width */
.detail-grid > * { min-width: 0; }
.table-wrap { max-width: 100%; }

@media (max-width: 560px) {
  .wrap { padding: 1rem .85rem 3.5rem; }
  h1 { font-size: 1.45rem; }
  .page-head { gap: .5rem; }
  .stat__n { font-size: 1.85rem; }
  .btn { padding: .62rem 1.05rem; }
  .filters input[type=search] { width: 100%; }
  .filters select { flex: 1 1 auto; }
  .card__body { padding: 1rem; }
  .inline-form { grid-template-columns: 1fr; }   /* add-forms stack on phones */
}
