/* =================================================================
   AR Digital Solutions IT Support — Master Stylesheet
   Refined utilitarian aesthetic. Dense data, fast scanning.
   ================================================================= */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&family=Inter+Tight:wght@400;500;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* ----- Brand palette (black + orange) ----- */
  --brand: #0a0a0a;          /* black — sidebar and primary surfaces */
  --brand-2: #ea580c;        /* orange-600 — links, hover, active highlights */
  --brand-soft: #fff7ed;     /* orange-50 — soft tint, hover backgrounds */
  --accent: #f97316;         /* orange-500 — accent CTAs, badges */

  /* ----- Neutrals ----- */
  --bg: #f7f8fa;
  --bg-elevated: #ffffff;
  --bg-subtle: #f1f3f6;
  --bg-canvas: #fafbfc;

  /* ----- Borders & dividers ----- */
  --border: #e2e6ec;
  --border-strong: #ccd2db;

  /* ----- Text ----- */
  --text: #0f1722;
  --text-muted: #5b6678;
  --text-soft: #8b95a4;
  --text-inverse: #ffffff;

  /* ----- Semantic colours ----- */
  --success: #16a34a;
  --success-bg: #e8f5ee;
  --warning: #d97706;
  --warning-bg: #fdf2dc;
  --danger:  #dc2626;
  --danger-bg: #fde8e8;
  --info:    #0284c7;
  --info-bg: #e0f2fe;

  /* ----- Priority colours (override per priority via inline style) ----- */
  --priority-low: #16a34a;
  --priority-normal: #2563eb;
  --priority-high: #d97706;
  --priority-urgent: #ea580c;
  --priority-critical: #dc2626;

  /* ----- Spacing / sizing ----- */
  --radius: 6px;
  --radius-lg: 10px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,0.06);
  --shadow:    0 1px 3px rgba(15,23,42,0.08), 0 1px 2px rgba(15,23,42,0.04);
  --shadow-lg: 0 8px 24px rgba(15,23,42,0.10);

  /* ----- Type ----- */
  --font-display: 'Inter Tight', system-ui, sans-serif;
  --font-body:    'Inter', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, Menlo, monospace;
}

/* ----- Reset & base ----- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 0 0 0.5em;
}
h1 { font-size: 1.875rem; line-height: 1.2; }
h2 { font-size: 1.375rem; line-height: 1.25; }
h3 { font-size: 1.125rem; line-height: 1.3; }
h4 { font-size: 1rem; }

a {
  color: var(--brand-2);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

code, .mono { font-family: var(--font-mono); font-size: 0.9em; }

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

/* =================================================================
   LAYOUT — App shell with sidebar
   ================================================================= */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--brand);
  color: rgba(255,255,255,0.85);
  padding: 1.25rem 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar__brand {
  padding: 0 1.25rem 1.25rem;
  color: var(--text-inverse);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
}
.sidebar__brand img {
  height: 42px;
  width: auto;
  max-width: 100%;
  display: block;
}
.sidebar__brand small {
  display: block;
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 600;
  color: rgba(255,255,255,0.7);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.sidebar__nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0 0.75rem;
}
.sidebar__section {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.45);
  padding: 1rem 0.5rem 0.35rem;
}
.sidebar__link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius);
  color: rgba(255,255,255,0.78);
  font-size: 0.85rem;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.sidebar__link:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text-inverse);
  text-decoration: none;
}
.sidebar__link--active {
  background: rgba(255,255,255,0.12);
  color: var(--text-inverse);
  font-weight: 500;
}
.sidebar__link i {
  width: 16px;
  font-size: 0.95rem;
  opacity: 0.85;
}
.sidebar__link .count {
  margin-left: auto;
  background: rgba(255,255,255,0.15);
  padding: 0.05rem 0.4rem;
  border-radius: var(--radius-pill);
  font-size: 0.7rem;
}
.sidebar__user {
  padding: 0.85rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 0.8rem;
  color: rgba(255,255,255,0.7);
}
.sidebar__user a { color: rgba(255,255,255,0.85); }

.main {
  display: flex;
  flex-direction: column;
  min-width: 0; /* prevents overflow in nested flex/grid */
}
.topbar {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  padding: 0.65rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 56px;
}
.topbar__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
}
.topbar__actions { margin-left: auto; display: flex; gap: 0.5rem; align-items: center; }
.topbar .search {
  flex: 1;
  max-width: 400px;
  position: relative;
}
.topbar .search input {
  width: 100%;
  background: var(--bg-subtle);
  border: 1px solid transparent;
  padding: 0.4rem 0.75rem 0.4rem 2.1rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: var(--text);
}
.topbar .search input:focus {
  outline: none;
  background: var(--bg-elevated);
  border-color: var(--brand-2);
}
.topbar .search i {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-soft);
  font-size: 0.9rem;
}

.content {
  padding: 1.5rem;
  flex: 1;
}

/* =================================================================
   CARDS & PANELS
   ================================================================= */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.card__header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.card__header h2, .card__header h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}
