/* Staff app shell and shared components. View-specific styles live in calendar.css and views.css. */

html.layer-open, html.layer-open body { overflow: hidden; }
body.app-body { min-height: 100dvh; }

/* ── Shell ── */
.app { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); min-height: 100dvh; }
.rail {
  position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column;
  background: var(--paper); border-right: 1px solid var(--line); padding: 18px 12px 14px;
  overflow-y: auto;
}
.rail-brand { padding: 4px 10px 18px; display: flex; flex-direction: column; gap: 6px; }
.rail-brand .wordmark { height: 30px; width: auto; }
.rail-brand small { color: var(--ink-3); font-size: var(--fs-xs); letter-spacing: .01em; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  position: relative; display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 0 12px;
  border-radius: var(--r-md); color: var(--ink-2); font-weight: 500; text-decoration: none;
}
.nav a svg { width: 19px; height: 19px; flex: none; color: var(--ink-3); }
.nav a:hover { background: var(--mist-2); text-decoration: none; }
.nav a[aria-current='page'] { background: var(--canopy-tint); color: var(--canopy); font-weight: 600; }
.nav a[aria-current='page'] svg { color: var(--canopy); }
.nav a[aria-current='page']::before { content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--horizon); }
.nav .count { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--sold); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.nav-sep { height: 1px; background: var(--line); margin: 10px 8px; }
.rail-foot { margin-top: auto; padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.ridges { height: 74px; margin: 0 -12px; background: var(--ridges) center bottom / cover no-repeat; opacity: .9; pointer-events: none; }
.me { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: var(--r-md); background: transparent; text-align: left; }
.me:hover { background: var(--mist-2); }
.topbar .mobile-only { display: none; }
@media (max-width: 899px) { .topbar .mobile-only { display: grid; } }
.me .avatar { flex: none; }
.me-name { font-weight: 600; font-size: var(--fs-sm); line-height: 1.2; }
.me-role { font-size: var(--fs-xs); color: var(--ink-3); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--canopy); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 12.5px; letter-spacing: .02em; flex: none; border: 0; }
.avatar.sm { width: 26px; height: 26px; font-size: 10.5px; }
.avatar.tint { background: var(--canopy-tint); color: var(--canopy); }

