:root {
  --bg: #f5f7f8;
  --card: #ffffff;
  --text: #18242b;
  --muted: #5b6b74;
  --border: #e3e8ec;
  --accent: #0f766e;
  --accent-dark: #0c5f59;
  --accent-soft: #e4f3f1;
  --danger: #b42318;
  --ok: #067647;
  --warn: #b54708;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* nav */
nav {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 0.6rem 1.1rem; background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: inline-flex; align-items: center; gap: 0.55rem; color: var(--text); text-decoration: none; }
.nav-links { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.nav-links a { color: #47565f; text-decoration: none; font-weight: 500; padding: 0.3rem 0.2rem; border-radius: 6px; }
.nav-links a:hover, .nav-links a:focus-visible { color: var(--accent); }
.who { color: var(--muted); font-size: 0.85rem; padding: 0.15rem 0.6rem; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; }
.bell { position: relative; color: var(--muted); display: inline-flex; }
.bell:hover, .bell:focus-visible { color: var(--accent); }
.badge {
  position: absolute; top: -4px; right: -8px; background: var(--danger); color: #fff;
  font-size: 0.68rem; font-weight: 700; padding: 0 0.32rem; border-radius: 999px; line-height: 1.4;
}
.nav-right { display: flex; align-items: center; gap: 0.9rem; }
.nav-burger { display: none; align-items: center; justify-content: center; width: 2.2rem; height: 2.2rem; border-radius: 8px; border: 1px solid var(--border); background: var(--card); color: var(--text); cursor: pointer; }

/* mobile slide-in menu */
.nav-overlay {
  position: fixed; inset: 0; background: rgba(8, 14, 18, 0.45); z-index: 40;
  opacity: 0; transition: opacity .2s ease;
}
.nav-overlay.open { opacity: 1; }
.nav-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(18rem, 84vw); z-index: 50;
  background: var(--card); border-left: 1px solid var(--border);
  box-shadow: -8px 0 28px rgba(8, 14, 18, 0.18);
  display: flex; flex-direction: column; padding: 0.9rem 0;
  transform: translateX(100%); transition: transform .2s ease;
}
.nav-panel.open { transform: translateX(0); }
.nav-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 0 1.1rem 0.8rem; border-bottom: 1px solid var(--border); }
.nav-close { display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; border-radius: 8px; border: 1px solid var(--border); background: transparent; color: var(--muted); cursor: pointer; }
.nav-close:hover, .nav-close:focus-visible { color: var(--accent); border-color: var(--accent); }
.nav-panel-links { display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 0.15rem; padding: 0.6rem 0.7rem; flex: 0 0 auto; }
.nav-panel-links a {
  display: flex; align-items: center; gap: 0.7rem; color: var(--text); text-decoration: none;
  font-weight: 500; padding: 0.7rem 0.7rem; border-radius: 8px; font-size: 1rem;
}
.nav-panel-links a:hover, .nav-panel-links a:focus-visible { background: var(--accent-soft); color: var(--accent-dark); }
html[data-theme="dark"] .nav-panel-links a:hover, html[data-theme="dark"] .nav-panel-links a:focus-visible { color: var(--accent); }
.nav-panel-links a.active-link { background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }
html[data-theme="dark"] .nav-panel-links a.active-link { color: var(--accent); }
.nav-panel-foot { display: flex; align-items: center; gap: 0.7rem; padding: 0.9rem 1.1rem 0; border-top: 1px solid var(--border); }
.theme-label { font-size: 0.85rem; color: var(--muted); flex: 1; }
.logout-link { color: var(--danger); text-decoration: none; font-weight: 600; font-size: 0.9rem; align-self: center; }
.logout-link:hover, .logout-link:focus-visible { text-decoration: underline; }

/* layout */
main { max-width: 62rem; margin: 0 auto; padding: 1.2rem 1.1rem 3rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin: 0.4rem 0 1rem; }
h1 { font-size: 1.45rem; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; margin: 0 0 0.8rem; }
h3 { font-size: 0.95rem; margin: 0 0 0.3rem; }
.sub { color: var(--muted); margin: 0.2rem 0 0; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem 1.2rem; margin-bottom: 1rem; display: block; text-decoration: none; color: inherit;
}

/* bento grid dashboard */
.bento {
  display: grid; gap: 0.9rem;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: minmax(4.5rem, auto);
}
.bento-cell { position: relative; min-width: 0; }
.bento.editing .tile-remove { display: inline-flex; }
.bento-cell[data-tile="activity"]     { grid-column: span 1; }
.bento.editing .bento-cell { outline: 2px dashed var(--accent); outline-offset: 2px; border-radius: var(--radius); }
.bento.editing .bento-cell.dragging { opacity: 0.5; cursor: grabbing; outline-style: solid; }
.bento.editing .tile-remove { display: inline-flex; }
.tile-remove { display: none; position: absolute; top: -8px; right: -8px; z-index: 5; width: 1.5rem; height: 1.5rem;
  border-radius: 50%; border: 1px solid var(--danger); background: var(--card); color: var(--danger);
  font-size: 0.8rem; cursor: pointer; align-items: center; justify-content: center;
}
.tile-remove:hover { background: var(--danger); color: #fff; }
.tile-move { display: none; position: absolute; top: -8px; left: -8px; z-index: 5; gap: 2px; }
.bento.editing .tile-move { display: inline-flex; flex-direction: column; }
.tile-up, .tile-down {
  display: none; width: 1.5rem; height: 1.5rem; border-radius: 6px; border: 1px solid var(--border);
  background: var(--card); color: var(--muted); font-size: 0.8rem; cursor: pointer; line-height: 1;
}
.bento.editing .tile-up, .bento.editing .tile-down { display: inline-block; }
@media (min-width: 641px) and (hover: hover) {
  /* desktop has drag-and-drop for moving: hide arrows, keep ✕/⟷/resize-handle */
  .bento.editing .tile-move, .bento.editing .tile-up, .bento.editing .tile-down { display: none !important; }
}
.tile-up:hover, .tile-down:hover { color: var(--accent); border-color: var(--accent); }

/* drag-to-resize handle (right edge, edit mode, desktop) */
.tile-resize-handle {
  display: none; position: absolute; top: 0; right: -9px; bottom: 0; width: 18px;
  cursor: col-resize; z-index: 6;
}
.bento.editing .tile-resize-handle { display: block; }
.tile-resize-handle::after {
  content: ""; position: absolute; top: 25%; bottom: 25%; left: 50%; width: 4px;
  transform: translateX(-50%); border-radius: 2px;
  background: var(--border); opacity: 0; transition: opacity .15s ease, background .15s ease;
}
.bento.editing .bento-cell:hover .tile-resize-handle::after { opacity: 1; }
.bento.editing .bento-cell:hover .tile-resize-handle:hover::after { background: var(--accent); opacity: 1; }
.resize-preview-2 { outline: 2px solid var(--accent) !important; outline-offset: 2px; box-shadow: 0 0 0 300px rgba(15, 118, 110, 0.04); }
.resize-preview-3 { outline: 2px solid var(--accent) !important; outline-offset: 2px; box-shadow: 0 0 0 300px rgba(15, 118, 110, 0.06); }
.resize-preview-4 { outline: 2px solid var(--accent) !important; outline-offset: 2px; box-shadow: 0 0 0 300px rgba(15, 118, 110, 0.08); }
.tile-add-row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; padding: 0.5rem 0.2rem; }
.add-tile-btn { border: 1px dashed var(--accent); color: var(--accent); background: transparent; border-radius: 8px; padding: 0.35rem 0.8rem; font: inherit; font-weight: 600; font-size: 0.85rem; cursor: pointer; }
.add-tile-btn:hover, .add-tile-btn:focus-visible { background: var(--accent-soft); }
.tile-placeholder { border: 2px dashed var(--border); border-radius: var(--radius); padding: 1.2rem; min-height: 6rem; display: flex; flex-direction: column; justify-content: center; gap: 0.3rem; }
.layout-actions { display: none; align-items: center; gap: 0.6rem; margin-top: 0.9rem; flex-wrap: wrap; }
body.editing-bento .layout-actions { display: flex; }
.head-actions { display: flex; gap: 0.5rem; align-items: center; }
.bento-tile { margin-bottom: 0; min-width: 0; }
.b-kpi { display: flex; flex-direction: column; align-items: flex-start; gap: 0.15rem; padding: 1.1rem 1.2rem; position: relative; overflow: hidden; }
.b-kpi .stat-num { font-size: 2.3rem; line-height: 1.1; }
.b-kpi::after {
  content: ""; position: absolute; right: -14px; bottom: -14px; width: 72px; height: 72px;
  border-radius: 50%; background: currentColor; opacity: 0.07; pointer-events: none;
}
.b-open { color: var(--accent); }
.b-proc { color: #1d4ed8; }
html[data-theme="dark"] .b-proc { color: #93b4ff; }
.b-closed { color: var(--ok); }
.b-vendors { color: #7c5cd6; }
html[data-theme="dark"] .b-vendors { color: #b39dff; }
.b-kpi .stat-num, .b-kpi { color: inherit; }
.b-open .stat-num, .b-proc .stat-num, .b-closed .stat-num, .b-vendors .stat-num { color: inherit; }
.b-kpi > :last-child { font-size: 0.88rem; font-weight: 600; color: var(--text); }
.big-pct { font-size: 2.6rem; font-weight: 800; letter-spacing: -0.02em; color: var(--accent); line-height: 1; }
.big-pct span { font-size: 1.3rem; font-weight: 700; margin-left: 2px; }
.progress-track { height: 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--border); overflow: hidden; margin: 0.6rem 0 0.7rem; }
.progress-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), #155e75); transition: width .6s ease; }
.mini-legend { display: flex; align-items: center; gap: 0.4rem; font-size: 0.78rem; color: var(--muted); }
.mini-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-open { background: var(--accent); }
.dot-proc { background: #1d4ed8; }
html[data-theme="dark"] .dot-proc { background: #93b4ff; }

/* filter bar on work orders page */
.filter-bar { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; flex-wrap: wrap; padding: 0.8rem 1rem; }
.filter-chips { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.chip { display: inline-block; padding: 0.35rem 0.9rem; border-radius: 999px; border: 1px solid var(--border); background: var(--card); color: var(--text); font-weight: 600; font-size: 0.88rem; text-decoration: none; }
.chip:hover, .chip:focus-visible { border-color: var(--accent); color: var(--accent); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
html[data-theme="dark"] .chip.active { color: #06241f; }
.chip-open.active { background: var(--warn); border-color: var(--warn); }
.chip-proc.active { background: #1d4ed8; border-color: #1d4ed8; }
html[data-theme="dark"] .chip-proc.active { background: #93b4ff; border-color: #93b4ff; color: #17233f; }
.chip-closed.active { background: var(--ok); border-color: var(--ok); }
.filter-controls { display: flex; gap: 0.5rem; align-items: center; }
.filter-controls select { width: auto; min-width: 10rem; padding: 0.35rem 0.6rem; font-size: 0.88rem; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.8rem; margin-bottom: 1rem; }
.stats-4 { grid-template-columns: repeat(4, 1fr); }
.stat { text-align: center; padding: 1.1rem 0.6rem; }
.stat .stat-num { display: block; font-size: 1.9rem; font-weight: 700; color: var(--accent); }
.stat:hover, .stat:focus-visible { border-color: var(--accent); }
.stat-proc .stat-num { color: #1d4ed8; }
html[data-theme="dark"] .stat-proc .stat-num { color: #93b4ff; }

/* dashboard two-column layout */
.dash-grid { display: grid; grid-template-columns: 1.9fr 1fr; gap: 1rem; align-items: start; }
.dash-side { position: sticky; top: 4.2rem; max-height: calc(100vh - 6rem); overflow: auto; }
.dash-main { margin-bottom: 0; }

/* activity feed */
.feed { list-style: none; margin: 0; padding: 0; }
.feed-item { display: flex; gap: 0.6rem; padding: 0.55rem 0; border-bottom: 1px solid var(--border); }
.feed-item:last-child { border-bottom: 0; }
.feed-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; margin-top: 0.45rem; }
.feed-dot.created { background: var(--accent); }
.feed-dot.comment { background: #b45309; }
.feed-dot.closed { background: var(--ok); }
.feed-body p { margin: 0; font-size: 0.88rem; line-height: 1.4; }
.feed-who { font-size: 0.82rem; }
.feed-body time { font-size: 0.75rem; color: var(--muted); }
td:first-child, td:nth-child(3) { white-space: nowrap; }
/* table inside orders tile: adaptive columns via data-col (picker) */
.b-orders table { table-layout: fixed; }
.b-orders td, .b-orders th { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b-orders td:first-child { word-break: keep-all; hyphens: none; white-space: normal; }
/* column picker */
.tile-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.8rem; }
.tile-head h2 { margin: 0; }
.cols-picker { position: relative; }
.cols-toggle { display: none; border: 1px solid var(--border); background: var(--card); color: var(--muted); font: inherit; font-size: 0.8rem; font-weight: 600; padding: 0.3rem 0.6rem; border-radius: 8px; cursor: pointer; }
.cols-toggle:hover, .cols-toggle:focus-visible { color: var(--accent); border-color: var(--accent); }
.cols-picker.show .cols-toggle { display: inline-block; }
.cols-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 9.5rem;
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(8, 14, 18, 0.16); padding: 0.4rem 0.2rem;
}
.cols-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.35rem 0.7rem; font-size: 0.88rem; cursor: pointer; border-radius: 6px; }
.cols-item:hover { background: var(--accent-soft); }
.cols-item input { width: auto; margin: 0; }
@media (max-width: 640px) {
  .bento.editing .bento-cell { padding-top: 3.4rem; }
  .bento.editing .tile-move { display: inline-flex !important; flex-direction: row; gap: 0.5rem; top: 6px; left: 6px; }
  .bento.editing .tile-up, .bento.editing .tile-down { width: 2.4rem; height: 2.4rem; font-size: 1.05rem; border-radius: 8px; background: var(--card); }
  .bento.editing .tile-remove { width: 2.4rem; height: 2.4rem; font-size: 1.05rem; top: 6px; right: 6px; }
}

/* buttons & forms */
.btn {
  display: inline-flex; align-items: center; gap: 0.35rem; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  font: inherit; font-weight: 600; font-size: 0.92rem; padding: 0.45rem 0.95rem; text-decoration: none;
}
.btn:hover, .btn:focus-visible { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover, .btn.primary:focus-visible { background: var(--accent-dark); color: #fff; }
.btn.success { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ghost { background: transparent; }
.btn.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.filters { display: flex; gap: 0.4rem; }

form label, legend { display: block; font-weight: 600; font-size: 0.88rem; margin: 0.8rem 0 0.25rem; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); margin: 1.2rem 0 0; padding: 0.2rem 1rem 1rem; }
input, select, textarea {
  width: 100%; padding: 0.55rem 0.7rem; border: 1px solid var(--border); border-radius: 8px;
  font: inherit; background: #fff; color: var(--text);
}
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
textarea { resize: vertical; }
.form-narrow { max-width: 34rem; }
form .btn { margin-top: 1rem; }

/* tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfc; }
td a { color: inherit; text-decoration: none; }
td a:hover { color: var(--accent); }

/* badges */
.badge-pill { display: inline-flex; align-items: center; gap: 0.4rem; white-space: nowrap; vertical-align: middle; padding: 0.35rem 0.65rem; border-radius: 999px; font-size: 0.78rem; line-height: 1; font-weight: 650; }
.badge-pill.open { background: #fef0e6; color: var(--warn); }
.badge-pill.in_process { background: #eaf0fe; color: #1d4ed8; }
.badge-pill.closed { background: #e6f4ec; color: var(--ok); }
.badge-pill.lg { font-size: 0.95rem; padding: 0.4rem 0.8rem; }

/* flash */
.flash { padding: 0.65rem 1rem; border-radius: 8px; margin-bottom: 0.9rem; font-weight: 500; }
.flash.ok { background: #e6f4ec; color: var(--ok); }
.flash.error { background: #fdecea; color: var(--danger); }

/* auth */
.auth-wrap { display: flex; justify-content: center; padding: 12vh 1rem 0; }
.auth-card { width: 100%; max-width: 22rem; padding: 1.6rem 1.5rem; }
.auth-card h1 { margin-bottom: 0.4rem; }
.auth-card .btn { width: 100%; justify-content: center; }

/* wo detail */
.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: 0.7rem 1.2rem; margin: 0; }
.meta-grid dt { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.meta-grid dd { margin: 0.1rem 0 0; font-weight: 500; }
.desc { margin: 1rem 0 0; white-space: pre-wrap; }
.completion { margin-top: 1rem; padding: 0.8rem 1rem; background: var(--accent-soft); border-radius: 8px; }
.completion h3 { color: var(--accent-dark); }
.completion p { margin: 0; white-space: pre-wrap; }

/* files */
.files { display: flex; flex-wrap: wrap; gap: 0.7rem; }
.files img { width: 8.5rem; height: 8.5rem; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); display: block; }
.files.small img { width: 6rem; height: 6rem; }
.pdf-file { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.55rem 0.8rem; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; color: var(--text); text-decoration: none; font-weight: 500; }
.pdf-file:hover, .pdf-file:focus-visible { border-color: var(--accent); color: var(--accent); }

/* thread */
.thread { list-style: none; margin: 0; padding: 0; }
.msg { padding: 0.7rem 0.9rem; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 0.6rem; max-width: 46rem; background: var(--bg); }
.msg.mine { background: var(--accent-soft); border-color: transparent; margin-left: auto; }
.msg-head { font-size: 0.82rem; color: var(--muted); margin-bottom: 0.2rem; }
.msg-head time { margin-left: 0.4rem; }
.msg p { margin: 0; white-space: pre-wrap; }
.comment-form { margin-top: 1rem; }
.comment-form .btn { margin-top: 0.6rem; }
.file-label { display: inline-block; margin: 0.6rem 0 0.2rem; color: var(--muted); cursor: pointer; }
.close-form { margin-top: 1.4rem; padding-top: 1rem; border-top: 1px dashed var(--border); }
.close-form .btn { margin-top: 0.6rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }

/* notifications & settings extras */
.checks { display: flex; gap: 1.4rem; margin-top: 0.6rem; }
label.inline { display: inline-flex; align-items: center; gap: 0.4rem; font-weight: 500; margin: 0; }
label.inline input { width: auto; }
.bar { display: inline-block; height: 10px; border-radius: 5px; margin-right: 4px; }
.bar.created { background: var(--accent); }
.bar.closed { background: #86b7ae; }

.role-pill { display: inline-flex; align-items: center; white-space: nowrap; padding: 0.14rem 0.6rem; border-radius: 999px; font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.role-pill.admin { background: var(--accent-soft); color: var(--accent-dark); }
.role-pill.vendor { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.actions { white-space: nowrap; }
.inline-form { display: inline-flex; gap: 0.3rem; margin-right: 0.4rem; vertical-align: middle; }
.inline-form input[type="password"] { width: 10rem; padding: 0.3rem 0.5rem; font-size: 0.85rem; }
.inline-form .btn { padding: 0.3rem 0.55rem; font-size: 0.82rem; margin-top: 0; }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.danger:hover, .btn.danger:focus-visible { background: var(--danger); color: #fff; }

/* notifications */
.notif-list { list-style: none; margin: 0; padding: 0; }
.notif { display: flex; justify-content: space-between; gap: 1rem; padding: 0.65rem 0.2rem; border-bottom: 1px solid var(--border); }
.notif:last-child { border-bottom: 0; }
.notif a { color: var(--text); text-decoration: none; font-weight: 500; }
.notif a:hover, .notif a:focus-visible { color: var(--accent); }
.notif time { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.notif.unread a { color: var(--accent); }
.notif.unread::before { content: "●"; color: var(--accent); margin-right: 0.4rem; }

/* empty */
.empty { text-align: center; padding: 2.2rem 1rem; color: var(--muted); }
.empty p { margin: 0.2rem 0; }
.empty .btn { margin-top: 0.9rem; }

/* dark theme */
html[data-theme="dark"] {
  --bg: #10161a;
  --card: #182128;
  --text: #e2e8f0;
  --muted: #8fa1ab;
  --border: #2a363e;
  --accent: #2dd4bf;
  --accent-dark: #14b8a6;
  --accent-soft: #123b37;
  --danger: #f97066;
  --ok: #32d583;
  --warn: #fdb022;
}
html[data-theme="dark"] body { color-scheme: dark; }
html[data-theme="dark"] .btn.primary { background: var(--accent); border-color: var(--accent); color: #06241f; }
html[data-theme="dark"] .btn.primary:hover, html[data-theme="dark"] .btn.primary:focus-visible { background: var(--accent-dark); color: #06241f; }
html[data-theme="dark"] .btn.success { background: var(--ok); border-color: var(--ok); color: #06281a; }
html[data-theme="dark"] .badge-pill.open { background: #3a2413; }
html[data-theme="dark"] .badge-pill.in_process { background: #17233f; color: #93b4ff; }
html[data-theme="dark"] .badge-pill.closed { background: #11321f; }
html[data-theme="dark"] .flash.ok { background: #11321f; }
html[data-theme="dark"] .flash.error { background: #3a1713; }
html[data-theme="dark"] .completion { background: var(--accent-soft); }
html[data-theme="dark"] .msg { background: #1f2930; }
html[data-theme="dark"] .msg.mine { background: var(--accent-soft); }
html[data-theme="dark"] tbody tr:hover { background: #1d262c; }
html[data-theme="dark"] .pdf-file { background: var(--bg); }
html[data-theme="dark"] .bar.closed { background: #2f5f54; }
html[data-theme="dark"] .auth-card h1, html[data-theme="dark"] .brand strong { color: var(--text); }
html[data-theme="dark"] input, html[data-theme="dark"] select, html[data-theme="dark"] textarea { background: var(--bg); border-color: var(--border); color: var(--text); }
html[data-theme="dark"] .who { background: var(--bg); border-color: var(--border); }
html[data-theme="dark"] .nav-links a { color: #a9bac3; }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
}
.theme-toggle:hover, .theme-toggle:focus-visible { color: var(--accent); border-color: var(--accent); }
html[data-theme="light"] .icon-moon { display: none; }
html[data-theme="dark"] .icon-sun { display: none; }

/* Theme control is a native keyboard-operable button on every shell. */
.theme-switch { display:inline-flex; align-items:center; justify-content:center; min-height:44px; padding:8px 12px; border:1px solid currentColor; border-radius:8px; background:transparent; color:inherit; font:inherit; cursor:pointer; flex-shrink:0; }
.theme-switch:focus-visible { outline:3px solid #60a5fa; outline-offset:3px; }
.theme-switch :where(svg) { display:block; } .icon-moon { display:none; }
html[data-theme="dark"] .icon-sun { display:none; }
html[data-theme="dark"] .icon-moon { display:inline; }
@media (prefers-color-scheme:dark) { html:not([data-theme]) .icon-sun { display:none; } html:not([data-theme]) .icon-moon { display:inline; } }
.auth-theme-bar { display:flex; justify-content:flex-end; padding:12px 16px; }

/* polish: motion + depth */
.card { transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease; }
.card:hover { box-shadow: 0 4px 14px rgba(10, 30, 40, .07); }
main > *, .card { animation: rise .28s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { main > *, .card { animation: none; } .card, .btn { transition: none; } }

.btn { transition: background .12s ease, color .12s ease, border-color .12s ease, transform .06s ease; }
.btn:active { transform: translateY(1px); }
.btn.primary { box-shadow: 0 1px 2px rgba(15, 118, 110, .25); }
.stat:hover { transform: translateY(-2px); }

/* status dot + pulse for live states */
.badge-pill.open::before, .badge-pill.in_process::before, .badge-pill.closed::before {
  content: ""; display: inline-block; width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%;
  background: currentColor;
}
.badge-pill.in_process::before { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* avatars in discussion */
.msg { padding-left: 3.1rem; position: relative; }
.avatar {
  position: absolute; left: 0.7rem; top: 0.7rem; width: 1.8rem; height: 1.8rem;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 0.78rem; font-weight: 700; color: #fff; text-transform: uppercase;
  background: var(--muted);
}
.avatar.vendor { background: #b45309; }
.avatar.admin { background: var(--accent); }

/* login page backdrop */
.auth-wrap { position: relative; }
.auth-card { position: relative; overflow: visible; box-shadow: 0 10px 30px rgba(10, 30, 40, .10); }
.auth-card::before {
  content: ""; position: absolute; inset: -1px; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent), #155e75); z-index: -1; opacity: 0; pointer-events: none;
}
.auth-card h1 { display: flex; align-items: center; gap: 0.55rem; }
.auth-card h1::before {
  content: ""; width: 2rem; height: 2rem; border-radius: 8px; flex: none;
  background: linear-gradient(135deg, var(--accent), #155e75);
  -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><rect x="1" y="1" width="22" height="22" rx="5" fill="black"/><path d="M6.5 12.5l3.5 3.5 7.5-8" stroke="white" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" fill="none"/></svg>') center / contain no-repeat;
          mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><rect x="1" y="1" width="22" height="22" rx="5" fill="black"/><path d="M6.5 12.5l3.5 3.5 7.5-8" stroke="white" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" fill="none"/></svg>') center / contain no-repeat;
}

/* empty states */
.empty svg { display: block; margin: 0 auto 0.5rem; color: var(--muted); }

/* bento edit mode: touch-friendly */
.bento.editing { padding-bottom: 4.6rem; }
body.editing-bento .layout-actions {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 1rem;
  z-index: 30; max-width: min(94vw, 40rem);
  margin: 0; padding: 0.7rem 1.2rem;
  background: var(--card); border: 1px solid var(--border); border-radius: 999px;
  box-shadow: 0 8px 28px rgba(8, 14, 18, 0.18);
  justify-content: center; flex-wrap: wrap;
}
.layout-hint-touch .layout-hint-drag { display: none; }
@media (max-width: 640px) {
  /* mobile edit: controls in a compact strip at the tile top; content shifted below */
  .bento.editing .bento-cell { padding-top: 3.4rem; }
  .bento.editing .tile-move { display: inline-flex !important; flex-direction: row; gap: 0.5rem; top: 6px; left: 6px; }
  .bento.editing .tile-up, .bento.editing .tile-down { width: 2.4rem; height: 2.4rem; font-size: 1.05rem; border-radius: 8px; background: var(--card); }
  .bento.editing .tile-remove { width: 2.4rem; height: 2.4rem; font-size: 1.05rem; top: 6px; right: 6px; }
}

.tile-wide-2 { grid-column: span 2 !important; }
.tile-wide-3 { grid-column: span 3 !important; }
.tile-wide-4 { grid-column: span 4 !important; }
@media (max-width: 640px) {
  .tile-wide-2, .tile-wide-3, .tile-wide-4 { grid-column: span 2 !important; }
}
.tile-wide {
  display: none; position: absolute; top: -8px; left: -8px; z-index: 5;
  width: 1.5rem; height: 1.5rem; border-radius: 6px; border: 1px solid var(--border);
  background: var(--card); color: var(--muted); font-size: 0.8rem; cursor: pointer; line-height: 1;
  align-items: center; justify-content: center;
}
.bento.editing .tile-wide { display: inline-flex; }
.tile-wide:hover { color: var(--accent); border-color: var(--accent); }
.tile-wide[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-dark); border-color: var(--accent); }
html[data-theme="dark"] .tile-wide[aria-pressed="true"] { color: var(--accent); }

/* responsive */
@media (max-width: 640px) {
  nav { padding: 0.55rem 0.8rem; }
  .nav-links { display: none; }
  .nav-burger { display: inline-flex; }
  .nav-panel .who { font-size: 0.95rem; }
  .stats, .stats-4 { grid-template-columns: repeat(2, 1fr); }
  .bento { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
  .dash-side { position: static; max-height: none; overflow: visible; }
  th { display: none; }
  td { display: block; border-bottom: 0; padding: 0.15rem 0.2rem; }
  tr { display: block; padding: 0.6rem 0.2rem; border-bottom: 1px solid var(--border); }
  tr:last-child { border-bottom: 0; }
  td:first-child { padding-top: 0; }
  td:empty { display: none; }
  .msg { max-width: 100%; }
  main { padding: 1rem 0.8rem 3rem; }
}
/* Tables scroll only in explicitly wide, navigable table regions. */
.wo-table-scroll { max-width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; }
table .actions { white-space: nowrap; }
table .actions .inline-form { display: inline-flex; gap: 0.35rem; align-items: center; }
table .actions input[type="password"] { width: 10rem; }
@media (max-width: 900px) {
  table .actions input[type="password"] { width: 8.5rem; }
}

/* Shared page header + summary strip for directory screens (Users, Vendors, Work orders). */
.page-heading { align-items: flex-end; }
.page-kicker { margin: 0 0 0.2rem; color: var(--accent); font-size: 0.7rem; font-weight: 750; letter-spacing: 0.12em; }
.page-heading .sub { max-width: 34rem; }
.page-summary {
  display: inline-flex; align-items: center; gap: 1rem;
  padding: 0.65rem 0.9rem; margin: 0 0 0.9rem;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--card);
}
.page-summary > div, .page-summary > a { display: flex; align-items: baseline; gap: 0.4rem; }
.page-summary strong { font-size: 1.08rem; }
.page-summary span { color: var(--muted); font-size: 0.82rem; }
.page-summary a { color: inherit; text-decoration: none; }
.page-summary a:hover strong, .page-summary a:focus-visible strong { color: var(--accent); }
.page-summary .page-summary-divider { display: block; width: 1px; height: 1.25rem; background: var(--border); }
.user-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 27rem), 1fr)); gap: 0.85rem; list-style: none; margin: 0; padding: 0; }
.user-card { display: flex; flex-direction: column; gap: 0.8rem; min-width: 0; margin: 0; padding: 1rem; border-top: 3px solid var(--accent); }
.user-card-head, .user-identity, .user-tags, .user-name-control, .user-actions, .user-action-buttons { display: flex; align-items: center; }
.user-identity { gap: 0.7rem; min-width: 0; }
.user-avatar { display: grid; place-items: center; flex: 0 0 2.65rem; width: 2.65rem; height: 2.65rem; border-radius: 9px; background: var(--accent-soft); color: var(--accent-dark); font-size: 1.1rem; font-weight: 750; }
.user-identity-text { min-width: 0; }
.user-email { display: block; overflow-wrap: anywhere; font-size: 0.94rem; line-height: 1.35; }
.user-tags { flex-wrap: wrap; gap: 0.35rem; margin-top: 0.35rem; }
.user-meta dt { margin: 0; color: var(--muted); font-size: 0.68rem; font-weight: 750; letter-spacing: 0.07em; text-transform: uppercase; }
.user-meta { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr); gap: 0.75rem; margin: 0; padding: 0.7rem 0.75rem; border-block: 1px solid var(--border); }
.user-meta-item { min-width: 0; }
.user-meta dd { margin: 0.18rem 0 0; overflow-wrap: anywhere; font-size: 0.86rem; }
.user-actions { justify-content: space-between; flex-wrap: wrap; gap: 0.45rem; }
.user-actions-label { color: var(--muted); font-size: 0.72rem; font-weight: 700; }
.user-action-buttons { flex-wrap: wrap; gap: 0.4rem; }
.user-action-buttons .btn { margin: 0; padding: 0.4rem 0.65rem; font-size: 0.8rem; }
.user-reset { position: relative; min-width: 0; }
.user-reset summary { list-style: none; cursor: pointer; }
.user-reset summary::-webkit-details-marker { display: none; }
.user-reset-form { display: grid; gap: 0.45rem; min-width: 13rem; margin-top: 0.5rem; }
.user-reset-form input { min-width: 0; width: 100%; }
.user-reset-form .btn, .user-toggle-form { margin: 0; }
html[data-theme="dark"] .user-avatar { color: var(--accent); }

/* Vendors: the same directory language as Users. */
.vendor-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 27rem), 1fr)); gap: 0.85rem; list-style: none; margin: 0; padding: 0; }
.vendor-card { display: flex; flex-direction: column; gap: 0.8rem; min-width: 0; margin: 0; padding: 1rem; border-top: 3px solid var(--accent); }
.vendor-card-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.vendor-identity { display: flex; align-items: center; gap: 0.7rem; min-width: 0; }
.vendor-avatar { display: grid; place-items: center; flex: 0 0 2.65rem; width: 2.65rem; height: 2.65rem; border-radius: 9px; background: var(--accent-soft); color: var(--accent-dark); font-size: 1.1rem; font-weight: 750; }
.vendor-identity-text { min-width: 0; }
.vendor-name { display: block; overflow-wrap: anywhere; font-size: 0.98rem; line-height: 1.35; }
.vendor-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.35rem; }
.vendor-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 0.75rem; margin: 0; padding: 0.7rem 0.75rem; border-block: 1px solid var(--border); }
.vendor-meta-item { min-width: 0; }
.vendor-meta dt { margin: 0; color: var(--muted); font-size: 0.68rem; font-weight: 750; letter-spacing: 0.07em; text-transform: uppercase; }
.vendor-meta dd { margin: 0.18rem 0 0; overflow-wrap: anywhere; font-size: 0.86rem; }
html[data-theme="dark"] .vendor-avatar { color: var(--accent); }

/* Work orders: polished data table. */
.wo-table td[data-col="number"] a { font-variant-numeric: tabular-nums; }
.wo-table td[data-col="created"] { color: var(--muted); font-size: 0.88rem; white-space: nowrap; }
.wo-table td[data-col="site"], .wo-table td[data-col="vendor"] { overflow-wrap: anywhere; }

@media (max-width: 640px) {
  .page-heading { align-items: stretch; }
  .page-heading > .btn { justify-content: center; }
  .page-summary { display: flex; flex-wrap: wrap; gap: 0.5rem 0.9rem; }
  .user-list { grid-template-columns: minmax(0, 1fr); }
  .user-card { padding: 0.9rem; }
  .user-actions { align-items: flex-start; }
  .user-action-buttons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .user-action-buttons > * { min-width: 0; }
  .user-action-buttons .btn, .user-reset summary { width: 100%; justify-content: center; text-align: center; }
  .user-reset[open] { grid-column: 1 / -1; }
  .vendor-list { grid-template-columns: minmax(0, 1fr); }
  .vendor-card { padding: 0.9rem; }
  .vendor-card-head .btn { flex: 0 0 auto; }
}

/* vendor contact rows (edit form) */
.contact-row { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; padding: 0.4rem 0; border-bottom: 1px solid var(--border); }
.contact-row:last-of-type { border-bottom: 0; }
.contact-row .btn { flex: none; }

/* view toggle (list/card) in page headers */
.view-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--card); }
.view-toggle button { display: inline-flex; align-items: center; justify-content: center; width: 2.1rem; height: 2.1rem; border: 0; padding: 0; background: transparent; color: var(--muted); cursor: pointer; }
.view-toggle button + button { border-left: 1px solid var(--border); }
.view-toggle button:hover, .view-toggle button:focus-visible { color: var(--accent); }
.view-toggle button.active { background: var(--accent-soft); color: var(--accent-dark); }
html[data-theme="dark"] .view-toggle button.active { color: var(--accent); }

/* clickable directory cards/rows */
.user-card-open, .vendor-card-open {
  display: flex; flex-direction: column; gap: 0.8rem; width: 100%; min-width: 0;
  padding: 0; margin: 0; background: none; border: 0; font: inherit; color: inherit;
  text-align: left; cursor: pointer; border-radius: var(--radius);
}
.user-card-open:hover .user-email, .vendor-card-open:hover .vendor-name,
.user-card-open:focus-visible .user-email, .vendor-card-open:focus-visible .vendor-name { color: var(--accent); }
.user-card-open:focus-visible, .vendor-card-open:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
tr[data-modal-url] { cursor: pointer; }
tr[data-modal-url]:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* list view: compress directory cards into scannable rows */
.view-list.user-list, .view-list.vendor-list { grid-template-columns: minmax(0, 1fr); gap: 0; }
.view-list .user-card, .view-list .vendor-card {
  flex-direction: row; align-items: center; flex-wrap: wrap; gap: 0.3rem 1rem;
  padding: 0.55rem 0.75rem; border-top: 0; border-bottom: 1px solid var(--border); border-radius: 0;
}
.view-list .user-card:first-child, .view-list .vendor-card:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.view-list .user-card:last-child, .view-list .vendor-card:last-child { border-bottom: 0; border-radius: 0 0 var(--radius) var(--radius); }
.view-list .user-card-open, .view-list .vendor-card-open { flex: 1 1 20rem; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 0.3rem 0.9rem; }
.view-list .user-avatar, .view-list .vendor-avatar { flex-basis: 2.2rem; width: 2.2rem; height: 2.2rem; font-size: 0.9rem; }
.view-list .user-tags, .view-list .vendor-tags { margin-top: 0; }
.view-list .user-email { font-size: 0.9rem; }
.view-list .user-meta, .view-list .vendor-meta { display: flex; flex-wrap: wrap; gap: 0.15rem 1rem; border-block: 0; padding: 0; margin: 0; }
.view-list .user-meta dt, .view-list .vendor-meta dt { display: inline; margin-right: 0.35rem; }
.view-list .user-meta dd, .view-list .vendor-meta dd { display: inline; margin: 0; font-size: 0.85rem; }
.view-list .user-actions { margin-left: auto; align-items: center; }
.view-list .user-actions-label { display: none; }
.view-list .user-action-buttons { display: flex; }

/* card view: turn the work-order table into stacked cards */
.view-card .wo-table thead { display: none; }
.view-card .wo-table tbody { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 24rem), 1fr)); gap: 0.7rem; }
.view-card .wo-table tr { display: block; border: 1px solid var(--border); border-radius: var(--radius); padding: 0.7rem 0.85rem; background: var(--card); }
.view-card .wo-table td { display: block; border-bottom: 0; padding: 0.2rem 0; }
.view-card .wo-table td::before { content: attr(data-label); display: block; font-size: 0.66rem; font-weight: 750; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); }
.view-card .wo-table td[data-col="number"] strong { font-size: 1rem; font-variant-numeric: tabular-nums; }
.view-card .wo-table td[data-col="status"] .badge-pill { margin-top: 0.15rem; }

/* modal dialog (native <dialog>) */
.app-modal { width: min(34rem, calc(100vw - 2rem)); max-height: calc(100vh - 3rem); border: 1px solid var(--border); border-radius: var(--radius); padding: 0; background: var(--card); color: var(--text); }
.app-modal::backdrop { background: rgba(8, 14, 18, 0.5); }
.app-modal-frame { position: relative; padding: 1.1rem 1.2rem 1.2rem; }
.app-modal-close { position: absolute; top: 0.65rem; right: 0.65rem; width: 2rem; height: 2rem; border-radius: 8px; border: 1px solid var(--border); background: transparent; color: var(--muted); cursor: pointer; font-size: 0.9rem; line-height: 1; padding: 0; }
.app-modal-close:hover, .app-modal-close:focus-visible { color: var(--accent); border-color: var(--accent); }
.app-modal-body { max-height: calc(100vh - 9rem); overflow-y: auto; }
.app-modal-title { margin: 0; font-size: 1.12rem; padding-right: 2.3rem; overflow-wrap: anywhere; }
.app-modal-sub { margin: 0.15rem 0 0.9rem; color: var(--muted); font-size: 0.88rem; overflow-wrap: anywhere; }
.app-modal-loading { color: var(--muted); margin: 0; }
.app-modal-note { margin: 0.9rem 0 0; color: var(--muted); font-size: 0.8rem; }
.app-modal .flash { margin: 0 0 0.8rem; }
.app-modal .meta-grid { margin: 0 0 0.4rem; }
.app-modal .desc { margin-top: 0.6rem; }
.app-modal-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }
.app-modal-actions .btn { margin: 0; }
.app-modal form .btn { margin-top: 0; }
.app-modal fieldset { margin: 0.9rem 0 0; }
.app-modal .contact-row .btn { padding: 0.3rem 0.55rem; font-size: 0.8rem; }

@media (max-width: 640px) {
  .view-list .user-card, .view-list .vendor-card { padding: 0.55rem 0.6rem; }
  .view-list .user-actions { margin-left: 0; width: 100%; }
  .app-modal-frame { padding: 0.9rem 0.95rem 1rem; }
  .app-modal-actions .btn { flex: 1 1 auto; justify-content: center; }
}

/* A list is a real, accessible table; only Work Orders uses the same table in both modes. */
.directory-list-view { display: none; }
.view-list .directory-card-view { display: none; }
.view-list .directory-list-view { display: block; }
.directory-table-wrap { width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; }
.directory-table { min-width: 54rem; }
.directory-table th, .directory-table td { padding: 0.65rem 0.7rem; vertical-align: middle; }
.directory-table td:first-child, .directory-table td:nth-child(3) { white-space: normal; }
.directory-table tbody tr:hover { background: var(--bg); }
.directory-table tr[data-modal-url]:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
table.user-directory-table { table-layout: fixed; min-width: 58rem; }
.user-directory-table th:nth-child(1), .user-directory-table td:nth-child(1) { width: 18%; }
.user-directory-table th:nth-child(2), .user-directory-table td:nth-child(2) { width: 18%; }
.user-directory-table th:nth-child(3), .user-directory-table td:nth-child(3) { width: 10%; }
.user-directory-table th:nth-child(4), .user-directory-table td:nth-child(4) { width: 14%; }
.user-directory-table th:nth-child(5), .user-directory-table td:nth-child(5) { width: 12%; }
.user-directory-table th:nth-child(6), .user-directory-table td:nth-child(6) { width: 12%; }
.user-directory-table th:nth-child(7), .user-directory-table td:nth-child(7) { width: 16%; }
.user-directory-table td { white-space: normal; overflow-wrap: anywhere; }
.user-directory-table td.user-name-cell { min-width: 0; }
.user-directory-table td.actions { min-width: 0; }
.user-directory-table .user-action-buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.user-directory-table .user-action-buttons .btn { margin: 0; white-space: nowrap; }
.user-display-name { display: block; overflow-wrap: anywhere; font-size: 0.98rem; line-height: 1.3; }
.user-email { display: block; margin-top: 0.12rem; color: var(--muted); font-size: 0.8rem; line-height: 1.3; overflow-wrap: anywhere; }
.user-identity-text .user-tags { margin-top: 0.35rem; }
.vendor-tags { align-items: center; }
.vendor-tags .badge-pill { padding: 0.32rem 0.55rem; }

/* Scroll containers clip outlines that extend beyond their edges; reserve inner room for focus rings. */
.app-modal-body { padding: 0.25rem; margin: -0.25rem; }

/* Keep list mode tabular on narrow screens: scroll the table, never restyle rows as cards. */
@media (max-width: 640px) {
  .directory-table { min-width: 54rem; }
  .directory-table th { display: table-cell; }
  .directory-table tr[data-modal-url] { display: table-row; padding: 0; border-bottom: 0; }
  .directory-table td { display: table-cell; padding: 0.65rem 0.7rem; border-bottom: 1px solid var(--border); }
  .directory-table td::before { display: none; content: none; }
  .view-list .wo-table { min-width: 48rem; }
  .view-list .wo-table thead { display: table-header-group; }
  .view-list .wo-table tbody { display: table-row-group; }
  .view-list .wo-table tr { display: table-row; padding: 0; border: 0; border-radius: 0; background: transparent; }
  .view-list .wo-table td { display: table-cell; padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--border); }
  .view-list .wo-table td::before { display: none; content: none; }
}

.form-narrow small.muted { display: block; margin: 0.25rem 0 0.8rem; font-size: 0.8rem; }
.report-trend { display: grid; gap: 0.35rem; width: 100%; max-width: 14rem; }
.report-trend-line { display: grid; grid-template-columns: 4.25rem minmax(0, 1fr); align-items: center; gap: 0.45rem; color: var(--muted); font-size: 0.72rem; }
.report-track { display: block; width: 100%; height: 0.5rem; border-radius: 999px; background: var(--bg); }
.report-track .bar { display: block; height: 100%; max-width: 100%; margin: 0; border-radius: inherit; }

@media (max-width: 640px) {
  .filter-bar { align-items: stretch; }
  .filter-controls { display: grid; grid-template-columns: minmax(0, 1fr); width: 100%; min-width: 0; }
  .filter-controls select { width: 100%; min-width: 0; max-width: 100%; }
  .report-table thead {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0, 0, 0, 0); clip-path: inset(50%); white-space: nowrap; border: 0;
  }
  .report-table th { display: table-cell; padding: 0; border: 0; }
  .directory-view-toggle { display: none; }
  .users-directory.view-list .directory-card-view,
  .users-directory.view-card .directory-card-view,
  .vendor-directory.view-list .directory-card-view,
  .vendor-directory.view-card .directory-card-view { display: grid; }
  .users-directory .directory-list-view,
  .vendor-directory .directory-list-view { display: none; }

  .report-table tbody tr {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.15rem 0.8rem;
    margin: 0 0 0.65rem; padding: 0.55rem 0.65rem; border: 1px solid var(--border);
    border-radius: 8px; background: var(--card);
  }
  .report-table tbody tr:last-child { margin-bottom: 0; }
  .report-table td { display: block; min-width: 0; padding: 0.35rem 0.15rem; border: 0; white-space: normal; overflow-wrap: anywhere; }
  .report-table td[data-label]::before {
    content: attr(data-label); display: block; margin-bottom: 0.1rem; color: var(--muted);
    font-size: 0.68rem; font-weight: 750; letter-spacing: 0.06em; text-transform: uppercase;
  }
  .report-monthly td:first-child, .report-monthly td.bar-cell,
  .report-vendors td:first-child { grid-column: 1 / -1; }
  .report-table td.bar-cell::before { margin-bottom: 0.4rem; }
  .report-trend { max-width: none; }
}

/* landing page */
.landing-header{display:flex;align-items:center;justify-content:space-between;gap:1rem;padding:0.7rem 1.2rem;background:var(--card);border-bottom:1px solid var(--border);position:sticky;top:0;z-index:10;flex-wrap:wrap;}
.landing-header-actions{display:flex;align-items:center;gap:0.6rem;}
.landing-header-actions .btn{white-space:nowrap;}
.landing-hero{max-width:56rem;margin:0 auto;padding:4rem 1.2rem 1rem;text-align:center;}
.landing-kicker{color:var(--accent);font-weight:700;font-size:0.8rem;letter-spacing:0.12em;margin:0 0 0.75rem;}
.landing-hero h1{font-size:2.6rem;line-height:1.15;margin:0 0 1rem;}
.landing-sub{color:var(--muted);font-size:1.08rem;max-width:44rem;margin:0 auto 1.5rem;}
.landing-actions{display:flex;gap:0.8rem;justify-content:center;margin-bottom:2.5rem;}
.landing-shot{margin:0;background:var(--card);border:1px solid var(--border);border-radius:var(--radius);overflow:hidden;box-shadow:0 12px 32px rgba(8,14,18,0.08);}
.landing-shot img{display:block;width:100%;height:auto;}
.landing-shot figcaption{padding:0.75rem 1rem;color:var(--muted);font-size:0.9rem;text-align:left;}
.landing-section{max-width:56rem;margin:0 auto;padding:2.5rem 1.2rem;}
.landing-section h2{font-size:1.7rem;margin:0 0 1.25rem;text-align:center;}
.landing-features{display:grid;grid-template-columns:repeat(auto-fit,minmax(185px,1fr));gap:1rem;}
.landing-features .card{margin:0;}
.landing-shots{display:grid;gap:1.5rem;}
.landing-pricing{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:1rem;align-items:stretch;}
.landing-price{margin:0;display:flex;flex-direction:column;position:relative;}
.landing-price h3{margin:0;}
.landing-price-num{font-size:2.2rem;font-weight:800;margin:0.5rem 0 1rem;}
.landing-price-num span{font-size:0.9rem;font-weight:500;color:var(--muted);}
.landing-price ul{list-style:none;margin:0 0 1.25rem;padding:0;color:var(--muted);display:grid;gap:0.4rem;}
.landing-price ul li::before{content:"✓";color:var(--accent);font-weight:700;margin-right:0.5rem;}
.landing-price .btn{margin-top:auto;align-self:flex-start;}
.landing-price.featured{border-color:var(--accent);box-shadow:0 12px 32px rgba(15,118,110,0.14);}
.landing-price-badge{position:absolute;top:-0.75rem;left:50%;transform:translateX(-50%);background:var(--accent);color:#fff;font-size:0.72rem;font-weight:700;letter-spacing:0.06em;padding:0.2rem 0.7rem;border-radius:999px;white-space:nowrap;}
.landing-price-note{text-align:center;margin-top:1rem;}
.landing-contact{max-width:32rem;margin:0 auto;}
.landing-contact .btn{margin-top:1.25rem;}
.landing-hp{position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden;}
.landing-footer{border-top:1px solid var(--border);color:var(--muted);text-align:center;padding:1.5rem;margin-top:2rem;}
/* settings tabs */
.settings-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 14px; }
.settings-tab { border: 1px solid var(--border); background: transparent; color: var(--text); padding: 7px 14px; border-radius: 999px; cursor: pointer; font-size: .9rem; }
.settings-tab.active { background: #0f766e; color: #fff; border-color: #0f766e; }
.license-details { display: grid; gap: 8px; margin: 0 0 16px; }
.license-details div { display: flex; gap: 10px; align-items: baseline; }
.license-details dt { min-width: 110px; opacity: .75; font-size: .85rem; }
.license-details dd { margin: 0; overflow-wrap: anywhere; }
.license-key { width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .78rem; padding: .45rem .6rem; }
.license-apply { margin-top: 1.25rem; padding-top: 1.1rem; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: .5rem; }
.pager { display: flex; gap: 1rem; align-items: center; justify-content: flex-end; margin-top: .75rem; font-size: .85rem; }
.email-frame { width: 100%; height: 640px; margin-top: 1rem; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.email-text { margin-top: 1rem; }
.email-text pre { white-space: pre-wrap; font-size: .8rem; color: var(--text); }

@media (max-width:640px){.landing-hero h1{font-size:2rem;}.landing-actions{flex-direction:column;align-items:center;}}

/* dark-theme adaptation of the paper-style work-order document preview.
   shortcut: keyed to the template's inline colors; update if _wo_document.html colors change. PDFs/emails stay light on purpose. */
html[data-theme="dark"] .wo-document{background:#12181d !important;color:#e8eef2 !important;border-bottom-color:#2a3440 !important;border-left-color:#2a3440 !important;border-right-color:#2a3440 !important;}
html[data-theme="dark"] .wo-document td{background:transparent !important;border-color:#2a3440 !important;}
html[data-theme="dark"] .wo-document p,html[data-theme="dark"] .wo-document div{color:#c7d2da !important;}
html[data-theme="dark"] .wo-document p[style*="#68758a"]{color:#8fa0ab !important;}
html[data-theme="dark"] .wo-document p[style*="#3d4b60"]{color:#a9b6c0 !important;}
html[data-theme="dark"] .wo-document a,html[data-theme="dark"] .wo-document p[style*="#1762f5"]{color:#7ab8ff !important;}
html[data-theme="dark"] .wo-document td[style*="#e7edf4"]{border-color:#2a3440 !important;}
html[data-theme="dark"] .wo-document div[style*="#f8fafc"],html[data-theme="dark"] .wo-document p[style*="#f8fafc"]{background:#1a232b !important;border-color:#2a3440 !important;color:#e8eef2 !important;}
html[data-theme="dark"] .wo-document div[style*="#f2f6ff"]{background:#16202b !important;}
html[data-theme="dark"] .wo-document div[style*="#f2f6ff"] p{color:#e8eef2 !important;}
html[data-theme="dark"] .wo-document div[style*="#f2f6ff"] p[style*="#3d4b60"]{color:#a9b6c0 !important;}
html[data-theme="dark"] .wo-document div[style*="#f3fbf6"]{background:#12201a !important;border-color:#24533d !important;color:#9fd8bd !important;}

/* landing lightbox */
.landing-shot img{cursor:zoom-in;}
.lightbox{position:fixed;inset:0;background:rgba(8,14,18,0.85);z-index:100;display:flex;align-items:center;justify-content:center;padding:2rem;cursor:zoom-out;}
.lightbox img{max-width:100%;max-height:100%;border-radius:8px;box-shadow:0 24px 64px rgba(0,0,0,0.5);}