.card__header .actions {
  margin-left: auto;
  display: flex;
  gap: 0.5rem;
}
.card__body { padding: 1.25rem; }
.card__body--flush { padding: 0; }
.card__footer {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--bg-canvas);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* =================================================================
   STATS / KPI GRID
   ================================================================= */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  position: relative;
  overflow: hidden;
}
.stat::before {
  content: "";
  position: absolute;
  inset: 0;
  border-left: 3px solid var(--brand-2);
  opacity: 0;
  transition: opacity 0.2s;
}
.stat:hover::before { opacity: 1; }
.stat__label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}
.stat__value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--text);
}
.stat__value--success { color: var(--success); }
.stat__value--danger  { color: var(--danger); }
.stat__value--warning { color: var(--warning); }
.stat__sub {
  font-size: 0.75rem;
  color: var(--text-soft);
  margin-top: 0.35rem;
}

/* =================================================================
   TABLES — for ticket queues, lists
   ================================================================= */
.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.table th {
  text-align: left;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-canvas);
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr { transition: background 0.1s; }
.table tbody tr:hover { background: var(--bg-canvas); }
.table tbody tr:last-child td { border-bottom: 0; }
.table a { color: var(--text); }
.table a:hover { color: var(--brand-2); }
.table .num { font-family: var(--font-mono); color: var(--text-soft); font-size: 0.8rem; }

/* =================================================================
   PILLS / BADGES — status, priority, etc.
   ================================================================= */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--bg-subtle);
  color: var(--text-muted);
  white-space: nowrap;
}
.pill--dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* status pills */
.status-new            { background: #e0f2fe; color: #075985; }
.status-open           { background: #dbeafe; color: #1e40af; }
.status-acknowledged   { background: #ede9fe; color: #5b21b6; }
.status-in_progress    { background: #fef3c7; color: #92400e; }
.status-pending_client { background: #fee2e2; color: #991b1b; }
.status-resolved       { background: #d1fae5; color: #065f46; }
.status-closed         { background: #e5e7eb; color: #374151; }
.status-reopened       { background: #fde68a; color: #92400e; }

/* SLA pill */
.sla-ok       { background: var(--success-bg); color: var(--success); }
.sla-warning  { background: var(--warning-bg); color: var(--warning); }
.sla-breached { background: var(--danger-bg);  color: var(--danger); }

/* =================================================================
   BUTTONS
   ================================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
  white-space: nowrap;
}
.btn:hover {
  background: var(--bg-subtle);
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn--primary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--text-inverse);
}
.btn--primary:hover {
  background: var(--brand-2);
  border-color: var(--brand-2);
  color: var(--text-inverse);
}
.btn--accent {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-inverse);
}
.btn--accent:hover {
  background: var(--brand-2);
  border-color: var(--brand-2);
  color: var(--text-inverse);
}
.btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}
.btn--ghost:hover {
  background: var(--bg-subtle);
  color: var(--text);
}
.btn--danger {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--text-inverse);
}
.btn--danger:hover { background: #b91c1c; border-color: #b91c1c; color: var(--text-inverse); }
.btn--sm { padding: 0.25rem 0.55rem; font-size: 0.75rem; }
.btn--lg { padding: 0.6rem 1.2rem; font-size: 0.95rem; }
.btn--block { display: flex; width: 100%; justify-content: center; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* =================================================================
   FORMS
   ================================================================= */
.field { margin-bottom: 1rem; }
.field label, .label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.35rem;
}
.field .help, .help {
  font-size: 0.75rem;
  color: var(--text-soft);
  margin-top: 0.25rem;
}
.input, .select, .textarea {
  display: block;
  width: 100%;
  padding: 0.5rem 0.7rem;
  font-family: var(--font-body);
  font-size: 0.88rem;
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(29,78,216,0.12);
}
.textarea { resize: vertical; min-height: 100px; font-family: var(--font-body); }
.field--inline { display: flex; align-items: center; gap: 0.5rem; }
.field--inline label { margin: 0; min-width: 120px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}
.form-grid .full { grid-column: 1 / -1; }

.errors {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.82rem;
}
.errors ul { margin: 0.3rem 0 0 1rem; padding: 0; }

.flash {
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.85rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.flash--success { background: var(--success-bg); color: var(--success); }
.flash--error   { background: var(--danger-bg);  color: var(--danger); }
.flash--info    { background: var(--info-bg);    color: var(--info); }

/* =================================================================
   PAGE HEADER (above-content title bar)
   ================================================================= */
.page-header {
  display: flex;
  align-items: flex-end;
  margin-bottom: 1.25rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-header h1 {
  margin: 0;
  font-size: 1.5rem;
  line-height: 1.1;
}
.page-header .breadcrumbs {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-soft);
  margin-bottom: 0.3rem;
}
.page-header .breadcrumbs a { color: var(--text-muted); }
.page-header .actions { margin-left: auto; display: flex; gap: 0.5rem; }

/* =================================================================
   PUBLIC AUTH PAGES — login/register
   ================================================================= */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
  background:
    radial-gradient(ellipse at top right, rgba(29,78,216,0.08), transparent 60%),
    radial-gradient(ellipse at bottom left, rgba(245,158,11,0.06), transparent 60%),
    var(--bg);
}
@media (min-width: 900px) {
  .auth-wrap { grid-template-columns: 1fr 1fr; }
}
.auth-side {
  display: none;
  padding: 3rem;
  background: var(--brand);
  color: var(--text-inverse);
  position: relative;
  overflow: hidden;
}
@media (min-width: 900px) {
  .auth-side { display: flex; flex-direction: column; justify-content: space-between; }
}
.auth-side::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(245,158,11,0.18), transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(29,78,216,0.4), transparent 50%);
  pointer-events: none;
}
.auth-side > * { position: relative; z-index: 1; }
.auth-side__brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.6rem;
}
.auth-side__brand img {
  height: 56px;
  width: auto;
}
.auth-side__brand small {
  display: block;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.65);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.auth-side h1,
.auth-side h2,
.auth-side h3,
.auth-side h4,
.auth-side h5 { color: var(--text-inverse); }
.auth-side__heading {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.05;
  margin-bottom: 1rem;
  color: var(--text-inverse);
}
.auth-side__sub { color: rgba(255,255,255,0.75); font-size: 1rem; line-height: 1.6; max-width: 420px; }
.auth-side__foot {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.5);
}

.auth-form-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
}
.auth-form {
  width: 100%;
  max-width: 380px;
}
.auth-form h1 {
  font-size: 1.6rem;
  margin-bottom: 0.25rem;
}
.auth-form .lead {
  color: var(--text-muted);
  margin-bottom: 1.75rem;
}
.auth-form .small-links {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  margin-top: 1rem;
  color: var(--text-muted);
}

/* =================================================================
   TICKET WORKSPACE (staff)
   ================================================================= */
.workspace {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 1100px) {
  .workspace { grid-template-columns: 1fr; }
}

.thread {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.thread__head {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}
.thread__head h2 {
  margin: 0;
  font-size: 1.15rem;
  flex: 1;
  min-width: 0;
}
.thread__head .meta {
  font-size: 0.75rem;
  color: var(--text-soft);
  margin-top: 0.2rem;
}
.thread__meta-bar {
  padding: 0.5rem 1.25rem;
  background: var(--bg-canvas);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.thread__msgs {
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 600px;
  overflow-y: auto;
}
.msg {
  display: flex;
  gap: 0.75rem;
}
.msg__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--brand-2);
  color: var(--text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.msg__avatar--client { background: var(--brand); }
.msg__avatar--system { background: var(--text-soft); }
.msg__body {
  flex: 1;
  min-width: 0;
  background: var(--bg-canvas);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.95rem;
}
.msg__body--internal {
  background: #fffbeb;
  border-color: #fde68a;
}
.msg__head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}
.msg__head strong { color: var(--text); font-size: 0.85rem; }
.msg__head .role {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-soft);
}
.msg__head time { margin-left: auto; }
.msg__content {
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
  word-wrap: break-word;
}
.msg__content p { margin: 0 0 0.5em; }
.msg__content p:last-child { margin-bottom: 0; }

.reply-box {
  border-top: 1px solid var(--border);
  padding: 1rem 1.25rem;
  background: var(--bg-canvas);
}
.reply-box__tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 0.5rem;
}
.reply-box__tab {
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius);
}
.reply-box__tab--active {
  background: var(--bg-elevated);
  border-color: var(--border);
  color: var(--text);
  font-weight: 500;
}
.reply-box textarea {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 0.6rem 0.8rem;
  font-family: var(--font-body);
  font-size: 0.88rem;
  resize: vertical;
  min-height: 120px;
}
.reply-box__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}
.reply-box__actions select { padding: 0.35rem 0.5rem; font-size: 0.8rem; }

