/* =====================================================================
   styles.css: the look and feel of the whole app
   Colours are stored once as "variables" at the top (the :root block),
   so changing a brand colour here changes it everywhere.
   ===================================================================== */

:root {
  --navy:        #3b3c86;   /* sidebar */
  --navy-line:   #4a4b94;   /* thin lines inside the sidebar */
  --navy-text:   #d6d7ef;   /* soft text on navy */
  --yellow:      #e8b649;   /* active menu item, highlights */
  --primary:     #3b3c86;   /* main buttons */
  --primary-hover:#2f3070;

  --bg:          #f7f8fb;   /* page background */
  --card:        #ffffff;
  --border:      #e6e8ef;
  --text:        #14151a;
  --muted:       #6b7280;
  --danger:      #c2410c;

  --radius:      14px;
  --radius-sm:   8px;
  --shadow:      0 1px 2px rgba(20, 21, 26, 0.04);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

/* Anything marked "hidden" in the HTML stays hidden, even if another
   style (like .button) gives it a display value */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
}

.icon { width: 20px; height: 20px; flex-shrink: 0; }

/* ---------- App frame: sidebar on the left, content on the right ---------- */
.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 22px 20px;
  border-bottom: 1px solid var(--navy-line);
}
.brand-logo-panel {
  background: #fff;
  border-radius: 10px;
  padding: 10px 14px;
  align-self: flex-start;
}
.brand-logo { height: 34px; width: auto; display: block; }
.brand-name { font-weight: 700; font-size: 18px; }
.brand-sub  { color: var(--navy-text); font-size: 13px; letter-spacing: 0.02em; }

.nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px 12px;
  flex: 1;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--navy-text);
  text-decoration: none;
  font-size: 15px;
}
.nav-item:hover  { background: rgba(255, 255, 255, 0.08); color: #fff; }
.nav-item.active {
  background: #fff;
  color: var(--navy);
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--navy-line);
}
.avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: #2f9e6e;
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 14px;
}
.user-text { flex: 1; min-width: 0; }
.user-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 12px; color: var(--navy-text); }

.icon-button {
  background: none; border: 0; cursor: pointer;
  color: var(--navy-text); padding: 6px; border-radius: 6px;
}
.icon-button:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }

/* ---------- Main content ---------- */
.main { padding: 32px 40px; }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 28px;
}
.page-title    { margin: 0; font-size: 26px; font-weight: 700; }
.page-subtitle { margin: 6px 0 0; color: var(--muted); }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

/* ---------- Buttons ---------- */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px;
  border: 0; border-radius: var(--radius-sm);
  font: inherit; font-weight: 600;
  cursor: pointer;
  background: var(--primary); color: #fff;
}
.button:hover    { background: var(--primary-hover); }
.button:disabled { opacity: 0.6; cursor: not-allowed; }
.button .icon    { width: 18px; height: 18px; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.field label { font-weight: 600; font-size: 14px; }
.field input {
  font: inherit;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
}
.field input:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }

.message {
  background: #fff4ec;
  color: var(--danger);
  border: 1px solid #fed7aa;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  margin-bottom: 18px;
}

/* ---------- Login page ---------- */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--navy);
  padding: 24px;
}
.login-card { width: 100%; max-width: 400px; padding: 36px; }
.login-brand { text-align: center; margin-bottom: 28px; }
.login-brand img { height: 44px; margin-bottom: 12px; }
.login-brand h1 { margin: 0; font-size: 22px; }
.login-brand p  { margin: 6px 0 0; color: var(--muted); }
.login-card .button { width: 100%; margin-top: 6px; }

/* Shown while the page checks who is signed in */
.loading { color: var(--muted); }

/* =====================================================================
   Step 6: claims list
   ===================================================================== */

