/* Apple HIG — 手机 iOS App + 电脑 macOS 统一 */

:root {
  --bg: #f5f5f7;
  --bg-elevated: #ffffff;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --muted-2: #86868b;
  --line: rgba(0, 0, 0, 0.08);
  --line-strong: rgba(0, 0, 0, 0.12);
  --fill: #e8e8ed;
  --fill-soft: rgba(118, 118, 128, 0.12);
  --blue: #0071e3;
  --blue-hover: #0077ed;
  --blue-pressed: #006edb;
  --blue-soft: rgba(0, 113, 227, 0.12);
  --qa-bg: #e8f2fc;
  --qa-fg: #0066cc;
  --case-bg: #e8f6ec;
  --case-fg: #248a3d;
  --note-bg: #fff6e5;
  --note-fg: #b25000;
  --danger-bg: #fce8e8;
  --danger-fg: #d70015;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-pill: 980px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.08);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Helvetica Neue", sans-serif;
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-h: 52px;
  --tab-h: 56px;
}

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

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

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.47;
  min-height: 100dvh;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 主屏幕全屏 / 独立 App：无浏览器栏，吃满安全区 */
html.is-standalone,
html.is-standalone body {
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  overscroll-behavior: none;
}
body.is-standalone {
  /* 状态栏半透明时内容可延伸到顶部 */
  padding-top: 0;
}
@media (display-mode: standalone), (display-mode: fullscreen) {
  html, body {
    min-height: 100dvh;
    overscroll-behavior: none;
  }
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }

/* —— Shell —— */
.app-shell {
  max-width: 980px;
  margin: 0 auto;
  min-height: 100dvh;
  padding-bottom: calc(var(--tab-h) + var(--safe-bottom) + 12px);
}

/* —— Top bar（与底栏统一的毛玻璃） —— */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: var(--nav-h);
  padding: calc(8px + var(--safe-top)) 18px 8px;
  background: rgba(249, 249, 249, 0.94);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid rgba(0, 0, 0, 0.18);
}

.brand {
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: -0.03em;
  white-space: nowrap;
  color: var(--ink);
}

.topnav {
  display: none;
  gap: 2px;
  margin-left: 4px;
}

.topnav a {
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 500;
  transition: color 0.25s var(--ease), background 0.25s var(--ease);
}

.topnav a.is-active,
.topnav a:hover {
  color: var(--ink);
  background: var(--fill-soft);
}

.topbar-user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8125rem;
}

.user-name {
  color: var(--muted);
  max-width: 88px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-muted { color: var(--blue); font-weight: 500; }
.link-muted:hover { opacity: 0.8; }

.main {
  padding: 8px 16px 32px;
}

/* —— Page head (iOS large title) —— */
.page-head {
  margin: 8px 0 18px;
}

.page-head h1 {
  margin: 0 0 4px;
  font-size: clamp(1.75rem, 5.5vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1.1;
  text-wrap: balance;
}

.page-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9375rem;
  font-weight: 400;
}

.page-head .back-link {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-bottom: 10px;
  color: var(--blue);
  font-size: 0.9375rem;
  font-weight: 500;
}

/* —— Search (iOS style) —— */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.search-bar input[type="search"] {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 14px 0 36px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--fill-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236e6e73' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='M11 11l3.5 3.5'/%3E%3C/svg%3E") 12px 50% no-repeat;
  outline: none;
  font-size: 1rem;
  transition: background 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.search-bar input[type="search"]::-webkit-search-decoration,
.search-bar input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.search-bar input:focus {
  background-color: #fff;
  box-shadow: 0 0 0 3.5px var(--blue-soft), var(--shadow-sm);
}

/* —— Buttons —— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 44px;
  padding: 0 18px;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--blue);
  color: #fff;
  font-size: 0.9375rem;
  font-weight: 560;
  letter-spacing: -0.01em;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.25s var(--ease), transform 0.15s var(--ease), opacity 0.2s;
}

.btn:hover { background: var(--blue-hover); }
.btn:active { background: var(--blue-pressed); transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-ghost {
  background: var(--fill-soft);
  color: var(--ink);
}
.btn-ghost:hover { background: rgba(118, 118, 128, 0.18); }
.btn-ghost:active { background: rgba(118, 118, 128, 0.22); }

.btn-sm {
  height: 36px;
  padding: 0 14px;
  font-size: 0.875rem;
}

.btn-block { width: 100%; }
.btn-copy-primary { min-width: 96px; }

/* —— Segmented control (types) —— */
.type-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
  margin-bottom: 14px;
  padding: 3px;
  background: var(--fill-soft);
  border-radius: var(--radius-sm);
}

.type-tabs a {
  text-align: center;
  padding: 8px 4px;
  border-radius: 8px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted);
  transition: background 0.2s var(--ease), color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.type-tabs a.is-active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 1px rgba(0, 0, 0, 0.04);
  font-weight: 600;
}