/* Side panel on workspace */
.sidepanel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.sidepanel .card__body { padding: 0.85rem 1rem; }
.sidepanel dl {
  margin: 0;
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.3rem 0.75rem;
  font-size: 0.8rem;
}
.sidepanel dt { color: var(--text-soft); }
.sidepanel dd { margin: 0; color: var(--text); font-weight: 500; }
.sidepanel dd .pill { font-size: 0.7rem; }

.viewers-warning {
  background: var(--warning-bg);
  color: var(--warning);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.8rem;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* =================================================================
   FILTER BAR (above ticket queue)
   ================================================================= */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  padding: 0.65rem 0.85rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 1rem;
}
.filter-bar select, .filter-bar input {
  font-size: 0.8rem;
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-elevated);
}
.filter-bar .group {
  display: flex;
  gap: 0.15rem;
  padding: 0.15rem;
  background: var(--bg-subtle);
  border-radius: var(--radius);
}
.filter-bar .group button {
  border: 0;
  background: transparent;
  font-size: 0.78rem;
  padding: 0.3rem 0.65rem;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
}
.filter-bar .group button.active {
  background: var(--bg-elevated);
  color: var(--text);
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}

/* =================================================================
   EMPTY STATES
   ================================================================= */
.empty {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--text-soft);
}
.empty i {
  font-size: 2rem;
  display: block;
  margin-bottom: 0.5rem;
  opacity: 0.5;
}
.empty h3 { color: var(--text-muted); margin-bottom: 0.25rem; }

/* =================================================================
   PAGINATION
   ================================================================= */