/* ---------- Stat cards ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.stat { display: flex; align-items: center; gap: 16px; padding: 20px; }
.stat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: grid; place-items: center; flex-shrink: 0;
}
.stat-icon .icon { width: 24px; height: 24px; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: 14px; margin-top: 2px; }

.tone-blue   { background: #e8efff; color: #3b63d1; }
.tone-yellow { background: #fdf6dc; color: #b8860b; }
.tone-orange { background: #fdeee2; color: #d9661f; }
.tone-green  { background: #e4f6ea; color: #23925a; }
.tone-navy   { background: #ebebf6; color: var(--navy); }

/* ---------- Search and filters ---------- */
.filters {
  display: grid;
  grid-template-columns: 1fr 190px 220px 170px;
  gap: 14px;
  padding: 16px;
  margin-bottom: 20px;
}
.search { position: relative; }
.search .icon {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--muted);
}
.search input, .filters select {
  width: 100%;
  font: inherit;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
}
.search input { padding-left: 40px; }
.search input:focus, .filters select:focus { outline: 2px solid var(--primary); outline-offset: -1px; }

/* ---------- Table ---------- */
.table-card { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  font-size: 12px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--muted);
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr[data-id] { cursor: pointer; }
.table tbody tr[data-id]:hover { background: #fafbfd; }
.table .actions { text-align: center; width: 70px; }
.table .icon-button { color: var(--muted); }
.table .icon-button:hover { color: var(--navy); background: #ebebf6; }

.empty { text-align: center; color: var(--muted); padding: 48px 16px !important; }
.error { color: var(--danger); }
.strong { font-weight: 600; }
.small  { font-size: 13px; margin-top: 2px; }
.muted  { color: var(--muted); }
.nowrap { white-space: nowrap; }
.overdue { color: var(--danger); font-weight: 600; }
.result-count { padding: 12px 16px; font-size: 13px; color: var(--muted); }

/* ---------- Badges (status, priority, type) ---------- */
.badge {
  display: inline-block;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 13px; font-weight: 600;
  white-space: nowrap;
}
.badge-type      { background: #f1ecfd; color: #6d3fd1; }

.status-open     { background: #e8efff; color: #3b63d1; }
.status-assigned { background: #ebebf6; color: var(--navy); }
.status-delayed  { background: #fdeee2; color: #c2410c; }
.status-resolved { background: #e4f6ea; color: #1d7a4b; }
.status-reopened { background: #fdf6dc; color: #94690a; }
.status-rejected { background: #eef0f3; color: #4b5563; }

.priority-urgent { background: #dc3c3c; color: #fff; }
.priority-high   { background: #ec7a32; color: #fff; }
.priority-medium { background: #e8b649; color: #fff; }
.priority-low    { background: #eef0f3; color: #4b5563; }

/* ---------- Toast (short message at the bottom) ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff;
  padding: 12px 20px; border-radius: var(--radius-sm);
  font-size: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

/* ---------- Smaller screens ---------- */
@media (max-width: 1280px) {
  .stats   { grid-template-columns: repeat(3, 1fr); }
  .filters { grid-template-columns: 1fr 1fr 1fr; }
  .search  { grid-column: 1 / -1; }
}

/* =====================================================================
   Step 7: pop-up window (dialog) and the Register Claim form
   ===================================================================== */
.dialog {
  width: min(680px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  border: 0;
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: 0 24px 64px rgba(20, 21, 26, 0.25);
}
.dialog::backdrop { background: rgba(20, 21, 26, 0.45); }
.dialog:focus { outline: none; }

.dialog-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.dialog-header h2 { margin: 0; font-size: 22px; }
.dialog-header p  { margin: 6px 0 0; }
.close-button {
  background: none; border: 0; cursor: pointer;
  font-size: 28px; line-height: 1; color: var(--muted); padding: 0 4px;
}
.close-button:hover { color: var(--text); }

.form-section {
  font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); margin: 8px 0 12px;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.span-2 { grid-column: 1 / -1; }

.field select, .field textarea {
  font: inherit;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
}
.field textarea { resize: vertical; }
.field select:focus, .field textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }

.hint {
  background: #ebebf6; color: var(--navy);
  border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: 14px;
  margin: -6px 0 18px;
}

.dialog-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 8px; }
.button-secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.button-secondary:hover { background: var(--bg); }

/* =====================================================================
   Step 8: Claim Details window
   ===================================================================== */
.dialog-wide { width: min(860px, calc(100vw - 32px)); }
.badge-row { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

.panel {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 16px;
}
.panel-plain { background: none; padding: 8px 0 0; border-top: 1px solid var(--border); border-radius: 0; margin-top: 8px; }
.panel h3 { margin: 0 0 14px; font-size: 17px; }
.panel-plain h3 { margin-top: 12px; }

.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 20px; }
.info-grid .span-2 { grid-column: span 2; }
.info-label { color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.description {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px 16px; white-space: pre-wrap; line-height: 1.5;
}

.control-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 14px; margin-top: 12px; }
.field select:disabled, .field textarea:disabled { background: var(--bg); color: var(--muted); cursor: not-allowed; }

.count {
  display: inline-block; min-width: 22px; padding: 1px 7px; margin-left: 6px;
  border-radius: 999px; background: #ebebf6; color: var(--navy);
  font-size: 13px; text-align: center;
}

.timeline { list-style: none; margin: 0 0 16px; padding: 0; }
.timeline li { border-left: 3px solid var(--yellow); padding: 4px 0 12px 14px; }
.timeline-meta { font-size: 13px; color: var(--muted); }
.timeline-meta strong { color: var(--text); }
.timeline-text { margin-top: 4px; white-space: pre-wrap; line-height: 1.5; }

.followup-form .field { margin-bottom: 10px; }
.followup-actions { display: flex; justify-content: flex-end; gap: 10px; }
.followup-actions select {
  font: inherit; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: #fff;
}

.history { list-style: none; margin: 0; padding: 0; }
.history li { padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.history li:last-child { border-bottom: 0; }
.history .small { display: inline-block; min-width: 140px; }

@media (max-width: 760px) {
  .info-grid, .control-grid { grid-template-columns: 1fr 1fr; }
}

/* =====================================================================
   Password reset and notices
   ===================================================================== */
.notice {
  background: #e4f6ea;
  color: #1d7a4b;
  border: 1px solid #bfe6cc;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  margin-bottom: 18px;
}
.login-switch { text-align: center; margin: 18px 0 0; font-size: 14px; }
.login-switch a { color: var(--navy); font-weight: 600; text-decoration: none; }
.login-switch a:hover { text-decoration: underline; }
.field-help { font-size: 13px; color: var(--muted); }

/* =====================================================================
   Staff and Settings pages
   ===================================================================== */
.filters-staff { grid-template-columns: 1fr 220px auto; align-items: center; }
.checkbox { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); white-space: nowrap; }
.checkbox input { width: 16px; height: 16px; }

.button-small { padding: 7px 14px; font-size: 14px; }
.row-inactive td { opacity: 0.55; }
.row-inactive td.actions { opacity: 1; }

.role-cso        { background: #e8efff; color: #3b63d1; }
.role-supervisor { background: #fdf6dc; color: #94690a; }
.role-manager    { background: #e4f6ea; color: #1d7a4b; }
.role-admin      { background: #ebebf6; color: var(--navy); }

.dialog-actions.spread { justify-content: space-between; align-items: center; }
.dialog-actions .dialog-actions { margin-top: 0; }

/* Tabs */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab {
  background: none; border: 0; cursor: pointer;
  font: inherit; font-weight: 600; color: var(--muted);
  padding: 10px 16px; border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--navy); border-bottom-color: var(--navy); }
.settings-help { margin: 0 0 16px; font-size: 14px; }

/* Editable table cells */
.settings-table td { padding: 10px 16px; }
.settings-table .center { text-align: center; }
.settings-table input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }
.cell-input {
  width: 100%; font: inherit; font-size: 14px;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff;
}
.cell-input:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.cell-number { max-width: 110px; }
.settings-table .actions { width: 100px; }
.add-row td { background: #fafbfd; }

/* =====================================================================
   Step 10: public claim form
   ===================================================================== */
.public-page { background: var(--bg); padding: 32px 16px; }
.public-card { max-width: 760px; margin: 0 auto; padding: 36px; }
.public-brand { display: flex; align-items: center; gap: 20px; margin-bottom: 24px; }
.public-brand img { height: 48px; }
.public-brand h1 { margin: 0; font-size: 24px; }
.public-brand p { margin: 4px 0 0; }
.public-submit { width: 100%; margin-top: 8px; padding: 14px; font-size: 16px; }
.trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.public-done { text-align: center; padding: 20px 0 8px; }
.public-done h2 { margin: 12px 0 18px; }
.done-icon {
  width: 64px; height: 64px; margin: 0 auto; border-radius: 50%;
  background: #e4f6ea; color: #1d7a4b; display: grid; place-items: center;
  font-size: 32px; font-weight: 700;
}
.claim-number { font-size: 40px; font-weight: 700; color: var(--navy); margin: 4px 0 14px; letter-spacing: 0.02em; }

@media (max-width: 640px) {
  .public-card { padding: 22px; }
  .public-brand { flex-direction: column; align-items: flex-start; gap: 12px; }
  .form-grid { grid-template-columns: 1fr; }
}

/* =====================================================================
   Step 11: analytics
   ===================================================================== */
.period-select {
  font: inherit; font-weight: 600; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff;
}
.stats-6 { grid-template-columns: repeat(6, 1fr); }
.stat-plain { padding: 18px 20px; }
.stat-plain .stat-value { font-size: 26px; }

.chart-card { margin-bottom: 20px; }
.chart-title { margin: 0 0 18px; font-size: 17px; }
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.chart-grid .chart-card { margin-bottom: 20px; }
.chart-small { max-width: 640px; }
.chart-note { font-size: 13px; color: var(--muted); margin: 12px 0 0; }

/* Vertical bars (claims over time) */
.col-chart { display: flex; gap: 10px; height: 220px; margin-bottom: 34px; }
.col-axis {
  display: flex; flex-direction: column; justify-content: space-between;
  font-size: 12px; color: var(--muted); text-align: right; min-width: 24px;
  margin: -7px 0 -7px;      /* centre the top and bottom numbers on their lines */
}
.col-bars {
  flex: 1; display: flex; align-items: stretch; gap: 2px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(var(--border), var(--border)) top / 100% 1px no-repeat;
}
.col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; min-width: 0; cursor: default; }
.col-bar { background: var(--navy); border-radius: 4px 4px 0 0; min-height: 0; max-width: 48px; width: 100%; margin: 0 auto; }
.col:hover .col-bar { background: var(--primary-hover); }
.col-label { height: 22px; margin-bottom: -23px; font-size: 11px; color: var(--muted); text-align: center; white-space: nowrap; padding-top: 6px; }

/* Horizontal bars (per service, per type) */
.bar-row { display: grid; grid-template-columns: 170px 1fr 40px; align-items: center; gap: 12px; padding: 6px 0; }
.bar-name { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 14px; }
.bar-fill { height: 100%; background: var(--navy); border-radius: 0 4px 4px 0; min-width: 2px; }
.bar-row:hover .bar-fill { background: var(--primary-hover); }
.bar-value { font-size: 14px; font-weight: 600; text-align: right; }

.table-compact th, .table-compact td { padding: 11px 14px; }
.num { text-align: right; white-space: nowrap; }

.chart-tip {
  position: fixed; z-index: 10; pointer-events: none;
  background: var(--text); color: #fff; font-size: 13px;
  padding: 7px 10px; border-radius: 6px; box-shadow: 0 6px 18px rgba(0,0,0,0.18);
}

@media (max-width: 1280px) {
  .stats-6 { grid-template-columns: repeat(3, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
}