.main { min-width: 0; display: flex; flex-direction: column; min-height: 100dvh; }
.topbar {
  position: sticky; top: 0; z-index: 30; background: rgba(243, 247, 244, .92); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line); padding: 10px var(--gutter); padding-top: calc(10px + var(--safe-top));
  display: flex; align-items: center; gap: 12px; min-height: var(--topbar-h);
}
.topbar .brand-mini { display: none; }
.scope { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; flex: 1 1 auto; min-width: 0; padding: 2px 1px; }
.scope::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 14px; border-radius: var(--r-pill);
  border: 1px solid var(--line-strong); background: var(--paper); color: var(--ink-2);
  font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; letter-spacing: .01em;
}
.chip:hover { background: var(--mist-2); }
.chip[aria-pressed='true'] { background: var(--canopy); border-color: var(--canopy); color: #fff; }
.chip .pdot { box-shadow: 0 0 0 2px rgba(255,255,255,.9); }
.chip[aria-pressed='true'] .pdot { box-shadow: 0 0 0 2px rgba(255,255,255,.35); }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.searchbtn {
  display: flex; align-items: center; gap: 8px; height: 38px; min-width: 230px; padding: 0 12px; border-radius: var(--r-md);
  border: 1px solid var(--line-strong); background: var(--paper); color: var(--ink-3); font-size: var(--fs-sm); text-align: left;
}
.searchbtn svg { width: 17px; height: 17px; }
.searchbtn:hover { border-color: #9DB2A7; }
.searchbtn kbd { margin-left: auto; font: inherit; font-size: 11px; border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; color: var(--ink-3); background: var(--mist); }

.view { flex: 1 1 auto; padding: var(--s5) var(--gutter) var(--s10); min-width: 0; }
.view.flush { padding-left: 0; padding-right: 0; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s3) var(--s4); margin-bottom: var(--s5); }
.page-head h1 { font-size: 30px; }
.page-head .sub { color: var(--ink-3); margin-top: 4px; }
.page-actions { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }

.tabbar { display: none; }

/* ── Phone layout ── */
@media (max-width: 899px) {
  .app { display: block; }
  .rail { display: none; }
  .topbar { position: static; flex-wrap: wrap; row-gap: 8px; padding-top: calc(8px + var(--safe-top)); }
  .topbar .brand-mini { display: flex; align-items: center; gap: 8px; order: 0; }
  .topbar .brand-mini img { height: 22px; width: auto; }
  .topbar-actions { order: 1; margin-left: auto; }
  .scope { order: 2; flex: 1 0 100%; }
  .topbar .searchbtn { min-width: 0; width: 40px; height: 40px; padding: 0; justify-content: center; }
  .topbar .searchbtn span, .topbar .searchbtn kbd { display: none; }
  .topbar .new-btn { display: none; }
  .view { padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 28px); }
  .page-head h1 { font-size: 26px; }
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: grid; grid-template-columns: repeat(5, 1fr); align-items: stretch;
    height: calc(var(--tabbar-h) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
    background: rgba(255, 255, 255, .96); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid var(--line);
  }
  .tabbar a, .tabbar button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; background: transparent;
    color: var(--ink-3); font-size: 10.5px; font-weight: 600; text-decoration: none; position: relative; -webkit-tap-highlight-color: transparent;
  }
  .tabbar svg { width: 22px; height: 22px; }
  .tabbar a[aria-current='page'] { color: var(--canopy); }
  .tabbar a[aria-current='page']::before { content: ''; position: absolute; top: 0; width: 28px; height: 3px; border-radius: 0 0 3px 3px; background: var(--horizon); }
  .tabbar .fab { position: relative; }
  .tabbar .fab span.disc {
    position: absolute; top: -18px; width: 54px; height: 54px; border-radius: 50%; background: var(--canopy); color: #fff; display: grid; place-items: center;
    box-shadow: 0 6px 16px rgba(27, 90, 71, .45), 0 0 0 5px var(--mist);
  }
  .tabbar .fab svg { width: 26px; height: 26px; }
  .tabbar .fab small { margin-top: 30px; font-size: 10.5px; font-weight: 600; color: var(--ink-3); }
  .tabbar .badge-dot { position: absolute; top: 8px; margin-left: 16px; width: 8px; height: 8px; border-radius: 50%; background: var(--sold); }
}

/* ── Layers ── */
#layers { position: relative; z-index: 100; }
.layer-wrap { position: fixed; inset: 0; z-index: 100; display: flex; justify-content: flex-end; }
.scrim { position: absolute; inset: 0; background: rgba(12, 36, 29, .5); animation: fade .18s ease-out; }
.layer {
  position: relative; display: flex; flex-direction: column; background: var(--paper); color: var(--ink); max-height: 100%;
  box-shadow: var(--shadow-pop); outline: none;
}
.layer-head { display: flex; align-items: flex-start; gap: 8px; padding: 16px 12px 12px 20px; border-bottom: 1px solid var(--line); flex: none; }
.layer-title { flex: 1 1 auto; min-width: 0; padding-top: 3px; }
.layer-title h2 { font-size: 21px; overflow-wrap: anywhere; }
.layer-sub { color: var(--ink-3); font-size: var(--fs-sm); margin-top: 3px; }
.layer-body { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding: 18px 20px 24px; -webkit-overflow-scrolling: touch; }
.layer-foot { flex: none; display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 10px; padding: 12px 20px calc(12px + var(--safe-bottom)); border-top: 1px solid var(--line); background: var(--paper); }
.layer-foot .foot-info { margin-right: auto; }
.layer-sheet { width: min(100%, 560px); height: 100%; animation: slide-in .24s var(--ease); }
.layer-sheet.size-sm { width: min(100%, 440px); }
.layer-sheet.size-lg { width: min(100%, 760px); }
.layer-sheet.size-xl { width: min(100%, 980px); }
.layer-dialog { margin: auto; width: min(92vw, 460px); border-radius: var(--r-lg); animation: pop-in .2s var(--ease); max-height: min(88dvh, 760px); }
.layer-dialog.size-md { width: min(92vw, 560px); }
.layer-dialog.size-lg { width: min(92vw, 720px); }
.layer-wrap .layer-dialog { align-self: center; }
.layer-wrap:has(.layer-dialog) { justify-content: center; }
.layer-wrap.closing .scrim { animation: fade-out .18s ease-in forwards; }
.layer-wrap.closing .layer-sheet { animation: slide-out .18s ease-in forwards; }
.layer-wrap.closing .layer-dialog { animation: pop-out .16s ease-in forwards; }
.dialog-msg { color: var(--ink-2); font-size: var(--fs-md); }

