/* Shared design system. Loaded by index.html / login.html / admin.html. */

:root {
  /* Neutrals carry a hint of blue so large white areas don't look sallow. */
  --bg:        #fbfbfd;
  --bg-tint:   #f4f5f9;
  --panel:     #ffffff;
  --panel-2:   #fafafd;

  /* Borders as translucent black: they stay coherent over any background. */
  --line:      rgba(17, 24, 39, .08);
  --line-2:    rgba(17, 24, 39, .05);
  --line-str:  rgba(17, 24, 39, .14);

  --fg:        #0f1116;
  --fg-2:      #3d4351;
  --muted:     #737b8c;
  --faint:     #a2a9b8;

  --accent:      #4f46e5;
  --accent-hov:  #4338ca;
  --accent-weak: #eef0fe;
  --accent-ring: rgba(79, 70, 229, .14);

  --ok:        #0f7a3d;
  --ok-weak:   #eafaf0;
  --ok-line:   rgba(15, 122, 61, .18);
  --warn:      #a35a07;
  --warn-weak: #fff6e9;
  --warn-line: rgba(163, 90, 7, .18);
  --bad:       #c72d2d;
  --bad-weak:  #fef1f1;
  --bad-line:  rgba(199, 45, 45, .18);

  /* Layered shadows: one tight for the edge, one diffuse for lift. */
  --sh-sm: 0 1px 2px rgba(16, 24, 40, .04);
  --sh:    0 1px 2px rgba(16, 24, 40, .04), 0 4px 12px -2px rgba(16, 24, 40, .06);
  --sh-lg: 0 2px 4px rgba(16, 24, 40, .04), 0 12px 32px -8px rgba(16, 24, 40, .12);

  --r-sm: 8px;
  --r:    11px;
  --r-lg: 16px;

  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
          "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

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

::selection { background: var(--accent-ring); }

.wrap { max-width: 880px; margin: 0 auto; padding: 44px 24px 120px; }
.wrap.narrow { max-width: 400px; padding-top: 88px; }

/* ---------- type ---------- */

h1 {
  font-size: 22px; font-weight: 640; letter-spacing: -.021em;
  margin: 0 0 5px; line-height: 1.25;
}
h2 {
  font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--faint); margin: 34px 0 12px;
}
.sub { color: var(--muted); font-size: 14px; margin: 0 0 26px; }
.meta { color: var(--muted); font-size: 13px; }
.tnum { font-variant-numeric: tabular-nums; }

.top { display: flex; justify-content: space-between; align-items: center; gap: 20px; }

/* ---------- surfaces ---------- */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: var(--sh-sm);
}
.card.flush { padding: 8px 20px; }
.card.lift { box-shadow: var(--sh); }

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

label {
  display: block; font-size: 13px; font-weight: 500;
  color: var(--fg-2); margin: 16px 0 6px;
}
label:first-child { margin-top: 0; }

input[type=text], input[type=email], input[type=password], select {
  width: 100%;
  padding: 10px 13px;
  background: var(--panel);
  border: 1px solid var(--line-str);
  border-radius: var(--r-sm);
  color: var(--fg);
  font-size: 14px;
  font-family: inherit;
  transition: border-color .13s, box-shadow .13s;
}
input::placeholder { color: var(--faint); }
input:hover, select:hover { border-color: rgba(17, 24, 39, .22); }
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3.5px var(--accent-ring);
}

select {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%23737b8c' stroke-width='1.4' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
}

/* Explicit stack for masked fields: an inherited CJK-first font can fail to
   render the U+2022 mask glyph, making a filled field look empty. */
input[type=password] { font-family: var(--mono); letter-spacing: .06em; }
input[type=password]::placeholder { font-family: var(--sans); letter-spacing: normal; }

.pwrow { display: flex; gap: 8px; align-items: stretch; }
.pwrow input { flex: 1; }

.row { display: flex; gap: 14px; }
.row > * { flex: 1; min-width: 0; }

/* Kept in the DOM for password managers, but out of sight and out of tab order. */
.offscreen { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

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

button {
  padding: 9px 15px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-str);
  background: var(--panel);
  color: var(--fg-2);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  font-family: inherit;
  transition: background .13s, border-color .13s, box-shadow .13s, color .13s;
  box-shadow: var(--sh-sm);
}
button:hover { background: var(--panel-2); border-color: rgba(17, 24, 39, .2); color: var(--fg); }
button:active { transform: translateY(.5px); }

