/* The control panel. Right to left, logical properties only, borders instead of shadows. */
:root {
  --ink: #14191D;
  --ink-soft: #2A333A;
  --muted: #4B5760;
  --teal: #1EBEBB;
  --teal-700: #0E7A77;
  --teal-50: #E9F8F7;
  --line: #E4E8EA;
  --surface: #F4F6F7;
  --paper: #FFFFFF;
  --danger: #B42318;
  --danger-50: #FDF0EE;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --font: "Titillium Web", "Tajawal", "Segoe UI", Tahoma, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
}

a { color: var(--teal-700); }
a:hover { color: var(--ink); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--teal-700);
  outline-offset: 2px;
}

h1 { margin: 0; font-size: 28px; line-height: 1.3; font-weight: 800; }
h2 { margin: 0 0 12px; font-size: 19px; line-height: 1.4; font-weight: 800; }
h3 { margin: 16px 0 8px; font-size: 16px; font-weight: 700; }

/* Header and menu */
.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 24px;
  padding: 12px clamp(16px, 4vw, 40px);
  background: var(--paper);
  border-block-end: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 700; }
.brand img { height: 26px; width: auto; display: block; }
.brand span { color: var(--muted); font-size: 14px; }
/* On a phone the menu takes its own row and scrolls sideways; from 760px it sits between the brand and sign-out. */
.menu { order: 3; flex: 1 1 100%; display: flex; gap: 4px; overflow-x: auto; }
@media (min-width: 760px) { .menu { order: 0; flex: 1 1 auto; } }
.menu a { flex: none; }
.menu a {
  padding: 6px 14px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
}
.menu a:hover { color: var(--ink); border-color: var(--line); }
.menu a[aria-current="page"] { color: var(--ink); border-color: var(--ink); }
.signout { display: flex; align-items: center; gap: 10px; margin: 0; margin-inline-start: auto; }
.who { color: var(--muted); font-size: 14px; }
@media (max-width: 520px) { .who { display: none; } }

.wrap { max-width: 1200px; margin-inline: auto; padding: 28px clamp(16px, 4vw, 40px) 64px; display: flex; flex-direction: column; gap: 20px; }

/* Pages before sign-in */
body.center { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.card {
  width: 100%;
  max-width: 460px;
  padding: 32px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.card-logo { height: 30px; width: auto; align-self: flex-start; }
.card h1 { font-size: 24px; }

/* Notes */
.note { margin: 0; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--paper); }
.note-ok { border-color: var(--teal); background: var(--teal-50); }
.note-error { border-color: var(--danger); background: var(--danger-50); color: var(--danger); }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 14px; }
.empty { margin: 0; padding: 32px; text-align: center; color: var(--muted); background: var(--paper); border: 1px dashed var(--line); border-radius: var(--r-md); }

/* Forms */
.stack { display: flex; flex-direction: column; gap: 14px; margin: 0; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 700; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-weight: 400;
}
input[type="checkbox"] { width: 18px; min-height: 18px; height: 18px; accent-color: var(--teal-700); }
input[type="file"] { padding: 8px; }
textarea { min-height: 96px; resize: vertical; line-height: 1.7; }
textarea.longtext { font-size: 15px; }
input.num { max-width: 160px; }
[aria-invalid="true"] { border-color: var(--danger); background: var(--danger-50); }
.field-error { color: var(--danger); font-weight: 500; font-size: 13px; }
fieldset { margin: 0; min-width: 0; }
/* A floated legend sits inside its box like a heading, not on the border. */
legend { float: inline-start; width: 100%; padding: 0; margin: 0; font-size: 17px; font-weight: 800; }
legend + * { clear: both; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.btn-ink { background: var(--ink); color: var(--paper); }
.btn-ink:hover { background: var(--ink-soft); color: var(--paper); }
.btn-line { background: var(--paper); color: var(--ink); border-color: var(--line); }
.btn-line:hover { border-color: var(--muted); color: var(--ink); }
.btn-quiet { min-height: 36px; padding: 0 12px; background: transparent; color: var(--muted); border-color: var(--line); }
.btn-quiet:hover { color: var(--ink); border-color: var(--muted); }
.btn-danger { background: var(--paper); color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-50); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* Layout pieces */
.bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.panel { padding: 20px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); gap: 20px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 14px 20px; align-items: end; }

