/* OnlyCRM — self-contained stylesheet.
   No CDN and no build step on purpose: this has to render correctly on a
   developer's WAMP machine with no network. Replace with a compiled
   Tailwind build when the front end is productionised. */

:root {
  --paper: #eef0f4;
  --surface: #ffffff;
  --surface-2: #f6f7fa;
  --ink: #151a26;
  --ink-2: #414b5e;
  --muted: #6b7588;
  --line: #d6dbe4;
  --line-soft: #e6e9f0;
  --accent: #0d6a63;
  --accent-ink: #0b544e;
  --accent-wash: #dcebe8;
  --warn: #a86e15;
  --warn-wash: #f6ead3;
  --crit: #9e2f26;
  --crit-wash: #f7e0dd;
  --ok: #3a6f36;
  --ok-wash: #e0eede;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(20, 25, 36, .05), 0 8px 24px -18px rgba(20, 25, 36, .3);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0d1118; --surface: #151a24; --surface-2: #1b212c;
    --ink: #e7eaf0; --ink-2: #b6bfcd; --muted: #8894a7;
    --line: #2a3240; --line-soft: #222936;
    --accent: #57c1b2; --accent-ink: #7fd5c8; --accent-wash: #123430;
    --warn: #dda851; --warn-wash: #3a2e14;
    --crit: #e5837a; --crit-wash: #3d1f1c;
    --ok: #76bb6c; --ok-wash: #1c2f1a;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px -20px rgba(0,0,0,.9);
  }
}
:root[data-theme="dark"] {
  --paper: #0d1118; --surface: #151a24; --surface-2: #1b212c;
  --ink: #e7eaf0; --ink-2: #b6bfcd; --muted: #8894a7;
  --line: #2a3240; --line-soft: #222936;
  --accent: #57c1b2; --accent-ink: #7fd5c8; --accent-wash: #123430;
  --warn: #dda851; --warn-wash: #3a2e14;
  --crit: #e5837a; --crit-wash: #3d1f1c;
  --ok: #76bb6c; --ok-wash: #1c2f1a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.2; font-weight: 650; letter-spacing: -.012em; }
h1 { font-size: 24px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
h4 { font-size: 13px; }
p { margin: 0 0 10px; }

.mono, code, .tabular { font-family: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, monospace; }
.tabular { font-variant-numeric: tabular-nums; }
code {
  font-size: .85em; background: var(--surface-2); border: 1px solid var(--line-soft);
  border-radius: 3px; padding: .1em .35em; color: var(--ink-2); word-break: break-all;
}

/* ---------- shell ---------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px; flex: none; background: var(--surface);
  border-right: 1px solid var(--line); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { padding: 18px 18px 14px; border-bottom: 1px solid var(--line-soft); }
.brand .name { font-size: 17px; font-weight: 700; letter-spacing: -.02em; }
.brand .org { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* The wordmark comes in two inks because the sidebar sits on --surface, which
   is near-white in one theme and near-black in the other; a single dark-green
   file would disappear in dark mode. Two files swapped by CSS rather than a
   <picture> element, because the theme here is also settable by hand with
   [data-theme] and a media query alone cannot follow that. */
.brand .wordmark { display: block; height: 26px; width: auto; }
.brand .wordmark.on-dark { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand .wordmark.on-light { display: none; }
  :root:not([data-theme="light"]) .brand .wordmark.on-dark { display: block; }
}
:root[data-theme="light"] .brand .wordmark.on-light { display: block; }
:root[data-theme="light"] .brand .wordmark.on-dark { display: none; }
:root[data-theme="dark"] .brand .wordmark.on-light { display: none; }
:root[data-theme="dark"] .brand .wordmark.on-dark { display: block; }

.nav { padding: 10px 10px 20px; display: flex; flex-direction: column; gap: 1px; }
.nav .group {
  font-size: 10px; letter-spacing: .11em; text-transform: uppercase;
  color: var(--muted); padding: 14px 8px 5px; font-weight: 600;
}
.nav a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 10px; border-radius: var(--radius); color: var(--ink-2); font-size: 14px;
}
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.nav a.active { background: var(--accent-wash); color: var(--accent-ink); font-weight: 600; }
.nav .count {
  font-size: 11px; background: var(--surface-2); border: 1px solid var(--line-soft);
  border-radius: 10px; padding: 1px 7px; color: var(--muted); font-variant-numeric: tabular-nums;
}
.nav a.active .count { background: var(--surface); border-color: var(--accent); color: var(--accent-ink); }
.nav .count.alert { background: var(--crit-wash); color: var(--crit); border-color: transparent; }

.sidebar-foot { margin-top: auto; padding: 14px 18px; border-top: 1px solid var(--line-soft); font-size: 13px; }
.sidebar-foot .who { color: var(--ink); font-weight: 600; }
.sidebar-foot .role { color: var(--muted); font-size: 12px; text-transform: capitalize; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 14px 24px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.topbar .title { flex: 1; min-width: 200px; }
.topbar .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.content { padding: 22px 24px 64px; }

/* ---------- panels ---------- */

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.panel + .panel { margin-top: 16px; }
.panel-head {
  padding: 13px 16px; border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.panel-head h2, .panel-head h3 { flex: 1; min-width: 120px; }
.panel-body { padding: 16px; }
.panel-body.tight { padding: 0; }

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid.four { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
@media (max-width: 980px) { .split { grid-template-columns: 1fr; } }

/* ---------- stat tiles ---------- */

.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .n { font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat .l { font-size: 12px; color: var(--muted); margin-top: 4px; }
.stat.alert .n { color: var(--crit); }
.stat.good .n { color: var(--ok); }

/* ---------- tables ---------- */

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th {
  text-align: left; font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase;
  color: var(--muted); font-weight: 600; padding: 10px 14px; white-space: nowrap;
  border-bottom: 1px solid var(--line); background: var(--surface-2);
}
td { padding: 10px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; color: var(--ink-2); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
td .primary { color: var(--ink); font-weight: 600; }
td .sub { font-size: 12px; color: var(--muted); }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); font-size: 14px; }

/* ---------- pills ---------- */

.pill {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600;
  padding: 3px 8px; border-radius: 20px; white-space: nowrap;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line-soft);
}
.pill.slate { background: var(--surface-2); color: var(--muted); }
.pill.sky, .pill.indigo, .pill.violet { background: var(--accent-wash); color: var(--accent-ink); border-color: transparent; }
.pill.teal, .pill.emerald, .pill.ok { background: var(--ok-wash); color: var(--ok); border-color: transparent; }
.pill.amber, .pill.warn { background: var(--warn-wash); color: var(--warn); border-color: transparent; }
.pill.rose, .pill.crit, .pill.stone { background: var(--crit-wash); color: var(--crit); border-color: transparent; }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- forms ---------- */

label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
label .req { color: var(--crit); }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number],
input[type=date], input[type=datetime-local], input[type=search], input[type=file], select, textarea {
  width: 100%; padding: 7px 10px; font: inherit; font-size: 14px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
textarea { min-height: 74px; resize: vertical; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 28px; }
.field { margin-bottom: 12px; }
.field .help { font-size: 12px; color: var(--muted); margin-top: 4px; }
.field .error { font-size: 12px; color: var(--crit); margin-top: 4px; }
.form-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.checkline { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.checkline label { margin: 0; font-weight: 400; }
input[type=checkbox], input[type=radio] { width: 15px; height: 15px; accent-color: var(--accent); }
fieldset { border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 12px 14px; margin: 0 0 14px; }
legend { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 0 5px; }

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

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
:root[data-theme="dark"] .btn.primary, :root:not([data-theme="light"]) .btn.primary { color: #08211f; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .btn.primary { color: #fff; } }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--crit); border-color: var(--crit); background: transparent; }
.btn.small { padding: 4px 9px; font-size: 12.5px; }
.btn.link { border-color: transparent; background: transparent; color: var(--accent-ink); padding: 4px 6px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- filters ---------- */

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.filters .field { margin: 0; min-width: 140px; }
.filters .field.grow { flex: 1; min-width: 200px; }

/* ---------- timeline ---------- */

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 22px 1fr; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.timeline li:last-child { border-bottom: none; }
.timeline .marker {
  width: 22px; height: 22px; border-radius: 50%; background: var(--surface-2);
  border: 1px solid var(--line); display: grid; place-items: center;
  font-size: 10px; font-weight: 700; color: var(--muted); margin-top: 2px;
}
.timeline .marker.system { background: var(--accent-wash); border-color: transparent; color: var(--accent-ink); }
.timeline .head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.timeline .head .who { font-weight: 600; color: var(--ink); font-size: 14px; }
.timeline .head .when { font-size: 12px; color: var(--muted); margin-left: auto; }
.timeline .body { font-size: 14px; color: var(--ink-2); margin-top: 4px; white-space: pre-wrap; }

/* ---------- key/value ---------- */

.kv { display: grid; grid-template-columns: minmax(120px, 38%) 1fr; gap: 8px 14px; font-size: 14px; }
.kv dt { color: var(--muted); font-size: 12.5px; }
.kv dd { margin: 0; color: var(--ink); word-break: break-word; }

/* ---------- flash ---------- */

.flash {
  padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 14px;
  background: var(--ok-wash); color: var(--ok); border: 1px solid transparent;
}
.flash.error { background: var(--crit-wash); color: var(--crit); }
.errors { background: var(--crit-wash); color: var(--crit); padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; font-size: 13.5px; }
.errors ul { margin: 4px 0 0; padding-left: 18px; }

/* ---------- banners ----------
   Distinct from .flash on purpose. A flash is a receipt for something the
   user just did and goes away on the next page; a banner is a standing
   condition — a lapsing subscription, a platform administrator in the room —
   and stays on every screen until it is no longer true. */

.banner {
  display: flex; gap: 14px; align-items: center; justify-content: space-between;
  flex-wrap: wrap; padding: 11px 15px; border-radius: var(--radius);
  margin-bottom: 16px; font-size: 13.5px; line-height: 1.5;
  border: 1px solid transparent;
}
.banner strong { font-weight: 650; }
.banner.warn { background: var(--warn-wash); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.banner.crit { background: var(--crit-wash); color: var(--crit); border-color: color-mix(in srgb, var(--crit) 30%, transparent); }
/* Support reads as "someone is watching", not as an error. */
.banner.support {
  background: var(--accent-wash); color: var(--accent-ink);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
}
.banner form { margin: 0; }

/* ---------- workspace switcher ----------
   Only rendered for people who work in more than one workspace, so it has to
   read as part of the brand block rather than as a control bolted beside it. */

.brand .switcher { margin-top: 4px; }
.brand .switcher select {
  width: 100%; font-size: 13px; padding: 3px 6px;
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line-soft); border-radius: 4px;
}
.brand .switcher select:hover { border-color: var(--line); }

/* ---------- pagination ---------- */

.pagination { display: flex; gap: 4px; flex-wrap: wrap; padding: 12px 16px; font-size: 13.5px; align-items: center; }
.pagination a, .pagination span { padding: 4px 9px; border-radius: 4px; border: 1px solid var(--line-soft); color: var(--ink-2); }
.pagination .active span { background: var(--accent-wash); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.pagination .disabled span { opacity: .45; }
.pagination svg { width: 13px; height: 13px; }

/* ---------- bar chart ---------- */

.bars { display: flex; align-items: flex-end; gap: 4px; height: 64px; }
.bars .bar { flex: 1; background: var(--accent); border-radius: 2px 2px 0 0; min-height: 2px; opacity: .85; }
.bars .bar:hover { opacity: 1; }
.barlist { display: flex; flex-direction: column; gap: 8px; }
.barlist .row { display: grid; grid-template-columns: minmax(90px, 34%) 1fr auto; gap: 10px; align-items: center; font-size: 13.5px; }
.barlist .val { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }

/* Unnested, so a bar can also sit in a table cell — the reports use both. */
.track { background: var(--surface-2); border-radius: 3px; height: 8px; overflow: hidden; }
.fill { background: var(--accent); height: 100%; border-radius: 3px; }

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

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; }
.login-card .brand { border: none; padding: 0 0 18px; }

/* ---------- misc ---------- */

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.divider { height: 1px; background: var(--line-soft); margin: 14px 0; }
details.disclose > summary { cursor: pointer; font-weight: 600; font-size: 14px; padding: 6px 0; }
.copy-field { display: flex; gap: 6px; align-items: center; }
.copy-field code { flex: 1; overflow-x: auto; white-space: nowrap; padding: 6px 8px; }

@media (max-width: 820px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--line); }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav .group { display: none; }
  .sidebar-foot { display: none; }
  .content { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