/* —— Category chips —— */
.filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 10px;
  margin: 0 -4px 12px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  height: 32px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  border: none;
  background: var(--bg-elevated);
  color: var(--ink);
  font-size: 0.8125rem;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.chip.is-active {
  background: var(--ink);
  color: #fff;
}

.cat-level3 .chip {
  background: transparent;
  box-shadow: none;
  border: 1px solid var(--line-strong);
}
.cat-level3 .chip.is-active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.filters-desktop { display: none !important; }
.topbar-admin-m { display: inline; }

/* —— Item list / cards —— */
.item-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item-card {
  display: block;
  background: var(--bg-elevated);
  border: none;
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s var(--ease), box-shadow 0.25s var(--ease);
}

.item-card:active {
  transform: scale(0.985);
}

.item-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-pill);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.tag-qa { background: var(--qa-bg); color: var(--qa-fg); }
.tag-case { background: var(--case-bg); color: var(--case-fg); }
.tag-note { background: var(--note-bg); color: var(--note-fg); }
.tag-warn { background: var(--danger-bg); color: var(--danger-fg); }
.tag-pin { background: var(--fill-soft); color: var(--muted); }

.item-title {
  margin: 0 0 6px;
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.item-preview {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.item-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.item-kicker {
  margin: 0 0 4px;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--muted-2);
}

.item-preview-label {
  display: inline-block;
  margin-right: 4px;
  padding: 0 5px;
  border-radius: 4px;
  background: var(--qa-bg);
  color: var(--qa-fg);
  font-size: 0.625rem;
  font-weight: 700;
  vertical-align: 1px;
}

.item-card--qa {
  border-left: 3px solid var(--qa-fg);
}
.item-card--qa .item-kicker { color: var(--qa-fg); }

.item-card--case {
  border-left: 3px solid var(--case-fg);
  background: linear-gradient(180deg, #f3faf5 0%, var(--bg-elevated) 48%);
}
.item-card--case .item-kicker { color: var(--case-fg); }
.item-card--case .item-preview { -webkit-line-clamp: 3; }

.item-card--note {
  border-left: 3px solid var(--note-fg);
  background: linear-gradient(180deg, #fffaf0 0%, var(--bg-elevated) 55%);
}
.item-card--note .item-kicker { color: var(--note-fg); }
.item-preview--note {
  font-family: "Songti SC", "Noto Serif SC", Georgia, serif;
}

.detail-label {
  margin: 0 0 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.detail-head--qa .detail-label { color: var(--qa-fg); }
.detail-head--case .detail-label { color: var(--case-fg); }
.detail-head--note .detail-label { color: var(--note-fg); }

.detail-card--qa { border-top: 3px solid var(--qa-fg); }
.detail-card--case {
  border-top: 3px solid var(--case-fg);
  background: linear-gradient(180deg, #f3faf5 0%, #fff 40%);
}
.detail-card--note {
  border-top: 3px solid var(--note-fg);
  background: linear-gradient(180deg, #fffaf0 0%, #fff 40%);
}
.detail-card--note .detail-body {
  font-family: "Songti SC", "Noto Serif SC", Georgia, serif;
  font-size: 1.05rem;
}

.internal-box--top { margin-bottom: 12px; }

.btn-case { background: var(--case-fg) !important; }
.btn-case:active { background: #1e6f32 !important; }
.btn-note { background: var(--note-fg) !important; }
.btn-note:active { background: #8a3e00 !important; }

.seg-section-title {
  font-size: 0.8125rem;
  margin: 20px 0 12px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.segment--qa { border-left: 3px solid var(--qa-fg); padding-left: 12px; }
.segment--case { border-left: 3px solid var(--case-fg); padding-left: 12px; }
.segment--note { border-left: 3px solid var(--note-fg); padding-left: 12px; }

/* —— Detail —— */
.detail-card {
  background: var(--bg-elevated);
  border: none;
  border-radius: var(--radius-lg);
  padding: 20px 18px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

.detail-body {
  font-size: 1.0625rem;
  line-height: 1.65;
  letter-spacing: -0.015em;
}
.detail-body p { margin: 0 0 14px; }
.detail-body p:last-child { margin-bottom: 0; }

.internal-box {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--note-bg);
  color: var(--note-fg);
  font-size: 0.875rem;
  line-height: 1.5;
}

.segment {
  background: var(--bg-elevated);
  border: none;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
}

.segment-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.segment-label {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0.02em;
}

.segment-body {
  white-space: pre-wrap;
  line-height: 1.6;
  font-size: 0.975rem;
}

.sticky-copy {
  position: sticky;
  bottom: calc(var(--tab-h) + var(--safe-bottom) + 8px);
  z-index: 30;
  padding: 12px 0 4px;
  background: linear-gradient(to top, var(--bg) 55%, transparent);
  pointer-events: none;
}
.sticky-copy .btn {
  pointer-events: auto;
}

.empty {
  text-align: center;
  padding: 56px 20px;
  color: var(--muted);
  font-size: 0.975rem;
}

/* —— iOS Tab Bar（均分 · 纯描边图标） —— */
.bottomnav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  height: calc(var(--tab-h) + var(--safe-bottom));
  background: rgba(249, 249, 249, 0.94);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid rgba(0, 0, 0, 0.18);
  box-sizing: border-box;
}

.bottomnav-track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  align-items: stretch;
  height: var(--tab-h);
  padding: 0;
  margin: 0;
}

.bottomnav .bn-item,
.bottomnav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  margin: 0;
  padding: 4px 2px 6px;
  min-width: 0;
  min-height: 0;
  max-width: none;
  height: 100%;
  color: #8e8e93;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.18s var(--ease);
}

.bottomnav .bn-item.is-active,
.bottomnav a.is-active {
  color: var(--blue);
}

.bottomnav .bn-item:active,
.bottomnav a:active {
  opacity: 0.55;
}

.bn-ico {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  line-height: 0;
}

.bn-ico svg {
  display: block;
  width: 24px;
  height: 24px;
  overflow: visible;
}

.bn-label {
  display: block;
  max-width: 100%;
  padding: 0 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
  line-height: 12px;
  text-align: center;
}

/* —— Toast —— */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tab-h) + var(--safe-bottom) + 20px);
  transform: translateX(-50%) translateY(10px);
  background: rgba(29, 29, 31, 0.92);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-pill);
  font-size: 0.875rem;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
  z-index: 100;
  backdrop-filter: blur(12px);
}
.toast.is-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* —— Auth (Apple login) —— */
.auth-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 28px 20px;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(0, 113, 227, 0.08), transparent 55%),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-elevated);
  border: none;
  border-radius: var(--radius-lg);
  padding: 36px 28px 28px;
  box-shadow: var(--shadow);
}

