/* ============================================================
   DogHouse Farms — PM & Ticketing
   Design language: equipment nameplate / service-tag industrial.
   Grounded in the subject matter: mini-splits, RTUs, dehumidifiers —
   the signature "dial" gauge on each task card echoes the physical
   gauges on that same equipment.
   ============================================================ */

:root {
  /* base palette */
  --bg: #14171a;
  --surface: #1d2126;
  --surface-raised: #262b32;
  --line: #333a40;
  --ink: #ece8dd;
  --ink-muted: #8f98a1;

  /* brand / interactive */
  --brass: #ba8a3f;
  --brass-bright: #d9ac57;

  /* status */
  --ok: #4e9b84;
  --ok-bg: rgba(78, 155, 132, 0.14);
  --warn: #d6a23b;
  --warn-bg: rgba(214, 162, 59, 0.14);
  --danger: #c1543f;
  --danger-bg: rgba(193, 84, 63, 0.16);
  --muted-bg: rgba(143, 152, 161, 0.12);

  --font-display: 'Oswald', sans-serif;
  --font-body: 'IBM Plex Sans', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;

  --radius: 10px;
  --shadow-modal: 0 20px 60px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  height: 100%;
}

body { min-height: 100vh; }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.01em;
  margin: 0;
}

button, input, select, textarea {
  font-family: inherit;
  color: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--brass-bright); }

.hidden { display: none !important; }