button.primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
  box-shadow: 0 1px 2px rgba(79, 70, 229, .3);
}
button.primary:hover { background: var(--accent-hov); border-color: var(--accent-hov); color: #fff; }

button.ghost {
  background: transparent; border-color: transparent; box-shadow: none;
  color: var(--muted); padding: 9px 12px; white-space: nowrap;
}
button.ghost:hover { background: var(--bg-tint); color: var(--fg); border-color: transparent; }

button.danger:hover { border-color: var(--bad-line); color: var(--bad); background: var(--bad-weak); }

button.sm { padding: 6px 11px; font-size: 12.5px; }

button:disabled { opacity: .45; cursor: default; }
button:disabled:hover { background: var(--panel); border-color: var(--line-str); }

button.link {
  border: none; background: none; box-shadow: none;
  color: var(--muted); padding: 0; font-size: 13px; font-weight: 500;
}
button.link:hover { background: none; color: var(--fg); }

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

.actions { display: flex; gap: 8px; margin-top: 20px; align-items: center; flex-wrap: wrap; }

.chk {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13.5px; color: var(--fg-2); margin: 0; cursor: pointer; font-weight: 400;
}
.chk input { width: auto; accent-color: var(--accent); cursor: pointer; }

/* ---------- table ---------- */

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; color: var(--faint); font-weight: 600;
  font-size: 11.5px; letter-spacing: .05em; text-transform: uppercase;
  padding: 12px 12px 12px 0; border-bottom: 1px solid var(--line);
}
td { padding: 14px 12px 14px 0; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--panel-2); }
td:last-child, th:last-child { padding-right: 0; text-align: right; }

code {
  font-family: var(--mono); font-size: 12.5px; color: var(--muted);
  word-break: break-all;
}

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

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 500; line-height: 1.6;
  border: 1px solid var(--line); color: var(--muted); background: var(--panel-2);
  white-space: nowrap;
}
.pill.on    { color: var(--ok);     border-color: var(--ok-line);   background: var(--ok-weak); }
.pill.def   { color: var(--accent); border-color: var(--accent-ring); background: var(--accent-weak); }
.pill.admin { color: var(--warn);   border-color: var(--warn-line); background: var(--warn-weak); }
.pill.off   { color: var(--bad);    border-color: var(--bad-line);  background: var(--bad-weak); }

/* ---------- messages ---------- */

.msg {
  padding: 11px 14px; border-radius: var(--r-sm);
  font-size: 13.5px; margin-bottom: 16px; line-height: 1.55;
}
.msg.err { background: var(--bad-weak); border: 1px solid var(--bad-line); color: #96201f; }
.msg.ok  { background: var(--ok-weak);  border: 1px solid var(--ok-line);  color: #0b5c2e; }

.note {
  background: var(--warn-weak); border: 1px solid var(--warn-line); color: #7c4406;
  padding: 12px 15px; border-radius: var(--r-sm);
  font-size: 13.5px; line-height: 1.6; margin-bottom: 18px;
}
.note b { font-weight: 600; }
.note code { color: inherit; opacity: .85; }

/* ---------- tabs ---------- */

.tabs {
  display: flex; gap: 2px; margin-bottom: 22px;
  border-bottom: 1px solid var(--line);
}
.tabs button {
  border: none; background: none; box-shadow: none; border-radius: 0;
  color: var(--muted); font-weight: 500;
  padding: 10px 14px; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button:hover { background: none; color: var(--fg); }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- header bar ---------- */

.userbar { display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--muted); }
.userbar .email {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px 5px 6px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line);
  box-shadow: var(--sh-sm); color: var(--fg-2); font-weight: 500;
}
.avatar {
  width: 20px; height: 20px; border-radius: 999px; flex: none;
  background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 600; text-transform: uppercase;
}

.hide { display: none !important; }

/* ---------- motion ---------- */

/* No fill-mode on purpose: with `both` the element keeps the 0% keyframe
   (opacity 0) whenever the animation cannot run, which renders results
   invisible. Without it, the resting state is the element's own style. */
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } }
.anim { animation: fadeUp .28s cubic-bezier(.2, .7, .3, 1); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
