:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #16202b;
  --muted: #6b7a8c;
  --line: #dfe5ec;
  --brand: #12507a;
  --brand-ink: #ffffff;
  --accent: #0f9d76;
  --warn: #c8791a;
  --danger: #b6362f;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 32, 48, .06), 0 4px 14px rgba(16, 32, 48, .06);
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------------------------------------------------------------- layout */

.topbar {
  background: var(--brand);
  color: var(--brand-ink);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .brand { font-weight: 700; letter-spacing: .2px; display: flex; align-items: center; gap: 8px; }
.topbar .brand small { display: block; font-weight: 400; opacity: .8; font-size: 11px; letter-spacing: 0; }
.topbar .spacer { flex: 1; }
.topbar select, .topbar button.linkish {
  width: auto;
  max-width: 190px;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.25);
  color: #fff;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
}
.topbar select option { color: #16202b; }
.topbar .who { font-size: 13px; opacity: .95; text-align: right; line-height: 1.25; }
.topbar .who b { display: block; }

.tabs {
  display: flex;
  gap: 2px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 0 12px;
  position: sticky;
  top: 52px;
  z-index: 15;
  overflow-x: auto;
}
.tabs button {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 12px 14px;
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); }

.wrap { max-width: 1180px; margin: 0 auto; padding: 18px 16px 64px; }

