/* ===========================================================================
   Creative Desk - design system
   Self-hosted Inter, one accent, a neutral scale, and a sidebar shell.
   Every class the templates already use is kept working.
   =========================================================================== */

@font-face {
  font-family: "InterVariable";
  src: url("/static/fonts/inter-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Neutral scale */
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #fbfcfd;
  --line: #e6e8ec;
  --line-strong: #d3d7de;
  --ink: #101828;
  --ink-2: #344054;
  --muted: #667085;
  --muted-2: #98a2b3;

  /* Accent */
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --accent-ink: #ffffff;

  /* Semantic */
  --ok: #027a48;
  --ok-bg: #ecfdf3;
  --ok-line: #abefc6;
  --warn: #b54708;
  --warn-bg: #fffaeb;
  --warn-line: #fedf89;
  --bad: #b42318;
  --bad-bg: #fef3f2;
  --bad-line: #fecdca;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.1), 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 12px 16px -4px rgba(16, 24, 40, 0.08), 0 4px 6px -2px rgba(16, 24, 40, 0.03);

  --sidebar-w: 248px;
  --font: "InterVariable", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -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 { color: var(--accent-hover); text-decoration: underline; }

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

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

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 18px;
  font-weight: 640;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.sidebar .brand .mark {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent) 0%, #7c6cf5 100%);
  color: #fff;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
  flex: 0 0 28px;
}

.sidebar nav { padding: 4px 12px; display: flex; flex-direction: column; gap: 2px; }
.sidebar .group {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-2);
  font-weight: 600;
  padding: 16px 8px 6px;
}
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-weight: 500;
  font-size: 13.5px;
  transition: background 0.12s ease, color 0.12s ease;
}
.sidebar nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.sidebar nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sidebar nav a .ico { width: 16px; text-align: center; opacity: 0.85; flex: 0 0 16px; }

.sidebar .foot {
  margin-top: auto;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
}
.sidebar .who { display: flex; align-items: center; gap: 10px; }
.sidebar .who .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center;
  font-weight: 650; font-size: 12px; flex: 0 0 32px;
}
.sidebar .who .name { font-weight: 570; font-size: 13px; line-height: 1.3; }
.sidebar .who .meta { color: var(--muted); font-size: 11.5px; line-height: 1.3; }
.sidebar .foot form { margin: 10px 0 0; }
.sidebar .foot button { width: 100%; }

main {
  flex: 1;
  min-width: 0;
  padding: 28px 32px 72px;
  max-width: 1280px;
}
main.narrow { max-width: 480px; margin: 0 auto; padding-top: 0; }

/* --------------------------------------------------------- page header -- */

h1 {
  font-size: 22px;
  font-weight: 640;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
  color: var(--ink);
}
h2 {
  font-size: 14px;
  font-weight: 620;
  letter-spacing: -0.005em;
  margin: 0 0 14px;
  color: var(--ink);
}
p.sub {
  color: var(--muted);
  margin: 0 0 24px;
  font-size: 13.5px;
  max-width: 76ch;
}
p.sub code { font-size: 12.5px; }

/* --------------------------------------------------------------- cards -- */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}
.panel > h2 {
  margin: 0 0 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.panel > h2:only-child { border-bottom: 0; padding-bottom: 0; margin-bottom: 0; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 18px; }

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.stat .n {
  font-size: 26px;
  font-weight: 640;
  letter-spacing: -0.03em;
  line-height: 1.2;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.stat .l { color: var(--muted); font-size: 12.5px; margin-top: 3px; }

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

.table-wrap {
  overflow-x: auto;
  margin: 0 -20px -20px;
  border-top: 1px solid var(--line);
}
.panel > .table-wrap:first-child { border-top: 0; margin-top: -20px; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left;
  padding: 10px 20px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td {
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  color: var(--ink-2);
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background 0.1s ease; }
tbody tr:hover { background: var(--surface-2); }
td.right, th.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* Key-value tables (no thead) read better without the header treatment. */
.panel table:not(:has(thead)) th {
  background: transparent;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
  width: 34%;
  padding-left: 0;
}
.panel table:not(:has(thead)) td { padding-right: 0; }
.panel table:not(:has(thead)) { margin: -4px 0; }

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

label {
  display: block;
  font-size: 13px;
  font-weight: 550;
  color: var(--ink-2);
  margin: 16px 0 6px;
}
label.inline {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 450;
  margin: 8px 0;
  color: var(--ink-2);
  cursor: pointer;
}
label.inline input { margin: 0; accent-color: var(--accent); width: 15px; height: 15px; }

input[type="text"], input[type="password"], input[type="email"], input[type="number"],
input[type="date"], input[type="search"], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 13.5px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}
input[type="file"] {
  width: 100%;
  font-size: 13px;
  padding: 9px 12px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
}
input[type="file"]::file-selector-button {
  font: inherit;
  font-size: 12.5px;
  font-weight: 550;
  margin-right: 10px;
  padding: 5px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
}
textarea { resize: vertical; min-height: 78px; line-height: 1.55; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}
.hint { color: var(--muted); font-size: 12.5px; margin-top: 6px; }

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

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 13.5px;
  font-weight: 550;
  line-height: 1.3;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
  text-decoration: none;
}
button:hover, .btn:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  text-decoration: none;
  color: var(--accent-ink);
}
button:focus-visible, .btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.25);
}
button:disabled, .btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: var(--muted-2);
  border-color: var(--muted-2);
}
button.ghost, .btn.ghost {
  background: var(--surface);
  color: var(--ink-2);
  border-color: var(--line-strong);
}
button.ghost:hover, .btn.ghost:hover {
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--line-strong);
}
button.danger, .btn.danger { background: var(--bad); border-color: var(--bad); }
button.danger:hover, .btn.danger:hover { background: #912018; border-color: #912018; }
button.small, .btn.small { padding: 5px 11px; font-size: 12.5px; }

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 18px;
}
.actions form { margin: 0; }
.actions .muted { font-size: 13px; }

