/* ==========================================================================
   Infostock admin - v2 shell & components
   Transcribed from the approved design mockups (design-admin/build.sh).
   Single stylesheet: tokens, shell, components, helpers, responsive drawer.
   ========================================================================== */

:root {
  --ink: #1c1c1a;
  --muted: #6f6e69;
  --faint: #9b9a94;
  --ink-soft: #4a4945;

  --bg: #f6f6f4;
  --surface: #fff;
  --surface-2: #fafaf8;
  --hover: #f1f0ec;
  --hover-2: #eeede9;

  --line: #e6e5e1;
  --line-soft: #eeede9;
  --line-field: #d9d8d3;
  --line-box: #c9c8c2;

  --brand: #2b5fb3;
  --brand-hover: #24519a;
  --brand-ink: #1e4a8f;
  --brand-soft: #e8eef9;

  --ok-bg: #e3f3ea;
  --ok-fg: #1f7a4d;
  --off-bg: #fbf1d9;
  --off-fg: #9a6400;
  --danger: #b42323;
  --danger-bg: #fbe7e7;
  --danger-line: #f3d0d0;

  --radius: 6px;
  --radius-lg: 8px;
  --sidebar-w: 232px;
}

/* --------------------------------------------------------------- base ---- */

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-ink); text-decoration: underline; }

input, select, textarea, button { font: inherit; color: inherit; }

img { max-width: 100%; }

h1, h2, h3, h4 { margin: 0; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}
.btn:focus-visible,
.ibtn:focus-visible,
.tb-btn:focus-visible,
.nav-item:focus-visible,
.nav-sub a:focus-visible,
.input:focus-visible,
input.input:focus-visible,
select.input:focus-visible,
textarea.input:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}
input.input:focus, select.input:focus, textarea.input:focus {
  border-color: var(--brand);
}

/* -------------------------------------------------------------- shell ---- */

.app {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  gap: 4px;
}

.sidebar-logo {
  padding: 4px 12px 16px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo img { width: 128px; height: auto; }
.sidebar-logo a:hover { text-decoration: none; }

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 36px;
  padding: 0 12px;
  border-radius: var(--radius);
  color: var(--ink);
  font-weight: 500;
  font-size: 14px;
}
.nav-item:hover { background: var(--hover); text-decoration: none; color: var(--ink); }
.nav-item.active { background: var(--brand-soft); color: var(--brand-ink); }

.nav-sub {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 2px 0 6px 0;
}
.nav-sub a {
  display: flex;
  align-items: center;
  height: 32px;
  padding: 0 12px 0 36px;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 14px;
}
.nav-sub a:hover { background: var(--hover); text-decoration: none; color: var(--ink); }
.nav-sub a.active { color: var(--brand-ink); font-weight: 500; }

.nav-spacer { flex-grow: 1; }

