/* OwedRx base styles: tokens, type, controls. Shared by the site and the app. */

:root {
  --bg: #f6f6f2;
  --surface: #ffffff;
  --surface-2: #efefea;
  --text: #1b1f1c;
  --text-2: #5a605c;
  --border: #dcddd6;
  --border-strong: #c3c5bd;
  --accent: #0e6a4e;
  --accent-ink: #ffffff;
  --accent-tint: #e3f1ea;
  --good: #1d7448;
  --good-bg: #e4f3ea;
  --warn: #8f5b00;
  --warn-bg: #fbf0d9;
  --bad: #b02a20;
  --bad-bg: #fbe8e5;
  --info: #2a57a0;
  --info-bg: #e7edf9;
  --neutral-bg: #ebede7;
  --focus: #1f6feb;
  --shadow: 0 1px 2px rgba(20, 30, 25, 0.06), 0 4px 16px rgba(20, 30, 25, 0.05);
  --radius: 10px;
  --radius-sm: 6px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111412;
    --surface: #191d1a;
    --surface-2: #212622;
    --text: #e8ebe8;
    --text-2: #a3aaa5;
    --border: #2f3531;
    --border-strong: #454c47;
    --accent: #4dbf8e;
    --accent-ink: #0b1f16;
    --accent-tint: #173629;
    --good: #5fd19a;
    --good-bg: #163827;
    --warn: #efb24a;
    --warn-bg: #382b11;
    --bad: #ff8a7e;
    --bad-bg: #3b1916;
    --info: #8eb1ff;
    --info-bg: #1a263e;
    --neutral-bg: #252a26;
    --focus: #79a8ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #111412;
  --surface: #191d1a;
  --surface-2: #212622;
  --text: #e8ebe8;
  --text-2: #a3aaa5;
  --border: #2f3531;
  --border-strong: #454c47;
  --accent: #4dbf8e;
  --accent-ink: #0b1f16;
  --accent-tint: #173629;
  --good: #5fd19a;
  --good-bg: #163827;
  --warn: #efb24a;
  --warn-bg: #382b11;
  --bad: #ff8a7e;
  --bad-bg: #3b1916;
  --info: #8eb1ff;
  --info-bg: #1a263e;
  --neutral-bg: #252a26;
  --focus: #79a8ff;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
}

h1,
h2,
h3,
h4 {
  line-height: 1.2;
  margin: 0 0 0.5em;
  letter-spacing: -0.01em;
}

h1 { font-size: clamp(1.9rem, 4vw, 2.8rem); }
h2 { font-size: clamp(1.4rem, 2.6vw, 1.9rem); }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; }

p { margin: 0 0 1em; }

a {
  color: var(--accent);
  text-underline-offset: 2px;
}

a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

code,
kbd {
  font-family: var(--mono);
  font-size: 0.92em;
  background: var(--surface-2);
  border-radius: 4px;
  padding: 0.05em 0.35em;
}

.muted { color: var(--text-2); }
.small { font-size: 0.88rem; }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45em;
  min-height: 38px;
  padding: 0.5em 1em;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled,
.btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn-sm { min-height: 30px; padding: 0.25em 0.7em; font-size: 0.88rem; }
.btn-lg { min-height: 48px; padding: 0.7em 1.4em; font-size: 1.05rem; }

/* Forms */
label { font-weight: 600; font-size: 0.92rem; }
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
select,
textarea {
  width: 100%;
  min-height: 38px;
  padding: 0.45em 0.65em;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
textarea { min-height: 120px; font-family: var(--mono); font-size: 0.85rem; }
.field { display: grid; gap: 0.3em; margin-bottom: 0.9em; }
.field .hint { font-weight: 400; color: var(--text-2); font-size: 0.85rem; }

/* Surfaces */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  padding: 0.12em 0.55em;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  background: var(--neutral-bg);
  color: var(--text);
}
.badge-good { background: var(--good-bg); color: var(--good); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-info { background: var(--info-bg); color: var(--info); }

/* Tables */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th,
td {
  padding: 0.55em 0.75em;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-2);
  white-space: nowrap;
}
td.r,
th.r { text-align: right; }
tbody tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }

.banner {
  display: flex;
  gap: 0.75em;
  align-items: flex-start;
  padding: 0.8em 1em;
  border-radius: var(--radius-sm);
  background: var(--info-bg);
  color: var(--text);
  border: 1px solid var(--border);
}
.banner-warn { background: var(--warn-bg); }
.banner-bad { background: var(--bad-bg); }
.banner-good { background: var(--good-bg); }
