* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font-body); font-size: var(--fs-body); line-height: 1.5;
  color: var(--color-text); background: var(--bg-app); -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; }
h1 { font-size: var(--fs-title); }
h2 { font-size: var(--fs-section); }
a { color: var(--color-link); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; font-size: inherit; }
::selection { background: var(--color-accent-200); }
:focus-visible { outline: 2px solid var(--color-accent-500); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--color-text-muted); }
.small { font-size: var(--fs-label); }
.mono { font-family: var(--font-body); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- login ---------- */
#login { display: none; min-height: 100vh; align-items: center; justify-content: center; background: var(--bg-app); padding: 16px; }
#login.shown { display: flex; }
#loginForm { width: 100%; max-width: 340px; background: var(--bg-panel); border: 1px solid var(--color-border); border-radius: var(--radius-card); padding: 32px 28px; }
#loginForm .logo { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
#loginForm .logo b { font-size: 22px; letter-spacing: 0.04em; }
#loginForm .error { color: var(--bad); min-height: 20px; font-size: var(--fs-label); margin: 6px 0 10px; }

/* ---------- app shell: ink frame, one white sheet ---------- */
#app { display: none; min-height: 100vh; }
#app.shown { display: flex; flex-direction: column; height: 100vh; background: var(--ink); }
.topbar {
  height: var(--topbar-h); flex: none; display: flex; align-items: center; gap: 16px; padding: 0 16px;
  background: var(--ink); color: var(--white); position: relative; z-index: 30;
}
.topbar-brand { color: var(--white); font-weight: 600; font-size: 17px; letter-spacing: 0.1em; text-decoration: none; width: calc(var(--sidebar-w) - 24px); flex: none; }
.topbar-brand:hover { text-decoration: none; }
.topbar .menu-btn { display: none; }
.search-trigger {
  flex: 1; max-width: 560px; margin: 0 auto; display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px; cursor: pointer; border: 0;
  border-radius: var(--radius-full); background: color-mix(in srgb, var(--white) 12%, transparent); color: color-mix(in srgb, var(--white) 72%, transparent);
}
.search-trigger:hover { background: color-mix(in srgb, var(--white) 18%, transparent); }
.search-trigger kbd { margin-left: auto; font-family: var(--font-body); font-size: 11px; border: 1px solid color-mix(in srgb, var(--white) 30%, transparent); border-radius: var(--radius-md); padding: 0 6px; color: inherit; }
.topbar-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.topbar .icon-btn { color: var(--white); }
.topbar .icon-btn:hover { background: color-mix(in srgb, var(--white) 12%, transparent); border-color: transparent; }
.topbar .ai-btn { background: transparent; border: 1px solid color-mix(in srgb, var(--white) 30%, transparent); color: var(--white); height: 32px; padding: 0 12px; font-size: var(--fs-label); }
.topbar .ai-btn:disabled { opacity: .65; cursor: not-allowed; }
.bell-wrap { position: relative; }
.icon-btn { position: relative; display: inline-grid; place-items: center; width: 36px; height: 36px; border: 1px solid transparent; border-radius: var(--radius-ctl); background: none; cursor: pointer; color: var(--color-neutral-700); }
.icon-btn:hover { background: var(--bg-hover); border-color: var(--color-border); }
.icon-btn .dot { position: absolute; top: 3px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: var(--radius-full); background: var(--bad); color: var(--white); font-size: 10px; line-height: 16px; text-align: center; }
.avatar { width: 30px; height: 30px; border-radius: var(--radius-full); background: var(--white); color: var(--ink); display: grid; place-items: center; font-weight: 600; font-size: 12px; }

.sheet { flex: 1; min-height: 0; display: flex; margin: 0 8px 8px; background: var(--bg-panel); border-radius: var(--radius-xl); overflow: hidden; }
.sidebar { flex: none; width: var(--sidebar-w); display: flex; flex-direction: column; background: var(--n50); border-right: 1px solid var(--color-border); transition: width .15s ease; }
.sidebar-restaurant { padding: 14px 12px 6px; }
.sidebar-restaurant select { width: 100%; }
.sidebar-scroll { flex: 1; overflow-y: auto; padding: 4px 8px 8px; }
.nav-group { margin-top: 10px; }
.nav-group-head {
  display: flex; align-items: center; justify-content: space-between; width: 100%; background: none; border: 0; cursor: pointer;
  padding: 6px 8px; color: var(--color-text-muted); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 600;
}
.nav-group-head .i { transition: transform .12s; }
.nav-group.closed .nav-group-head .i { transform: rotate(-90deg); }
.nav-group.closed .nav-items { display: none; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none; cursor: pointer; text-align: left;
  border-radius: var(--radius-md); color: var(--color-neutral-700); text-decoration: none; font-size: var(--fs-body);
}
.nav-item:hover { background: var(--white); text-decoration: none; }
.nav-item.active { background: var(--white); color: var(--ink); font-weight: 500; }
.nav-item.active::before { content: ''; position: absolute; left: 0; top: 7px; bottom: 7px; width: 3px; border-radius: var(--radius-full); background: var(--green); }
.nav-item .label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-count { min-width: 20px; padding: 0 6px; border-radius: var(--radius-full); background: var(--white); border: 1px solid var(--color-border); color: var(--ink); font-size: 11px; font-weight: 600; line-height: 18px; text-align: center; }
.sidebar-bottom { border-top: 1px solid var(--color-border); padding: 8px; }
.sidebar-collapse { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none; cursor: pointer; color: var(--color-text-muted); border-radius: var(--radius-md); }
.sidebar-collapse:hover { background: var(--white); }

body.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
body.sidebar-collapsed .sidebar-restaurant, body.sidebar-collapsed .nav-group-head,
body.sidebar-collapsed .nav-item .label, body.sidebar-collapsed .sidebar-collapse .label { display: none; }
body.sidebar-collapsed .nav-group.closed .nav-items { display: block; }
body.sidebar-collapsed .nav-item { justify-content: center; padding: 9px 0; }
body.sidebar-collapsed .nav-count { position: absolute; top: 2px; right: 4px; }
body.sidebar-collapsed .sidebar-collapse { justify-content: center; }

.main { flex: 1; min-width: 0; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; }
.page { flex: 1; padding: 20px 24px 48px; min-width: 0; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-header .titles { min-width: 0; }
.breadcrumb { font-size: var(--fs-label); color: var(--color-text-muted); margin-bottom: 4px; display: flex; gap: 6px; align-items: center; }
.breadcrumb a { color: var(--color-text-muted); }
.page-header .title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-header .sub { color: var(--color-text-muted); margin-top: 2px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

@media (max-width: 860px) {
  #app.shown { height: auto; min-height: 100vh; }
  .topbar { padding: 0 12px; gap: 8px; position: sticky; top: 0; }
  .topbar .menu-btn { display: inline-grid; }
  .topbar-brand { width: auto; }
  .ai-wrap { display: none; }
  .sheet { margin: 0; border-radius: var(--radius-xl) var(--radius-xl) 0 0; overflow: visible; }
  .main { overflow: visible; }
  .sidebar { position: fixed; z-index: 60; left: 0; top: 0; height: 100vh; transform: translateX(-100%); transition: transform .15s; width: var(--sidebar-w) !important; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax var(--scrim); }
  .search-trigger kbd, .search-trigger .t { display: none; }
  .search-trigger { flex: none; margin: 0 0 0 auto; width: 36px; justify-content: center; padding: 0; }
  .page { padding: 16px 12px 40px; }
}