.auth-card .auth-mark {
  width: 52px;
  height: 52px;
  margin: 0 auto 18px;
  border-radius: 14px;
  background: linear-gradient(180deg, #3a3a3c 0%, #1d1d1f 100%);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.auth-card h1 {
  margin: 0 0 6px;
  text-align: center;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.15;
}

.auth-card .sub {
  margin: 0 0 28px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.field { margin-bottom: 14px; }
.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted);
}
.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 12px 14px;
  outline: none;
  font-size: 1rem;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.field textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.5;
  font-size: 0.975rem;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3.5px var(--blue-soft);
}

.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  font-size: 0.875rem;
}
.alert-error { background: var(--danger-bg); color: var(--danger-fg); }
.alert-ok { background: var(--case-bg); color: var(--case-fg); }

.remember-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 20px;
  font-size: 0.8125rem;
  color: var(--muted);
}

/* —— Admin (macOS System Settings — fixed shell) —— */
.admin-body {
  background:
    radial-gradient(ellipse 70% 40% at 100% 0%, rgba(0, 113, 227, 0.05), transparent 50%),
    var(--bg);
  min-height: 100dvh;
}

.admin-shell {
  --admin-side-w: 260px;
  display: grid;
  grid-template-columns: var(--admin-side-w) minmax(0, 1fr);
  min-height: 100dvh;
  max-width: 1440px;
  margin: 0 auto;
}

.admin-side {
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100dvh;
  padding: calc(18px + var(--safe-top)) 12px 16px;
  background: rgba(246, 246, 248, 0.92);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  border-right: 0.5px solid rgba(0, 0, 0, 0.12);
  z-index: 20;
}

.admin-side-head { margin-bottom: 18px; padding: 0 6px; }

.admin-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px;
  border-radius: 12px;
  transition: background 0.2s var(--ease);
}
.admin-brand:hover { background: var(--fill-soft); }

