/* Techworks portal design system — matches /srv/dispatch + /srv/purchase */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #fbfbfb;
  --panel: #fff;
  --sidebar: #f5f5f4;
  --border: #e5e5e3;
  --border-strong: #d6d6d4;
  --text: #1c1c1a;
  --text-2: #6b6b68;
  --text-3: #9b9b98;
  --accent: #2563eb;
  --accent-soft: #eff4ff;
  --danger: #dc2626;
  --green: #16a34a;
  --radius: 8px;
  --shadow: 0 2px 12px rgba(0,0,0,.08);
}
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  font-size: 13.5px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
#app { height: 100vh; height: 100dvh; display: flex; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }

/* ---------- login ---------- */
.login-wrap { margin: auto; width: 340px; padding: 20px; }
.login-logo { width: 52px; height: 52px; border-radius: 12px; background: #222; color: #fff; font-weight: 700; font-size: 22px; display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; }
.login-wrap h1 { font-size: 19px; text-align: center; margin-bottom: 4px; }
.login-sub { text-align: center; color: var(--text-2); margin-bottom: 22px; }
.login-wrap input { width: 100%; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius); margin-bottom: 10px; background: #fff; }
.login-wrap input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.btn-primary { background: #222; color: #fff; border-radius: var(--radius); padding: 10px 16px; font-weight: 600; width: 100%; }
.btn-primary:hover { background: #000; }
.login-err { color: var(--danger); text-align: center; margin-top: 10px; min-height: 18px; }

/* ---------- layout ---------- */
.sidebar { width: 220px; min-width: 220px; background: var(--sidebar); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 12px 8px; }
.ws { display: flex; align-items: center; gap: 8px; padding: 6px 8px 14px; font-weight: 700; font-size: 14px; }
.ws-logo { width: 24px; height: 24px; border-radius: 6px; background: #222; color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.nav-item { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 7px; color: var(--text-2); font-weight: 500; width: 100%; text-align: left; }
.nav-item svg { width: 16px; height: 16px; flex: none; }
.nav-item:hover { background: rgba(0,0,0,.05); }
.nav-item.active { background: rgba(0,0,0,.07); color: var(--text); }
.nav-count { margin-left: auto; color: var(--text-3); font-size: 12px; }
.nav-count.hot { background: var(--danger); color: #fff; border-radius: 99px; min-width: 18px; height: 18px; line-height: 18px; text-align: center; font-weight: 700; font-size: 11px; padding: 0 5px; }
.nav-sec { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); padding: 16px 10px 6px; }
.sidebar-bottom { margin-top: auto; border-top: 1px solid var(--border); padding-top: 8px; }
.me-block { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 7px; width: 100%; text-align: left; }
.me-block:hover { background: rgba(0,0,0,.05); }
.me-name { font-weight: 600; line-height: 1.2; }
.me-role { font-size: 11px; color: var(--text-3); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 20px; border-bottom: 1px solid var(--border); background: var(--panel); }
.topbar h2 { font-size: 15px; font-weight: 700; margin-right: auto; display: flex; align-items: center; gap: 8px; }
.topbar h2 .cnt { color: var(--text-3); font-weight: 500; font-size: 13px; }
.search { position: relative; }
.search input { border: 1px solid var(--border-strong); border-radius: 7px; padding: 7px 10px 7px 30px; width: 220px; background: var(--bg); }
.search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.search svg { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--text-3); }
.btn-new { background: #222; color: #fff; border-radius: 7px; padding: 7px 14px; font-weight: 600; white-space: nowrap; }
.btn-new:hover { background: #000; }
.view { flex: 1; overflow: auto; }

/* ---------- table ---------- */
.tbl-wrap { padding: 14px 20px 30px; overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.tbl th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3); padding: 9px 12px; border-bottom: 1px solid var(--border); background: #fafaf9; white-space: nowrap; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr { cursor: pointer; }
.tbl tbody tr:hover { background: #f7f7f6; }
.tbl td.wrap { white-space: normal; }
.rec-name { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.muted { color: var(--text-3); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-actions { display: flex; gap: 5px; flex-wrap: wrap; }

/* ---------- pills & avatars ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 99px; padding: 2px 10px; font-size: 12px; font-weight: 600; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 99px; background: currentColor; }
.av { width: 22px; height: 22px; min-width: 22px; border-radius: 99px; color: #fff; font-size: 10px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.av.lg { width: 34px; height: 34px; min-width: 34px; font-size: 13px; border-radius: 10px; }
.owner-cell { display: flex; align-items: center; gap: 7px; }

/* ---------- stats ---------- */
.stats { display: flex; gap: 12px; padding: 14px 20px 0; flex-wrap: wrap; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 16px; min-width: 160px; }
.stat .lbl { font-size: 12px; color: var(--text-3); font-weight: 600; }
.stat .val { font-size: 17px; font-weight: 700; margin-top: 2px; }
.stat .val .sub { font-size: 12.5px; color: var(--text-3); font-weight: 500; }
.stat .val.green { color: var(--green); }
.stat .val.red { color: var(--danger); }

/* ---------- forms ---------- */
.fld { margin-bottom: 12px; }
.fld label { display: block; font-size: 11.5px; color: var(--text-3); font-weight: 600; margin-bottom: 3px; }
.fld input, .fld select, .fld textarea { width: 100%; border: 1px solid var(--border-strong); background: #fff; border-radius: 6px; padding: 8px 10px; }
.fld textarea { resize: vertical; min-height: 54px; }
.fld input:focus, .fld select:focus, .fld textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.fld input:disabled { background: var(--sidebar); color: var(--text-2); }
.btn { border: 1px solid var(--border-strong); background: #fff; border-radius: 7px; padding: 6px 12px; font-weight: 600; font-size: 12.5px; }
.btn:hover { background: var(--sidebar); }
.btn.primary { background: #222; border-color: #222; color: #fff; }
.btn.primary:hover { background: #000; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: #fef2f2; border-color: #fecaca; }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; }
.btn.green:hover { background: #15803d; }
.btn.small { padding: 4px 9px; font-size: 12px; }
.icon-btn { width: 30px; height: 30px; border-radius: 7px; display: flex; align-items: center; justify-content: center; color: var(--text-2); }
.icon-btn:hover { background: var(--sidebar); color: var(--text); }
.hint { font-size: 12px; color: var(--text-3); margin-top: 8px; }
.seg { display: flex; border: 1px solid var(--border-strong); border-radius: 7px; overflow: hidden; margin-bottom: 12px; }
.seg button { flex: 1; padding: 8px; color: var(--text-2); background: #fff; font-weight: 500; }
.seg button.on { background: #222; color: #fff; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.3); padding: 16px; }
.modal-box { background: #fff; border-radius: 12px; width: 430px; max-width: 100%; max-height: 92vh; overflow: auto; box-shadow: var(--shadow); }
.modal-box.wide { width: 640px; }
.modal-head { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 15px; gap: 8px; }
.modal-head .icon-btn { margin-left: auto; }
.modal-body { padding: 16px 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 18px 16px; }
.form-err { color: var(--danger); font-size: 12.5px; min-height: 16px; margin-bottom: 6px; }

/* detail modal bits */
.dl { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; margin-bottom: 12px; }
.dl dt { color: var(--text-3); font-weight: 600; font-size: 12px; padding-top: 2px; }
.dl dd { min-width: 0; }
.tl-item { display: flex; gap: 9px; margin-bottom: 10px; }
.tl-body { flex: 1; }
.tl-meta { font-size: 11.5px; color: var(--text-3); margin-bottom: 2px; }
.tl-meta b { color: var(--text-2); }
.tl-text { background: #fafaf9; border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; white-space: pre-wrap; }
.side-sec { font-size: 12px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: .03em; margin: 14px 0 8px; }

/* ---------- badges / users ---------- */
.badge { font-size: 11px; font-weight: 700; border-radius: 5px; padding: 2px 7px; }
.badge.admin { background: #fef3c7; color: #92400e; }
.badge.accounts { background: #ede9fe; color: #5b21b6; }
.badge.manager { background: #dbeafe; color: #1e40af; }
.badge.member { background: var(--sidebar); color: var(--text-2); }
.badge.inactive { background: #fee2e2; color: #991b1b; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #222; color: #fff; padding: 9px 18px; border-radius: 9px; z-index: 100; font-weight: 600; box-shadow: var(--shadow); }
.empty { padding: 60px 20px; text-align: center; color: var(--text-3); }

/* ---------- GPS trip ---------- */
.trip-wrap { padding: 14px 20px 30px; max-width: 560px; }
.trip-card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 20px; text-align: center; }
.trip-dist { font-size: 40px; font-weight: 700; margin: 8px 0 2px; font-variant-numeric: tabular-nums; }
.trip-card .fld { text-align: left; }
.trip-card .btn { width: 100%; padding: 10px; margin-top: 8px; }

/* ---------- mobile ---------- */
@media (max-width: 760px) {
  .sidebar { position: fixed; z-index: 30; height: 100%; left: -230px; transition: left .18s; box-shadow: none; }
  .sidebar.open { left: 0; box-shadow: 0 0 40px rgba(0,0,0,.25); }
  .burger { display: flex !important; }
  .search input { width: 130px; }
  .topbar { padding: 10px 12px; }
  .tbl-wrap, .trip-wrap { padding-left: 12px; padding-right: 12px; }
  .stats { padding: 12px 12px 0; }
  .stat { min-width: calc(50% - 6px); flex: 1; }
}
.burger { display: none; }
