/* Ticket Tracker demo client styles. Plain CSS, system fonts, no external assets
   (the Content-Security-Policy only allows this origin). Colours are CSS variables. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #64707d;
  --border: #e2e6eb;
  --primary: #2f5bd3;
  --primary-hover: #2549ad;
  --ok: #1f8a4c;
  --ok-bg: #e5f5ec;
  --info: #2f5bd3;
  --info-bg: #e8eefc;
  --danger: #c23b3b;
  --danger-bg: #fbeaea;
  --warn-bg: #fff4dc;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  color: var(--text);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* component display rules must never un-hide elements */
body { margin: 0; background: var(--bg); line-height: 1.45; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 4px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 { font-size: 1.1rem; margin: 0 0 12px; }
h3 { font-size: 0.95rem; margin: 16px 0 6px; }
code { background: #eef1f4; padding: 1px 5px; border-radius: 4px; font-size: 0.9em; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.danger { color: var(--danger); }
.center { text-align: center; margin: 16px 0; }
.empty { text-align: center; padding: 24px 0; }

/* ---- top bar */
.topbar {
  display: flex; align-items: center; gap: 24px; padding: 10px 24px;
  background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; color: var(--text); font-size: 1.05rem; }
.nav { display: flex; gap: 4px; }
.nav a { padding: 6px 12px; border-radius: 8px; color: var(--muted); }
.nav a.active, .nav a:hover { background: var(--info-bg); color: var(--primary); text-decoration: none; }
.who { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 0.9rem; }

/* ---- layout */
.view { max-width: 1120px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; }
.page-head p { margin: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card.narrow { max-width: 460px; margin: 40px auto; }
.split { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.back { display: inline-block; margin-bottom: 10px; color: var(--muted); }
.notice { background: var(--warn-bg); border: 1px solid #f1d9a6; padding: 10px 14px; border-radius: 8px; }
@media (max-width: 820px) { .split { grid-template-columns: 1fr; } .topbar { flex-wrap: wrap; } }

/* ---- login */
.login-wrap { min-height: 80vh; display: flex; align-items: center; justify-content: center; }
.login h1 { justify-content: center; }
.login > .muted { text-align: center; margin-bottom: 18px; }
.login-links { margin: 14px 0 0 !important; }

/* ---- stats */
.cards { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; align-items: flex-start; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px;
  min-width: 140px; display: flex; flex-direction: column; color: var(--muted); box-shadow: var(--shadow);
}
a.stat:hover { border-color: var(--primary); text-decoration: none; }
.stat-num { font-size: 1.8rem; font-weight: 700; color: var(--text); line-height: 1.1; }
.stat-wide { flex: 1; min-width: 260px; }
.by-client { list-style: none; padding: 0; margin: 6px 0 0; color: var(--text); }
.by-client li { padding: 2px 0; }

/* ---- tabs and filters */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.filters input[type="search"] { min-width: 220px; }

/* ---- tables */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); background: #fafbfc; }
tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #f8faff; }
.num { text-align: right; white-space: nowrap; }

/* ---- forms */
label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--muted); margin-bottom: 12px; flex: 1; }
label.check { flex-direction: row; align-items: center; gap: 6px; margin: 0; flex: none; color: var(--text); }
input, select, textarea {
  font: inherit; color: var(--text); padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; width: 100%;
}
.filters input, .filters select { width: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid #c9d7fb; border-color: var(--primary); }
input.short { max-width: 90px; }
.invalid { border-color: var(--danger) !important; }
.field-error { color: var(--danger); font-size: 0.8rem; }
.form-error { background: var(--danger-bg); color: var(--danger); padding: 8px 12px; border-radius: 8px; margin: 0 0 12px; }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row > button { margin-bottom: 12px; }
.inline-form h2 { margin-bottom: 8px; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; flex-wrap: wrap; }
.danger-zone { border-color: #f1c9c9; }

/* ---- buttons */
.btn {
  font: inherit; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px;
  border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: #c7ced6; text-decoration: none; }
.btn:disabled { opacity: 0.6; cursor: wait; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-danger-ghost { color: var(--danger); border-color: #f1c9c9; }
.btn.block { width: 100%; }

/* ---- badges, pills, chips */
.badge { font-size: 0.75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; text-transform: lowercase; white-space: nowrap; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-muted { background: #eef0f3; color: var(--muted); }
.pill { font-size: 0.75rem; background: #eef1f4; padding: 2px 8px; border-radius: 999px; color: var(--muted); }
.pill-accent { background: var(--info-bg); color: var(--primary); }
.chip { display: inline-block; background: #eef1f4; padding: 1px 8px; border-radius: 999px; margin: 0 4px 4px 0; font-size: 0.85rem; }

/* ---- ticket details */
.facts { display: grid; grid-template-columns: 130px 1fr; gap: 8px 16px; margin: 0; }
.facts dt { color: var(--muted); font-size: 0.85rem; }
.facts dd { margin: 0; }
.description p { white-space: pre-wrap; margin: 0; }
.timeline { list-style: none; padding: 0; margin: 0; }
.event { padding: 0 0 14px 16px; border-left: 2px solid var(--border); position: relative; }
.event::before { content: ""; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.event-completed::before { background: var(--ok); }
.event-created::before { background: var(--primary); }
.event-archived::before { background: #9aa4ae; }
.event-reopened::before, .event-assigned::before, .event-updated::before { background: #d08b14; }
.event-details { margin: 4px 0 0; padding-left: 18px; font-size: 0.9rem; }

/* ---- stat tiles (top of pages) */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stats .stat { min-width: 0; border-top: 4px solid var(--border); }
.stat-label { color: var(--muted); font-size: 0.85rem; }
.stat-info { border-top-color: var(--primary) !important; }
.stat-danger { border-top-color: var(--danger) !important; }
.stat-danger .stat-num { color: var(--danger); }
.stat-ok { border-top-color: var(--ok) !important; }
.stat-neutral { border-top-color: #9aa4ae !important; }
.stat-who { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text); min-height: 2rem; word-break: break-all; }
.head-actions { display: flex; gap: 8px; align-items: center; }
.section-title { margin: 8px 0 12px; }

/* ---- tiles */
.tile {
  display: flex; flex-direction: column; gap: 6px; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-left: 4px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; box-shadow: var(--shadow); transition: transform 0.08s ease, box-shadow 0.08s ease;
}
a.tile:hover { text-decoration: none; transform: translateY(-1px); box-shadow: 0 6px 16px rgba(16, 24, 40, 0.10); }
.tile.tone-info { border-left-color: var(--primary); }
.tile.tone-danger { border-left-color: var(--danger); }
.tile.tone-ok { border-left-color: var(--ok); }
.tile.tone-muted { border-left-color: #c3cad2; opacity: 0.85; }
.tile-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tile-kicker { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; }
.tile-title { font-weight: 600; font-size: 1rem; line-height: 1.3; }
.tile-sub { color: var(--muted); font-size: 0.88rem; }
.tile-meta { font-size: 0.85rem; }
.tile-chips { display: flex; flex-wrap: wrap; }
.tile-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.tile-counts { display: flex; gap: 14px; font-size: 0.9rem; color: var(--muted); }
.tile-counts strong { color: var(--text); font-size: 1.1rem; }
.chip-sm { font-size: 0.75rem; padding: 0 7px; }
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; margin-bottom: 16px; }

.avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--info-bg); color: var(--primary);
  display: inline-flex; align-items: center; justify-content: center; font-size: 0.72rem; font-weight: 700; flex: none;
}
.avatar-empty { background: #eef0f3; color: var(--muted); }

.progress { height: 6px; background: #eef0f3; border-radius: 999px; overflow: hidden; }
.progress-bar { display: block; height: 100%; width: 0; background: var(--ok); border-radius: 999px; }

/* ---- board */
.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: start; }
.column { background: #eef1f5; border-radius: 12px; padding: 10px; min-height: 120px; }
.column-head { display: flex; align-items: center; gap: 8px; padding: 4px 6px 10px; }
.column-head h2 { margin: 0; font-size: 0.95rem; }
.column-head .count { margin-left: auto; background: var(--surface); border-radius: 999px; padding: 0 9px; font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.column-info .dot { background: var(--primary); }
.column-danger .dot { background: var(--danger); }
.column-ok .dot { background: var(--ok); }
.column-body { display: flex; flex-direction: column; gap: 10px; }
.empty-col { text-align: center; padding: 18px 0; margin: 0; font-size: 0.9rem; }
.column > .btn { margin-top: 10px; }
@media (max-width: 900px) { .board { grid-template-columns: 1fr; } }

/* ---- toast */
.toast { position: fixed; top: 16px; right: 16px; padding: 10px 16px; border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,0.12); z-index: 20; background: #1c2430; color: #fff; }
.toast-error { background: var(--danger); }
.toast-warn { background: #9a6700; }