.admin-brand-mark {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #3a3a3c 0%, #1d1d1f 100%);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.admin-brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
}
.admin-brand-name {
  font-size: 0.9375rem;
  font-weight: 650;
  letter-spacing: -0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.admin-brand-sub {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--muted-2);
  letter-spacing: 0.02em;
}

.admin-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 2px;
}

.admin-nav-label {
  margin: 14px 10px 6px;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--muted-2);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.admin-nav-label:first-child { margin-top: 0; }

.admin-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}
.admin-nav-item:hover { background: rgba(0, 0, 0, 0.045); }
.admin-nav-item.is-active {
  background: var(--blue);
  color: #fff;
  font-weight: 600;
}
.admin-nav-item.is-active .admin-nav-ico { color: #fff; opacity: 1; }
.admin-nav-front { margin-top: 8px; color: var(--muted); }
.admin-nav-front:hover { color: var(--ink); }

.admin-nav-ico {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  color: var(--muted);
  opacity: 0.9;
}
.admin-nav-item:hover .admin-nav-ico { color: var(--ink); }

.admin-side-foot {
  margin-top: auto;
  padding: 12px 6px 4px;
  border-top: 0.5px solid rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  min-width: 0;
}

.admin-avatar {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--fill-soft);
  color: var(--ink);
  font-size: 0.8125rem;
  font-weight: 650;
  text-transform: uppercase;
}

.admin-user-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}
.admin-user-name {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.admin-user-role {
  font-size: 0.6875rem;
  color: var(--muted-2);
  font-weight: 500;
}

.admin-logout {
  align-self: flex-start;
  margin-left: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--blue);
  transition: background 0.18s var(--ease);
}
.admin-logout:hover { background: var(--blue-soft); }

.admin-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.admin-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 28px 16px;
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(245, 245, 247, 0.82);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid rgba(0, 0, 0, 0.08);
}

.admin-top-titles { min-width: 0; }
.admin-eyebrow {
  margin: 0 0 2px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted-2);
  letter-spacing: 0.01em;
}
.admin-top h1 {
  margin: 0;
  font-size: clamp(1.5rem, 2.4vw, 1.875rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.15;
}

.admin-top-front {
  flex: 0 0 auto;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--blue);
  background: var(--blue-soft);
  transition: background 0.18s var(--ease), transform 0.15s var(--ease);
}
.admin-top-front:hover { background: rgba(0, 113, 227, 0.18); }
.admin-top-front:active { transform: scale(0.97); }

.admin-content {
  padding: 20px 28px 56px;
  max-width: 1080px;
  width: 100%;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}
.toolbar .spacer { flex: 1; }

.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: stretch;
  margin-bottom: 16px;
}

.admin-filter {
  display: flex;
  flex: 1 1 280px;
  gap: 8px;
  min-width: 0;
  margin: 0;
}

.admin-filter input[type="search"] {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 14px 0 36px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--fill-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236e6e73' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='M11 11l3.5 3.5'/%3E%3C/svg%3E") 12px 50% no-repeat;
  outline: none;
  font-size: 0.9375rem;
  transition: background 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.admin-filter input[type="search"]:focus {
  background-color: #fff;
  box-shadow: 0 0 0 3.5px var(--blue-soft), var(--shadow-sm);
}

.admin-select {
  height: 40px;
  min-width: 112px;
  padding: 0 28px 0 12px;
  border: none;
  border-radius: var(--radius-sm);
  background-color: var(--fill-soft);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%236e6e73' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  font-size: 0.875rem;
  font-weight: 500;
  outline: none;
  cursor: pointer;
}
.admin-select:focus {
  background-color: #fff;
  box-shadow: 0 0 0 3.5px var(--blue-soft);
}

.admin-input-sm {
  height: 36px;
  width: 120px;
  max-width: 100%;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  font-size: 0.8125rem;
  outline: none;
}
.admin-input-sm:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
}

