/* Optiqs theme: tokens and shared components.
   Plain variant of the design language: D-DIN headings, IBM Plex Sans body,
   IBM Plex Mono data, cold neutrals, blue accent, 4px corners. Green, yellow
   and red mean status. Light is the default; <html data-theme="dark">
   switches. The server sets data-theme from the "theme" cookie. */

@font-face { font-family: "D-DIN"; src: url("../fonts/D-DIN.otf") format("opentype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "D-DIN"; src: url("../fonts/D-DIN-Bold.otf") format("opentype"); font-weight: 700; font-display: swap; }

:root {
  color-scheme: light;

  --bg: #F4F6F8;
  --surface: #FFFFFF;
  --subtle: #EDF0F3;      /* gridlines, inset fills, secondary buttons */
  --rule: #D5DBE1;
  --faint: #8A95A1;       /* tertiary text, disabled */
  --muted: #5B6672;
  --text: #1A2129;

  --blue: #0F6FB3;
  --blue-hover: #0C5D97;
  --blue-tint: #E6F1FA;
  --on-blue: #FFFFFF;
  --link: #0F6FB3;
  --row-hover: #FAFBFC;

  --red: #B8173F;
  --red-tint: #FBE9EE;
  --green: #3F7A12;
  --green-tint: #EBF5E1;
  --yellow: #8F7600;      /* readable on white; status text and chart lines */
  --yellow-tint: #FDF6CC;
  --yellow-ink: #6B5A00;
  --yellow-rule: #6B5A00;

  /* extra data-series hues for charts with many lines */
  --purple: #7442C8;
  --orange: #C2540A;
  --teal: #0E8A8A;

  --overlay: rgba(26, 33, 41, .45);
  --shadow: 0 4px 12px rgba(26, 33, 41, .12);

  --heading: "D-DIN", "IBM Plex Sans", sans-serif;
  --body: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

[data-theme="dark"] {
  color-scheme: dark;

  --bg: #080B10;
  --surface: #10161E;
  --subtle: #18202A;
  --rule: #263140;
  --faint: #5F6B78;
  --muted: #8D98A4;
  --text: #D9DDE0;

  --blue: #168CDE;
  --blue-hover: #3AA0E8;
  --blue-tint: #0F2638;
  --on-blue: #080B10;
  --link: #4DA8EA;
  --row-hover: #141C26;

  --red: #F0567A;
  --red-tint: #33121C;
  --green: #83D62F;
  --green-tint: #1A2A10;
  --yellow: #F5D000;
  --yellow-tint: #2B2508;
  --yellow-ink: #F5D000;
  --yellow-rule: #F5D000;

  --purple: #B48CF2;
  --orange: #F0883E;
  --teal: #3CC8C8;

  --overlay: rgba(0, 0, 0, .7);
  --shadow: 0 4px 12px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--body);
}

h1, h2, h3 { font-family: var(--heading); font-weight: 700; line-height: 1.2; }
h1 { font-size: 32px; }
h2 { font-size: 22px; }
h3 { font-size: 17px; }
.muted { color: var(--muted); }
code, .mono { font-family: var(--mono); font-size: 13px; }

a { color: var(--link); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.card { background: var(--surface); border: 1px solid var(--rule); border-radius: 4px; }

/* ---------- top bar (non-dashboard pages) ---------- */
.topbar { display: flex; align-items: center; gap: 24px; height: 52px; padding: 0 20px; border-bottom: 1px solid var(--rule); background: var(--surface); }
.topbar .name { font-family: var(--heading); font-weight: 700; font-size: 18px; color: var(--text); text-decoration: none; }
.topbar .end { margin-left: auto; display: flex; align-items: center; gap: 16px; font-size: 14px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 500 14px/1 var(--body);
  height: 36px; padding: 0 14px;
  border-radius: 4px; border: 1px solid var(--rule);
  background: var(--surface); color: var(--text);
  text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--bg); }
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center;
  font: 500 14px/1 var(--body);
  height: 36px; padding: 0 14px;
  border-radius: 4px; border: 1px solid var(--blue);
  background: var(--blue); color: var(--on-blue);
  cursor: pointer;
}
.btn-primary:hover { background: var(--blue-hover); border-color: var(--blue-hover); }

/* POST-only actions (e.g. logout) rendered inline as a link or button */
.inline-form { display: inline; margin: 0; }
.link-button {
  background: none; border: 0; padding: 0; margin: 0;
  font: inherit; color: var(--link); cursor: pointer;
}
.link-button:hover { text-decoration: underline; }

/* ---------- forms ---------- */
.form-group { display: grid; gap: 6px; margin-bottom: 16px; }
.form-group label { color: var(--muted); font-size: 13px; }
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group textarea {
  width: 100%;
  font: 14px var(--body);
  height: 36px; padding: 0 10px;
  border: 1px solid var(--rule); border-radius: 4px;
  background: var(--bg); color: var(--text);
}
.form-group textarea { height: auto; padding: 8px 10px; resize: vertical; }
.form-group input:focus, .form-group textarea:focus { outline: none; border-color: var(--blue); }
.form-group-inline { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; font-size: 14px; color: var(--muted); }
.field-errors { color: var(--red); font-size: 13px; }

/* ---------- status ---------- */
.tag { display: inline-block; padding: 2px 8px; border-radius: 3px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.tag.ok { background: var(--green-tint); color: var(--green); }
.tag.warn { background: var(--yellow-tint); color: var(--yellow-ink); }
.tag.err { background: var(--red-tint); color: var(--red); }
.tag.info { background: var(--blue-tint); color: var(--link); }

.notice { display: flex; gap: 12px; padding: 12px 16px; border-radius: 4px; border-left: 3px solid var(--yellow-rule); background: var(--yellow-tint); font-size: 14px; }

.flash { margin-bottom: 16px; padding: 10px 14px; border-radius: 4px; font-size: 14px; border-left: 3px solid; }
.flash-error   { background: var(--red-tint);    color: var(--red);        border-color: var(--red); }
.flash-success { background: var(--green-tint);  color: var(--green);      border-color: var(--green); }
.flash-info    { background: var(--blue-tint);   color: var(--link);       border-color: var(--blue); }
.flash-warning { background: var(--yellow-tint); color: var(--yellow-ink); border-color: var(--yellow-rule); }

/* segmented control */
.segmented { display: inline-flex; border: 1px solid var(--rule); border-radius: 4px; overflow: hidden; background: var(--surface); }
.segmented button, .segmented label {
  font: 400 14px/1 var(--body);
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 14px;
  border: 0; border-right: 1px solid var(--rule);
  background: none; color: var(--muted); cursor: pointer;
}
.segmented > :last-child { border-right: 0; }
.segmented button:hover, .segmented label:hover { color: var(--text); background: var(--bg); }
.segmented button[aria-pressed="true"], .segmented label:has(input:checked) { color: var(--link); background: var(--blue-tint); font-weight: 500; }
.segmented input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--blue); outline-offset: -2px; }