@media (max-width: 899px) {
  .layer-wrap, .layer-wrap:has(.layer-dialog) { align-items: flex-end; justify-content: stretch; }
  .layer-sheet, .layer-sheet.size-sm, .layer-sheet.size-lg, .layer-sheet.size-xl {
    width: 100%; height: calc(100dvh - 22px - var(--safe-top)); max-height: none; border-radius: 20px 20px 0 0; box-shadow: var(--shadow-sheet); animation: rise .26s var(--ease);
  }
  .layer-dialog, .layer-dialog.size-md, .layer-dialog.size-lg { width: 100%; margin: 0; border-radius: 20px 20px 0 0; max-height: 90dvh; box-shadow: var(--shadow-sheet); animation: rise .24s var(--ease); align-self: flex-end; }
  .layer-wrap.closing .layer-sheet, .layer-wrap.closing .layer-dialog { animation: sink .18s ease-in forwards; }
  .layer-head::before { content: ''; position: absolute; top: 7px; left: 50%; width: 38px; height: 4px; margin-left: -19px; border-radius: 3px; background: var(--line-strong); }
  .layer-head { padding-top: 20px; }
  .layer-body { padding: 16px 16px 20px; }
  .layer-foot { padding: 10px 16px calc(10px + var(--safe-bottom)); }
  .layer-foot > .btn:not(.btn-quiet) { flex: 1 1 0; }
  .layer-foot .foot-info { flex: 1 0 100%; margin: 0 0 4px; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } }
@keyframes slide-out { to { transform: translateX(40px); opacity: 0; } }
@keyframes pop-in { from { transform: translateY(10px) scale(.98); opacity: 0; } }
@keyframes pop-out { to { transform: translateY(6px) scale(.98); opacity: 0; } }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
@keyframes sink { to { transform: translateY(40px); opacity: 0; } }

.action-list { display: flex; flex-direction: column; gap: 4px; margin: -6px -8px; }
.action { display: flex; align-items: center; gap: 14px; min-height: 52px; padding: 8px 12px; border: 0; background: transparent; border-radius: var(--r-md); text-align: left; font-weight: 600; color: var(--ink); }
.action:hover:not(:disabled) { background: var(--mist-2); }
.action svg { width: 20px; height: 20px; color: var(--ink-3); flex: none; }
.action.danger, .action.danger svg { color: var(--danger); }
.action-label { display: block; }
.action-hint { display: block; font-size: var(--fs-xs); font-weight: 400; color: var(--ink-3); margin-top: 2px; }

