/* ---------------------------------------------------------------------------
   jDesk — Jugaad help desk shared stylesheet (customer portal + staff panel)
   Brand: Jugaad blue #2aaae1
   --------------------------------------------------------------------------- */

:root {
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --hairline: #e1e0d9;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2aaae1;
  --accent-strong: #1287bd;
  --accent-ink: #0e6d9a;
  --accent-wash: #d9f0fb;
  --bar-track: #ecf6fb;
  --good: #0ca30c;
  --good-ink: #006300;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --hairline: #2c2c2a;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #35b4ea;
    --accent-strong: #1287bd;
    --accent-ink: #7fd0ef;
    --accent-wash: #0c3648;
    --bar-track: #1f2b31;
    --good-ink: #0ca30c;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

/* The hidden attribute must win over any display rule (e.g. .topbar's flex). */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

a { color: var(--accent-ink); }

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }

/* ---------- Layout ---------- */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--hairline);
  padding: .7rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.topbar .brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.brand-mark {
  height: 24px;
  width: auto;
  display: inline-block;
}

.brand .brand-name { letter-spacing: .01em; }
.brand .brand-sub { font-weight: 400; font-size: .78rem; color: var(--muted); margin-left: .1rem; }

.topbar nav { display: flex; gap: .25rem; flex-wrap: wrap; }

.topbar nav a, .navlink {
  color: var(--ink-2);
  text-decoration: none;
  padding: .35rem .7rem;
  border-radius: 6px;
  font-size: .92rem;
}

.topbar nav a:hover, .navlink:hover { background: var(--page); color: var(--ink); }
.topbar nav a.active { background: var(--accent-wash); color: var(--accent-ink); font-weight: 600; }
.topbar .spacer { flex: 1; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 1.25rem; }
.wrap-narrow { max-width: 760px; }

.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.25rem;
  margin-bottom: 1rem;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