.pagination {
  display: flex;
  gap: 0.25rem;
  justify-content: flex-end;
  padding-top: 1rem;
}
.pagination a, .pagination span {
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--text);
  text-decoration: none;
}
.pagination .active { background: var(--brand); color: var(--text-inverse); border-color: var(--brand); }
.pagination .disabled { opacity: 0.4; pointer-events: none; }

/* =================================================================
   UTILITY
   ================================================================= */
.muted { color: var(--text-muted); }
.soft  { color: var(--text-soft); }
.mono  { font-family: var(--font-mono); font-size: 0.85em; }
.text-sm { font-size: 0.8rem; }
.text-xs { font-size: 0.72rem; }
.fw-600 { font-weight: 600; }
.flex { display: flex; gap: 0.5rem; align-items: center; }
.flex-1 { flex: 1; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.ml-auto { margin-left: auto; }
.w-100 { width: 100%; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.no-underline { text-decoration: none; }
.no-underline:hover { text-decoration: none; }
.divider { border-top: 1px solid var(--border); margin: 0.75rem 0; }

/* =================================================================
   PUBLIC HEADER (dark)
   ================================================================= */
.public-header {
  background: var(--brand);
  color: rgba(255,255,255,0.85);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.public-header__brand {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.85rem;
  text-decoration: none;
  color: rgba(255,255,255,0.95);
  line-height: 1;
}
.public-header__brand img {
  height: 48px;
  width: auto;
  display: block;
}
.public-header__brand span {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.7);
  padding-left: 0.85rem;
  border-left: 1px solid rgba(255,255,255,0.18);
}
.public-header__nav {
  display: flex;
  gap: 1rem;
  margin-left: 1rem;
}
.public-header__nav a {
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.25rem 0;
  border-bottom: 1px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.public-header__nav a:hover,
.public-header__nav a.is-active {
  color: var(--text-inverse);
  border-bottom-color: var(--brand-2);
}
.public-header__actions {
  margin-left: auto;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.public-header__btn {
  background: transparent;
  border-color: rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.9);
}
.public-header__btn:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.4);
  color: var(--text-inverse);
}

/* =================================================================
   MOBILE — app-like responsive behaviour
   The whole portal is built as a mobile-friendly progressive web shell.
   Sidebar becomes a slide-in drawer, topbar gets a hamburger, tables
   scroll horizontally, forms collapse to a single column, and tap targets
   meet the 44px iOS Human Interface Guidelines minimum.
   ================================================================= */

/* Hamburger button — injected by mobile-shell.js into .topbar */
.topbar__menu {
  display: none;
  background: transparent;
  border: 0;
  padding: 0.5rem;
  margin-right: 0.25rem;
  cursor: pointer;
  color: var(--text);
  font-size: 1.35rem;
  border-radius: var(--radius);
  align-items: center;
  justify-content: center;
}
.topbar__menu:hover { background: var(--bg-subtle); }

/* Backdrop — injected once into <body>, shown when sidebar drawer is open */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 998;
  animation: ar-fade-in 0.15s ease;
}
.sidebar-backdrop--show { display: block; }
@keyframes ar-fade-in { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 900px) {
  /* Single-column layout */
  .app-shell { grid-template-columns: 1fr; }

  /* Sidebar becomes an off-canvas drawer */
  .sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: 280px;
    max-width: 85vw;
    z-index: 999;
    transform: translateX(-100%);
    transition: transform 0.22s cubic-bezier(.4,0,.2,1);
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.18);
  }
  .sidebar--open { transform: translateX(0); }

  /* Hamburger appears, sidebar topbar tightens */
  .topbar__menu { display: inline-flex; }
  .topbar {
    padding: 0.5rem 0.75rem;
    gap: 0.5rem;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 5;
  }
  .topbar__title {
    font-size: 0.95rem;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .topbar .search {
    width: 100%;
    order: 10;
    max-width: none;
    flex-basis: 100%;
  }
  .topbar__actions { gap: 0.25rem; }
  .topbar__actions .btn { padding: 0.35rem 0.55rem; }
  .topbar__actions .btn span { display: none; }   /* hide button labels on tight screens */

  /* Content padding */
  .content { padding: 0.85rem; }

  /* Tap-target sizing */
  .btn {
    min-height: 40px;
    padding: 0.55rem 0.9rem;
  }
  .btn--sm { min-height: 34px; padding: 0.35rem 0.7rem; }
  .sidebar__link { padding: 0.75rem 1rem; font-size: 0.95rem; }

  /* Form grids collapse */
  .form-grid { grid-template-columns: 1fr !important; }

  /* Page header stacks */
  .page-header { flex-wrap: wrap; gap: 0.5rem; align-items: flex-start; }
  .page-header > .actions { width: 100%; }
  .page-header h1 { font-size: 1.35rem; }

  /* Cards span full width, drop inline max-widths */
  .card { max-width: 100% !important; }

  /* Filter bars stack */
  .filter-bar {
    flex-wrap: wrap;
    gap: 0.4rem;
  }
  .filter-bar > * { flex: 1 1 auto; min-width: 0; }
  .filter-bar input[type=text], .filter-bar input[type=email] { min-width: 0; width: 100%; }

  /* Tables — keep them scrollable */
  .table-wrap { -webkit-overflow-scrolling: touch; }
  .table { font-size: 0.85rem; }
  .table th, .table td { padding: 0.5rem 0.6rem; }

  /* Two-column workspaces (ticket show, client edit, project show) collapse */
  .workspace,
  .client-edit-grid { grid-template-columns: 1fr !important; }
  .sidepanel { order: 2; }

  /* Public header */
  .public-header { flex-wrap: wrap; gap: 0.75rem; padding: 0.75rem 1rem; }
  .public-header__nav { order: 3; margin-left: 0; width: 100%; }
  .public-header__actions { margin-left: auto; }
  .public-header__brand img { height: 36px; }

  /* Browser-notifications close-all button — clear the bottom edge on iOS Safari */
  #ar-close-all-notifs { bottom: max(1rem, env(safe-area-inset-bottom)); }
}

