/* ============================================================
   Cambridge East School Grants Tracker - base stylesheet
   British English throughout. No emojis. Hyphens only.
   ============================================================ */

:root {
  --orange: #f15a22;
  --orange-soft: #fde6dc;
  --maroon: #981b45;        /* primary ring colour on the school badge */
  --maroon-soft: #f3d9e1;
  --gold: #faa61a;
  --bg: #fafaf8;
  --surface: #ffffff;
  --border: #e8e6e0;
  --text: #1f1f1f;
  --text-muted: #6a6a6a;
  --green: #2d8f4e;
  --amber: #d99100;
  --red: #c0392b;
  --green-soft: #e3f1e7;
  --amber-soft: #faeed1;
  --red-soft: #f5dad6;
  --font-display: 'Fraunces', 'Cambria', Georgia, serif;
  --font-body: 'Inter', 'Calibri', 'Helvetica Neue', Arial, sans-serif;
  --radius: 6px;
  --shadow-1: 0 1px 2px rgba(0,0,0,0.04), 0 1px 3px rgba(0,0,0,0.06);
  --shadow-2: 0 4px 12px rgba(0,0,0,0.08);
  --transition: 150ms ease;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; margin: 0 0 0.6em; }
h1 { font-size: 28px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }

a { color: var(--orange); text-decoration: none; transition: opacity var(--transition); }
a:hover { opacity: 0.75; }

button {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 8px 14px;
  border-radius: var(--radius);
  transition: background var(--transition), border-color var(--transition);
}
button:hover { background: var(--bg); }
button.primary {
  background: var(--orange);
  color: #fff;
  border-color: var(--orange);
}
button.primary:hover { background: #d94d18; }
button.ghost { background: transparent; }

input, select, textarea {
  font: inherit;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--orange); outline-offset: -1px; }

/* ============================================================ */
/* Layout */
/* ============================================================ */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; opacity: 1; }
.topbar .brand:hover { opacity: 0.85; }
.topbar .logo-badge { height: 40px; width: 40px; }
.topbar .wordmark {
  display: inline-block;
  height: 26px;
  width: 170px;
  background-color: var(--maroon);
  -webkit-mask: url('wordmark.svg') no-repeat left center / contain;
  mask: url('wordmark.svg') no-repeat left center / contain;
}
.tabs { display: flex; gap: 4px; flex: 1; }
.tab {
  padding: 8px 14px;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  transition: color var(--transition), border-color var(--transition);
  cursor: pointer;
}
.tab.active { color: var(--text); border-bottom-color: var(--orange); }
.search { min-width: 220px; }

.main { padding: 24px; max-width: 1280px; margin: 0 auto; width: 100%; }

/* ============================================================ */
/* Cards */
/* ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-1);
}
.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.summary-card .label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.summary-card .value { font-family: var(--font-display); font-size: 28px; font-weight: 600; margin-top: 4px; }

/* ============================================================ */
/* Status pills */
/* ============================================================ */
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.amber { background: var(--amber-soft); color: var(--amber); }
.pill.red { background: var(--red-soft); color: var(--red); }
.pill.neutral { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; vertical-align: middle; margin-right: 6px; }
.dot.green { background: var(--green); }
.dot.amber { background: var(--amber); }
.dot.red { background: var(--red); }

/* ============================================================ */
/* Tables */
/* ============================================================ */
table.grants { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
table.grants th, table.grants td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
table.grants th { background: var(--bg); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
table.grants tr { cursor: pointer; transition: background var(--transition); }
table.grants tr:hover td { background: var(--bg); }

/* ============================================================ */
/* Side panel */
/* ============================================================ */
.panel { position: fixed; top: 0; right: 0; width: 480px; max-width: 100vw; height: 100vh; background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-2); overflow-y: auto; padding: 24px; z-index: 50; }
.panel-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.2); z-index: 40; }

/* ============================================================ */
/* Banner */
/* ============================================================ */
.banner { background: var(--amber-soft); border: 1px solid var(--amber); color: var(--amber); padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; display: flex; gap: 12px; align-items: center; }
.banner button { margin-left: auto; }

/* ============================================================ */
/* Verification flag */
/* ============================================================ */
.flag-confirm { color: var(--red); margin-left: 6px; font-size: 12px; }