/* --------------------------------------------------------------- notes -- */

.note {
  padding: 12px 15px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  font-size: 13.5px;
  border: 1px solid;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.note::before { font-size: 14px; line-height: 1.4; flex: 0 0 auto; }
.note.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.note.ok::before { content: "\2713"; }
.note.err { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-line); }
.note.err::before { content: "\26A0"; }
.note.warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.note.warn::before { content: "\26A0"; }
.note strong { font-weight: 620; }
.note a { color: inherit; text-decoration: underline; }

/* ---------------------------------------------------------------- tags -- */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 550;
  background: #f2f4f7;
  color: var(--ink-2);
  border: 1px solid var(--line);
  white-space: nowrap;
  line-height: 1.6;
}
.tag + .tag { margin-left: 4px; }
.tag.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.tag.warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.tag.bad { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-line); }

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

.filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.filters label { margin: 0 0 6px; }
.filters .f { min-width: 150px; }
.filters .f:has(button), .filters .f:has(.btn) { min-width: 0; }

/* ------------------------------------------------------- code / mono ---- */

code, .mono {
  font-family: var(--mono);
  font-size: 12.5px;
  font-variant-ligatures: none;
}
code {
  background: #f2f4f7;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
  color: var(--ink-2);
}
pre.json {
  background: #0f1729;
  color: #d6e0f5;
  border: 1px solid #1d2841;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.credential {
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
  color: #e0e7ff;
  padding: 16px 18px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.credential .pw {
  font-family: var(--mono);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #fff;
  margin-top: 3px;
  user-select: all;
}

/* ------------------------------------------------------------ utility --- */

.muted { color: var(--muted); }
.right { text-align: right; }
.pager {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}
ul { padding-left: 20px; margin: 8px 0; color: var(--ink-2); }
li { margin: 4px 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

/* ----------------------------------------------------------- sign-in ---- */

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  background:
    radial-gradient(1000px 500px at 50% -10%, #eef2ff 0%, transparent 60%),
    var(--bg);
}
.auth-card { width: 100%; max-width: 400px; }
.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  margin-bottom: 22px;
  font-weight: 640;
  font-size: 17px;
  letter-spacing: -0.02em;
}
.auth-brand .mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent) 0%, #7c6cf5 100%);
  color: #fff; display: grid; place-items: center;
  font-size: 15px; font-weight: 700;
}
.auth-card .panel { box-shadow: var(--shadow-lg); padding: 26px; margin-bottom: 14px; }
.auth-card h1 { font-size: 18px; margin-bottom: 4px; }
.auth-card p.sub { margin-bottom: 4px; font-size: 13px; }
.auth-card .actions { margin-top: 20px; }
.auth-card .actions button { flex: 1; padding: 9px 14px; }
.auth-foot { text-align: center; color: var(--muted); font-size: 12.5px; }

/* --------------------------------------------------------- responsive --- */

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: 100%; flex: none; height: auto; position: static;
    border-right: 0; border-bottom: 1px solid var(--line);
  }
  .sidebar nav {
    flex-direction: row; flex-wrap: wrap; padding: 0 12px 12px; gap: 4px;
  }
  .sidebar .group { display: none; }
  .sidebar .foot { margin-top: 0; }
  .sidebar .foot form { display: inline-block; margin: 0 0 0 10px; }
  .sidebar .foot button { width: auto; }
  .sidebar .who { display: inline-flex; }
  main { padding: 20px 18px 56px; }
  .table-wrap { margin: 0 -20px -20px; }
}
