/* Red Folder — the one design system for every page of redfolder.uk.
   Same look as the earlier ATL apps: warm grey page, white cards, black
   primary buttons, ATL red for danger and the brand. */
* { box-sizing: border-box; }
:root {
  --bg: #f5f4f0;
  --card: #ffffff;
  --red: #ba1f1f;
  --red-dark: #951717;
  --red-soft: #fdecec;
  --text: #101014;
  --muted: #5e5e66;
  --line: #d9d9de;
  --soft: #f1f1f3;
  --green: #146b38;
  --green-soft: #e3f3e9;
  --amber: #8a5a00;
  --amber-soft: #fff3d6;
  --shadow-card: 0 2px 8px rgba(16, 16, 20, 0.1), 0 1px 2px rgba(16, 16, 20, 0.05);
  --shadow-pop: 0 12px 30px rgba(0, 0, 0, 0.16);
  --radius: 20px;
  --radius-sm: 12px;
  --gutter: 16px;
  --header-h: 64px;
}
html { background: var(--bg); overflow-x: hidden; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
img { max-width: 100%; }
a { color: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 12px; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #1a73e8; outline-offset: 2px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- shell: header + main ---- */
.rf-header {
  position: sticky; top: 0; z-index: 30; height: var(--header-h);
  display: flex; align-items: center; gap: 12px; padding: 0 var(--gutter);
  background: #fff; border-bottom: 1px solid var(--line);
}
.rf-back {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 12px 0 10px; border: 1px solid var(--line); border-radius: 999px;
  background: #fff; color: var(--text); text-decoration: none; font-weight: 700; font-size: .92rem; flex-shrink: 0;
}
.rf-back svg { width: 18px; height: 18px; }
.rf-back:hover { background: var(--soft); }
.rf-header .rf-logo { height: 36px; width: auto; display: block; }
.rf-header .rf-home { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; }
.rf-header .rf-title { font-weight: 700; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rf-header .rf-spacer { flex: 1; }
@media (max-width: 520px) {
  .rf-back span { display: none; }
  .rf-back { padding: 0; width: 40px; }
  .rf-header .rf-title { display: none; }
}
.rf-account { position: relative; }
.rf-account > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; font-weight: 700; font-size: .92rem;
}
.rf-account > summary::-webkit-details-marker { display: none; }
.rf-account-panel {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 240px; padding: 8px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-pop);
}
.rf-account-panel p { margin: 6px 10px 10px; font-size: .88rem; }
main.rf-main { width: 100%; max-width: 1120px; margin: 0 auto; padding: 20px var(--gutter) 48px; }
.rf-banner { margin: 0 0 16px; padding: 12px 14px; border-radius: var(--radius-sm); font-weight: 600; }
.rf-banner.warn { background: var(--amber-soft); color: var(--amber); }
.rf-banner.bad { background: var(--red-soft); color: var(--red-dark); }
.rf-banner.good { background: var(--green-soft); color: var(--green); }
.rf-offline { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 60; padding: 8px 14px; border-radius: 999px; background: #18181b; color: #fff; font-size: .88rem; font-weight: 700; }

/* ---- cards, layout ---- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-card); padding: 20px; margin: 0 0 16px; }
.card > :last-child { margin-bottom: 0; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 0 0 16px; }
.page-head h1 { margin: 0; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }

/* ---- home tiles ---- */
.section-title { margin: 28px 0 12px; font-size: 1.05rem; font-weight: 800; letter-spacing: -0.01em; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.tile {
  display: flex; flex-direction: column; gap: 6px; min-height: 120px; padding: 18px;
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-card);
  text-decoration: none; color: var(--text); border: 2px solid transparent;
}
.tile:hover { border-color: var(--line); }
.tile svg { width: 30px; height: 30px; color: var(--red); }
.tile strong { font-size: 1.08rem; }
.tile span { color: var(--muted); font-size: .9rem; }
.tile-group { margin: 22px 0 10px; font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 800; }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: var(--radius-sm); border: 1.5px solid transparent;
  font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-black { background: linear-gradient(165deg, #27272c, #18181b); color: #fff; }
.btn-light { background: #fff; color: var(--text); border-color: var(--line); }
.btn-light:hover:not(:disabled) { background: #f6f6f8; }
.btn-danger { background: var(--red); color: #fff; }
.btn-sm { min-height: 38px; padding: 0 12px; font-size: .9rem; border-radius: 10px; }
.btn-block { width: 100%; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--text); text-decoration: underline; cursor: pointer; }

/* ---- forms ---- */
label { display: block; margin: 0 0 14px; font-weight: 700; }
label > input, label > select, label > textarea { margin-top: 6px; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=tel], input[type=number], input[type=date], input[type=time], select, textarea {
  display: block; width: 100%; min-height: 46px; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  background: #fff; color: var(--text); font: inherit; font-weight: 500;
}
textarea { min-height: 90px; }
input:focus, select:focus, textarea:focus { border-color: #18181b; outline: none; }
.hint { color: var(--muted); font-size: .88rem; font-weight: 500; }
.error { color: var(--red-dark); font-weight: 700; min-height: 1.2em; }
fieldset { border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px 12px; margin: 0 0 14px; }
legend { padding: 0 6px; font-weight: 700; }
.choice { display: flex; align-items: flex-start; gap: 10px; min-height: 40px; padding: 6px 0; font-weight: 600; cursor: pointer; margin: 0; }
.choice input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--red); flex: none; }
.choice small { display: block; color: var(--muted); font-weight: 500; }

/* ---- pills, chips ---- */
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 800; white-space: nowrap; }
.pill-good { background: var(--green-soft); color: var(--green); }
.pill-off { background: #ececee; color: #55555c; }
.pill-warn { background: var(--amber-soft); color: var(--amber); }
.pill-bad { background: var(--red-soft); color: var(--red-dark); }
.chip { display: inline-flex; align-items: center; gap: 4px; margin: 2px 6px 2px 0; padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: .85rem; font-weight: 600; white-space: nowrap; }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th { text-align: left; padding: 10px 12px; font-size: .74rem; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); background: #f6f6f8; }
table.data td { padding: 12px; border-top: 1px solid var(--line); vertical-align: middle; }
table.data td.actions { width: 64px; text-align: right; }

/* ---- ⋯ action menus (one open at a time, placed in the viewport) ---- */
.menu { position: relative; display: inline-block; }
.menu > summary {
  list-style: none; display: grid; place-items: center; width: 42px; height: 42px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 12px; background: #fff; font-size: 1.45rem; font-weight: 800; line-height: 1;
}
.menu > summary::-webkit-details-marker { display: none; }
.menu[open] > summary, .menu > summary:hover { background: var(--soft); }
.menu-panel { position: fixed; z-index: 50; top: 0; left: 0; min-width: 200px; padding: 6px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-pop); }
.menu-item { display: block; width: 100%; min-height: 42px; padding: 9px 11px; border: 0; border-radius: 8px; background: transparent; color: var(--text); text-align: left; font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; }
.menu-item:hover, .menu-item:focus-visible { background: var(--soft); }
.menu-item.danger { color: var(--red-dark); }
.menu-item.danger:hover { background: var(--red-soft); }

/* ---- dialogs ---- */
.dialog { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: var(--gutter); background: rgba(16, 16, 20, .45); }
.dialog-box { width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow: auto; padding: 22px; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-pop); }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 16px; }

/* ---- toast ---- */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 80; max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 12px; background: #18181b; color: #fff; font-weight: 700; box-shadow: var(--shadow-pop); }

/* ---- sign-in screen ---- */
.auth { max-width: 440px; margin: 6vh auto 0; }
.auth .brand { display: flex; justify-content: center; margin: 0 0 18px; }
.auth .brand img { height: 64px; }

@media (max-width: 640px) {
  :root { --header-h: 58px; }
  h1 { font-size: 1.35rem; }
  .card { padding: 16px; border-radius: 16px; }
  .rf-header .rf-title { display: none; }
  .tiles { grid-template-columns: 1fr 1fr; gap: 10px; }
  .tile { min-height: 104px; padding: 14px; }
}
@media (max-width: 380px) { .tiles { grid-template-columns: 1fr; } }

/* ---- tablets ---- */
.tablet-code { margin: 14px 0; text-align: center; font-size: 2.2rem; font-weight: 800; letter-spacing: .12em; font-variant-numeric: tabular-nums; }
.mode-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
@media (max-width: 640px) { .mode-row { grid-template-columns: 1fr auto; } }

/* ---- site picker (dropdown with search) ---- */
.site-picker { border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.site-picker > summary { list-style: none; display: flex; align-items: center; justify-content: space-between; min-height: 46px; padding: 0 14px; font-weight: 700; cursor: pointer; }
.site-picker > summary::-webkit-details-marker { display: none; }
.site-picker > summary::after { content: ''; width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); margin-top: -4px; }
.site-picker[open] > summary::after { transform: rotate(-135deg); margin-top: 4px; }
.site-picker-panel { padding: 10px 14px 12px; border-top: 1px solid var(--line); }
.site-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 2px 16px; max-height: 260px; overflow-y: auto; }
.chip-x { border: 0; background: none; color: var(--red-dark); font-size: 1.05rem; font-weight: 800; cursor: pointer; padding: 0 2px; line-height: 1; }
.more { margin: 2px 0; padding: 3px 10px; border: 0; border-radius: 999px; background: var(--soft); font: inherit; font-size: .85rem; font-weight: 700; cursor: pointer; }

/* ---- people on site ---- */
.rf-site { width: auto; min-height: 40px; max-width: 46vw; font-weight: 700; }
tr.long-open td { background: #fffaf0; }
.unseen-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); }