/* ── Toasts ── */
#toasts { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(92vw, 460px); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 12px 14px; border-radius: 12px; background: var(--ink); color: #fff; font-weight: 500; box-shadow: var(--shadow-pop); animation: rise .22s var(--ease); }
.toast svg { flex: none; margin-top: 1px; color: #7DE0A6; }
.toast.error { background: #7C2415; }
.toast.error svg { color: #FFC2B7; }
.toast.out { opacity: 0; transform: translateY(8px); transition: .2s; }
@media (max-width: 899px) { #toasts { bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 14px); } }

/* ── Generic components ── */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: var(--s4); }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: var(--s3); }
.card-head h3 { font-size: var(--fs-lg); }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: var(--s6) 0 var(--s3); }
.sec-head:first-child { margin-top: 0; }
.sec-head h3 { font-size: var(--fs-lg); }
.divider { height: 1px; background: var(--line); margin: var(--s4) 0; }
.kv { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 4px 12px; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: var(--fs-base); }
.kv:last-child { border-bottom: 0; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.kv.total dd, .kv.total dt { font-weight: 700; color: var(--ink); }

.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); margin-bottom: var(--s4); }
.tabs::-webkit-scrollbar { display: none; }
.tab { position: relative; flex: none; min-height: 42px; padding: 0 14px; border: 0; background: transparent; color: var(--ink-3); font-weight: 600; font-size: var(--fs-base); display: inline-flex; align-items: center; gap: 8px; }
.tab:hover { color: var(--ink); }
.tab[aria-selected='true'] { color: var(--canopy); }
.tab[aria-selected='true']::after { content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--canopy); }
.tab-badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--mist-3); color: var(--ink-2); font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.tab[aria-selected='true'] .tab-badge { background: var(--canopy); color: #fff; }

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 44px 20px; color: var(--ink-3); }
.empty h3 { color: var(--ink); font-size: var(--fs-lg); }
.empty p { max-width: 38ch; }
.empty-ico { width: 54px; height: 54px; border-radius: 50%; background: var(--mist-2); display: grid; place-items: center; color: var(--canopy); margin-bottom: 4px; }
.empty-ico.bad { background: var(--danger-bg); color: var(--danger); }
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 48px 0; color: var(--ink-3); }
.spin { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--canopy); animation: spin .7s linear infinite; }
.skeleton { display: flex; flex-direction: column; gap: 10px; padding: 4px 0; }
.sk-row { height: 56px; border-radius: 12px; background: linear-gradient(100deg, var(--mist-2) 30%, #F6FAF7 50%, var(--mist-2) 70%); background-size: 300% 100%; animation: shimmer 1.4s infinite linear; }
@keyframes shimmer { to { background-position: -150% 0; } }

/* ── Login ── */
.auth { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); background: var(--paper); }
.auth-art {
  position: relative; overflow: hidden; color: #E7F3EC; padding: 48px 56px; display: flex; flex-direction: column; justify-content: flex-start; gap: 9vh;
  background: linear-gradient(165deg, #0F3A2E 0%, #134A3A 52%, #1B5A47 100%);
}
.auth-art::before { content: ''; position: absolute; left: 0; right: 0; bottom: 0; top: 46%; background: var(--ridges-dark) center bottom / 100% 100% no-repeat; }
.auth-art > * { position: relative; }
.auth-art .brand-chip { align-self: flex-start; background: #fff; border-radius: 14px; padding: 12px 18px; }
.auth-art .brand-chip img { height: 30px; width: auto; }
.auth-art h2 { font-size: clamp(30px, 3.6vw, 46px); line-height: 1.08; color: #fff; max-width: 14ch; }
.auth-art p { color: #BBD7C9; max-width: 38ch; margin-top: 14px; font-size: var(--fs-md); }
.auth-form-wrap { position: relative; z-index: 1; display: grid; place-items: center; padding: 32px 24px; }
.auth-form { width: min(100%, 380px); display: flex; flex-direction: column; gap: 18px; }
.auth-form h1 { font-size: 30px; margin-bottom: 6px; }
.auth-form .note { color: var(--ink-3); font-size: var(--fs-sm); }
.auth-form .pw { position: relative; }
.auth-form .pw .peek { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
@media (max-width: 899px) {
  .auth { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .auth-art { padding: 28px 22px 70px; min-height: 0; }
  .auth-art::before { top: 0; }
  .auth-art h2, .auth-art p { display: none; }
  .auth-art .brand-chip { padding: 10px 14px; }
  .auth-art .brand-chip img { height: 24px; }
  .auth-form-wrap { align-items: start; padding-top: 4px; margin-top: -40px; }
  .auth-form { background: var(--paper); border-radius: 20px; padding: 24px 20px; box-shadow: var(--shadow-pop); }
}

@media print {
  html, body { background: #fff !important; }
  .rail, .topbar, .tabbar, #toasts, .no-print { display: none !important; }
  .app { display: block; }
  .view { padding: 0 !important; }
}
