/* Tracefix design system: ink + safety orange, no build step. */
:root {
  --ink: #0f172a; --ink-2: #334155; --muted: #64748b; --line: #e2e8f0; --bg: #f8fafc; --card: #ffffff;
  --brand: #ff5a1f; --brand-dark: #e04812; --brand-soft: #fff1eb;
  --ok: #16a34a; --ok-soft: #dcfce7; --warn: #d97706; --warn-soft: #fef3c7; --bad: #dc2626; --bad-soft: #fee2e2;
  --info: #2563eb; --info-soft: #dbeafe;
  --radius: 10px; --shadow: 0 1px 2px rgba(15,23,42,.06), 0 4px 16px rgba(15,23,42,.05);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.5; }
a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
img { max-width: 100%; }
small, .muted { color: var(--muted); }
code { background: #f1f5f9; padding: .1em .35em; border-radius: 4px; font-size: .9em; }

/* Layout: app shell */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--ink); color: #cbd5e1; padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .logo { color: #fff; font-weight: 800; font-size: 1.2rem; padding: 4px 10px 16px; display: flex; align-items: center; gap: 8px; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; color: #cbd5e1; padding: 8px 10px; border-radius: 8px; font-weight: 500; }
.sidebar nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.sidebar nav a.active { background: rgba(255,90,31,.16); color: #fff; }
.sidebar .section { text-transform: uppercase; font-size: .7rem; letter-spacing: .08em; color: #64748b; padding: 16px 10px 6px; }
.sidebar .org { font-size: .85rem; color: #94a3b8; padding: 10px; border-top: 1px solid rgba(255,255,255,.08); margin-top: 16px; }
.main { padding: 24px 28px 64px; min-width: 0; }
.topbar { display: none; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { margin: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 30% 0 0; transform: translateX(-100%); transition: transform .2s; z-index: 50; height: 100%; }
  .sidebar.open { transform: none; }
  .topbar { display: flex; align-items: center; justify-content: space-between; background: var(--ink); color: #fff; padding: 10px 16px; position: sticky; top: 0; z-index: 40; }
  .topbar button { background: none; border: 0; color: #fff; font-size: 1.4rem; }
  .main { padding: 16px 16px 80px; }
}

/* Cards, grids */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card h2, .card h3 { margin-top: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 860px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }
.stat { font-size: 1.9rem; font-weight: 800; }
.stat-label { color: var(--muted); font-size: .85rem; }
dl.props { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.props dt { color: var(--muted); }
dl.props dd { margin: 0; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); font-weight: 600; font-size: .95rem; cursor: pointer; text-decoration: none; font-family: inherit; }
.btn:hover { text-decoration: none; border-color: #cbd5e1; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-danger { color: var(--bad); }
.btn-sm { padding: 5px 10px; font-size: .85rem; }
.btn-lg { padding: 13px 22px; font-size: 1.05rem; }
.btn-block { width: 100%; }

/* Forms */
form .field { margin-bottom: 14px; }
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=tel],
input[type=date], input[type=datetime-local], input[type=search], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #cbd5e1; border-radius: 8px; font: inherit; background: #fff; color: var(--ink);
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(255,90,31,.35); border-color: var(--brand); }
input[type=checkbox] { width: 18px; height: 18px; vertical-align: middle; margin-inline-end: 6px; }
.checkbox label { display: inline; font-weight: 500; }
select[multiple] { min-height: 120px; }
.helptext { color: var(--muted); font-size: .82rem; margin-top: 3px; }
.errorlist { color: var(--bad); list-style: none; padding: 0; margin: 4px 0 0; font-size: .85rem; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0 16px; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: start; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
tr:hover td { background: #fafafa; }
td.num, th.num { text-align: end; }

/* Badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: #f1f5f9; color: var(--ink-2); white-space: nowrap; }
.badge-new { background: var(--info-soft); color: var(--info); }
.badge-scheduled { background: #ede9fe; color: #6d28d9; }
.badge-in_progress { background: var(--warn-soft); color: var(--warn); }
.badge-completed { background: var(--ok-soft); color: var(--ok); }
.badge-cancelled { background: #f1f5f9; color: var(--muted); }
.badge-urgent, .badge-high { background: var(--bad-soft); color: var(--bad); }

/* Messages */
.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.messages li { padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; background: var(--info-soft); color: #1e3a8a; }
.messages li.success { background: var(--ok-soft); color: #14532d; }
.messages li.warning { background: var(--warn-soft); color: #78350f; }
.messages li.error { background: var(--bad-soft); color: #7f1d1d; }
.banner { padding: 10px 14px; border-radius: 8px; background: var(--brand-soft); color: #7c2d12; margin-bottom: 16px; font-size: .92rem; }

/* Filters */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters a { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--ink-2); font-size: .88rem; font-weight: 500; }
.filters a.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.filters a:hover { text-decoration: none; }

/* Timeline */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding-block: 8px; padding-inline: 16px 0; border-inline-start: 2px solid var(--line); position: relative; font-size: .9rem; }
.timeline li::before { content: ""; position: absolute; inset-inline-start: -6px; top: 14px; width: 10px; height: 10px; border-radius: 50%; background: #cbd5e1; }
.timeline li.comment::before { background: var(--brand); }

/* Checklist */
.check-item { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.check-item .choices { display: flex; gap: 4px; }
.check-item .choices label { font-weight: 600; padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; margin: 0; font-size: .85rem; }
.check-item .choices input { display: none; }
.check-item .choices input:checked + span.ok { color: var(--ok); }
.check-item input[type=text] { grid-column: 1 / -1; }
.check-section { font-weight: 700; padding-top: 14px; }

/* Signature pad */
.sigpad { border: 2px dashed #cbd5e1; border-radius: 10px; background: #fff; touch-action: none; width: 100%; height: 200px; display: block; }

/* Photos */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.photos figure { margin: 0; }
.photos img { width: 100%; height: 120px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.photos figcaption { font-size: .8rem; color: var(--muted); }

/* Auth pages */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth .card { width: 100%; max-width: 440px; padding: 28px; }
.auth .logo { font-weight: 800; font-size: 1.4rem; text-align: center; margin-bottom: 18px; color: var(--ink); display: block; }

/* Day groups (planning) */
.day { margin-bottom: 18px; }
.day h3 { font-size: .95rem; color: var(--ink-2); border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.job { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-inline-start: 4px solid var(--brand); border-radius: 8px; background: #fff; margin-bottom: 8px; }
.job:hover { text-decoration: none; border-color: #cbd5e1; }
.job .when { font-weight: 700; color: var(--ink); white-space: nowrap; }
.job .what { color: var(--ink-2); }

.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.qr img { width: 180px; height: 180px; }
.hide-mobile { } @media (max-width: 860px) { .hide-mobile { display: none; } }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; } .right { text-align: end; }
td:first-child a { white-space: nowrap; }
.job .badge { align-self: center; }

[dir=rtl] .sidebar { inset: 0 0 0 30%; }
@media (max-width: 860px) { [dir=rtl] .sidebar { transform: translateX(100%); } [dir=rtl] .sidebar.open { transform: none; } }