/* ---------- screens ---------- */
.screen { min-height: 100vh; width: 100%; }
.screen.center {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.loader-mark {
  height: 96px;
  width: auto;
  opacity: 0.9;
}

/* ---------- auth card ---------- */
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px 28px;
}
.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--brass-bright);
  margin: 0 0 8px;
}
.auth-card h1 {
  font-size: 1.35rem;
  line-height: 1.3;
  margin-bottom: 10px;
}
.auth-sub {
  font-size: 0.88rem;
  color: var(--ink-muted);
  line-height: 1.5;
  margin: 0 0 20px;
}
.field {
  display: block;
  margin-bottom: 16px;
}
.field span {
  display: block;
  font-size: 0.78rem;
  color: var(--ink-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.field input, .field select {
  width: 100%;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 1rem;
  color: var(--ink);
}
.field input:focus, .field select:focus {
  outline: 2px solid var(--brass);
  outline-offset: 1px;
}
.form-error {
  background: var(--danger-bg);
  color: #f0a08f;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.85rem;
  margin-bottom: 16px;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 8px;
  padding: 11px 18px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s, background 0.15s;
}
.btn:active { filter: brightness(0.92); }
.btn-primary { background: var(--brass); color: #1a1400; }
.btn-primary:hover { background: var(--brass-bright); }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--brass); }
.btn-danger { background: var(--danger-bg); color: #f0a08f; }
.btn-small { padding: 7px 12px; font-size: 0.78rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  flex-wrap: wrap;
  gap: 10px;
}
.topbar-brand { display: flex; align-items: center; gap: 14px; }
.topbar-mark {
  height: 56px;
  width: auto;
  display: block;
}
.topbar-titles h1 { font-size: 1.05rem; }
.topbar-titles p { margin: 2px 0 0; font-size: 0.78rem; color: var(--ink-muted); }
.topbar-user { display: flex; align-items: center; gap: 10px; }
#current-user-name { font-weight: 600; font-size: 0.9rem; }
.role-chip {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--surface-raised);
  color: var(--brass-bright);
  border-radius: 20px;
  padding: 3px 10px;
}

/* ---------- tabs (folder-tag styling) ---------- */
.tabs {
  display: flex;
  gap: 4px;
  padding: 10px 20px 0;
  background: var(--bg);
  border-bottom: 2px solid var(--line);
  overflow-x: auto;
}
.tab {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  font-size: 0.82rem;
  padding: 12px 24px 12px;
  background: var(--surface);
  color: var(--ink-muted);
  border: none;
  cursor: pointer;
  clip-path: polygon(10% 0%, 90% 0%, 100% 100%, 0% 100%);
  position: relative;
  top: 2px;
  white-space: nowrap;
}
.tab.active {
  background: var(--surface-raised);
  color: var(--brass-bright);
  box-shadow: inset 0 2px 0 var(--brass);
}
.tab:hover:not(.active) { color: var(--ink); }

/* ---------- content / panels ---------- */
.content { padding: 20px 24px 60px; max-width: 900px; margin: 0 auto; }
.panel { display: none; }
.panel.active { display: block; }
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.panel-lead { color: var(--ink-muted); font-size: 0.88rem; margin: 0; }

.summary-strip { display: flex; gap: 10px; flex-wrap: wrap; }
.summary-pill {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  border-radius: 20px;
  padding: 6px 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.summary-pill.overdue { background: var(--danger-bg); color: #f0a08f; }
.summary-pill.due_soon { background: var(--warn-bg); color: var(--brass-bright); }
.summary-pill.ok { background: var(--ok-bg); color: #8fd0bd; }
.summary-pill.not_started { background: var(--muted-bg); color: var(--ink-muted); }

/* ---------- task cards + dial gauge (signature element) ---------- */
.task-list { display: flex; flex-direction: column; gap: 10px; }
.task-card {
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--ink-muted);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.task-card.status-overdue { border-left-color: var(--danger); }
.task-card.status-due_soon { border-left-color: var(--warn); }
.task-card.status-ok { border-left-color: var(--ok); }
.task-card.status-not_started { border-left-color: var(--ink-muted); }

.dial { width: 78px; height: 78px; flex: none; position: relative; }
.dial svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.dial-bg { fill: none; stroke: var(--line); stroke-width: 7; }
.dial-progress { fill: none; stroke-width: 7; stroke-linecap: round; }
.dial-progress.status-ok { stroke: var(--ok); }
.dial-progress.status-due_soon { stroke: var(--warn); }
.dial-progress.status-overdue { stroke: var(--danger); }
.dial-progress.status-not_started { stroke: var(--ink-muted); stroke-dasharray: 3 7; }
.dial-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.dial-value { font-family: var(--font-mono); font-weight: 600; font-size: 1.15rem; line-height: 1; }
.dial-value.status-overdue { color: #f0a08f; }
.dial-value.status-due_soon { color: var(--brass-bright); }
.dial-value.status-ok { color: #8fd0bd; }
.dial-value.status-not_started { color: var(--ink-muted); }
.dial-label { font-size: 0.55rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-muted); margin-top: 2px; }

.task-main { flex: 1; min-width: 0; }
.task-main h3 { font-size: 1rem; margin-bottom: 3px; }
.task-meta { font-size: 0.82rem; color: var(--ink-muted); margin-bottom: 6px; }
.task-lastdone { font-family: var(--font-mono); font-size: 0.78rem; color: var(--ink-muted); }
.task-notes { font-size: 0.8rem; color: var(--ink-muted); font-style: italic; margin-top: 4px; }

.task-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; flex: none; }
.task-actions-row { display: flex; gap: 6px; }
.link-btn {
  background: none; border: none; cursor: pointer;
  color: var(--ink-muted); font-size: 0.76rem; text-decoration: underline;
  padding: 2px;
}
.link-btn:hover { color: var(--brass-bright); }

/* ---------- history ---------- */
.history-list { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 10px; }
.history-row {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 0.8rem; color: var(--ink-muted); padding: 4px 0;
  font-family: var(--font-mono);
}
.history-row span:first-child { color: var(--ink); }

/* ---------- tickets ---------- */
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-muted);
  border-radius: 20px;
  padding: 7px 16px;
  font-size: 0.8rem;
  cursor: pointer;
}
.chip.active { background: var(--surface-raised); color: var(--brass-bright); border-color: var(--brass); }

.ticket-list { display: flex; flex-direction: column; gap: 10px; }
.ticket-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.ticket-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.ticket-top h3 { font-size: 1rem; margin-bottom: 4px; }
.ticket-meta { font-size: 0.8rem; color: var(--ink-muted); }
.ticket-desc { font-size: 0.88rem; margin: 10px 0; line-height: 1.5; }

.badge {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 20px;
  padding: 4px 10px;
  white-space: nowrap;
}
.badge.priority-low { background: var(--muted-bg); color: var(--ink-muted); }
.badge.priority-medium { background: var(--warn-bg); color: var(--brass-bright); }
.badge.priority-high { background: var(--danger-bg); color: #f0a08f; }
.badge.priority-urgent { background: var(--danger); color: #1a0a08; }
.badge.status-open { background: var(--warn-bg); color: var(--brass-bright); }
.badge.status-in_progress { background: var(--ok-bg); color: #8fd0bd; }
.badge.status-closed { background: var(--muted-bg); color: var(--ink-muted); }

.ticket-controls { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; align-items: center; }
.ticket-controls select {
  background: var(--surface-raised);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.8rem;
}

/* ---------- team ---------- */
.team-list { display: flex; flex-direction: column; gap: 8px; }
.team-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 16px; flex-wrap: wrap;
}
.team-row.inactive { opacity: 0.5; }
.team-name { font-weight: 600; font-size: 0.94rem; }
.team-row-actions { display: flex; gap: 8px; align-items: center; }

/* ---------- empty states ---------- */
.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--ink-muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.empty-state h3 { color: var(--ink); margin-bottom: 6px; font-size: 1rem; }
.empty-state p { font-size: 0.85rem; margin: 0; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10, 12, 14, 0.7);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 100;
}
.modal {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-modal);
  width: 100%; max-width: 460px;
  max-height: 90vh; overflow-y: auto;
  padding: 26px;
}
.modal h2 { font-size: 1.15rem; margin-bottom: 18px; }
.modal-choice-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 4px 0 22px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.modal textarea {
  width: 100%; background: var(--surface-raised); border: 1px solid var(--line);
  border-radius: 8px; padding: 12px 14px; font-size: 0.92rem; color: var(--ink);
  resize: vertical; min-height: 80px; font-family: inherit;
}

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--surface-raised); border: 1px solid var(--brass);
  color: var(--ink); padding: 12px 20px; border-radius: 8px;
  font-size: 0.88rem; z-index: 200;
  box-shadow: var(--shadow-modal);
}
.toast.error { border-color: var(--danger); color: #f0a08f; }

/* ---------- responsive ---------- */
@media (max-width: 640px) {
  .task-card { flex-wrap: wrap; }
  .task-actions { flex-direction: row; align-items: center; width: 100%; justify-content: space-between; }
  .topbar { padding: 12px 16px; }
  .topbar-mark { height: 44px; }
  .content { padding: 16px 14px 50px; }
  .tabs { padding: 8px 14px 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