/* ============================================================ */
/* Filters */
/* ============================================================ */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; align-items: center; }
.chip {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  background: var(--surface);
  cursor: pointer;
  transition: all var(--transition);
}
.chip.active { background: var(--orange); color: #fff; border-color: var(--orange); }

/* ============================================================ */
/* Calendar / gantt timeline */
/* ============================================================ */
.cal-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.cal-toolbar .legend { display: flex; gap: 12px; align-items: center; font-size: 12px; color: var(--text-muted); }
.cal-toolbar .legend span.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 2px; margin-right: 4px; vertical-align: -2px; }

.cal-grid {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.cal-months {
  display: grid;
  grid-template-columns: 240px 1fr;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.cal-months .cal-month-cell { padding: 8px 12px; border-right: 1px solid var(--border); }
.cal-months .cal-month-row { display: grid; }
.cal-row {
  display: grid;
  grid-template-columns: 240px 1fr;
  border-bottom: 1px solid var(--border);
  min-height: 44px;
  position: relative;
}
.cal-row:last-child { border-bottom: 0; }
.cal-row .cal-label {
  padding: 10px 12px;
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 2px;
  cursor: pointer;
  transition: background var(--transition);
}
.cal-row .cal-label:hover { background: var(--bg); }
.cal-row .cal-label .funder { font-weight: 600; font-size: 14px; color: var(--text); }
.cal-row .cal-label .grant-name { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-track { position: relative; background: repeating-linear-gradient(90deg, transparent 0, transparent calc(100%/26 - 1px), var(--border) calc(100%/26 - 1px), var(--border) calc(100%/26)); }
.cal-bar {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 22px;
  border-radius: 4px;
  background: var(--maroon-soft);
  border: 1px solid var(--maroon);
  display: flex;
  align-items: center;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  transition: filter var(--transition);
}
.cal-bar:hover { filter: brightness(0.96); }
.cal-bar .cal-progress {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--maroon) 0%, var(--maroon) var(--pct, 0%), transparent var(--pct, 0%));
  opacity: 0.25;
  border-radius: 3px;
  pointer-events: none;
}
.cal-bar .cal-bar-text { position: relative; z-index: 1; color: var(--maroon); }
.cal-bar.status-drafting { background: var(--amber-soft); border-color: var(--amber); }
.cal-bar.status-drafting .cal-bar-text { color: var(--amber); }
.cal-bar.status-drafting .cal-progress { background: linear-gradient(90deg, var(--amber) 0%, var(--amber) var(--pct, 0%), transparent var(--pct, 0%)); }
.cal-bar.status-submitted, .cal-bar.status-awarded, .cal-bar.status-partial { background: var(--green-soft); border-color: var(--green); }
.cal-bar.status-submitted .cal-bar-text, .cal-bar.status-awarded .cal-bar-text, .cal-bar.status-partial .cal-bar-text { color: var(--green); }
.cal-bar.status-submitted .cal-progress, .cal-bar.status-awarded .cal-progress, .cal-bar.status-partial .cal-progress { background: linear-gradient(90deg, var(--green) 0%, var(--green) var(--pct, 0%), transparent var(--pct, 0%)); }
.cal-bar.status-declined, .cal-bar.status-withdrawn, .cal-bar.status-not-eligible { background: #efefef; border-color: #b8b8b8; opacity: 0.6; }
.cal-bar.status-declined .cal-bar-text, .cal-bar.status-withdrawn .cal-bar-text, .cal-bar.status-not-eligible .cal-bar-text { color: var(--text-muted); }
.cal-bar.overdue { border-color: var(--red); }
.cal-bar.overdue .cal-bar-text { color: var(--red); }
.cal-bar-deadline {
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
  background: var(--red);
  z-index: 2;
}
.cal-bar-deadline::after {
  content: '';
  position: absolute;
  top: 50%; transform: translate(-50%, -50%);
  left: 50%;
  width: 9px; height: 9px;
  background: var(--red);
  transform: translate(-50%, -50%) rotate(45deg);
}
.cal-today-line {
  position: absolute;
  top: 0; bottom: 0;
  width: 1px;
  background: var(--orange);
  z-index: 3;
  pointer-events: none;
}
.cal-today-line::before {
  content: 'Today';
  position: absolute;
  top: -16px;
  left: -16px;
  font-size: 10px;
  font-weight: 600;
  color: var(--orange);
}
.cal-empty { padding: 32px; text-align: center; color: var(--text-muted); }

/* ============================================================ */
/* Mobile */
/* ============================================================ */
@media (max-width: 720px) {
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .tabs { overflow-x: auto; }
  .panel { width: 100vw; }
  table.grants { display: block; overflow-x: auto; }
}
