/* ============================================================================
   Kelderhof Ops — layout (v16 design-system refresh)
   App shell: white sidebar (desktop), floating pill nav (mobile),
   sage hero band, cream/sage canvas split.
   ============================================================================ */

/* --- Mobile canvas — cream like desktop, sage lives in the hero only --- */
body { background: var(--cream); }

.app {
  background: var(--cream);
  min-height: 100vh;
  max-width: 560px;
  margin: 0 auto;
  position: relative;
  padding-bottom: 92px;
}

/* --- Mobile top bar (only on legacy pages without a .page-hero) ----- */
.app-header {
  padding: 16px 18px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--brown);
}
.app-header .brand { flex: 1; min-width: 0; }
.app-header .brand .name {
  font-size: 16px; line-height: 1.1;
  color: var(--brown); font-weight: 600;
  letter-spacing: 0.16em; text-transform: uppercase;
}
.app-header .brand small {
  display: block; font-size: 11px;
  color: var(--text-light); margin-top: 3px;
  letter-spacing: 0.02em; text-transform: none; font-weight: 400;
}
.app-header .back-btn {
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-md);
  background: var(--white);
  border: 1px solid var(--border);
  color: var(--brown); font-size: 18px;
  margin-right: 8px; flex-shrink: 0;
}

/* --- Floating pill bottom nav ------------------------- */
.bottom-tabs {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 24px);
  max-width: 456px;
  background: var(--white);
  border-radius: var(--r-pill);
  padding: 8px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 8px 24px rgba(67, 35, 17, 0.12);
  z-index: 50;
}
.bottom-tabs a {
  flex: 1;
  background: transparent;
  padding: 10px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  border-radius: var(--r-pill);
  color: var(--text-light);
  font-size: 10px;
  font-weight: 500;
  min-height: 52px;
  justify-content: center;
  text-decoration: none;
  position: relative;
  letter-spacing: 0;
  text-transform: none;
}
.bottom-tabs a.active {
  background: var(--sage-darker);
  color: var(--white);
  padding: 10px 16px;
  flex-direction: row;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
}
.bottom-tabs .ico { font-size: 18px; line-height: 1; }
.bottom-tabs a.active .ico { font-size: 16px; }
.bottom-tabs .badge {
  position: absolute; top: 4px; right: 22%;
  background: var(--danger); color: var(--white);
  border-radius: var(--r-pill); font-size: 10px; padding: 1px 6px; font-weight: 700;
}

/* --- Desktop shell (sidebar) -------------------------- */
.shell { display: block; }
.sidebar { display: none; }

@media (min-width: 768px) {
  body { background: var(--cream); }
  .app {
    max-width: none;
    background: var(--cream);
    padding-bottom: 60px;
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
  }
  .app-header { display: none; }
  .bottom-tabs { display: none; }

  .shell {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
    background: var(--cream);
  }
  .shell .app {
    max-width: none;
    background: var(--cream);
    padding-bottom: 60px;
    display: block;
    padding-left: 28px;
    padding-right: 28px;
  }

  .sidebar {
    display: flex;
    flex-direction: column;
    background: var(--white);
    border-right: 1px solid var(--border);
    padding: 22px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
  }
  .sidebar .brand-block {
    text-align: center;
    padding: 6px 0 22px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
  }
  .sidebar .brand-block .name {
    font-size: 16px;
    color: var(--brown);
    letter-spacing: 0.16em;
    font-weight: 600;
    text-transform: uppercase;
  }
  .sidebar .brand-block small {
    display: block; font-size: 11px;
    color: var(--brown); font-style: italic;
    margin-top: 4px; letter-spacing: 0;
    text-transform: none; font-weight: 400;
  }
  .sidebar .brand-block .version-stamp {
    font-style: normal !important;
    margin-top: 6px !important;
    font-size: 10px !important;
    color: var(--text-light) !important;
    letter-spacing: 0.16em !important;
    opacity: 0.6;
  }
  .sidebar nav {
    display: flex; flex-direction: column; gap: 3px; flex: 1 0 auto;
  }
  .sidebar nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: var(--r-md);
    font-size: 14px;
    color: var(--text-mid);
    font-weight: 500;
    text-decoration: none;
    transition: all var(--t-fast);
    letter-spacing: 0; text-transform: none;
    position: relative;
  }
  .sidebar nav a:hover { background: var(--sage-tint); color: var(--text); }
  .sidebar nav a.active {
    background: var(--sage-soft);
    color: var(--text);
    font-weight: 600;
  }
  .sidebar nav a .ico {
    width: 26px; height: 26px;
    border-radius: 8px;
    background: var(--sage-soft);
    color: var(--sage-darker);
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 700;
    flex-shrink: 0;
    opacity: 1;
    text-align: center;
  }
  .sidebar nav a.active .ico {
    background: var(--sage-darker);
    color: var(--white);
  }
  .sidebar nav a .badge {
    margin-left: auto;
    background: var(--danger);
    color: var(--white);
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
    letter-spacing: 0;
  }
  .sidebar .me {
    margin-top: auto;
    padding: 12px;
    background: var(--cream);
    border-radius: var(--r-md);
    display: flex; align-items: center; gap: 11px;
  }
  .sidebar .me .av {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--brown);
    color: var(--cream);
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 600;
    flex-shrink: 0;
  }
  .sidebar .me .info { flex: 1; min-width: 0; overflow: hidden; }
  .sidebar .me .name {
    font-size: 13px; color: var(--text); font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    letter-spacing: 0; text-transform: none;
  }
  .sidebar .me .role {
    font-size: 11px; color: var(--text-light);
    margin-top: 2px; letter-spacing: 0; text-transform: none;
  }
  .sidebar .signout { padding: 10px 0 4px; }
  .sidebar .signout button {
    width: 100%; padding: 9px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--white);
    font-size: 12px; font-weight: 500;
    color: var(--text-mid);
    text-transform: none; letter-spacing: 0;
  }
  .sidebar .signout button:hover { color: var(--text); border-color: var(--text-light); }
}