.sidebar-foot {
  border-top: 1px solid var(--line-soft);
  padding: 12px 12px 4px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.sidebar-user { display: flex; flex-direction: column; min-width: 0; }
.sidebar-name {
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-role { font-size: 12px; color: var(--muted); }
.sidebar-foot a { font-size: 13px; color: var(--muted); white-space: nowrap; }

.main {
  flex-grow: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 60px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.page-title {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}

.crumb { font-size: 13px; color: var(--muted); }

.content {
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* --------------------------------------------------------- form fields --- */

.field { display: flex; flex-direction: column; gap: 6px; }

.label { font-size: 13px; font-weight: 500; color: var(--muted); }

.input {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line-field);
  border-radius: var(--radius);
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}
.input.placeholder { color: var(--faint); }

/* the same look on real controls */
input.input,
select.input,
textarea.input {
  display: block;
  width: 100%;
  max-width: 100%;
}
input.input::-webkit-input-placeholder { color: var(--faint); }
input.input::placeholder,
textarea.input::placeholder { color: var(--faint); }

select.input {
  padding: 0 6px;
  line-height: normal;
}

textarea.input {
  height: auto;
  min-height: 90px;
  padding: 8px 10px;
  line-height: 1.45;
  resize: vertical;
}

.check { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.box {
  width: 18px;
  height: 18px;
  border: 1px solid var(--line-box);
  border-radius: 4px;
  background: var(--surface);
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.box.on { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ------------------------------------------------------------ buttons ---- */

.btn {
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line-field);
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  color: var(--ink);
}
.btn:hover { text-decoration: none; background: var(--surface-2); color: var(--ink); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-hover); color: #fff; }
.btn.quiet { border-color: transparent; background: transparent; color: var(--muted); }
.btn.quiet:hover { background: var(--hover); color: var(--ink); }
.btn.danger { color: var(--danger); }
.btn[disabled], .btn.disabled { opacity: .55; cursor: default; }

.icon { width: 18px; height: 18px; flex: none; }

.ibtn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  cursor: pointer;
}
.ibtn:hover { background: var(--hover-2); color: var(--ink); text-decoration: none; }

/* --------------------------------------------------- badges and chips ---- */

.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.badge.ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge.off { background: var(--off-bg); color: var(--off-fg); }
.badge.neutral { background: var(--hover-2); color: var(--muted); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 6px 0 10px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

/* -------------------------------------------------------------- cards ---- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
.card-h {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-b {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ------------------------------------------------------------- tables ---- */

table { border-collapse: collapse; width: 100%; font-size: 14px; }
th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  position: sticky;
  top: 0;
  z-index: 1;
}
td {
  padding: 0 12px;
  height: 44px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
  white-space: nowrap;
}
tr:hover td { background: var(--surface-2); }
td.title { white-space: normal; font-weight: 500; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.table-wrap { overflow-x: auto; }

/* --------------------------------------------------------------- tabs ---- */

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tab {
  padding: 10px 14px;
  font-weight: 500;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { text-decoration: none; color: var(--ink); }
.tab.active { color: var(--brand-ink); border-bottom-color: var(--brand); }

/* ----------------------------------------------------- editor toolbar ---- */

.editor-tb {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  flex-wrap: wrap;
}
.tb-btn {
  width: 30px;
  height: 30px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  border: 0;
  background: transparent;
  cursor: pointer;
}
.tb-btn:hover { background: var(--hover-2); text-decoration: none; }
.tb-sep { width: 1px; height: 20px; background: var(--line); margin: 0 6px; }

/* ------------------------------------------------------------ banners ---- */

.banner {
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 14px;
}
.banner.error { background: var(--danger-bg); border-color: var(--danger-line); color: var(--danger); }
.banner.success { background: var(--ok-bg); border-color: #cbe7d8; color: var(--ok-fg); }

/* ------------------------------------------------------------ helpers ---- */

.muted { color: var(--muted); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.grid-6 { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }

/* ---------------------------------------------------------- home page ---- */

.home-card {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.home-card-t { font-size: 16px; font-weight: 600; color: var(--ink); }
.home-card-t:hover { color: var(--brand-ink); }
.home-card-l {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 13px;
}

/* --------------------------------------------------------- login page ---- */

.login-wrap {
  flex-grow: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
}
.login-card {
  width: 380px;
  max-width: 100%;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.login-card .logo { width: 150px; height: auto; }
.login-card .input,
.login-card .btn { height: 40px; }

/* -------------------------------------------------- off-canvas drawer ---- */

.nav-toggle {
  display: none;
  position: fixed;
  top: 13px;
  left: 12px;
  z-index: 60;
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}
.nav-scrim { display: none; }

@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform .18s ease-out;
    box-shadow: 0 8px 32px rgba(28, 28, 26, .16);
  }
  body.nav-open .sidebar { transform: translateX(0); }

  body.nav-open .nav-scrim {
    display: block;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 45;
    background: rgba(28, 28, 26, .35);
  }

  .topbar {
    padding: 10px 16px 10px 56px;
    flex-wrap: wrap;
  }
  .content { padding: 16px; }

  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .grid-2, .grid-3, .grid-6 { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}

/* Pagination emitted by the shared PaginationTag (wrap its output in <div class="pager">) */
.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  padding: 12px 16px;
  border-top: 1px solid #eeede9;
  font-size: 13px;
}

.pager a.speclnk {
  height: 32px;
  padding: 0 12px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #6f6e69;
  text-decoration: none;
  font-weight: 500;
}

.pager a.speclnk:hover {
  background: #eeede9;
  text-decoration: none;
}

.pager b {
  font-weight: 500;
}

.pager b u {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 12px;
  border-radius: 6px;
  background: #e8eef9;
  color: #1e4a8f;
  text-decoration: none;
}
