/* ------------------------------------------------------------------------------------------
   Navigation shell for the landlord app: sidebar, top bar and the page frame around them.
   This is the only stylesheet that styles .sidebar / .topbar / .main / .content. It is loaded
   last on every landlord page, after theme.css, app.css and ui.css.

   States (set by shell.js):
     .sidebar.is-wide   labels visible (hover peek, pinned on desktop, or the phone drawer)
     .sidebar.is-peek   expanded as an overlay above the content (no layout shift)
     .sidebar.is-open   phone drawer open
     :root[data-nav-pinned="1"]   user pinned the sidebar (desktop >= 1100px pushes content)
   ------------------------------------------------------------------------------------------ */
:root{
  --sb-rail:72px;
  --sb-wide:264px;
  --tb-h:64px;
  --sb-bg:#0f1513;
  --sb-border:rgba(255,255,255,.08);
  --sb-text:#aeb9b3;
  --sb-text-strong:#f5f8f6;
  --sb-muted:#6b7872;
  --sb-hover:rgba(255,255,255,.06);
  --sb-active:rgba(255,255,255,.1);
  --sb-accent:color-mix(in srgb,var(--brand,#159447) 68%,#fff);
  --sb-focus:0 0 0 2px var(--sb-bg),0 0 0 4px var(--sb-accent);
  --tb-bg:color-mix(in srgb,var(--surface,#fff) 88%,transparent);
  --tb-border:var(--border,#e2e8e5);
  --tb-text:var(--text,#111a16);
  --tb-muted:var(--muted,#68756f);
  --tb-soft:var(--ui-neutral-soft,#f1f4f3);
  --tb-sep:var(--ui-border-strong,#cfd8d3);
  --shell-ease:cubic-bezier(.2,.8,.2,1);
  --shell-font:var(--ui-font,Inter,ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif);
}
:root[data-theme="dark"]{--sb-bg:#090d0b;--sb-border:rgba(255,255,255,.07);--tb-soft:#1b2520;--tb-sep:#33443a}

/* ---- Page frame ------------------------------------------------------------------------ */
.app{min-height:100vh}
.main{margin-left:var(--sb-rail);min-height:100vh;min-width:0;transition:margin-left .22s var(--shell-ease)}
.content{width:100%;max-width:1480px;margin:0 auto;padding:28px 32px 96px;min-width:0;box-sizing:border-box}
.content>*{min-width:0;max-width:100%;box-sizing:border-box}
@media(min-width:1100px){:root[data-nav-pinned="1"] .main{margin-left:var(--sb-wide)}}
@media(max-width:1099px){.content{padding:24px 24px 48px}}

/* ---- Sidebar --------------------------------------------------------------------------- */
.sidebar{position:fixed;top:0;left:0;bottom:0;z-index:60;width:var(--sb-rail);display:flex;flex-direction:column;background:var(--sb-bg);color:var(--sb-text);border-right:1px solid var(--sb-border);font-family:var(--shell-font);overflow:hidden;transition:width .22s var(--shell-ease),box-shadow .22s var(--shell-ease)}
.sidebar *{box-sizing:border-box}
.sidebar.is-wide{width:var(--sb-wide)}
.sidebar.is-peek{box-shadow:18px 0 48px rgba(4,10,7,.32)}

.sb-head{height:var(--tb-h);flex:0 0 auto;display:flex;align-items:center;gap:6px;padding:0 12px;border-bottom:1px solid var(--sb-border)}
.sb-brand{flex:1 1 auto;min-width:0;height:48px;display:flex;align-items:center;gap:12px;padding:0 6px;border-radius:12px;color:inherit;text-decoration:none;outline:none}
.sb-brand:focus-visible{box-shadow:var(--sb-focus)}
.sb-mark{width:36px;height:36px;flex:0 0 36px;border-radius:11px;display:grid;place-items:center;background:var(--brand,#159447);color:#fff;box-shadow:inset 0 1px 0 rgba(255,255,255,.18),0 6px 16px rgba(0,0,0,.28)}
.sb-mark svg{display:block}
.sb-brand-text{display:flex;flex-direction:column;min-width:0;white-space:nowrap;opacity:0;transform:translateX(-6px);transition:opacity .16s ease,transform .18s var(--shell-ease)}
.sidebar.is-wide .sb-brand-text{opacity:1;transform:none;transition-delay:.05s}
.sb-brand-name{font-size:14.5px;font-weight:700;letter-spacing:-.01em;color:var(--sb-text-strong);line-height:1.15}
.sb-brand-sub{font-size:11px;font-weight:500;color:var(--sb-muted);margin-top:3px;line-height:1.1}
.sb-pin,.sb-close{width:32px;height:32px;flex:0 0 32px;border:0;border-radius:8px;background:transparent;color:var(--sb-muted);display:grid;place-items:center;cursor:pointer;padding:0;transition:background .14s,color .14s,opacity .14s}
.sb-pin svg,.sb-close svg{display:block}
.sb-pin:hover,.sb-close:hover{background:var(--sb-hover);color:var(--sb-text-strong)}
.sb-pin:focus-visible,.sb-close:focus-visible{outline:none;box-shadow:var(--sb-focus)}
.sb-pin{opacity:0;pointer-events:none}
.sidebar.is-wide .sb-pin{opacity:1;pointer-events:auto}
.sb-pin[aria-pressed="true"]{color:var(--sb-accent);background:var(--sb-hover)}
.sb-close{display:none}
@media(max-width:1099px){.sb-pin{display:none}}

.sb-nav{flex:1 1 auto;min-height:0;overflow-y:auto;overflow-x:hidden;padding:10px 12px 8px;scrollbar-width:none;-ms-overflow-style:none}
.sb-nav::-webkit-scrollbar{width:0;height:0}
.nav-section{padding:2px 0}
/* Group titles keep the same height in both states so items never move vertically; the rail
   shows a short divider where the expanded sidebar shows the group name. */
.nav-section-title{position:relative;height:28px;margin:4px 0 2px;padding:0 12px;display:flex;align-items:center;white-space:nowrap;font-size:10.5px;font-weight:700;letter-spacing:.09em;text-transform:uppercase;color:var(--sb-muted)}
.nav-section-title span{opacity:0;transition:opacity .15s ease}
.nav-section-title::before{content:"";position:absolute;left:14px;right:14px;top:50%;height:1px;background:var(--sb-border);transition:opacity .15s ease}
.sidebar.is-wide .nav-section-title span{opacity:1;transition-delay:.06s}
.sidebar.is-wide .nav-section-title::before{opacity:0}

/* Icon column is 48px wide in both states, so icons stay put while the labels fade in. */
.nav-link{position:relative;display:flex;align-items:center;gap:12px;width:100%;height:42px;margin:2px 0;padding:0 12px;border:0;border-radius:10px;background:transparent;color:var(--sb-text);font:600 13.5px/1 var(--shell-font);text-decoration:none;white-space:nowrap;cursor:pointer;outline:none;text-align:left;transition:background .14s ease,color .14s ease}
.nav-link:hover{background:var(--sb-hover);color:var(--sb-text-strong)}
.nav-link:focus-visible{box-shadow:var(--sb-focus)}
.nav-link.active{background:var(--sb-active);color:var(--sb-text-strong)}
.nav-link.active::before{content:"";position:absolute;left:0;top:50%;width:3px;height:20px;margin-top:-10px;border-radius:0 3px 3px 0;background:var(--sb-accent)}
.nav-icon{width:24px;height:24px;flex:0 0 24px;display:grid;place-items:center;color:var(--sb-muted);transition:color .14s ease}
.nav-icon svg{width:20px;height:20px;display:block}
.nav-link:hover .nav-icon{color:var(--sb-text)}
.nav-link.active .nav-icon{color:var(--sb-accent)}
.nav-label{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;opacity:0;transform:translateX(-6px);transition:opacity .15s ease,transform .18s var(--shell-ease)}
.sidebar.is-wide .nav-label{opacity:1;transform:none;transition-delay:.05s}
.sb-foot{flex:0 0 auto;padding:8px 12px 12px;border-top:1px solid var(--sb-border)}

/* ---- Top bar --------------------------------------------------------------------------- */
.topbar{position:sticky;top:0;z-index:40;height:var(--tb-h);display:flex;align-items:center;gap:10px;padding:0 24px 0 16px;background:var(--tb-bg);-webkit-backdrop-filter:blur(14px) saturate(140%);backdrop-filter:blur(14px) saturate(140%);border-bottom:1px solid var(--tb-border);color:var(--tb-text);font-family:var(--shell-font);box-sizing:border-box}
.tb-toggle,.tb-icon-btn{position:relative;width:38px;height:38px;flex:0 0 38px;border:0;border-radius:10px;background:transparent;color:var(--tb-muted);display:grid;place-items:center;padding:0;cursor:pointer;text-decoration:none;transition:background .14s,color .14s}
.tb-toggle svg,.tb-icon-btn svg{display:block}
.tb-toggle:hover,.tb-icon-btn:hover{background:var(--tb-soft);color:var(--tb-text)}
.tb-toggle[aria-expanded="true"]{color:var(--tb-text)}
.tb-toggle:focus-visible,.tb-icon-btn:focus-visible,.tb-avatar-btn:focus-visible{outline:none;box-shadow:var(--ui-focus,0 0 0 3px rgba(21,148,71,.3))}
.tb-heading{display:flex;align-items:center;gap:8px;min-width:0;font-size:14px;line-height:1.2;padding-left:2px}
.tb-crumb{color:var(--tb-muted);font-weight:500;white-space:nowrap}
.tb-sep{color:var(--tb-sep)}
.tb-title{font-weight:650;color:var(--tb-text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;letter-spacing:-.01em}
.topbar-quick-nav{display:flex;align-items:center;gap:2px;margin-left:10px;padding-left:14px;border-left:1px solid var(--tb-border);min-width:0;overflow:hidden;flex:0 1 auto}
.topbar-quick-nav:empty{display:none}
.topbar-quick-nav a{display:inline-flex;align-items:center;height:32px;padding:0 11px;border-radius:8px;color:var(--tb-muted);font:600 12.5px/1 var(--shell-font);text-decoration:none;white-space:nowrap;transition:background .14s,color .14s}
.topbar-quick-nav a:hover{background:var(--tb-soft);color:var(--tb-text)}
.topbar-quick-nav a.active{background:var(--brand-soft,#eaf7ef);color:var(--brand-strong,#0f7a39)}
@media(max-width:1099px) and (min-width:761px){.topbar-quick-nav{display:none}}
.top-actions{margin-left:auto;display:flex;align-items:center;gap:4px;flex:0 0 auto}
.tb-date{display:inline-flex;align-items:center;gap:7px;height:34px;padding:0 12px;margin-right:8px;border:1px solid var(--tb-border);border-radius:9px;background:var(--surface,#fff);color:var(--tb-muted);font:600 12px/1 var(--shell-font);white-space:nowrap}
.tb-date svg{display:block}
@media(max-width:1199px){.tb-date{display:none}}
.notification-badge{position:absolute;top:4px;right:4px;min-width:17px;height:17px;padding:0 4px;border-radius:99px;background:var(--ui-danger,#c0262d);color:#fff;font:700 10px/17px var(--shell-font);text-align:center;box-shadow:0 0 0 2px var(--surface,#fff)}
.notification-badge[hidden]{display:none}
.tb-profile{position:relative;margin-left:6px}
.tb-avatar-btn{border:0;background:transparent;padding:2px;border-radius:50%;cursor:pointer;display:grid;place-items:center}
.tb-avatar{width:34px;height:34px;border-radius:50%;display:grid;place-items:center;background:var(--brand,#159447);color:#fff;font:700 12.5px/1 var(--shell-font);letter-spacing:.03em;box-shadow:0 0 0 2px var(--surface,#fff),0 0 0 3px var(--tb-border)}
.tb-avatar.large{width:40px;height:40px;flex:0 0 40px;font-size:14px;box-shadow:none}
.profile-menu{position:absolute;right:0;top:calc(100% + 10px);width:272px;padding:8px;background:var(--surface,#fff);border:1px solid var(--tb-border);border-radius:14px;box-shadow:0 24px 56px rgba(16,24,20,.16),0 2px 6px rgba(16,24,20,.06);z-index:80;font-family:var(--shell-font);box-sizing:border-box}
.profile-menu[hidden]{display:none}
.profile-menu-head{display:flex;align-items:center;gap:11px;padding:8px 8px 6px}
.profile-menu-head>div{min-width:0;display:flex;flex-direction:column;gap:2px}
.profile-menu-head strong{font-size:14px;color:var(--tb-text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.profile-menu-head small{font-size:12px;color:var(--tb-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.profile-role{display:inline-flex;align-items:center;margin:2px 8px 8px;padding:3px 9px;border-radius:99px;background:var(--brand-soft,#eaf7ef);color:var(--brand-strong,#0f7a39);font:650 11px/1.4 var(--shell-font)}
.profile-menu-divider{height:1px;margin:4px 6px;background:var(--tb-border)}
.profile-menu a,.profile-menu button{width:100%;min-height:38px;display:flex;align-items:center;gap:10px;padding:0 10px;border:0;border-radius:9px;background:transparent;color:var(--tb-text);font:600 13px/1 var(--shell-font);text-decoration:none;cursor:pointer;text-align:left;box-sizing:border-box}
.profile-menu a svg,.profile-menu button svg{color:var(--tb-muted);flex:0 0 auto}
.profile-menu a:hover,.profile-menu button:hover{background:var(--tb-soft)}
.profile-menu a:focus-visible,.profile-menu button:focus-visible{outline:none;box-shadow:var(--ui-focus,0 0 0 3px rgba(21,148,71,.3))}
.profile-menu #profile-signout,.profile-menu #profile-signout svg{color:var(--ui-danger,#c0262d)}

/* ---- Phone: drawer sidebar, bottom tab bar ------------------------------------------- */
.shell-backdrop{position:fixed;inset:0;z-index:55;background:rgba(6,12,9,.48);opacity:0;pointer-events:none;transition:opacity .2s ease}
.shell-backdrop.show{opacity:1;pointer-events:auto}
@media(max-width:760px){
  .main{margin-left:0}
  body.nav-drawer-open{overflow:hidden}
  .sidebar,.sidebar.is-wide{width:min(300px,86vw);transform:translateX(-104%);visibility:hidden;border-right:0;box-shadow:none;transition:transform .26s var(--shell-ease),visibility 0s linear .26s}
  .sidebar.is-open{transform:none;visibility:visible;box-shadow:24px 0 60px rgba(4,10,7,.35);transition:transform .26s var(--shell-ease)}
  .sb-close{display:grid}
  .sb-pin{display:none}
  .nav-link{height:46px}
  .content{padding:18px 16px calc(96px + env(safe-area-inset-bottom))}
  .topbar{position:fixed;top:auto;bottom:0;left:0;right:0;height:auto;min-height:62px;padding:6px 8px calc(6px + env(safe-area-inset-bottom));gap:4px;border-top:1px solid var(--tb-border);border-bottom:0;background:var(--surface,#fff);-webkit-backdrop-filter:none;backdrop-filter:none;box-shadow:0 -8px 28px rgba(16,24,20,.08);z-index:70}
  .tb-heading,.tb-date{display:none}
  .topbar-quick-nav{display:flex;flex:1 1 auto;min-width:0;margin:0;padding:0 2px;border-left:0;overflow-x:auto;overflow-y:hidden;scrollbar-width:none;-webkit-overflow-scrolling:touch}
  .topbar-quick-nav::-webkit-scrollbar{display:none}
  .topbar-quick-nav a{height:40px;padding:0 11px;font-size:12px;flex:0 0 auto}
  .tb-toggle,.tb-icon-btn{width:42px;height:42px;flex-basis:42px}
  .tb-profile{margin-left:2px}
  .profile-menu{position:fixed;right:10px;left:auto;top:auto;bottom:calc(70px + env(safe-area-inset-bottom));width:min(288px,calc(100vw - 20px))}
}

@media(prefers-reduced-motion:reduce){
  .sidebar,.main,.nav-label,.nav-icon,.nav-link,.sb-brand-text,.nav-section-title span,.nav-section-title::before,.shell-backdrop,.sb-pin{transition:none!important}
}
@media print{
  .sidebar,.topbar,.shell-backdrop,#property-agent{display:none!important}
  .main{margin:0!important}
  .content{padding:0!important;max-width:none!important}
}

/* ---- Loading states --------------------------------------------------------------------- */
.brand-loader{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;padding:32px;color:var(--tb-muted);font:500 13px/1.3 var(--shell-font);min-height:160px}
.brand-loader-mark{position:relative;width:44px;height:44px;display:block}
.brand-loader-mark svg{width:44px;height:44px;display:block;animation:brand-breathe 1.6s var(--shell-ease) infinite}
.brand-loader-mark::after{content:"";position:absolute;inset:-6px;border-radius:16px;border:2px solid var(--brand,#159447);opacity:0;animation:brand-ring 1.6s var(--shell-ease) infinite}
@keyframes brand-breathe{0%,100%{transform:scale(1);opacity:1}50%{transform:scale(.94);opacity:.85}}
@keyframes brand-ring{0%{transform:scale(.9);opacity:.45}70%,100%{transform:scale(1.15);opacity:0}}
.brand-loader.full{min-height:100vh}
#boot{display:grid;place-items:center;min-height:100vh}
#route-loader .route-loader-spinner{width:28px;height:28px;margin-left:-14px;top:16px;border:0;border-radius:7px;background:url(/favicon.svg) center/contain no-repeat;box-shadow:0 6px 18px rgba(16,24,20,.18);animation:brand-breathe 1.2s var(--shell-ease) infinite}
/* Existing "Loading…" placeholders across the app get the brand mark without any markup change. */
.loading{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;padding:40px 20px;color:var(--tb-muted);font:500 13px/1.3 var(--shell-font);text-align:center}
.loading::before{content:"";width:40px;height:40px;border-radius:11px;background:url(/favicon.svg) center/contain no-repeat;animation:brand-breathe 1.4s var(--shell-ease) infinite}
.sk-cards{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:14px}
.sk-card{display:grid;gap:10px;align-content:start;min-height:140px}
.sk-row{display:flex;gap:12px;align-items:center;padding:10px 0;border-bottom:1px solid var(--tb-border)}
.sk-row:last-child{border-bottom:0}
.sk-row.head{padding-top:4px}
.sk-table{padding:14px 18px}
.sk-list{display:grid;gap:8px}
.sk-item{display:flex;gap:12px;align-items:center;padding:12px 14px;border:1px solid var(--tb-border);border-radius:12px;background:var(--surface,#fff)}
.sk-item .ui-skel:first-child{border-radius:10px;flex:0 0 36px}
.sk-lines{flex:1;display:grid;gap:8px}
.ui-btn.is-busy,.btn.is-busy{position:relative;color:transparent!important;pointer-events:none}
.ui-btn.is-busy::after,.btn.is-busy::after{content:"";position:absolute;width:16px;height:16px;left:50%;top:50%;margin:-8px 0 0 -8px;border-radius:50%;border:2px solid rgba(255,255,255,.45);border-top-color:#fff;animation:btn-spin .7s linear infinite}
.ui-btn.is-busy:not(.primary)::after,.btn.is-busy:not(.primary)::after{border-color:rgba(0,0,0,.18);border-top-color:var(--tb-text)}
@keyframes btn-spin{to{transform:rotate(360deg)}}
@media(prefers-reduced-motion:reduce){.brand-loader-mark svg,.brand-loader-mark::after,#route-loader .route-loader-spinner,.loading::before{animation:none}.brand-loader-mark::after{display:none}}

/* ---- Accent tokens (mirrors theme.css so pages that do not load it, e.g. maintenance, still get the chosen brand colour) ---- */
:root[data-accent="green"]{--brand:#159447;--brand-strong:#0f7a39;--brand-soft:#eaf7ef;--brand-pale:#f3fbf6}
:root[data-accent="blue"]{--brand:#315efb;--brand-strong:#2448d8;--brand-soft:#edf2ff;--brand-pale:#f6f8ff}
:root[data-accent="indigo"]{--brand:#4f46e5;--brand-strong:#3730a3;--brand-soft:#eef2ff;--brand-pale:#f7f7ff}
:root[data-accent="purple"]{--brand:#7c3aed;--brand-strong:#5b21b6;--brand-soft:#f3eefe;--brand-pale:#faf8ff}
:root[data-accent="teal"]{--brand:#0f8f87;--brand-strong:#0b6f69;--brand-soft:#e9f8f7;--brand-pale:#f3fcfb}
:root[data-accent="cyan"]{--brand:#0891b2;--brand-strong:#0e7490;--brand-soft:#e7f8fc;--brand-pale:#f3fcfe}
:root[data-accent="orange"]{--brand:#ea7b16;--brand-strong:#c85f0a;--brand-soft:#fff2e6;--brand-pale:#fffaf5}
:root[data-accent="rose"]{--brand:#e54867;--brand-strong:#be3150;--brand-soft:#fff0f3;--brand-pale:#fff8f9}
:root[data-accent="red"]{--brand:#dc3b3b;--brand-strong:#b42318;--brand-soft:#fff0f0;--brand-pale:#fff8f8}
:root[data-accent="slate"]{--brand:#475467;--brand-strong:#344054;--brand-soft:#f0f2f5;--brand-pale:#f8f9fa}

/* Section tabs: related pages that are not in the sidebar (Invoices · Billing centre, ...) */
.tb-sections{display:inline-flex;align-items:center;gap:2px;padding:3px;border-radius:11px;background:var(--ui-neutral-soft,#f1f4f3);min-width:0;overflow-x:auto;scrollbar-width:none}
.tb-sections::-webkit-scrollbar{display:none}
.tb-sections a{padding:6px 12px;border-radius:8px;font:600 13px/1.2 var(--ui-font,inherit);color:var(--ui-text-2,#3c4842);text-decoration:none;white-space:nowrap}
.tb-sections a:hover{color:var(--ui-text,#111a16)}
.tb-sections a.active{background:var(--ui-surface,#fff);color:var(--ui-text,#111a16);box-shadow:0 1px 2px rgba(0,0,0,.08)}
.tb-heading:has(.tb-sections)~.topbar-quick-nav{display:none}
@media(max-width:760px){.tb-heading:has(.tb-sections) .tb-crumb,.tb-heading:has(.tb-sections) .tb-sep{display:none}.tb-sections a{padding:6px 9px;font-size:12.5px}}