@media (max-width: 800px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: .6rem; flex-wrap: wrap; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mt { margin-top: 1rem; }
.mb0 { margin-bottom: 0; }

/* ---------- Forms ---------- */

label.field { display: block; margin-bottom: .8rem; }
label.field > span { display: block; font-size: .85rem; font-weight: 600; color: var(--ink-2); margin-bottom: .25rem; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="search"], input[type="datetime-local"], select, textarea {
  width: 100%;
  padding: .5rem .6rem;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

textarea { min-height: 120px; resize: vertical; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem .95rem;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover { background: var(--page); }
.btn-primary { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); }
.btn-danger { color: var(--critical); border-color: var(--critical); }
.btn-danger:hover { background: var(--critical); color: #fff; }
.btn-sm { padding: .25rem .6rem; font-size: .85rem; font-weight: 500; }
.btn[disabled] { opacity: .5; cursor: default; }

.inline-form { display: flex; gap: .5rem; flex-wrap: wrap; align-items: end; }

/* ---------- Alerts ---------- */

.alert { padding: .7rem .9rem; border-radius: 6px; margin-bottom: 1rem; border: 1px solid; }
.alert-error { border-color: var(--critical); color: var(--critical); background: color-mix(in srgb, var(--critical) 7%, var(--surface)); }
.alert-success { border-color: var(--good); color: var(--good-ink); background: color-mix(in srgb, var(--good) 7%, var(--surface)); }

/* ---------- Badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .1rem .55rem;
  border-radius: 99px;
  font-size: .78rem;
  font-weight: 600;
  border: 1px solid var(--hairline);
  color: var(--ink-2);
  white-space: nowrap;
}

.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }

.badge.st-NEW::before { background: var(--accent); }
.badge.st-WAITING_REPLY::before { background: var(--serious); }
.badge.st-REPLIED::before { background: var(--good); }
.badge.st-IN_PROGRESS::before { background: var(--warning); }
.badge.st-ON_HOLD::before { background: var(--muted); }
.badge.st-RESOLVED::before { background: var(--good-ink); }

.badge.pr-CRITICAL::before { background: var(--critical); }
.badge.pr-HIGH::before { background: var(--serious); }
.badge.pr-MEDIUM::before { background: var(--warning); }
.badge.pr-LOW::before { background: var(--muted); }

.badge.overdue { color: var(--critical); border-color: var(--critical); }
.badge.overdue::before { background: var(--critical); }

/* ---------- Tables ---------- */

.table-scroll { overflow-x: auto; }

table.list { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.list th {
  text-align: left;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  padding: .45rem .6rem;
  border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
}
table.list td { padding: .55rem .6rem; border-bottom: 1px solid var(--hairline); vertical-align: top; }
table.list tr:last-child td { border-bottom: none; }
table.list tbody tr.clickable { cursor: pointer; }
table.list tbody tr.clickable:hover { background: var(--page); }
table.list th.sortable { cursor: pointer; user-select: none; }
table.list th.sortable:hover { color: var(--ink); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Message thread ---------- */

.thread { display: flex; flex-direction: column; gap: .8rem; }

.msg {
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  overflow: hidden;
}

.msg-head {
  display: flex;
  justify-content: space-between;
  gap: .6rem;
  flex-wrap: wrap;
  padding: .5rem .85rem;
  font-size: .85rem;
  background: var(--page);
  border-bottom: 1px solid var(--hairline);
}

.msg-body { padding: .8rem .9rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.staff .msg-head { background: var(--accent-wash); }
.msg.note { border-style: dashed; }
.msg.note .msg-head { background: color-mix(in srgb, var(--warning) 12%, var(--surface)); }

.attachment-list { display: flex; flex-wrap: wrap; gap: .4rem; padding: 0 .9rem .7rem; }
.attachment-list a {
  font-size: .82rem;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  padding: .15rem .5rem;
  text-decoration: none;
}

/* ---------- Stat tiles & bars (dashboard/reports) ---------- */

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; margin-bottom: 1rem; }

.tile {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: .8rem .95rem;
}

.tile .label { font-size: .82rem; color: var(--ink-2); }
.tile .value { font-size: 1.7rem; font-weight: 600; margin-top: .15rem; }
.tile.alert-tile .value { color: var(--critical); }

.hbar-chart { display: flex; flex-direction: column; gap: .45rem; }

.hbar { display: grid; grid-template-columns: minmax(90px, 160px) 1fr 3.5em; gap: .6rem; align-items: center; font-size: .88rem; }
.hbar .hbar-label { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .hbar-track { background: var(--bar-track); border-radius: 4px; height: 16px; position: relative; }
.hbar .hbar-fill {
  position: absolute; inset: 0 auto 0 0;
  background: var(--accent);
  border-radius: 0 4px 4px 0;
  min-width: 2px;
}
.hbar .hbar-value { color: var(--ink-2); text-align: right; font-variant-numeric: tabular-nums; }

.cols-chart { display: flex; align-items: flex-end; gap: 2px; height: 130px; padding-top: .5rem; }
.cols-chart .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; min-width: 4px; }
.cols-chart .col .col-fill { background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; }
.cols-chart .col:hover .col-fill { background: var(--accent-ink); }
.cols-axis { display: flex; justify-content: space-between; font-size: .75rem; color: var(--muted); margin-top: .3rem; }

/* ---------- Misc ---------- */

.tracking-id {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: .08em;
  font-variant-numeric: tabular-nums;
  color: var(--accent-ink);
}

.kb-vote button { margin-right: .4rem; }

.rating-stars button {
  font-size: 1.5rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 0 .1rem;
}
.rating-stars button.on { color: var(--warning); }

.pager { display: flex; gap: .5rem; align-items: center; justify-content: center; margin-top: .8rem; }

.login-box { max-width: 380px; margin: 8vh auto 0; }
.login-logo { height: 44px; width: auto; display: block; margin-bottom: 1rem; }

footer.site img { height: 20px; width: auto; vertical-align: middle; opacity: .7; margin-left: .35rem; }

.empty { text-align: center; color: var(--muted); padding: 1.5rem 0; }

dialog {
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 1.2rem;
  max-width: 560px;
  width: calc(100vw - 2rem);
}
dialog::backdrop { background: rgba(0, 0, 0, .4); }

footer.site { text-align: center; color: var(--muted); font-size: .82rem; padding: 1.5rem 0 2rem; }