/* Tight phones */
@media (max-width: 420px) {
  .topbar__title { font-size: 0.85rem; }
  .public-header__brand img { height: 32px; }
  .public-header__brand span { padding-left: 0.5rem; font-size: 0.75rem; }
}

/* =================================================================
   MOBILE CARDS — alternative to wide data tables on small screens.
   Used by ticket lists, client lists, etc. Pages render BOTH the desktop
   table (wrapped in .desktop-only) AND a card list (.mobile-cards) and
   the media queries below pick which to show.
   ================================================================= */
.mobile-cards { display: none; }
.desktop-only { display: block; }
@media (max-width: 900px) {
  .desktop-only { display: none; }
  .mobile-cards { display: flex; flex-direction: column; gap: 0.5rem; }
  .mobile-cards a.mob-card,
  .mobile-cards .mob-card {
    display: block;
    padding: 0.85rem 1rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s, transform 0.05s;
  }
  .mobile-cards a.mob-card:active { transform: scale(0.995); }
  .mobile-cards a.mob-card:hover { border-color: var(--brand-2); }
  .mob-card__head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
  }
  .mob-card__num {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-muted);
  }
  .mob-card__title {
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.3;
    margin: 0.1rem 0 0.4rem;
    color: var(--text);
  }
  .mob-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem 0.7rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    align-items: center;
  }
  .mob-card__meta .pill { font-size: 0.7rem; }
  .mob-card__row {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    align-items: center;
  }
}

/* ---------- Avatars (global) ---------- */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--brand);
    color: var(--accent);
    font-weight: 600;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar--sm { width: 24px; height: 24px; font-size: 0.7rem; }
.avatar--md { width: 36px; height: 36px; font-size: 0.9rem; }
.avatar--lg { width: 72px; height: 72px; font-size: 1.6rem; }
.avatar__initial { line-height: 1; }

/* =============================================================
   Ticket-thread collapse (FAQ-style)
   --------------------------------------------------------------
   Each reply in the thread is a collapsible card. Recent replies
   render expanded; older ones collapse to a 3-line teaser with a
   gradient fade and a "View full message" button. Click to expand.
   ============================================================= */
.msg__expandable { position: relative; }
.msg__expandable .msg__content { transition: max-height 0.25s ease; }
.msg__expandable.is-collapsed .msg__content {
    max-height: 4.6em;       /* roughly 3 lines */
    overflow: hidden;
    position: relative;
}
.msg__expandable.is-collapsed .msg__content::after {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 2.4em;
    background: linear-gradient(180deg, rgba(255,255,255,0) 0%, #ffffff 90%);
    pointer-events: none;
}
.msg__body--internal.is-collapsed .msg__content::after {
    background: linear-gradient(180deg, rgba(254,243,199,0) 0%, #fef3c7 90%);
}
.msg__toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    margin-top: 0.5rem;
    padding: 0.3rem 0.65rem;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.78rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.1s, color 0.1s;
}
.msg__toggle:hover { background: var(--bg-canvas); color: var(--accent); border-color: var(--border-strong); }
.msg__toggle i { transition: transform 0.18s; }
.msg__expandable:not(.is-collapsed) .msg__toggle i { transform: rotate(180deg); }

/* =============================================================
   New-activity badge on ticket queue rows
   --------------------------------------------------------------
   Sits next to the ticket number / on the mobile card to flag a
   ticket that has unread notifications for the current user.
   ============================================================= */
.tq-new {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    min-width: 1.5rem;
    padding: 0.05rem 0.45rem;
    border-radius: var(--radius-pill);
    background: var(--accent);
    color: #1a0e02;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.4;
    white-space: nowrap;
    box-shadow: 0 0 0 2px rgba(249,115,22,0.18);
}
.tq-new::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #1a0e02;
    display: inline-block;
}
.tq-new__count { margin-left: 0.1rem; }
.table tr:has(.tq-new) td:first-child { box-shadow: inset 3px 0 0 var(--accent); }

/* Bell + mailbox indicators on the ticket queue.
   Render alongside (or instead of) the generic .tq-new pill when we
   know what kind of activity is unread — a new assigned ticket
   (bell) vs. a new client email reply (mailbox). */
