/*  Client Complaint System - one stylesheet, no framework.
    Colours follow the company brand: deep teal, with severity carrying its
    own colour so an overdue critical complaint is visible from across a desk. */

:root {
  --brand: #0E5D74;
  --brand-dark: #0A4557;
  --accent: #0EA5D6;
  --ink: #101828;
  --ink-2: #344054;
  --muted: #667085;
  --line: #E4E7EC;
  --bg: #F5F7F9;
  --card: #FFFFFF;
  --ok: #067647;
  --ok-bg: #ECFDF3;
  --warn: #B45309;
  --warn-bg: #FFFAEB;
  --bad: #B42318;
  --bad-bg: #FEF3F2;
  --info-bg: #EFF8FF;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--brand); }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 14px; }

/* ------------------------------------------------------------- sign in -- */

.signin-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, var(--brand-dark), var(--brand) 55%, #0B7A94);
  padding: 24px;
}
.signin {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 24px 48px rgba(10, 69, 87, .28);
}
.signin .logo {
  width: 46px; height: 46px; border-radius: 12px;
  background: var(--brand); color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 18px; margin-bottom: 16px;
}
.signin h1 { font-size: 19px; }
.signin p.sub { margin: 4px 0 22px; color: var(--muted); font-size: 13px; }

/* -------------------------------------------------------------- layout -- */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: var(--brand-dark);
  color: #D3E4EA;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px 18px;
  color: #fff;
}
.sidebar .brand .mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--accent); display: grid; place-items: center;
  font-weight: 700; color: #04303C;
}
.sidebar .brand b { font-size: 14px; display: block; line-height: 1.2; }
.sidebar .brand span { font-size: 11px; opacity: .7; }