.table-wrap {
  overflow-x: auto;
  border: none;
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: var(--shadow-sm);
  -webkit-overflow-scrolling: touch;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
table.data th,
table.data td {
  padding: 13px 16px;
  text-align: left;
  border-bottom: 0.5px solid rgba(0, 0, 0, 0.08);
  vertical-align: middle;
}
table.data th {
  font-size: 0.6875rem;
  color: var(--muted);
  font-weight: 600;
  background: rgba(250, 250, 252, 0.95);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}
table.data tbody tr {
  transition: background 0.15s var(--ease);
}
table.data tbody tr:hover { background: rgba(0, 0, 0, 0.02); }
table.data tr:last-child td { border-bottom: none; }
table.data .cell-title {
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ink);
}
table.data .cell-muted { color: var(--muted); }
table.data .cell-num {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
table.data .empty-row td {
  text-align: center;
  color: var(--muted);
  padding: 40px 16px;
}

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted);
}
.status-dot::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted-2);
}
.status-dot.is-on { color: var(--case-fg); }
.status-dot.is-on::before { background: var(--case-fg); }
.status-dot.is-off { color: var(--muted); }

.form-grid {
  display: grid;
  gap: 14px;
  max-width: 720px;
  background: #fff;
  border: none;
  border-radius: var(--radius-lg);
  padding: 22px 22px 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.form-grid > h2 {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 650;
  letter-spacing: -0.025em;
}
.form-grid > .form-lead {
  margin: -6px 0 0;
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.45;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 20px;
  padding-top: 4px;
}
.check-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  margin: 0;
}
.check-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
}

.segment-block > .seg-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted);
}

.segment-editor {
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 10px;
  background: var(--bg);
}
.segment-editor .field:last-child { margin-bottom: 0; }

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

.btn-danger-ghost { color: var(--danger-fg); }
.btn-danger-ghost:hover {
  background: var(--danger-bg);
  color: var(--danger-fg);
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
.stat {
  background: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.stat::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--blue);
  opacity: 0.85;
  border-radius: 0 2px 2px 0;
}
.stat .n {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1;
  margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
}
.stat .l {
  font-size: 0.8125rem;
  color: var(--muted);
  font-weight: 500;
}

.toast-admin { bottom: 36px; }

.cat-indent-1 { font-weight: 650; }
.cat-indent-2 { padding-left: 12px !important; color: var(--ink); }
.cat-indent-3 { padding-left: 24px !important; color: var(--muted); }

.user-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}
.user-actions form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 0;
}


/* —— Desktop Apple layout —— */
@media (min-width: 768px) {
  .app-shell {
    padding-bottom: 40px;
  }

  .bottomnav { display: none; }

  .topnav { display: flex; }

  .topbar-admin-m { display: none; }

  .user-name { max-width: 160px; }

  .main {
    padding: 20px 28px 56px;
  }

  .page-head {
    margin: 12px 0 22px;
  }

  .search-bar input[type="search"] {
    height: 42px;
    font-size: 0.9375rem;
  }

  .item-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }

  .item-card {
    display: flex;
    flex-direction: column;
    padding: 18px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
  }

  .item-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
  }

  .item-card:active { transform: none; }

  .item-actions { margin-top: auto; padding-top: 14px; }

  .sticky-copy {
    bottom: 24px;
    max-width: 420px;
  }

  .toast { bottom: 36px; }

  .auth-card {
    padding: 44px 36px 36px;
  }
}

@media (min-width: 1024px) {
  .item-list {
    grid-template-columns: 1fr 1fr;
  }

  .topbar {
    padding-left: 28px;
    padding-right: 28px;
  }
}


@media (max-width: 900px) {
  .admin-shell {
    grid-template-columns: 1fr;
    max-width: none;
  }
  .admin-side {
    position: sticky;
    top: 0;
    height: auto;
    max-height: none;
    border-right: none;
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.12);
    padding: calc(10px + var(--safe-top)) 12px 10px;
    z-index: 30;
  }
  .admin-side-head { margin-bottom: 8px; }
  .admin-brand-sub { display: none; }
  .admin-nav {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 4px;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .admin-nav::-webkit-scrollbar { display: none; }
  .admin-nav-label { display: none; }
  .admin-nav-item {
    flex: 0 0 auto;
    padding: 8px 12px;
    white-space: nowrap;
  }
  .admin-nav-front { margin-top: 0; }
  .admin-side-foot { display: none; }
  .admin-main { min-height: 0; }
  .admin-top {
    padding: 14px 16px 12px;
    align-items: center;
  }
  .admin-top h1 { font-size: 1.375rem; }
  .admin-content { padding: 14px 16px 40px; }
  .form-row-2 { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: 1fr; }
  .form-grid { max-width: none; padding: 18px 16px; }
  .admin-filter { flex: 1 1 100%; }
}

@media (min-width: 901px) and (max-width: 1100px) {
  .admin-shell { --admin-side-w: 220px; }
  .admin-content { padding-left: 22px; padding-right: 22px; }
}

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