.tq-flag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.6rem;
    height: 1.6rem;
    margin-left: 0.3rem;
    border-radius: 50%;
    font-size: 0.85rem;
    position: relative;
    box-shadow: 0 0 0 2px rgba(0,0,0,0.04);
}
.tq-flag--bell    { background: rgba(249,115,22,0.18); color: var(--accent); }
.tq-flag--mailbox { background: rgba(2,132,199,0.18); color: var(--info); }
.tq-flag__count {
    position: absolute;
    top: -4px; right: -4px;
    min-width: 1rem; height: 1rem;
    padding: 0 0.25rem;
    border-radius: var(--radius-pill);
    background: var(--accent);
    color: #1a0e02;
    font-size: 0.6rem;
    font-weight: 700;
    line-height: 1rem;
    text-align: center;
}
.tq-flag--mailbox .tq-flag__count { background: var(--info); color: #fff; }
@keyframes tq-flag-pulse {
    0%, 100% { box-shadow: 0 0 0 2px rgba(249,115,22,0.18); }
    50%      { box-shadow: 0 0 0 4px rgba(249,115,22,0.40); }
}
.tq-flag--bell  { animation: tq-flag-pulse 2.4s ease-in-out infinite; }

/* ============================================================ */
/* Punch-clock widget — topbar shift state + actions             */
/* ============================================================ */
.punch-clock {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    background: rgba(0,0,0,0.03);
    border: 1px solid rgba(0,0,0,0.08);
    padding: 0.25rem 0.55rem 0.25rem 0.7rem;
    border-radius: var(--radius-pill);
    font-size: 0.8rem;
}
.punch-clock__display {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--text);
    font-weight: 500;
}
.punch-clock__dot {
    width: 0.55rem; height: 0.55rem; border-radius: 50%;
    background: #94a3b8;
    box-shadow: 0 0 0 2px rgba(148,163,184,0.2);
}
.punch-clock--working .punch-clock__dot  { background: #22c55e; box-shadow: 0 0 0 2px rgba(34,197,94,0.25); animation: punch-pulse 2s infinite; }
.punch-clock--on_break .punch-clock__dot { background: #f59e0b; box-shadow: 0 0 0 2px rgba(245,158,11,0.25); }
@keyframes punch-pulse {
    0%, 100% { box-shadow: 0 0 0 2px rgba(34,197,94,0.25); }
    50%      { box-shadow: 0 0 0 5px rgba(34,197,94,0.10); }
}
.punch-clock__sep   { opacity: 0.45; }
.punch-clock__hours { font-variant-numeric: tabular-nums; opacity: 0.85; }
.punch-clock__actions { display: inline-flex; gap: 0.3rem; }
.punch-clock .btn--sm { padding: 0.22rem 0.55rem; font-size: 0.75rem; }
.punch-clock .btn--danger {
    background: rgba(239,68,68,0.12); color: #b91c1c; border: 1px solid rgba(239,68,68,0.25);
}
.punch-clock .btn--danger:hover { background: rgba(239,68,68,0.22); }
@media (max-width: 720px) {
    .punch-clock__display .punch-clock__sep,
    .punch-clock__display .punch-clock__hours { display: none; }
}

/* ============================================================ */
/* HR module                                                    */
/* ============================================================ */

/* ---- Tabs ---- */
.hr-tabs {
    display: flex; gap: 0.25rem;
    margin: -0.25rem 0 1.25rem;
    border-bottom: 1px solid var(--border);
}
.hr-tabs a, .hr-tabs span {
    padding: 0.55rem 0.95rem;
    color: var(--text-muted); text-decoration: none;
    border-bottom: 2px solid transparent;
    font-weight: 500; font-size: 0.88rem;
    transition: color 0.12s, border-color 0.12s;
}
.hr-tabs a:hover { color: var(--text); }
.hr-tabs a.is-active, .hr-tabs span.is-active {
    color: var(--text); border-bottom-color: var(--accent);
}

/* ---- KPI tile row ---- */
.hr-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}
.hr-kpi {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.85rem 1rem;
    display: flex; flex-direction: column; gap: 0.25rem;
    border-left: 3px solid var(--border);
}
.hr-kpi--working { border-left-color: var(--success); }
.hr-kpi--break   { border-left-color: var(--warning); }
.hr-kpi--off     { border-left-color: var(--text-soft); }
.hr-kpi__label {
    font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--text-muted); font-weight: 600;
}
.hr-kpi__value {
    font-size: 1.7rem; font-weight: 700; color: var(--text);
    font-variant-numeric: tabular-nums; line-height: 1.1;
}
.hr-kpi--working .hr-kpi__value { color: var(--success); }
.hr-kpi--break   .hr-kpi__value { color: var(--warning); }

/* ---- Live update indicator ---- */
.hr-update-line {
    display: flex; align-items: center; gap: 0.5rem;
    margin-bottom: 0.85rem;
    font-size: 0.78rem; color: var(--text-muted);
}
.hr-update-line::before {
    content: ''; width: 0.5rem; height: 0.5rem; border-radius: 50%;
    background: var(--success); box-shadow: 0 0 0 2px rgba(22,163,74,0.2);
    animation: hr-pulse 2s ease-in-out infinite;
}
@keyframes hr-pulse {
    0%, 100% { opacity: 0.6; }
    50%      { opacity: 1; }
}