.sidebar nav a {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 9px 12px; border-radius: 9px;
  color: #C6DCE4; text-decoration: none; font-size: 13.5px;
}
.sidebar nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.sidebar nav a.on { background: var(--brand); color: #fff; font-weight: 600; }
.sidebar nav .sep {
  margin: 14px 12px 6px; font-size: 10.5px; letter-spacing: .8px;
  text-transform: uppercase; opacity: .55;
}
.sidebar .foot { margin-top: auto; padding: 14px 12px 4px; font-size: 12px; opacity: .75; }
.sidebar .foot b { color: #fff; display: block; font-size: 13px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 14px 24px;
  display: flex; align-items: center; gap: 14px;
  position: sticky; top: 0; z-index: 20;
}
.topbar .grow { flex: 1; }
.content { padding: 22px 24px 60px; max-width: 1240px; width: 100%; }

/* --------------------------------------------------------------- cards -- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}
.card > h2 { margin-bottom: 4px; }
.card > .hint { color: var(--muted); font-size: 12.5px; margin: 0 0 14px; }

.grid { display: grid; gap: 14px; }
.grid.k2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.k3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.k4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.side { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }

.tile {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
}
.tile .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.tile .v { font-size: 26px; font-weight: 650; margin-top: 2px; letter-spacing: -.02em; }
.tile .s { font-size: 12px; color: var(--muted); }
.tile.bad .v { color: var(--bad); }
.tile.warn .v { color: var(--warn); }
.tile.ok .v { color: var(--ok); }
.tile.link { cursor: pointer; }
.tile.link:hover { border-color: var(--accent); }

/* ------------------------------------------------------------ controls -- */

label.f { display: block; margin-bottom: 12px; }
label.f > span {
  display: block; font-size: 12.5px; color: var(--ink-2);
  margin-bottom: 5px; font-weight: 500;
}
label.f > span em { color: var(--muted); font-style: normal; font-weight: 400; }

input[type=text], input[type=password], input[type=email], input[type=date],
input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 9px 11px; font: inherit; color: var(--ink);
  background: #fff; border: 1px solid #D0D5DD; border-radius: 9px;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(14, 165, 214, .16);
}
textarea { min-height: 96px; resize: vertical; line-height: 1.55; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #667085 50%), linear-gradient(135deg, #667085 50%, transparent 50%); background-position: calc(100% - 16px) 17px, calc(100% - 11px) 17px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 30px; }

.check { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 9px; font-size: 13px; }
.check input { margin-top: 2px; }

button, .btn {
  font: inherit; font-weight: 550; cursor: pointer;
  padding: 9px 15px; border-radius: 9px; border: 1px solid transparent;
  background: var(--brand); color: #fff; text-decoration: none;
  display: inline-flex; align-items: center; gap: 7px;
}
button:hover, .btn:hover { background: var(--brand-dark); }
button:disabled { opacity: .55; cursor: not-allowed; }
button.ghost, .btn.ghost { background: #fff; color: var(--ink-2); border-color: #D0D5DD; }
button.ghost:hover, .btn.ghost:hover { background: #F9FAFB; }
button.danger { background: var(--bad); }
button.danger:hover { background: #912018; }
button.small, .btn.small { padding: 6px 11px; font-size: 12.5px; }
button.link { background: none; color: var(--brand); padding: 0; border: 0; font-weight: 500; }
button.link:hover { background: none; text-decoration: underline; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }

/* --------------------------------------------------------------- table -- */

.tablewrap { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted); font-weight: 600; padding: 10px 12px;
  border-bottom: 1px solid var(--line); white-space: nowrap; background: #FCFCFD;
}
td { padding: 11px 12px; border-bottom: 1px solid #F2F4F7; vertical-align: top; }
tbody tr:hover { background: #FBFDFE; }
tbody tr.click { cursor: pointer; }
td.num, th.num { text-align: right; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }

/* -------------------------------------------------------------- badges -- */

.pill {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: #F2F4F7; color: var(--ink-2);
}
.pill.critical { background: var(--bad-bg); color: var(--bad); }
.pill.high { background: #FFF4ED; color: #C2410C; }
.pill.medium { background: var(--warn-bg); color: var(--warn); }
.pill.low { background: var(--info-bg); color: #175CD3; }
.pill.new { background: var(--info-bg); color: #175CD3; }
.pill.assigned { background: #F4F3FF; color: #5925DC; }
.pill.in_progress { background: #F4F3FF; color: #5925DC; }
.pill.awaiting_client { background: var(--warn-bg); color: var(--warn); }
.pill.resolved { background: var(--ok-bg); color: var(--ok); }
.pill.closed { background: #F2F4F7; color: var(--muted); }
.pill.reopened { background: var(--bad-bg); color: var(--bad); }
.pill.overdue { background: var(--bad); color: #fff; }
.pill.sent { background: var(--ok-bg); color: var(--ok); }
.pill.queued { background: var(--info-bg); color: #175CD3; }
.pill.failed { background: var(--bad-bg); color: var(--bad); }
.pill.skipped { background: var(--warn-bg); color: var(--warn); }

/* ------------------------------------------------------------- notices -- */

.notice {
  border-radius: 10px; padding: 11px 14px; font-size: 13px; margin-bottom: 14px;
  border: 1px solid transparent;
}
.notice.err { background: var(--bad-bg); color: var(--bad); border-color: #FECDCA; }
.notice.ok { background: var(--ok-bg); color: var(--ok); border-color: #ABEFC6; }
.notice.warn { background: var(--warn-bg); color: #93370D; border-color: #FEDF89; }
.notice.info { background: var(--info-bg); color: #175CD3; border-color: #B2DDFF; }
.notice b { font-weight: 650; }

#toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 100;
  display: flex; flex-direction: column; gap: 8px; max-width: 380px;
}
#toast div {
  background: var(--ink); color: #fff; padding: 11px 15px; border-radius: 10px;
  font-size: 13px; box-shadow: 0 12px 24px rgba(16, 24, 40, .22);
}
#toast div.err { background: var(--bad); }
#toast div.ok { background: var(--ok); }

/* ------------------------------------------------------------ timeline -- */

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  position: relative; padding: 0 0 18px 22px;
  border-left: 2px solid var(--line); margin-left: 6px;
}
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before {
  content: ""; position: absolute; left: -7px; top: 3px;
  width: 12px; height: 12px; border-radius: 50%;
  background: #fff; border: 2px solid var(--muted);
}
.timeline li.created::before { border-color: var(--brand); }
.timeline li.status::before { border-color: var(--accent); }
.timeline li.assigned::before { border-color: #5925DC; }
.timeline li.note::before { border-color: var(--warn); }
.timeline li.email::before { border-color: var(--ok); }
.timeline li.email_skipped::before { border-color: var(--bad); }
.timeline li.photo::before { border-color: #5925DC; }
.timeline li.client_mail::before { border-color: var(--brand); background: var(--brand); }
.timeline li.client_mail_skipped::before { border-color: var(--bad); }
.timeline .when { font-size: 11.5px; color: var(--muted); }
.timeline .what { white-space: pre-wrap; }
.timeline .who { font-size: 12px; color: var(--muted); }

/* ---------------------------------------------------------------- misc -- */

.kv { display: grid; grid-template-columns: 130px 1fr; gap: 7px 12px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.bar { height: 8px; border-radius: 999px; background: #EAECF0; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand); }

/* ------------------------------------------------------------- pictures -- */

.thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.thumb { margin: 0; }
.thumb a { display: block; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: #F9FAFB; }
.thumb a:hover { border-color: var(--accent); }
/* A fixed box with cover cropping: photos come off phones in every shape,
   and a ragged grid makes them hard to scan. */
.thumb img { display: block; width: 100%; height: 118px; object-fit: cover; }
.thumb .filecard {
  height: 118px; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 6px; padding: 8px; text-align: center;
}
.thumb .filecard b {
  background: var(--bad-bg); color: var(--bad); padding: 3px 8px;
  border-radius: 6px; font-size: 12px;
}
.thumb .filecard span { font-size: 11px; color: var(--muted); word-break: break-all; line-height: 1.3; }
.thumb figcaption {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11.5px; color: var(--muted); padding: 5px 2px 0;
}

input[type=file] {
  font: inherit; font-size: 13px; color: var(--ink-2);
  border: 1px dashed #D0D5DD; border-radius: 9px; padding: 10px; width: 100%;
  background: #FCFCFD;
}
input[type=file]:hover { border-color: var(--accent); }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty b { display: block; color: var(--ink-2); margin-bottom: 4px; font-size: 15px; }

.quote {
  white-space: pre-wrap; background: #F9FAFB; border-left: 3px solid var(--brand);
  padding: 11px 13px; border-radius: 0 8px 8px 0; margin: 0;
}

.spark { display: flex; align-items: flex-end; gap: 3px; height: 60px; }
.spark i { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; }

@media (max-width: 980px) {
  .grid.k4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.k3, .grid.k2, .grid.side { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; width: 100%; flex: none; }
  .app { flex-direction: column; }
  .sidebar nav { display: flex; flex-wrap: wrap; gap: 4px; }
}
