/* PlanetWeb Support. Self-hosted fonts, no external requests. */
@font-face { font-family: "Figtree"; src: url("../fonts/figtree-latin-wght-normal.woff2") format("woff2"); font-weight: 300 900; font-display: swap; }
@font-face { font-family: "Bricolage Grotesque"; src: url("../fonts/bricolage-grotesque-latin-wght-normal.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }

:root {
  --ink: #0f2f6e;          /* dark blue: avatars, strongest text on dark */
  --ink-2: #1a4290;
  --side: #143c8c;         /* PlanetWeb blue: sidebar and sign-in panel */
  --paper: #f4f6f5;        /* page */
  --surface: #ffffff;
  --line: #e1e6e4;
  --line-2: #cfd7d4;
  --text: #17252b;
  --muted: #5d6f75;
  --brand: #1e56c8;        /* PlanetWeb blue */
  --brand-dark: #143c8c;
  --brand-soft: #e3ebfb;
  --amber: #c77d00;
  --amber-soft: #fdf1d6;
  --red: #c23b2e;
  --red-soft: #fbe5e2;
  --green: #2c8a58;
  --green-soft: #def2e6;
  --violet: #5b4bb5;
  --violet-soft: #e8e5f8;
  --display: "Bricolage Grotesque", "Figtree", system-ui, sans-serif;
  --body: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r-sm: 6px; --r-md: 8px; --r-lg: 14px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.55 var(--body); color: var(--text); background: var(--paper); }
a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--display); font-weight: 650; letter-spacing: -.01em; margin: 0; line-height: 1.2; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

/* ---------- Shell ---------- */
.app { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--side); color: #d4e0f7; display: flex; flex-direction: column; padding: 22px 14px 16px; position: sticky; top: 0; height: 100vh; }
.logo { display: block; padding: 4px 10px 26px; color: #fff; font-family: var(--display); font-weight: 650; font-size: 1.15rem; letter-spacing: -.01em; }
.logo:hover { text-decoration: none; }
.logo img { display: block; width: 150px; height: auto; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: var(--r-md); color: #d4e0f7; font-weight: 500; }
.nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.nav a.on { background: rgba(255, 255, 255, .16); color: #fff; box-shadow: inset 3px 0 0 #ffffff; }
.nav .group { margin: 16px 12px 6px; font-size: .78rem; color: #9fb4e0; letter-spacing: .02em; }
.i { width: 19px; height: 19px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.side-foot { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid rgba(255, 255, 255, .1); display: grid; gap: 10px; }
.who { display: flex; gap: 10px; align-items: center; min-width: 0; }
.who .avatar { background: rgba(255, 255, 255, .12); color: #fff; }
.who b { display: block; color: #fff; font-weight: 600; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who span:not(.avatar) { font-size: .82rem; color: #a9bde6; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.foot-links { display: flex; gap: 14px; font-size: .88rem; }
.foot-links a, .foot-links button { color: #bccbee; background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.foot-links a:hover, .foot-links button:hover { color: #fff; text-decoration: underline; }
.main { min-width: 0; }
.content { max-width: 1160px; padding: 34px 40px 80px; }

.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.pagehead .sub { margin: 6px 0 0; color: var(--muted); }
.back { display: inline-block; font-size: .88rem; color: var(--muted); margin-bottom: 8px; }

/* ---------- Buttons and forms ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; background: var(--brand); color: #fff; border: 1px solid var(--brand); padding: 9px 16px; border-radius: var(--r-md); font: inherit; font-weight: 600; cursor: pointer; line-height: 1.2; }
.btn:hover { background: var(--brand-dark); border-color: var(--brand-dark); text-decoration: none; }
.btn.ghost { background: var(--surface); color: var(--text); border-color: var(--line-2); }
.btn.ghost:hover { background: #eef2f1; }
.btn.sm { padding: 5px 11px; font-size: .86rem; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--brand-dark); font: inherit; cursor: pointer; text-decoration: underline; }

label { display: block; font-weight: 600; margin: 16px 0 5px; font-size: .9rem; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; margin: 0; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], input[type=file], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line-2); border-radius: var(--r-md); font: inherit; background: var(--surface); color: var(--text);
}
input[type=file] { padding: 8px; background: var(--paper); border-style: dashed; }
textarea { min-height: 140px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(14, 124, 134, .25); border-color: var(--brand); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--brand); }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 160px; }
.hint { color: var(--muted); font-size: .84rem; margin-top: 4px; }
.inline-form { display: inline; }
.actions-row { margin-top: 20px; display: flex; gap: 10px; align-items: center; }

.flash { padding: 11px 14px; border-radius: var(--r-md); margin-bottom: 20px; border: 1px solid; }
.flash.ok { background: var(--green-soft); border-color: #aedcc2; color: #14543a; }
.flash.error { background: var(--red-soft); border-color: #f1bcb6; color: #7c1f16; }

/* ---------- Panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 22px 24px; margin-bottom: 20px; }
.panel > h2 { margin-bottom: 14px; }
.panel.flush { padding: 0; overflow: hidden; }
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 24px; border-bottom: 1px solid var(--line); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 28px; align-items: start; }

/* ---------- Figures strip ---------- */
.figures { display: flex; flex-wrap: wrap; gap: 0; margin-bottom: 26px; border-top: 1px solid var(--line-2); border-bottom: 1px solid var(--line); background: var(--surface); border-radius: var(--r-lg); border: 1px solid var(--line); overflow: hidden; }
.figure { flex: 1 1 150px; padding: 16px 22px; border-right: 1px solid var(--line); min-width: 140px; }
.figure:last-child { border-right: 0; }
.figure b { display: block; font-family: var(--display); font-size: 2rem; font-weight: 650; line-height: 1.1; letter-spacing: -.02em; }
.figure span { color: var(--muted); font-size: .88rem; }
.figure.alert b { color: var(--red); }
.figure.warn b { color: var(--amber); }

/* ---------- Tables ---------- */
.tablewrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 13px 16px; vertical-align: middle; }
th { font-size: .82rem; font-weight: 600; color: var(--muted); background: #f8faf9; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td, tr.click:hover td { background: #f8fbfa; }
td.ref { font-family: var(--display); font-weight: 600; white-space: nowrap; }
td.subject { min-width: 240px; }
td.subject a { color: var(--text); font-weight: 600; }
td.subject a:hover { color: var(--brand-dark); }
tr.edge td:first-child { box-shadow: inset 4px 0 0 var(--edge, transparent); }
tr.edge-urgent { --edge: var(--red); } tr.edge-high { --edge: #e08a2c; } tr.edge-normal { --edge: #b6c4c4; } tr.edge-low { --edge: #e1e6e4; }

/* ---------- Chips ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 8px; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; background: #e9eeed; color: #3d4f55; }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.s-open { background: var(--brand-soft); color: var(--brand-dark); }
.s-in_progress { background: var(--violet-soft); color: var(--violet); }
.s-waiting { background: var(--amber-soft); color: #86560a; }
.s-resolved { background: var(--green-soft); color: #14543a; }
.s-closed { background: #e9eeed; color: #4a5b61; }
.prio { font-weight: 650; font-size: .88rem; text-transform: capitalize; }
.p-urgent { color: var(--red); } .p-high { color: #b9631a; } .p-normal { color: var(--text); } .p-low { color: var(--muted); font-weight: 500; }

/* ---------- SLA gauge (the signature element) ---------- */
.gauge { min-width: 112px; }
.gauge .track { height: 6px; background: #e4eae8; border-radius: 99px; overflow: hidden; }
.gauge .fill { display: block; height: 100%; border-radius: 99px; background: var(--brand); }
.gauge .txt { display: block; margin-top: 4px; font-size: .8rem; color: var(--muted); white-space: nowrap; }
.gauge.soon .fill { background: var(--amber); } .gauge.soon .txt { color: #86560a; font-weight: 600; }
.gauge.breached .fill { background: var(--red); } .gauge.breached .txt { color: var(--red); font-weight: 700; }
.gauge.met .fill { background: var(--green); } .gauge.met .txt { color: var(--green); font-weight: 600; }
.gauge.paused .fill { background: repeating-linear-gradient(135deg, #b4c0be 0 5px, #d5dddb 5px 10px); }
.gauge.big .track { height: 9px; } .gauge.big .txt { font-size: .88rem; }

/* ---------- Tabs and filters ---------- */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 8px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.on { color: var(--brand-dark); border-bottom-color: var(--brand); }
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 18px; }
.filters > div { min-width: 140px; }
.filters label { margin: 0 0 4px; font-size: .82rem; color: var(--muted); }
.filters .grow { flex: 1; min-width: 200px; }

/* ---------- Ticket thread ---------- */
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-dark); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; flex: none; font-family: var(--display); }
.thread { margin-bottom: 24px; }
.msg { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 14px; padding: 0 0 22px; position: relative; }
.msg::before { content: ""; position: absolute; left: 16px; top: 38px; bottom: 4px; width: 2px; background: var(--line); }
.msg:last-child::before { display: none; }
.msg .bubble { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); border-top-left-radius: 4px; padding: 14px 18px; }
.msg.staff .avatar { background: var(--ink); color: #fff; }
.msg.staff .bubble { background: #f3fafa; border-color: #cfe6e8; }
.msg.internal .avatar { background: var(--amber-soft); color: #86560a; }
.msg.internal .bubble { background: #fffaf0; border: 1px dashed #e2b659; }
.msg .meta { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: .85rem; color: var(--muted); margin-bottom: 6px; }
.msg .meta strong { color: var(--text); }
.tag { display: inline-block; font-size: .76rem; font-weight: 700; padding: 1px 8px; border-radius: 99px; background: var(--amber-soft); color: #86560a; margin-left: 6px; }
.msg .body { white-space: pre-wrap; word-break: break-word; }
.files { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.files a { display: inline-flex; gap: 6px; align-items: center; border: 1px solid var(--line); border-radius: var(--r-md); padding: 4px 10px; font-size: .86rem; background: var(--paper); color: var(--text); }
.files a:hover { border-color: var(--brand); text-decoration: none; }
.reply { border-top: 1px solid var(--line-2); padding-top: 22px; }

.facts { margin: 0; display: grid; grid-template-columns: 100px 1fr; gap: 10px 12px; font-size: .92rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; word-break: break-word; }
.side-block { padding: 0 0 22px; margin-bottom: 22px; border-bottom: 1px solid var(--line); }
.side-block:last-child { border-bottom: 0; }
.side-block h2 { margin-bottom: 12px; font-size: 1rem; }
.clock { margin-bottom: 14px; }
.clock b { display: flex; justify-content: space-between; font-size: .88rem; margin-bottom: 5px; }
.clock b span { font-weight: 500; color: var(--muted); }
.timeline { list-style: none; padding: 0; margin: 0; font-size: .86rem; }
.timeline li { padding: 7px 0 7px 16px; border-left: 2px solid var(--line); position: relative; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 13px; width: 8px; height: 8px; border-radius: 50%; background: var(--line-2); }

/* ---------- Reports ---------- */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 130px; padding-top: 8px; }
.bars div { flex: 1; background: #9fd3d7; border-radius: 3px 3px 0 0; min-height: 3px; }
.bars div:hover { background: var(--brand); }
.hbar { background: #e6eeed; border-radius: 4px; height: 8px; margin: 4px 0 12px; }
.hbar i { display: block; height: 8px; background: var(--brand); border-radius: 4px; }
.hrow { display: flex; justify-content: space-between; font-size: .92rem; }

/* ---------- Sign in ---------- */
.guest { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.guest-art { background: var(--side); color: #e1eafa; padding: 56px 56px 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.guest-art::after { content: ""; position: absolute; right: -140px; bottom: -140px; width: 440px; height: 440px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .28); box-shadow: 0 0 0 46px rgba(255, 255, 255, .05), 0 0 0 92px rgba(255, 255, 255, .035); }
.guest-foot { font-style: normal; display: grid; gap: 3px; font-size: .95rem; color: #bccbee; }
.guest-foot b { color: #fff; font-weight: 600; }
.guest-foot a { color: #bccbee; }
.guest-foot a:hover { color: #fff; }
.guest-art h1 { color: #fff; font-size: 2.4rem; max-width: 17ch; line-height: 1.1; margin-bottom: 14px; }
.guest-art p { max-width: 38ch; color: #bccbee; margin: 0; font-size: 1.05rem; }
.guest-form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.guest-box { width: 100%; max-width: 380px; }
.guest-form h2 { font-size: 1.5rem; margin-bottom: 4px; }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty b { display: block; color: var(--text); font-family: var(--display); font-size: 1.1rem; margin-bottom: 4px; }

/* ---------- Pagination ---------- */
.pager { display: flex; gap: 8px; align-items: center; margin-top: 18px; }
.pager a, .pager span { padding: 6px 12px; border-radius: var(--r-md); border: 1px solid var(--line-2); background: var(--surface); font-size: .88rem; }
.pager span { color: var(--muted); border-color: var(--line); background: transparent; }

/* ---------- Small screens ---------- */
@media (max-width: 980px) {
  .layout, .grid2 { grid-template-columns: 1fr; }
  .guest { grid-template-columns: 1fr; }
  .guest-art { padding: 32px 24px; min-height: 0; gap: 28px; }
  .guest-art h1 { font-size: 1.7rem; }
}
@media (max-width: 860px) {
  .app { display: block; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 12px 14px; }
  .logo { padding: 0; }
  .logo img { width: 92px; }
  .nav { flex-direction: row; overflow-x: auto; flex: 1 1 100%; order: 3; padding-bottom: 2px; }
  .nav a { white-space: nowrap; padding: 7px 10px; }
  .nav a.on { box-shadow: none; }
  .nav .group { display: none; }
  .side-foot { margin: 0 0 0 auto; border: 0; padding: 0; display: flex; align-items: center; gap: 12px; }
  .who span:not(.avatar), .who .avatar { display: none; }
  .content { padding: 22px 16px 60px; }
  h1 { font-size: 1.45rem; }
  .figure { flex-basis: 45%; min-width: 0; padding: 14px 16px; border-bottom: 1px solid var(--line); }
  .tablewrap table { min-width: 680px; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn, .nav a, .gauge .fill { transition: background .15s ease, border-color .15s ease, width .4s ease; }
}

/* ---------- Admin: services ---------- */
.svc-row { display: grid; grid-template-columns: minmax(180px, 2fr) minmax(140px, 1.3fr) 90px 110px 150px auto auto; gap: 10px; align-items: center; padding: 10px 18px; border-top: 1px solid var(--line); }
.svc-row input, .svc-row select { margin: 0; }
.svc-used { white-space: nowrap; }
.svc-group { border: 0; padding: 0; margin: 0 0 14px; }
.svc-group legend { padding: 0; font-weight: 600; font-size: .88rem; color: var(--muted); margin-bottom: 6px; }
.svc-group .check { padding: 3px 0; }
@media (max-width: 980px) {
  .svc-row { grid-template-columns: 1fr 1fr; }
  .svc-row .svc-used { grid-column: 1 / -1; }
}

.label-row { display: flex; justify-content: space-between; align-items: baseline; }
.or { display: flex; align-items: center; gap: 12px; margin: 26px 0 14px; color: var(--muted); font-size: .85rem; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--line-2); }

/* Dashboards and team */
.dash-row { display: flex; align-items: center; gap: 14px; padding: 13px 24px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.dash-row:last-child { border-bottom: 0; }
.dash-row:hover { background: var(--bg-soft, #f4f7fc); }
.dash-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.dash-main b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-gauge { flex: 0 0 150px; }
.panel.flush .empty { padding: 28px 24px; text-align: center; color: var(--muted); }
.panel.flush .empty b { display: block; color: var(--ink, inherit); margin-bottom: 4px; }
.panel.flush table { width: 100%; }
.panel-head h2 { margin: 0; }
.levels-key { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-bottom: 22px; color: var(--muted); font-size: .9rem; }
.levels-key b { display: block; color: var(--ink, inherit); margin-bottom: 2px; }
.team-row { display: flex; align-items: center; gap: 14px; padding: 12px 24px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.team-row:last-child { border-bottom: 0; }
.team-actions { display: flex; gap: 8px; align-items: center; }
.team-actions input, .team-actions select { width: auto; max-width: 160px; margin: 0; }
@media (max-width: 900px) { .levels-key { grid-template-columns: 1fr; } .dash-gauge { flex-basis: 110px; } }
@media (max-width: 600px) { .dash-row { padding: 12px 16px; flex-wrap: wrap; } .dash-gauge { flex-basis: 100%; } }

.bulkbar { display: flex; gap: 10px; align-items: center; margin: 0 0 12px; flex-wrap: wrap; }
.bulkbar select { width: auto; margin: 0; }
td.chk, th.chk { width: 34px; padding-right: 0; }
.dash-assign { display: flex; gap: 6px; align-items: center; }
.dash-assign select { width: auto; max-width: 150px; margin: 0; }