/* ---- Roster cards ---- */
.hr-roster {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 0.85rem;
}
.hr-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.95rem;
    display: flex; gap: 0.85rem; align-items: flex-start;
    transition: border-color 0.12s, box-shadow 0.12s;
}
.hr-card:hover { border-color: var(--border-strong); box-shadow: 0 1px 4px rgba(0,0,0,0.04); }
.hr-card__avatar {
    width: 44px; height: 44px; border-radius: 50%;
    object-fit: cover; flex: 0 0 44px;
    background: var(--bg-canvas);
}
.hr-card__avatar--initial {
    display: flex; align-items: center; justify-content: center;
    background: rgba(249,115,22,0.14); color: var(--brand-2);
    font-weight: 700; font-size: 1.1rem;
}
.hr-card__body { flex: 1; min-width: 0; }
.hr-card__name {
    font-weight: 600; font-size: 0.95rem; color: var(--text);
    line-height: 1.2; margin-bottom: 0.1rem;
}
.hr-card__name a { color: inherit; text-decoration: none; }
.hr-card__name a:hover { color: var(--brand-2); }
.hr-card__title {
    font-size: 0.74rem; color: var(--text-soft);
    margin-bottom: 0.5rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hr-card__row {
    display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
    margin-bottom: 0.35rem;
}
.hr-card__hours {
    font-size: 0.78rem; color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}
.hr-card__hours b { color: var(--text); font-weight: 600; }
.hr-card__meta {
    font-size: 0.74rem; color: var(--text-soft);
    display: flex; gap: 0.5rem; flex-wrap: wrap;
}
.hr-card__meta b {
    color: var(--text); font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* ---- Status pills ---- */
.hr-status {
    display: inline-flex; align-items: center; gap: 0.35rem;
    padding: 0.18rem 0.6rem; border-radius: var(--radius-pill);
    font-size: 0.68rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.05em;
    line-height: 1.2;
}
.hr-status--working  { background: var(--success-bg); color: var(--success); }
.hr-status--on_break { background: var(--warning-bg); color: var(--warning); }
.hr-status--off      { background: rgba(139,149,164,0.14); color: var(--text-soft); }
.hr-status__dot {
    width: 0.45rem; height: 0.45rem; border-radius: 50%;
    background: currentColor;
}
.hr-status--working .hr-status__dot {
    box-shadow: 0 0 0 2px rgba(22,163,74,0.18);
    animation: hr-pulse 2s ease-in-out infinite;
}

/* ---- Filter bar ---- */
.hr-filter-bar {
    display: flex; align-items: flex-end; gap: 0.7rem; flex-wrap: wrap;
    padding: 0.85rem 1rem;
    background: var(--bg-elevated); border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 1rem;
}
.hr-filter-bar .field {
    display: flex; flex-direction: column; gap: 0.25rem;
}
.hr-filter-bar label {
    font-size: 0.66rem; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
}
.hr-filter-bar input, .hr-filter-bar select {
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--border); border-radius: var(--radius);
    background: #fff; font-size: 0.85rem;
    min-width: 9rem;
}
.hr-filter-bar input:focus, .hr-filter-bar select:focus {
    outline: 0; border-color: var(--brand-2);
    box-shadow: 0 0 0 3px rgba(234,88,12,0.12);
}
.hr-filter-bar .actions {
    margin-left: auto;
    display: flex; gap: 0.4rem; align-items: flex-end;
}

/* ---- Reports table ---- */
.hr-table-wrap {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.hr-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.hr-table th {
    text-align: left;
    font-size: 0.68rem; text-transform: uppercase;
    letter-spacing: 0.06em; font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-canvas);
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.hr-table th.num, .hr-table td.num { text-align: right; }
.hr-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    color: var(--text);
}
.hr-table tbody tr:last-child td { border-bottom: 0; }
.hr-table tbody tr { transition: background 0.1s; }
.hr-table tbody tr:hover { background: var(--bg-canvas); }
.hr-table .hr-table__name {
    font-weight: 600; color: var(--text);
    text-decoration: none;
}
.hr-table .hr-table__name:hover { color: var(--brand-2); }
.hr-table .hr-table__sub { font-size: 0.74rem; color: var(--text-soft); margin-top: 0.1rem; }
.hr-table td.hours { font-variant-numeric: tabular-nums; font-weight: 600; }
.hr-table td.hours .decimal { font-size: 0.7rem; color: var(--text-soft); font-weight: 400; display: block; margin-top: 0.1rem; }
.hr-table .empty { text-align: center; padding: 2rem; color: var(--text-muted); }

/* ---- Per-staff drilldown day cards ---- */
.hr-day {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.85rem 1rem;
    margin-bottom: 0.65rem;
}
.hr-day__head {
    display: flex; align-items: center; gap: 0.85rem;
    margin-bottom: 0.55rem; flex-wrap: wrap;
}
.hr-day__date {
    font-weight: 600; font-size: 0.95rem; color: var(--text);
}
.hr-day__inout {
    font-size: 0.78rem; color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}
.hr-day__inout b { color: var(--text); font-weight: 600; }
.hr-day__totals {
    margin-left: auto;
    display: flex; align-items: center; gap: 0.7rem;
}
.hr-day__break { font-size: 0.78rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.hr-day__worked {
    font-weight: 700; font-size: 1rem; color: var(--success);
    font-variant-numeric: tabular-nums;
    padding: 0.15rem 0.55rem;
    background: var(--success-bg); border-radius: var(--radius);
}
.hr-day__events { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.hr-event {
    display: inline-flex; align-items: center; gap: 0.3rem;
    padding: 0.22rem 0.6rem;
    border-radius: var(--radius-pill);
    background: var(--bg-canvas);
    border: 1px solid var(--border);
    font-size: 0.76rem; color: var(--text);
}
.hr-event b { font-weight: 600; }
.hr-event__time {
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    font-size: 0.74rem;
}
.hr-event--start  i { color: var(--success); }
.hr-event--break  i { color: var(--warning); }
.hr-event--resume i { color: var(--info); }
.hr-event--end    i { color: var(--danger); }
.hr-day__empty { font-size: 0.82rem; color: var(--text-soft); }

/* ---- Drilldown summary tiles ---- */
.hr-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.65rem;
    margin-bottom: 1rem;
}
.hr-summary__tile {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.85rem 1rem;
}
.hr-summary__label {
    font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--text-muted); font-weight: 600; margin-bottom: 0.2rem;
}
.hr-summary__value {
    font-size: 1.5rem; font-weight: 700; color: var(--text);
    font-variant-numeric: tabular-nums; line-height: 1.1;
}
.hr-summary__sub {
    font-size: 0.72rem; color: var(--text-soft); margin-top: 0.15rem;
}

/* ---- Devices panel + live monitor ---- */
.hr-devices {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem;
    margin-top: 1rem;
}
.hr-devices__head {
    display: flex; align-items: center; gap: 0.6rem;
    margin-bottom: 0.85rem; flex-wrap: wrap;
}
.hr-devices__head h3 { margin: 0; font-size: 1rem; color: var(--text); font-weight: 600; }
.hr-devices__head .sub { font-size: 0.78rem; color: var(--text-muted); }
.hr-devices__head .actions { margin-left: auto; display: flex; gap: 0.4rem; }
.hr-pair-result {
    margin-bottom: 0.85rem;
    padding: 0.85rem 1rem;
    background: var(--brand-soft);
    border: 1px dashed rgba(234,88,12,0.45);
    border-radius: var(--radius);
}
.hr-pair-result__label {
    font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--text-muted); font-weight: 600; margin-bottom: 0.25rem;
}
.hr-pair-result__code {
    font-family: var(--font-mono);
    font-size: 1.7rem; font-weight: 700;
    letter-spacing: 0.18em; color: var(--text);
}
.hr-pair-result__hint {
    font-size: 0.76rem; color: var(--text-muted); margin-top: 0.35rem;
}
.hr-device-row {
    display: flex; gap: 0.85rem; align-items: flex-start;
    padding: 0.75rem; margin-bottom: 0.5rem;
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--bg-canvas);
}
.hr-device-row:last-child { margin-bottom: 0; }
.hr-device-row__body { flex: 1; min-width: 0; }
.hr-device-row__name { font-weight: 600; color: var(--text); }
.hr-device-row__os { font-size: 0.74rem; color: var(--text-soft); margin-top: 0.15rem; }
.hr-device-row__hb { font-size: 0.76rem; color: var(--text-muted); margin-top: 0.25rem; font-variant-numeric: tabular-nums; }
.hr-device-row__hb b { color: var(--text); }
.hr-device-row__win { font-size: 0.76rem; color: var(--text-muted); margin-top: 0.2rem; }
.hr-device-row__win i { font-style: italic; color: var(--text); }
.hr-device-row__actions { display: flex; flex-direction: column; gap: 0.3rem; }
.hr-no-devices {
    font-size: 0.85rem; color: var(--text-muted);
    padding: 0.85rem 1rem;
    background: var(--bg-canvas);
    border-radius: var(--radius);
    text-align: center;
}

/* ---- Topbar punch-clock layout fix ---- */
/* Push the punch clock to the left of the action buttons and let it
   shrink before the page title does. */
.topbar .punch-clock { flex: 0 1 auto; }
.topbar .topbar__actions { gap: 0.5rem; }
@media (max-width: 900px) {
    .topbar .punch-clock__actions .btn--sm i + span,
    .topbar .punch-clock__actions .btn--sm { font-size: 0.72rem; padding: 0.18rem 0.45rem; }
}

/* ---- Responsive tweaks ---- */
@media (max-width: 720px) {
    .hr-filter-bar .actions { width: 100%; justify-content: flex-end; }
    .hr-filter-bar input, .hr-filter-bar select { min-width: 7rem; flex: 1; }
    .hr-day__totals { width: 100%; margin-left: 0; }
    .hr-day__head { gap: 0.5rem; }
    .hr-table th, .hr-table td { padding: 0.55rem 0.7rem; }
}
