/* Self-hosted fonts — see README-fonts.md for how these .woff2 files were
   obtained. Loading fonts from our own origin (rather than Google's CDN)
   means: no third-party request at all, no CSP exception needed for
   fonts.googleapis.com/fonts.gstatic.com, and no Subresource-Integrity
   problem (Google's font CSS varies per User-Agent, which is fundamentally
   incompatible with a single SRI hash — self-hosting sidesteps that
   entirely rather than working around it). */

@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url('/fonts/space-grotesk.woff2') format('woff2');
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url('/fonts/inter.woff2') format('woff2');
}

@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 500 600;
  font-display: swap;
  src: url('/fonts/ibm-plex-mono.woff2') format('woff2');
}
/* Service Desk — design tokens
   Ink slate rail, paper workspace, pine primary, amber SLA signal.
   Signature element: the monospace SLA clock chip. */

:root {
  --ink: #16202e;
  --ink-2: #24334a;
  --paper: #ffffff;
  --card: #ffffff;
  --line: #e3e6eb;
  --text: #1d2733;
  --text-dim: #66707d;
  --pine: #0e7c66;
  --pine-dark: #0a5f4e;
  --amber: #e8930c;
  --red: #d64545;
  --radius: 10px;
  --font-display: "Space Grotesk", sans-serif;
  --font-body: "Inter", sans-serif;
  --font-mono: "IBM Plex Mono", monospace;
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ---------- Global headings: one consistent display font everywhere ----------
   Every h1-h4 across all pages uses the display font. Page-specific rules
   below only adjust size/spacing; the family is unified here so no heading
   ever falls back to the body font. */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--text);
}
.card-title, .page-head h1, .section-head h2 { font-family: var(--font-display); }

/* ---------- Shell ---------- */
.shell { display: flex; height: 100%; }