/* --- Sage hero band (desktop) + mobile alternative ---- */
.page-hero {
  background: var(--sage);
  border-radius: var(--r-xl);
  padding: 24px 28px;
  color: var(--white);
  margin: 0 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  flex-wrap: wrap;
}
.page-hero .greeting { font-size: 13px; opacity: 0.85; }
.page-hero .title {
  font-size: 22px;
  font-weight: 700;
  color: var(--white);
  margin-top: 4px;
  line-height: 1.1;
  letter-spacing: -0.005em;
}
.page-hero .sub { font-size: 14px; opacity: 0.85; margin-top: 4px; }
.page-hero .actions { display: flex; gap: 10px; align-items: center; }

.icon-btn {
  width: 42px; height: 42px;
  border-radius: var(--r-md);
  background: rgba(255,255,255,0.2);
  color: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  position: relative;
  backdrop-filter: blur(6px);
}
.icon-btn:hover { background: rgba(255,255,255,0.3); }
.icon-btn .dot {
  position: absolute;
  top: 10px; right: 11px;
  width: 8px; height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--sage);
}
.page-hero .cta {
  background: var(--white);
  color: var(--sage-darker);
  padding: 11px 18px;
  border-radius: var(--r-md);
  font-size: 14px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 8px;
  text-decoration: none;
  cursor: pointer;
}
.page-hero .cta:hover { background: var(--cream); }

/* Back button inside a sage page-hero — white pill, sits above the greeting */
.hero-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px 7px 11px;
  background: rgba(255, 255, 255, 0.22);
  color: var(--white);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: var(--t-fast);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.hero-back-btn:hover {
  background: rgba(255, 255, 255, 0.32);
  border-color: rgba(255, 255, 255, 0.42);
}
.hero-back-btn span:first-child { font-size: 15px; line-height: 1; }

/* Back link sitting on cream above a white card hero (Task / Asset detail) */
.back-row { margin: 0 0 12px; }
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px 8px 12px;
  background: var(--white);
  color: var(--text-mid);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: var(--t-fast);
  box-shadow: var(--shadow-card);
}
.back-link:hover {
  color: var(--text);
  border-color: var(--text-light);
  background: var(--sage-tint);
}
.back-link span:first-child { font-size: 14px; line-height: 1; }

@media (min-width: 1100px) {
  .page-hero .title { font-size: 28px; }
  /* Note: do NOT cap .app — it breaks page centering. Let .app fill its grid cell. */
}

/* ==========================================================================
   Universal page content layout
   --------------------------------------------------------------------------
   #js-page is the container every page renders into. Apply consistent
   padding + centred max-width here so every page lines up identically.
   Per-page CSS should NOT override max-width/margin on #js-page.
   ========================================================================== */
#js-page {
  padding: 8px 18px 28px;
  margin-left: auto !important;
  margin-right: auto !important;
  width: auto;
  box-sizing: border-box;
}
@media (min-width: 768px) {
  #js-page { padding: 16px 28px 28px; }
}
@media (min-width: 1024px) {
  #js-page {
    padding: 24px 36px 40px;
    max-width: 1180px !important;
  }
}
@media (min-width: 1400px) {
  #js-page { max-width: 1320px !important; }
}
/* Settings forms read better narrower */
@media (min-width: 1024px) {
  body[data-page="settings"] #js-page { max-width: 960px !important; }
}
/* Job detail is a single-column read — keep tighter */
@media (min-width: 1024px) {
  body[data-page="tasks"][data-view="job"] #js-page { max-width: 960px !important; }
}

/* --- Grid helpers ------------------------------------ */
.grid       { display: grid; gap: 16px; }
.grid-2     { grid-template-columns: repeat(2, 1fr); }
.grid-3     { grid-template-columns: repeat(3, 1fr); }
.grid-4     { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.row.wrap    { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 14px; }

/* --- Login / reset-password (single-column form layout) --- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: var(--cream);
}
.login { width: 100%; max-width: 380px; text-align: left; }
.login .mark {
  font-size: 16px; color: var(--brown);
  letter-spacing: 0.16em; text-transform: uppercase; font-weight: 600;
  text-align: center;
}
.login .kicker { margin-top: 6px; text-align: center; }
.login h2 {
  font-size: 22px; color: var(--text);
  margin: 26px 0 6px; font-weight: 700;
  letter-spacing: -0.005em;
}
.login p { font-size: 14px; color: var(--text-mid); margin: 0 0 18px; line-height: 1.5; }
.login form { display: flex; flex-direction: column; gap: 10px; }
.login label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-top: 8px; }
.login input {
  padding: 14px 16px; border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  background: var(--white); font-size: 15px; outline: none;
  color: var(--text); min-height: 52px;
}
.login input:focus { border-color: var(--sage-deep); background: var(--white); }
.login .msg {
  font-size: 13px; color: var(--text-mid); margin-top: 12px;
  padding: 12px 14px;
  background: var(--cream); border: 1px solid var(--border);
  border-radius: var(--r-md); line-height: 1.5;
}
.login .msg.ok  { color: var(--sage-darker); background: var(--sage-tint); border-color: var(--sage-soft); }
.login .msg.err { color: var(--danger); background: var(--danger-soft); border-color: rgba(184,90,58,0.25); }
.leaf { display: none; }