/* ----------------------------------------------------------------- cards */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}
.panel h2 { margin: 0 0 4px; font-size: 17px; }
.panel h3 { margin: 0 0 10px; font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.meeting-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.meeting-head .grow { flex: 1; min-width: 200px; }
.weekchip {
  font-family: var(--mono);
  background: #eaf1f7;
  color: var(--brand);
  border-radius: 8px;
  padding: 6px 10px;
  font-weight: 700;
}

.stats { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.stat {
  background: #f7f9fb;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  min-width: 108px;
}
.stat b { display: block; font-size: 20px; line-height: 1.1; }
.stat span { font-size: 12px; color: var(--muted); }

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 860px) { .cols { grid-template-columns: 1fr; } }

.col-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.col-head h3 { margin: 0; }
.count { background: #eef2f6; color: var(--muted); border-radius: 20px; padding: 2px 9px; font-size: 12px; font-weight: 700; }

/* ----------------------------------------------------------------- items */

.item {
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: #fff;
}
.item.p1 { border-left-color: var(--danger); }
.item.p2 { border-left-color: var(--brand); }
.item.p3 { border-left-color: #b9c4d0; }
.item.opportunity.p2 { border-left-color: var(--accent); }
.item .t { font-weight: 600; cursor: pointer; }
.item .t:hover { text-decoration: underline; }
.item .meta { font-size: 12px; color: var(--muted); margin-top: 4px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.item .acts { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.item.done { opacity: .72; background: #f8faf9; }
.item.done .t { text-decoration: line-through; }

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  background: #eef2f6;
  color: var(--muted);
}
.badge.carried { background: #fdf1e0; color: var(--warn); }
.badge.high { background: #fbe9e8; color: var(--danger); }
.badge.done { background: #e6f5ef; color: var(--accent); }
.badge.prog { background: #e8f0f8; color: var(--brand); }

/* --------------------------------------------------------------- buttons */

button.btn {
  background: var(--brand);
  color: #fff;
  border: 1px solid var(--brand);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 600;
}
button.btn:hover { filter: brightness(1.08); }
button.btn.ghost { background: #fff; color: var(--brand); }
button.btn.ok { background: var(--accent); border-color: var(--accent); }
button.btn.sm { padding: 5px 10px; font-size: 13px; }
button.btn.grey { background: #fff; color: var(--muted); border-color: var(--line); }
button.btn.danger { background: #fff; color: var(--danger); border-color: #eccbc9; }
button.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------------------------------------------------------------- inputs */

label.field { display: block; margin-bottom: 10px; }
label.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=time],
select, textarea {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
textarea { min-height: 78px; resize: vertical; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }

/* ----------------------------------------------------------------- table */

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
tr:last-child td { border-bottom: none; }
.tablewrap { overflow-x: auto; }

/* ----------------------------------------------------------------- login */

.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; }
.login-card .logo { text-align: center; margin-bottom: 18px; }
.login-card .logo .lion { font-size: 40px; }
.login-card h1 { font-size: 21px; margin: 6px 0 2px; }

/* ----------------------------------------------------------------- modal */

.modal-bg {
  position: fixed; inset: 0; background: rgba(12, 22, 32, .45);
  display: grid; place-items: center; padding: 16px; z-index: 40;
}
.modal {
  background: #fff; border-radius: 12px; width: 100%; max-width: 620px;
  max-height: 88dvh; overflow: auto; box-shadow: 0 20px 50px rgba(0,0,0,.3);
}
.modal header { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.modal header h3 { margin: 0; flex: 1; font-size: 17px; }
.modal .body { padding: 18px; }
.modal footer { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.x { background: none; border: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { border-left: 2px solid var(--line); padding: 0 0 12px 12px; margin-left: 4px; position: relative; }
.timeline li::before {
  content: ''; position: absolute; left: -5px; top: 5px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--brand);
}
.timeline .who { font-size: 12px; color: var(--muted); }

/* ----------------------------------------------------------------- toast */

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 60; pointer-events: none;
}
#toast .t {
  background: #16202b; color: #fff; padding: 10px 16px; border-radius: 8px;
  margin-top: 8px; box-shadow: var(--shadow); font-size: 14px;
}
#toast .t.err { background: var(--danger); }

/* ------------------------------------------------- weekly personal sheet */

.planback {
  background: #fdf7ec;
  border: 1px solid #f0dfc2;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 14px;
}
.planback ul { margin: 6px 0 8px; padding-left: 20px; }
.planback li { margin-bottom: 2px; }

/* -------------------------------------------------- editable bullet lists */

.linebox {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfcfd;
}
.linebox .col-head { margin-bottom: 6px; }
.linebox .col-head h3 { font-size: 14px; }

ul.lines { list-style: none; margin: 0 0 8px; padding: 0; }
ul.lines li.line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  border-bottom: 1px dashed #e8edf2;
}
ul.lines li.line:last-child { border-bottom: none; }
ul.lines .tick { width: 17px; height: 17px; flex: 0 0 auto; cursor: pointer; accent-color: var(--accent); }
ul.lines .bullet, ul.lines .mark { flex: 0 0 auto; color: var(--muted); width: 17px; text-align: center; }
ul.lines input.txt {
  flex: 1;
  border: 1px solid transparent;
  background: transparent;
  padding: 4px 6px;
  border-radius: 6px;
}
ul.lines input.txt:hover { border-color: var(--line); background: #fff; }
ul.lines input.txt:focus { border-color: var(--brand); background: #fff; outline: none; }
ul.lines span.txt { flex: 1; padding: 4px 0; }
ul.lines li.done .txt { text-decoration: line-through; color: var(--muted); }
ul.lines li.done .mark { color: var(--accent); }
ul.lines .rm {
  border: none; background: none; color: #b9c4d0; font-size: 18px; line-height: 1;
  cursor: pointer; padding: 0 4px; flex: 0 0 auto;
}
ul.lines .rm:hover { color: var(--danger); }
ul.lines.read li.line { border-bottom: none; padding: 1px 0; }
ul.lines .badge.carried { flex: 0 0 auto; }

form.addline { display: flex; gap: 6px; }
form.addline input { flex: 1; }

.success {
  border-left: 4px solid var(--accent);
  background: #f3fbf8;
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 6px;
}

.sheetgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.sheetcard {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfcfd;
}
.sheetcard.submitted { background: #fff; border-color: #cfe0d9; }
.sheetcard-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.sheetcard .box { margin-bottom: 8px; }
.sheetcard .box > span {
  display: block; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .4px; color: var(--muted); margin-bottom: 2px;
}
.sheetcard .box > div { font-size: 13px; white-space: pre-wrap; }

/* ----------------------------------------------------------------- print */

/* The paper-style header. Hidden on screen, shown on every printout so the
   sheet always says who it belongs to and which week it covers. */
.printhead { display: none; }

@media print {
  .topbar, .tabs, .acts, button, a.btn, .addform, .planback, form.addline, .stats,
  .modal-bg, #toast { display: none !important; }

  /* an empty box should print empty, not show its grey hint text */
  ::placeholder { color: transparent !important; opacity: 0 !important; }

  body { background: #fff; font-size: 12px; }
  .wrap { padding: 0; max-width: none; }
  .panel { box-shadow: none; break-inside: avoid; border-color: #999; margin-bottom: 10px; }
  .sheetgrid { grid-template-columns: 1fr 1fr; }
  .sheetcard { break-inside: avoid; border-color: #999; }
  a[href]:after { content: ''; }

  /* inputs print as plain text, not as form fields */
  input.txt, textarea, input[type=text] {
    border: none !important;
    background: none !important;
    padding: 0 !important;
    font: inherit;
  }
  ul.lines .rm, ul.lines .tick { display: none !important; }
  /* the editable Last Week list prints as real tick boxes */
  ul.lines.edit.last li.line::before { content: '\2610'; margin-right: 6px; color: #444; }
  ul.lines.edit.last li.line.done::before { content: '\2611'; }

  .printhead {
    display: block;
    border: 2px solid #7d2b2b;
    border-radius: 6px;
    padding: 10px 14px;
    margin-bottom: 12px;
  }
  .printhead .ph-title {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -.5px;
    margin-bottom: 6px;
  }
  .printhead .ph-lion { float: right; font-size: 30px; }
  .printhead .ph-line { font-size: 13px; padding: 2px 0; border-bottom: 1px solid #ccc; }
  .printhead .ph-line:last-child { border-bottom: none; }
  .printhead .ph-line b { display: inline-block; min-width: 130px; }

  /* Printing the whole department agenda */
  body.print-team .panel.sheet { display: none; }

  /* Printing one person's own form */
  body.print-mine .panel.teamsheets,
  body.print-mine .printhead .ph-agenda { display: none; }
  body.print-mine .panel.sheet { display: block; }
  body.print-mine .linebox { border-color: #999; }
}