.rail {
  width: 216px;
  flex-shrink: 0;
  background: #ffffff;
  border-right: 1px solid var(--line);
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
}
.wordmark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  color: var(--text);
  letter-spacing: 0.2px;
  padding: 0 10px 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.wordmark .dot {
  width: 10px; height: 10px; border-radius: 3px;
  background: var(--amber);
  display: inline-block;
}
.rail nav { display: flex; flex-direction: column; gap: 2px; }
.rail nav a {
  padding: 9px 10px;
  border-radius: 8px;
  font-weight: 500;
  color: var(--text-dim);
  transition: background 120ms, color 120ms;
}
.rail nav a:hover { background: #f2f4f6; color: var(--text); }
.rail nav a.active { background: #e6f2ef; color: var(--pine-dark); }
.rail .rail-foot {
  margin-top: auto;
  padding: 10px;
  font-size: 12px;
  color: #5d6a7c;
}

.main { flex: 1; overflow-y: auto; padding: 28px 36px 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; gap: 16px; }
.page-head h1 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  margin: 0;
}
.page-head .sub { color: var(--text-dim); margin-top: 4px; font-size: 13px; }

/* ---------- Cards, stats ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat { padding: 16px 18px; }
.stat .label { font-size: 12px; color: var(--text-dim); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.stat .value { font-family: var(--font-display); font-size: 30px; font-weight: 600; margin-top: 6px; }
.stat .value.warn { color: var(--amber); }
.stat .value.bad { color: var(--red); }
.stat .value.good { color: var(--pine); }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text-dim); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line);
}
td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr { cursor: pointer; transition: background 100ms; }
tbody tr:hover { background: #f6f8f9; }
.ticket-no { font-family: var(--font-mono); font-weight: 600; font-size: 12.5px; color: var(--text-dim); }

/* ---------- Signature: SLA clock chip ---------- */
.sla-chip {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
  background: #eef4f2;
  color: var(--pine-dark);
}
.sla-chip.warn { background: #fdf3e2; color: #a26504; }
.sla-chip.breach { background: #fbeaea; color: var(--red); }
.sla-chip.met { background: #eef1f5; color: var(--text-dim); }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; font-size: 11.5px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px; text-transform: capitalize;
}
.badge.low     { background: #eef1f5; color: #5c6774; }
.badge.medium  { background: #e7f0fb; color: #2b5d9c; }
.badge.high    { background: #fdf3e2; color: #a26504; }
.badge.urgent   { background: #fbeaea; color: var(--red); }
.badge.critical { background: #fbeaea; color: var(--red); }
.badge.open    { background: #e7f0fb; color: #2b5d9c; }
.badge.pending { background: #fdf3e2; color: #a26504; }
.badge.resolved, .badge.done, .badge.active { background: #e6f2ef; color: var(--pine-dark); }
.badge.closed, .badge.archived { background: #eef1f5; color: #5c6774; }
.badge.planning, .badge.todo { background: #eef1f5; color: #5c6774; }
.badge.in_progress, .badge.review, .badge.on_hold { background: #f0ecfa; color: #6244b8; }

/* ---------- Buttons & forms ---------- */
.btn {
  border: 0; border-radius: 8px; padding: 9px 15px; font-weight: 600; font-size: 13.5px;
  cursor: pointer; background: var(--pine); color: #fff; transition: background 120ms;
}
.btn:hover { background: var(--pine-dark); }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn.ghost:hover { background: #fafbfc; }
.btn:focus-visible, a:focus-visible { outline: 2px solid var(--pine); outline-offset: 2px; }

input, select, textarea {
  font-family: inherit; font-size: 13.5px; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text);
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--pine); outline-offset: -1px; }
label { display: block; font-size: 12.5px; font-weight: 600; margin: 12px 0 5px; color: var(--text-dim); }

/* ---------- Kanban ---------- */
.board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; align-items: start; }
.col-head {
  font-family: var(--font-display); font-weight: 600; font-size: 13px;
  padding: 4px 2px 10px; display: flex; justify-content: space-between; color: var(--text-dim);
}
.task-card { padding: 12px 13px; margin-bottom: 10px; cursor: default; }
.task-card .t-title { font-weight: 500; margin-bottom: 8px; line-height: 1.35; }
.task-card .t-meta { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--text-dim); }
.task-move { display: flex; gap: 6px; margin-top: 10px; }
.task-move button {
  flex: 1; border: 1px solid var(--line); background: #fff; border-radius: 6px;
  font-size: 11.5px; padding: 4px 0; cursor: pointer; color: var(--text-dim);
}
.task-move button:hover { border-color: var(--pine); color: var(--pine-dark); }

/* ---------- Detail / drawer ---------- */
.detail-grid { display: grid; grid-template-columns: 1fr 300px; gap: 18px; align-items: start; }
.thread { padding: 0; }
.comment { padding: 14px 18px; border-bottom: 1px solid var(--line); }
.comment:last-child { border-bottom: 0; }
.comment .who { font-weight: 600; font-size: 13px; margin-bottom: 4px; display: flex; gap: 8px; align-items: center; }
.comment .when { color: var(--text-dim); font-weight: 400; font-size: 12px; }
.comment.internal { background: #fdf9f0; }
.note-tag { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--amber); }
.side .row { display: flex; justify-content: space-between; padding: 10px 16px; border-bottom: 1px solid var(--line); font-size: 13px; }
.side .row:last-child { border-bottom: 0; }
.side .row .k { color: var(--text-dim); }

.empty { text-align: center; padding: 48px 20px; color: var(--text-dim); }
.error-banner {
  background: #fbeaea; color: var(--red); border: 1px solid #f2c7c7;
  border-radius: var(--radius); padding: 12px 16px; margin-bottom: 18px; font-weight: 500;
}

/* ---------- Modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(22, 32, 46, 0.45);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal { width: 460px; max-width: 100%; padding: 22px 24px; max-height: 90vh; overflow-y: auto; }
.modal h2 { font-family: var(--font-display); font-size: 17px; margin: 0 0 6px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

@media (max-width: 900px) {
  .rail { width: 64px; }
  .rail .label-text, .rail .rail-foot { display: none; }
  .board { grid-template-columns: 1fr 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .main { padding: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(700px 380px at 78% 18%, rgba(232, 147, 12, 0.07), transparent 60%),
    radial-gradient(600px 400px at 15% 85%, rgba(14, 124, 102, 0.07), transparent 55%),
    #ffffff;
  padding: 24px;
}
.login-card {
  width: 380px;
  max-width: 100%;
  padding: 34px 32px 26px;
  text-align: center;
  border: 1px solid var(--line);
  box-shadow: 0 18px 44px rgba(22, 32, 46, 0.08);
}
.login-mark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 21px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
}
.login-mark .dot { width: 12px; height: 12px; border-radius: 4px; background: var(--amber); }
.login-sub { color: var(--text-dim); font-size: 13.5px; line-height: 1.55; margin: 12px 0 24px; }
.login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  margin-bottom: 10px;
  padding: 11px 0;
}
.login-btn.primary { background: var(--ink); }
.login-btn.primary:hover { background: var(--ink-2); }
.login-btn.dev { border-style: dashed; color: var(--text-dim); }
.login-foot { color: var(--text-dim); font-size: 12px; line-height: 1.5; margin: 16px 0 0; }

/* ---------- Rail user chip ---------- */
.rail-user {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-top: 1px solid var(--line);
}
.avatar {
  width: 30px; height: 30px; flex-shrink: 0;
  border-radius: 8px;
  background: var(--pine);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 12px;
  display: flex; align-items: center; justify-content: center;
}
.user-meta { display: flex; flex-direction: column; min-width: 0; }
.user-name { font-size: 12px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.signout {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--text-dim); font-size: 11.5px; text-align: left;
}
.signout:hover { color: var(--text); text-decoration: underline; }

/* ---------- RBAC / Team ---------- */
.user-role { font-size: 10.5px; color: #9aa4b0; text-transform: capitalize; }
.badge.role-agent   { background: #eef1f5; color: #5c6774; }
.badge.role-manager { background: #e7f0fb; color: #2b5d9c; }
.badge.role-admin   { background: #f0ecfa; color: #6244b8; }
.you-tag { font-size: 11px; color: var(--pine-dark); font-weight: 600; }
.notice-banner {
  background: #e6f2ef; color: var(--pine-dark); border: 1px solid #bcded5;
  border-radius: var(--radius); padding: 12px 16px; margin-bottom: 18px; font-weight: 500;
}
.role-legend { margin-top: 14px; padding: 14px 18px; display: flex; gap: 22px; align-items: center; font-size: 13px; color: var(--text-dim); flex-wrap: wrap; }
.role-legend div { display: flex; gap: 8px; align-items: center; }

/* ---------- Reports ---------- */
.breakdown-row {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin: 0 0 16px;
}
.breakdown-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text-dim); font-weight: 600;
}

/* ---------- Ticket sidebar: customer block ---------- */
.side-col { display: flex; flex-direction: column; gap: 14px; }
.side-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text-dim); font-weight: 600;
}
.edit-link {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--pine-dark); font-size: 12px; font-weight: 600; text-transform: none; letter-spacing: 0;
}
.edit-link:hover { text-decoration: underline; }

/* ---------- Section headings on detail pages ---------- */
.section-head {
  display: flex; justify-content: space-between; align-items: center;
  margin: 4px 0 12px;
}
.section-head h2 {
  font-family: var(--font-display); font-size: 15px; font-weight: 600; margin: 0;
}

/* ---------- Contracts ---------- */
.badge.tier-basic    { background: #eef1f5; color: #5c6774; }
.badge.tier-standard { background: #e7f0fb; color: #2b5d9c; }
.badge.tier-premium  { background: #f7efdc; color: #8a6410; }
.filter-row { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-chip {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 6px 14px; font-size: 12.5px; font-weight: 600; cursor: pointer;
  color: var(--text-dim); text-transform: capitalize; transition: all 120ms;
}
.filter-chip:hover { border-color: var(--pine); color: var(--pine-dark); }
.filter-chip.on { background: #e6f2ef; border-color: var(--pine); color: var(--pine-dark); }

/* Agent dashboard section headings */
.card-title {
  font-family: "Space Grotesk", sans-serif;
  font-size: 15px;
  font-weight: 600;
  margin: 2px 0 12px;
}


/* ---- Sidebar polish: nav icons + quick-stats widget ---- */
.rail nav a {
  display: flex;
  align-items: center;
  gap: 10px;
}
.rail nav a svg { flex-shrink: 0; opacity: 0.75; }
.rail nav a.active svg { opacity: 1; }

.rail-widget {
  margin-top: auto;
  margin-bottom: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafbfc;
}
.rail-widget-date {
  font-size: 11px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--muted, #66707d);
  margin-bottom: 8px;
}
.rail-widget-stats { display: flex; gap: 14px; }
.rail-widget-stat { display: flex; flex-direction: column; }
.rail-widget-value {
  font-family: "Space Grotesk", sans-serif;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.1;
}
.rail-widget-value.bad { color: #d64545; }
.rail-widget-label { font-size: 11px; color: var(--muted, #66707d); }
@media (max-width: 900px) {
  .rail .rail-widget { display: none; }
}

/* ---- Print: reports carry the company logo and hide app chrome ---- */
@media print {
  .rail, .page-head input, .btn { display: none !important; }
  .main { margin: 0 !important; padding: 0 !important; }
  .card { border: none !important; box-shadow: none !important; break-inside: avoid; }
  .report-header { border-bottom: 2px solid #000 !important; }
  .report-header img { display: block !important; }
}