/* Tabs */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.tabs a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
}
.tabs a[aria-current="page"] { color: var(--ink); border-color: var(--ink); }
.count { min-width: 24px; padding: 0 6px; border-radius: 999px; background: var(--surface); color: var(--ink); font-size: 13px; text-align: center; }

/* Tables */
.table-scroll { overflow-x: auto; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); }
.panel .table-scroll { border-radius: var(--r-sm); }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { padding: 10px 14px; text-align: start; vertical-align: top; border-block-end: 1px solid var(--line); }
thead th { background: var(--surface); color: var(--muted); font-size: 13px; font-weight: 700; white-space: nowrap; }
tbody tr:last-child td, tbody tr:last-child th { border-block-end: 0; }
.nowrap { white-space: nowrap; }
.prices td { min-width: 120px; }
.prices input.num { max-width: 120px; min-height: 38px; }
tbody.fallback td.muted { background: var(--surface); }
.pager { display: flex; gap: 10px; justify-content: flex-end; }

/* Chips */
.chip { display: inline-block; padding: 2px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.chip-new { border-color: var(--teal); background: var(--teal-50); color: var(--teal-700); }
.chip-contacted { border-color: var(--ink); color: var(--ink); }
.chip-closed { color: var(--muted); background: var(--surface); }
.chip-published { border-color: var(--teal); background: var(--teal-50); color: var(--teal-700); }
.chip-draft { color: var(--muted); background: var(--surface); }

/* A request's facts */
.facts { margin: 0; display: flex; flex-direction: column; }
.facts .row { display: grid; grid-template-columns: 140px 1fr; gap: 12px; padding: 8px 0; border-block-end: 1px solid var(--line); }
.facts .row:last-child { border-block-end: 0; }
.facts dt { color: var(--muted); font-size: 14px; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.message { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; padding: 12px 14px; background: var(--surface); border-radius: var(--r-sm); }

/* TOTP enrolment */
.label { margin: 0; font-size: 14px; font-weight: 700; }
.secret { margin: 0; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); font-size: 20px; letter-spacing: 2px; text-align: center; overflow-wrap: anywhere; }
.uri { margin: 0; padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); font-size: 13px; overflow-wrap: anywhere; user-select: all; }

/* Blog editor */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
@media (max-width: 900px) { .editor { grid-template-columns: minmax(0, 1fr); } }
.editor-main { padding: 20px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); }
.cover { width: 100%; height: auto; border: 1px solid var(--line); border-radius: var(--r-sm); }
.danger { border-color: var(--danger); }
.preview .prose { max-width: 760px; }
.prose { line-height: 1.9; overflow-wrap: anywhere; }
.prose img { max-width: 100%; height: auto; border-radius: var(--r-sm); }
.prose pre { overflow-x: auto; padding: 12px; background: var(--surface); border-radius: var(--r-sm); }
.prose blockquote { margin: 0; padding-inline-start: 16px; border-inline-start: 3px solid var(--teal); color: var(--muted); }

/* Spend */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr)); gap: 12px; }
.stat { display: flex; flex-direction: column; gap: 4px; padding: 16px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); }
.stat-label { color: var(--muted); font-size: 14px; font-weight: 700; }
.stat-value { font-size: 24px; font-weight: 800; text-align: end; }
.stat-note { color: var(--muted); font-size: 13px; }
.verify { display: inline-block; margin-inline-start: 6px; padding: 0 8px; border: 1px solid var(--teal); border-radius: 999px; background: var(--teal-50); color: var(--teal-700); font-size: 12px; font-weight: 700; }
