/* =========================================================================
   VesselData — lean UI
   Visual source of truth: docs/design/vesseldata-lean-prototype.html
   Section numbers in comments refer to docs/design/UI-REDESIGN-SPEC.md
   ========================================================================= */

/* ---------- Self-hosted fonts (spec 1: no CDN in production) ---------- */
/* latin */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url('/assets/fonts/inter-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* latin-ext */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url('/assets/fonts/inter-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url('/assets/fonts/space-grotesk-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* latin-ext */
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url('/assets/fonts/space-grotesk-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/assets/fonts/ibm-plex-mono-400-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* latin-ext */
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/assets/fonts/ibm-plex-mono-400-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/assets/fonts/ibm-plex-mono-500-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* latin-ext */
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/assets/fonts/ibm-plex-mono-500-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- Design tokens (spec 1, prototype :root) ---------- */
:root {
  color-scheme: light;

  --ink: #101820;
  --mut: #5B6B72;
  --faint: #8B979D;
  --paper: #F6F8F9;
  --card: #FFFFFF;
  --line: #E3E8EB;
  --line-soft: #EEF2F4;
  --teal: #0F6B66;
  --teal-dark: #0B5450;
  --teal-soft: #E4F0EF;
  --teal-mid: #CFE4E2;
  --red: #BC3A28;
  --red-soft: #F9E9E6;
  --amber: #9A6B12;
  --amber-soft: #F7EDD9;
  --blue: #2B5AA7;
  --blue-soft: #E8EEF8;

  --r: 10px;
  --r-sm: 7px;
  --shadow: 0 1px 2px rgba(16, 24, 32, .05), 0 4px 16px rgba(16, 24, 32, .05);
  --shadow-lg: 0 8px 40px rgba(16, 24, 32, .16);
  --ring: 0 0 0 3px rgba(15, 107, 102, .18);

  --ui: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --disp: 'Space Grotesk', var(--ui);
  --mono: 'IBM Plex Mono', ui-monospace, Consolas, monospace;

  --side-w: 236px;
  --rail-w: 64px;
  --drawer-w: 360px;
}

/* ---------- Reset & base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
}

body {
  font-family: var(--ui);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  height: 100vh;
  overflow: hidden;
  line-height: 1.5;
}

button {
  font: inherit;
  cursor: pointer;
  background: none;
  border: none;
  color: inherit;
}

button:disabled {
  cursor: not-allowed;
  opacity: .45;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

input,
textarea,
select {
  font: inherit;
  color: inherit;
}

::placeholder {
  color: var(--faint);
}

a {
  color: var(--teal-dark);
}

ul,
ol {
  list-style: none;
}

img {
  max-width: 100%;
}

h1 {
  font-family: var(--disp);
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: -.01em;
}

h2 {
  font-family: var(--disp);
  font-weight: 600;
  font-size: 1.02rem;
}

h3 {
  font-family: var(--disp);
  font-weight: 600;
  font-size: .95rem;
}

h4 {
  font-family: var(--disp);
  font-weight: 600;
  font-size: .87rem;
}

.hidden,
[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Convention: mono = data, UI font = labels (spec 1) */
.mono {
  font-family: var(--mono);
}

.spacer {
  flex: 1;
}

.muted,
.sub {
  color: var(--mut);
  font-size: .86rem;
}

.meta {
  color: var(--faint);
  font-size: .78rem;
}

.empty-state,
.compact-empty,
.members-empty {
  color: var(--faint);
  font-size: .85rem;
  padding: 14px 0;
}

.empty-line {
  padding: 26px 18px;
  text-align: center;
  color: var(--faint);
  font-size: .86rem;
}

.error,
.error-text {
  color: var(--red);
  font-size: .83rem;
}

.error:empty {
  display: none;
}

.brand-logo {
  display: block;
  object-fit: contain;
}

/* =========================================================================
   Spec 2 — Application frame: sidebar, topbar, drawer
   ========================================================================= */
.app-shell {
  display: grid;
  grid-template-columns: var(--side-w) 1fr;
  height: 100vh;
}

.app-shell.rail {
  grid-template-columns: var(--rail-w) 1fr;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--card);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  min-height: 0;
}

.side-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 4px 16px 6px;
}

.sidebar-logo {
  height: 24px;
  width: auto;
  flex: none;
}

.logo-word {
  font-family: var(--disp);
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: .01em;
  flex: 1;
  white-space: nowrap;
}

.logo-word b {
  color: var(--teal);
}

.railbtn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: var(--faint);
  flex: none;
}

.railbtn:hover {
  background: var(--paper);
  color: var(--ink);
}

.side-nav {
  display: flex;
  flex-direction: column;
}

/* Sidebar buttons: Home, New project, Settings, account actions */
.wide-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  color: var(--mut);
  font-weight: 500;
  font-size: .89rem;
  margin-bottom: 2px;
}

.wide-button svg {
  flex: none;
}

.wide-button:hover:not(:disabled) {
  background: var(--paper);
  color: var(--ink);
}

.wide-button.active-nav,
.wide-button.active {
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-weight: 600;
}

.wide-button.danger-link {
  color: var(--red);
}

.wide-button.danger-link:hover {
  background: var(--red-soft);
}

.sidebar-label {
  font-family: var(--mono);
  font-size: .66rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 18px 10px 8px;
}

.sidebar-sub-label {
  padding-top: 14px;
}

.sidebar-projects {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.sidebar-filter {
  display: flex;
  gap: 4px;
  padding: 0 4px 8px;
}

.sidebar-filter button {
  font-size: .74rem;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 20px;
  color: var(--mut);
  border: 1px solid transparent;
}

.sidebar-filter button:hover {
  background: var(--paper);
}

.sidebar-filter button.active {
  background: var(--ink);
  color: #fff;
}

.project-list {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  scrollbar-width: thin;
}

.project-list > p {
  color: var(--faint);
  font-size: .82rem;
  padding: 8px 10px;
}

/* Project entries: name + client·number in mono, status dot, red badge */
.project {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  margin-bottom: 2px;
  cursor: pointer;
  position: relative;
}

.project:hover {
  background: var(--paper);
}

.project.active {
  background: var(--teal-soft);
}

.project .pname {
  font-weight: 600;
  font-size: .9rem;
  display: flex;
  align-items: center;
  gap: 7px;
}

.project .pname .label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project .pmeta {
  font-family: var(--mono);
  font-size: .7rem;
  color: var(--faint);
  margin-top: 2px;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--teal);
  flex: none;
}

.dot.warn,
.dot.bad {
  background: var(--red);
}

.badge {
  margin-left: auto;
  font-family: var(--mono);
  font-size: .68rem;
  background: var(--red-soft);
  color: var(--red);
  border-radius: 20px;
  padding: 1px 7px;
  font-weight: 500;
  flex: none;
}

.sidebar-account {
  margin-top: auto;
  border-top: 1px solid var(--line-soft);
  padding-top: 10px;
  position: relative;
}

.account-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  width: 100%;
  text-align: left;
}

.account-chip:hover {
  background: var(--paper);
}

.account-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: .72rem;
  font-weight: 600;
  font-family: var(--disp);
  flex: none;
}

.account-meta {
  min-width: 0;
  line-height: 1.2;
}

.account-meta strong {
  font-size: .86rem;
  font-weight: 600;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-meta small {
  font-size: .72rem;
  color: var(--faint);
}

/* Account menu — log out and profile stay here (spec 7) */
.account-menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 70;
}

/* ---------- Collapsible rail (spec 2) ---------- */
.app-shell.rail .sidebar {
  padding: 16px 10px;
}

.app-shell.rail .side-head {
  justify-content: center;
  padding: 2px 0 14px;
}

.app-shell.rail .logo-word,
.app-shell.rail .lbl,
.app-shell.rail .sidebar-label,
.app-shell.rail .sidebar-filter,
.app-shell.rail .pmeta,
.app-shell.rail .account-meta,
.app-shell.rail .account-menu {
  display: none;
}

.app-shell.rail .wide-button {
  justify-content: center;
  padding: 9px 0;
}

.app-shell.rail .project {
  width: 38px;
  height: 38px;
  padding: 0;
  display: grid;
  place-items: center;
  margin: 0 auto 6px;
}

.app-shell.rail .project .pname {
  display: none;
}

.app-shell.rail .project::before {
  content: attr(data-init);
  font-family: var(--disp);
  font-weight: 600;
  font-size: .7rem;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--paper);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: var(--mut);
}

.app-shell.rail .project.active::before {
  background: var(--teal-soft);
  border-color: var(--teal-mid);
  color: var(--teal-dark);
}

/* Red pip preserves the overdue signal when collapsed (spec 2) */
.app-shell.rail .project[data-pip='1']::after {
  content: '';
  position: absolute;
  top: 3px;
  right: 3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  border: 1.5px solid var(--card);
}

.app-shell.rail .account-chip {
  justify-content: center;
  padding: 6px 0;
}

/* ---------- Main column & topbar ---------- */
.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
  flex: none;
}

.crumb {
  font-size: .85rem;
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crumb b {
  color: var(--ink);
  font-weight: 600;
}

.topbar-search {
  flex: 1;
  max-width: 420px;
  margin-left: auto;
  position: relative;
  display: flex;
  align-items: center;
}

.topbar-search svg {
  position: absolute;
  left: 10px;
  color: var(--faint);
  pointer-events: none;
}

/* The id is deliberate: this has to outrank the generic `input:not(...)` rule
   further down, otherwise the leading room for the magnifier icon is lost. */
.topbar-search input#home-search {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 7px 12px 7px 34px;
  background: var(--paper);
  font-size: .86rem;
}

.iconbtn {
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  color: var(--mut);
  border: 1px solid transparent;
  position: relative;
  flex: none;
}

.iconbtn:hover {
  background: var(--paper);
  color: var(--ink);
}

.iconbtn.on {
  background: var(--teal-soft);
  color: var(--teal-dark);
  border-color: var(--teal-mid);
}

.iconbtn .pip {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
  border: 1.5px solid var(--card);
}

.menubtn {
  display: none;
}

/* ＋ Create menu (spec 2) */
.create-wrap {
  position: relative;
  flex: none;
}

.popover-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  z-index: 70;
  min-width: 210px;
  padding: 6px;
}

.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  font-weight: 500;
  font-size: .86rem;
  color: var(--ink);
}

.menu-item:hover:not(:disabled) {
  background: var(--paper);
}

.menu-divider {
  height: 1px;
  background: var(--line-soft);
  margin: 5px 4px;
}

/* ---------- Views ---------- */
.view {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding: 28px;
  scroll-behavior: smooth;
}

.view.view-flush {
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.wrap {
  max-width: 880px;
  margin: 0 auto;
}

.wrap-wide {
  max-width: 1000px;
}

/* ---------- Right drawer (spec 2) ---------- */
.drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--drawer-w);
  background: var(--card);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  transform: translateX(105%);
  transition: transform .22s ease;
  display: flex;
  flex-direction: column;
  z-index: 40;
}

.drawer.open {
  transform: none;
}

.dhead {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  flex: none;
}

.dtab {
  padding: 7px 13px;
  border-radius: var(--r-sm);
  font-weight: 600;
  font-size: .86rem;
  color: var(--mut);
}

.dtab:hover {
  color: var(--ink);
}

.dtab.on {
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.dclose {
  margin-left: auto;
}

.dpane {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.dpane[hidden] {
  display: none !important;
}

.dbody {
  flex: 1;
  min-height: 0;
}

.dfoot {
  border-top: 1px solid var(--line);
  padding: 12px 16px;
  display: flex;
  gap: 8px;
  flex: none;
}

.dnote {
  font-size: .76rem;
  color: var(--faint);
  text-align: center;
  padding: 10px 0 2px;
}

.dmenu-wrap {
  position: relative;
  margin-left: auto;
}

.dmenu-wrap .popover-menu {
  min-width: 240px;
}

/* =========================================================================
   Generic components (prototype)
   ========================================================================= */
.card,
.dashboard-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}

.pad,
.dashboard-card {
  padding: 18px;
}

.card.flush {
  padding: 0;
  overflow: hidden;
}

/* Buttons — .btn is the new primitive; legacy button classes map onto it. */
.btn,
button.secondary,
button[type='submit'],
.dashboard-card button[type='button']:not(.iconbtn):not(.mini):not(.compact-button):not(.fchip):not(.tab):not(.chip-button):not(.suggestion),
dialog button[type='button']:not(.iconbtn):not(.mini):not(.compact-button):not(.fchip):not(.dialog-tab):not(.chip-button) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: var(--r-sm);
  font-weight: 600;
  font-size: .85rem;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  white-space: nowrap;
}

.btn:hover:not(:disabled),
button.secondary:hover:not(:disabled),
button[type='submit']:hover:not(:disabled) {
  border-color: var(--faint);
}

.btn.primary,
button.primary,
button[type='submit']:not(.secondary):not(.mini):not(.compact-button) {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.btn.primary:hover:not(:disabled),
button.primary:hover:not(:disabled),
button[type='submit']:not(.secondary):not(.mini):not(.compact-button):hover:not(:disabled) {
  background: var(--teal-dark);
  border-color: var(--teal-dark);
}

.btn.ghost {
  border-color: transparent;
  color: var(--mut);
  background: none;
}

.btn.ghost:hover:not(:disabled) {
  color: var(--ink);
  background: var(--paper);
  border-color: transparent;
}

.btn.danger,
button.danger {
  color: var(--red);
  border-color: #EDCDC6;
  background: var(--red-soft);
}

/* Small inline buttons */
.mini,
.compact-button {
  font-size: .76rem;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.mini:hover:not(:disabled),
.compact-button:hover:not(:disabled) {
  border-color: var(--faint);
}

.mini.go,
.compact-button:not(.secondary) {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.mini.go:hover:not(:disabled),
.compact-button:not(.secondary):hover:not(:disabled) {
  background: var(--teal-dark);
  border-color: var(--teal-dark);
}

.mini.danger {
  color: var(--red);
  border-color: #EDCDC6;
  background: var(--red-soft);
}

.chip-button {
  font-size: .74rem;
  padding: 2px 8px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--mut);
}

.chip-button:hover {
  border-color: var(--faint);
  color: var(--ink);
}

/* Chips & pills */
.chip,
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .78rem;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--mut);
  white-space: nowrap;
}

.chip.teal,
.chip-status,
.pill.ok,
.chip-health.active {
  background: var(--teal-soft);
  border-color: var(--teal-mid);
  color: var(--teal-dark);
}

.chip.red,
.pill.bad,
.chip-health.risk,
.pill.priority-urgent {
  background: var(--red-soft);
  border-color: #EDCDC6;
  color: var(--red);
}

.chip.amber,
.pill.warn,
.chip-health.watch,
.pill.priority-high {
  background: var(--amber-soft);
  border-color: #E9D9B4;
  color: var(--amber);
}

.chip.blue {
  background: var(--blue-soft);
  border-color: #CFDCEF;
  color: var(--blue);
}

.chip.mono,
.pill.mono {
  font-family: var(--mono);
  font-size: .72rem;
}

/* Status pill in plain words (spec 5) */
.st {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: .76rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
}

.st.ok {
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.st.off {
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--faint);
}

.st.warn {
  background: var(--amber-soft);
  color: var(--amber);
}

.st .sdot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

/* Section head */
.section-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 0 0 12px;
  flex-wrap: wrap;
}

.section-head > h2,
.section-head > h3,
.section-head > h4,
.section-head > div > h3,
.section-head > div > h4 {
  margin: 0;
}

.section-head .count {
  font-family: var(--mono);
  font-size: .78rem;
  color: var(--faint);
}

.section-head > .actions,
.section-head > .row-actions {
  margin-left: auto;
}

/* Filter chips */
.filters {
  display: flex;
  gap: 6px;
  margin-left: auto;
  flex-wrap: wrap;
}

.fchip {
  font-size: .78rem;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 20px;
  color: var(--mut);
  border: 1px solid transparent;
}

.fchip:hover {
  background: var(--paper);
}

.fchip.on,
.fchip.active {
  background: var(--ink);
  color: #fff;
}

/* Rows */
.row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line-soft);
  transition: background .12s;
  width: 100%;
  text-align: left;
}

.row:last-child {
  border-bottom: none;
}

.row:hover {
  background: var(--paper);
}

.row .ric {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  flex: none;
}

.ric.action {
  background: var(--red-soft);
  color: var(--red);
}

.ric.mail {
  background: var(--blue-soft);
  color: var(--blue);
}

.ric.doc {
  background: var(--amber-soft);
  color: var(--amber);
}

.ric.task,
.ric.insight {
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.row .body {
  min-width: 0;
  flex: 1;
}

.row .t {
  font-weight: 600;
  font-size: .9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.row .m {
  font-size: .76rem;
  color: var(--faint);
  margin-top: 2px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.row .m .proj {
  color: var(--teal-dark);
  font-weight: 500;
}

.row .when {
  font-family: var(--mono);
  font-size: .73rem;
  color: var(--faint);
  flex: none;
}

.row .when.over {
  color: var(--red);
  font-weight: 500;
}

.row .acts {
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity .12s;
  flex: none;
  position: relative;
}

/* Overflow menu on an inbox row keeps the old Work Inbox mail actions
   reachable without crowding the row (spec 0.1 allows "behind a menu"). */
.row-more {
  top: calc(100% + 4px);
  min-width: 220px;
}

.row .body[data-project-id] {
  cursor: pointer;
}

.row:hover .acts,
.row:focus-within .acts {
  opacity: 1;
}

.row.done {
  opacity: .45;
}

.row.done .t {
  text-decoration: line-through;
}

/* Dashed hint line — the "empty means hidden" collapse target (spec 0.3) */
.hint {
  border: 1px dashed var(--line);
  border-radius: var(--r);
  padding: 13px 18px;
  color: var(--faint);
  font-size: .83rem;
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
}

.hint a {
  color: var(--teal-dark);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

/* Timeline */
.tl li,
.timeline-item {
  display: flex;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: .86rem;
  align-items: baseline;
  width: 100%;
  text-align: left;
}

.tl li:last-child,
.timeline-item:last-child {
  border-bottom: none;
}

.tl .tld,
.timeline-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--teal-mid);
  flex: none;
  position: relative;
  top: -1px;
}

.timeline-dot.dot-email {
  background: var(--blue);
}

.timeline-dot.dot-task {
  background: var(--teal);
}

.timeline-dot.dot-insight {
  background: var(--amber);
}

.tl .tlt,
.timeline-body {
  flex: 1;
  min-width: 0;
}

.timeline-body strong {
  font-weight: 600;
  display: block;
}

.tl .tlm,
.timeline-body .meta {
  color: var(--faint);
  font-size: .76rem;
  margin-top: 1px;
  display: block;
}

.tl .tlw,
.timeline-time {
  font-family: var(--mono);
  font-size: .72rem;
  color: var(--faint);
  flex: none;
}

.timeline-item[data-project-id] {
  cursor: pointer;
}

.timeline-item:hover {
  background: var(--paper);
}

/* KPI cards */
.kpis,
.finance-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.finance-summary-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.finance-summary-grid:empty {
  display: none;
}

.kpi,
.finance-kpi {
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}

.kpi .l,
.finance-kpi > span {
  font-size: .74rem;
  color: var(--faint);
  font-weight: 500;
  display: block;
}

.kpi .v,
.finance-kpi > strong {
  font-family: var(--mono);
  font-size: 1.15rem;
  font-weight: 500;
  margin-top: 4px;
  display: block;
}

.kpi .v.good {
  color: var(--teal-dark);
}

.kpi .v.bad {
  color: var(--red);
}

/* Form fields — supports prototype (div.field > label) and legacy
   (label.field > span) markup alike. */
.field {
  min-width: 0;
}

.field > label,
label.field > span:first-child,
form > label:not(.inline):not(.compact-toggle) > span:first-child {
  display: block;
  font-size: .76rem;
  font-weight: 600;
  color: var(--mut);
  margin-bottom: 5px;
}

label.field,
form > label:not(.inline):not(.compact-toggle) {
  display: block;
  margin-bottom: 12px;
  font-size: .76rem;
  font-weight: 600;
  color: var(--mut);
}

input:not([type='checkbox']):not([type='radio']):not([type='file']),
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 8px 11px;
  background: var(--card);
  font-size: .88rem;
  font-weight: 400;
  font-family: var(--ui);
  color: var(--ink);
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--teal-mid);
  border-color: var(--teal);
}

textarea {
  resize: vertical;
  min-height: 62px;
}

input[type='checkbox'],
input[type='radio'] {
  accent-color: var(--teal);
  width: auto;
}

input[type='file'] {
  font-size: .82rem;
}

label.inline,
.compact-toggle {
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
  font-size: .83rem;
  font-weight: 500;
  color: var(--mut);
  margin-bottom: 0;
}

.fieldnote,
.help {
  font-size: .76rem;
  color: var(--faint);
  margin-top: 4px;
  line-height: 1.45;
  font-weight: 400;
}

.help {
  font-size: .8rem;
}

.form-actions,
.row-actions,
.actions,
.storage-actions,
.talk-actions,
.item-actions,
.todo-card-actions,
.file-detail-actions,
.quick-create-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.form-actions {
  justify-content: flex-end;
  margin-top: 14px;
}

/* Advanced fold — holds every technical field verbatim (spec 5) */
details.adv {
  margin-top: 14px;
  border-top: 1px solid var(--line-soft);
  padding-top: 11px;
}

details.adv summary {
  cursor: pointer;
  font-size: .8rem;
  font-weight: 600;
  color: var(--mut);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

details.adv summary::-webkit-details-marker {
  display: none;
}

details.adv summary::before {
  content: '▸';
  font-size: .72rem;
  transition: transform .15s;
}

details.adv[open] summary::before {
  transform: rotate(90deg);
}

details.adv > .grid-2,
details.adv > .grid-1 {
  margin-top: 12px;
}

/* Form grids */
.grid-2,
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.grid-1,
.stacked-form,
.members-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.grid-2 > .wide,
.settings-grid > .wide {
  grid-column: 1 / -1;
}

/* Assistant suggestions */
.suggestion,
.sugg {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: var(--r-sm);
  padding: 9px 13px;
  font-size: .85rem;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--ink);
}

.suggestion:hover,
.sugg:hover {
  border-color: var(--teal);
  color: var(--teal-dark);
}

.assistant-suggestions {
  margin-bottom: 12px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 90px);
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: .86rem;
  font-weight: 500;
  transition: transform .25s ease;
  z-index: 200;
  max-width: 90vw;
  text-align: center;
}

.toast.show {
  transform: translate(-50%, 0);
}

/* Mobile sidebar scrim */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 32, .35);
  z-index: 90;
  display: none;
}

.scrim.on {
  display: block;
}

/* =========================================================================
   Login
   ========================================================================= */
.login-view {
  display: grid;
  place-items: center;
  height: 100vh;
  padding: 20px;
  background:
    radial-gradient(1100px 520px at 50% -10%, var(--teal-soft), transparent 60%),
    var(--paper);
}

.login-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 30px 26px;
  width: 380px;
  max-width: 92vw;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-logo {
  width: min(200px, 70%);
  height: auto;
  margin-bottom: 4px;
}

.login-panel h1 {
  font-size: 1.35rem;
}

.login-panel > p {
  color: var(--mut);
  font-size: .86rem;
  margin-bottom: 4px;
}

.login-panel label {
  display: block;
  font-size: .76rem;
  font-weight: 600;
  color: var(--mut);
}

.login-panel button {
  width: 100%;
}

.provider-login-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.provider-login-buttons:empty {
  display: none;
}

/* =========================================================================
   Spec 3 — Home
   ========================================================================= */
.home-greeting-block {
  margin-bottom: 26px;
}

.home-greeting-block h1 {
  margin-bottom: 4px;
}

.home-section {
  margin-bottom: 30px;
}

.home-search-panel {
  margin-bottom: 24px;
}

/* Project status list (spec 3.2) */
.plist .row .t {
  font-family: var(--disp);
}

.plist .row {
  cursor: pointer;
}

/* "View all activity" footer under the activity card */
.tl-foot {
  text-align: center;
  border-top: 1px solid var(--line-soft);
  padding-top: 10px;
  margin-top: 6px;
}

.tl-foot .btn {
  font-size: .8rem;
}

/* =========================================================================
   Spec 4 — Project page
   ========================================================================= */
.project-view {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.workspace-head,
.phead {
  padding: 22px 28px 0;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  flex: none;
}

.titleline {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.titleline h1,
.titleline h2 {
  min-width: 0;
  font-family: var(--disp);
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: -.01em;
}

.project-subline {
  margin-top: 4px;
  font-size: .8rem;
}

.project-subline:empty {
  display: none;
}

.menu-note {
  padding: 6px 12px;
  font-size: .74rem;
}

.menu-note:empty {
  display: none;
}

.project-chips {
  display: flex;
  gap: 8px;
  margin: 10px 0 16px;
  align-items: center;
  flex-wrap: wrap;
}

.project-chips:empty {
  margin: 4px 0 12px;
}

.project-menu-wrap {
  position: relative;
}

.project-tabs,
.tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.project-tabs::-webkit-scrollbar,
.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  padding: 9px 14px;
  font-weight: 600;
  font-size: .88rem;
  color: var(--mut);
  border-bottom: 2px solid transparent;
  border-radius: 6px 6px 0 0;
  white-space: nowrap;
}

.tab:hover {
  color: var(--ink);
  background: var(--paper);
}

.tab.active,
.tab.on {
  color: var(--teal-dark);
  border-bottom-color: var(--teal);
}

.project-shell {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 28px;
  scroll-behavior: smooth;
}

.tab-panels {
  max-width: 880px;
  margin: 0 auto;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* Overview (spec 4.1) */
.ov-grid,
.overview-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.ov-grid .full,
.overview-row .full {
  grid-column: 1 / -1;
}

.overview-summary {
  margin-bottom: 16px;
}

.ai-strip {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.ai-strip-body {
  flex: 1;
  min-width: 0;
}

.ai-strip .btn {
  flex: none;
}

.overview-summary {
  margin-bottom: 16px;
}

/* The "Recent mail and documents" fold reuses the Advanced disclosure look. */
.overview-previews {
  margin-top: 0;
  border-top: none;
}

.overview-previews summary {
  font-size: .86rem;
}

/* Open-items rows link onward to the tab that owns them. */
#overview-actions li[data-goto-tab] {
  cursor: pointer;
}

#overview-actions li[data-goto-tab]:hover .tlt {
  color: var(--teal-dark);
}

.ai-strip .spark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--teal-soft);
  color: var(--teal-dark);
  display: grid;
  place-items: center;
  flex: none;
}

.ai-badge {
  font-size: .66rem;
  font-weight: 600;
  color: var(--teal-dark);
  background: var(--teal-soft);
  border-radius: 20px;
  padding: 1px 8px;
  vertical-align: middle;
  font-family: var(--ui);
}

.overview-summary-body {
  font-size: .88rem;
  color: var(--mut);
  line-height: 1.55;
}

.ai-meta {
  margin-top: 8px;
}

/* Files (spec 4.2) */
.files-browser-layout,
.files-grid {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
  align-items: start;
}

.file-drop-zone,
.dropzone {
  border: 1.5px dashed var(--teal-mid);
  background: var(--teal-soft);
  border-radius: var(--r);
  padding: 11px 16px;
  color: var(--teal-dark);
  font-size: .83rem;
  font-weight: 500;
  text-align: center;
  margin-bottom: 16px;
  cursor: pointer;
  display: block;
}

.file-drop-zone strong {
  display: block;
  font-weight: 600;
}

.file-drop-zone span {
  font-size: .76rem;
  opacity: .85;
}

.file-drop-zone input[type='file'] {
  display: none;
}

.file-drop-zone.drag-over {
  border-color: var(--teal);
  background: var(--teal-mid);
}

.file-drop-zone.uploading {
  opacity: .6;
}

.flist,
.fdetail,
.file-details-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.file-details-panel {
  padding: 16px;
}

.fitem {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line-soft);
  font-weight: 500;
  font-size: .89rem;
}

.fitem:last-child {
  border-bottom: none;
}

.fitem:hover {
  background: var(--paper);
}

.fitem.on,
.fitem.selected {
  background: var(--teal-soft);
}

.fitem .fico {
  color: var(--amber);
  flex: none;
}

.fitem .n {
  font-family: var(--mono);
  color: var(--faint);
  font-size: .76rem;
  width: 20px;
  flex: none;
}

/* Pinned Notes entry above the numbered folders (spec 4.2) */
.fitem.notes,
.fitem.notes .fico {
  color: var(--teal-dark);
}

.fitem.notes {
  border-bottom: 2px solid var(--line);
}

.fdrow {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line-soft);
  font-size: .87rem;
  width: 100%;
  text-align: left;
}

.fdrow:last-child {
  border-bottom: none;
}

.fdrow:hover {
  background: var(--paper);
}

.fdrow.selected {
  background: var(--teal-soft);
}

.fdhead {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.ftag {
  font-family: var(--mono);
  font-size: .7rem;
  color: var(--teal-dark);
  background: var(--teal-soft);
  padding: 2px 8px;
  border-radius: 5px;
  flex: none;
}

.ftag.pending {
  color: var(--amber);
  background: var(--amber-soft);
}

.ftag.missing {
  color: var(--faint);
  background: var(--paper);
}

/* The detail pane stacks its file rows and the selected-file aside. */
.fdetail .data-list {
  display: block;
}

.fdrow .file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  padding: 0;
  border: none;
  background: none;
  text-align: left;
  font-weight: 400;
  font-size: .87rem;
  justify-content: flex-start;
}

.fdrow .fname {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fdrow .acts {
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity .12s;
  flex: none;
}

.fdrow:hover .acts,
.fdrow:focus-within .acts {
  opacity: 1;
}

.file-details-panel {
  border: none;
  border-top: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
}

.file-details-panel .empty-state {
  padding: 12px 16px;
}

.notes-foot {
  padding: 10px 16px;
  font-size: .78rem;
  border-top: 1px solid var(--line-soft);
}

#note-form {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
}

/* Mail (spec 4.3) */
.mail-filing-toggle {
  cursor: pointer;
  gap: 7px;
}

.mail-rules-line {
  margin-top: 10px;
  font-size: .8rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.mail-rules-line a {
  font-weight: 600;
  cursor: pointer;
}

.mailrow {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line-soft);
  font-size: .87rem;
  width: 100%;
  text-align: left;
}

.mailrow:last-child {
  border-bottom: none;
}

.mailrow:hover {
  background: var(--paper);
}

.dir,
.direction-badge {
  font-family: var(--mono);
  font-size: .68rem;
  font-weight: 500;
  letter-spacing: .05em;
  padding: 2px 8px;
  border-radius: 5px;
  flex: none;
  text-transform: uppercase;
  background: var(--paper);
  color: var(--mut);
}

.dir.in,
.direction-badge.in,
.direction-badge.incoming {
  background: var(--blue-soft);
  color: var(--blue);
}

.dir.out,
.direction-badge.out,
.direction-badge.outgoing {
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.mailrow .who {
  width: 130px;
  flex: none;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mailrow .subj {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mailrow .fold {
  flex: none;
}

.mailrow .d {
  font-family: var(--mono);
  font-size: .73rem;
  color: var(--faint);
  flex: none;
  width: 52px;
  text-align: right;
}

.clip,
.attachment-icon {
  color: var(--faint);
  flex: none;
}

.mail-group-row {
  font-family: var(--mono);
  font-size: .66rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 10px 18px 4px;
  background: var(--paper);
  border-bottom: 1px solid var(--line-soft);
}

/* Work (spec 4.4) */
.wrow .type {
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 5px;
  flex: none;
}

.type.task {
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.type.pack {
  background: var(--blue-soft);
  color: var(--blue);
}

.type.deliv {
  background: var(--amber-soft);
  color: var(--amber);
}

.check {
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--line);
  border-radius: 5px;
  flex: none;
  display: grid;
  place-items: center;
  color: transparent;
  background: var(--card);
}

.check:hover {
  border-color: var(--teal);
}

.wrow.done .check {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.progress-track {
  height: 5px;
  border-radius: 3px;
  background: var(--line-soft);
  overflow: hidden;
  width: 70px;
  flex: none;
}

.progress-fill {
  height: 100%;
  background: var(--teal);
}

.chip-progress {
  font-family: var(--mono);
  font-size: .72rem;
}

.work-filter-wrap {
  position: relative;
}

#work-filter-menu {
  min-width: 280px;
  padding: 14px;
}

#work-filter-menu .task-filter-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 0;
}

.wrow .acts {
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity .12s;
  flex: none;
}

.wrow:hover .acts,
.wrow:focus-within .acts {
  opacity: 1;
}

/* Secondary finance figures fold under the four prominent KPIs (spec 4.5). */
.finance-secondary {
  grid-column: 1 / -1;
  border-top: 1px solid var(--line-soft);
  padding-top: 10px;
}

.finance-secondary summary {
  cursor: pointer;
  font-size: .8rem;
  font-weight: 600;
  color: var(--mut);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.finance-secondary summary::-webkit-details-marker {
  display: none;
}

.finance-secondary summary::before {
  content: '▸';
  font-size: .72rem;
  transition: transform .15s;
}

.finance-secondary[open] summary::before {
  transform: rotate(90deg);
}

.finance-secondary .finance-summary-grid {
  margin-top: 12px;
  margin-bottom: 0;
}

/* An unclassified index status should read neutral, not "indexed". */
.ftag.index-unknown,
.ftag.index-none {
  color: var(--faint);
  background: var(--paper);
}

.ftag.index-pending,
.ftag.index-queued {
  color: var(--amber);
  background: var(--amber-soft);
}

.ftag.index-error,
.ftag.index-failed {
  color: var(--red);
  background: var(--red-soft);
}

/* Finance cashbook fold sits below the details card. */
.ledger-fold {
  margin-top: 16px;
  border-top: 1px solid var(--line);
}

.ledger-fold summary {
  font-size: .9rem;
  font-family: var(--disp);
}

/* Finance (spec 4.5) */
.setup {
  padding: 34px;
  text-align: center;
}

.setup .big {
  font-family: var(--disp);
  font-weight: 600;
  font-size: 1.05rem;
  margin: 12px 0 6px;
}

.setup .sub {
  max-width: 380px;
  margin: 0 auto 16px;
}

.finance-notes-text {
  font-size: .84rem;
  color: var(--mut);
  margin-top: 10px;
  grid-column: 1 / -1;
}

.finance-status-line {
  font-size: .8rem;
  color: var(--faint);
  margin-top: 8px;
}

/* =========================================================================
   Spec 5 — Settings
   ========================================================================= */
.set-grid {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 26px;
  align-items: start;
}

.snav-label {
  font-family: var(--mono);
  font-size: .64rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 14px 10px 6px;
}

.snav {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  font-weight: 500;
  color: var(--mut);
  font-size: .88rem;
}

.snav:hover {
  background: var(--card);
  color: var(--ink);
}

.snav.on {
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-weight: 600;
}

.spanel {
  display: none;
}

.spanel.on {
  display: block;
}

.set-card {
  margin-bottom: 16px;
  padding: 18px;
}

.set-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.set-head h2,
.set-head h3 {
  margin: 0;
}

.urow {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: .87rem;
  flex-wrap: wrap;
}

.urow:last-child {
  border-bottom: none;
}

.atabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.apanel {
  display: none;
}

/* app.js's setAdminTab marks the live panel with .active; the prototype uses
   .on. Accept both so either path shows the panel. */
.apanel.on,
.apanel.active {
  display: block;
}

.ev {
  font-family: var(--mono);
  font-size: .68rem;
  color: var(--faint);
  background: var(--paper);
  border: 1px solid var(--line-soft);
  padding: 1px 7px;
  border-radius: 5px;
}

.ckrow {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
}

.ckrow:last-of-type {
  border-bottom: none;
}

.ckrow input {
  margin-top: 3px;
}

.ckrow b {
  font-size: .87rem;
  font-weight: 600;
}

.settings-info-grid,
.compact-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.settings-info-grid article {
  background: var(--paper);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  padding: 12px 14px;
}

.settings-info-grid strong {
  font-size: .82rem;
  display: block;
  margin-bottom: 3px;
}

.settings-inline-action {
  display: flex;
  align-items: center;
  gap: 10px;
  grid-column: 1 / -1;
}

/* =========================================================================
   Dialogs / modals
   ========================================================================= */
dialog {
  background: var(--card);
  border: none;
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 0;
  max-width: 92vw;
  max-height: 90vh;
  color: var(--ink);
}

dialog::backdrop {
  background: rgba(16, 24, 32, .35);
}

.project-form {
  padding: 22px;
  width: 560px;
  max-width: 100%;
  max-height: 86vh;
  overflow-y: auto;
}

.members-dialog-body,
.project-settings-dialog-body,
.admin-dialog-content,
.weaviate-dialog-content,
.mailbox-import-form,
.global-settings-form {
  width: 860px;
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.dialog-head h2 {
  font-size: 1.15rem;
}

.dialog-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 8px;
}

.dialog-tab {
  padding: 6px 12px;
  border-radius: 20px;
  font-weight: 500;
  font-size: .82rem;
  color: var(--mut);
}

.dialog-tab:hover {
  background: var(--paper);
}

.dialog-tab.active {
  background: var(--ink);
  color: #fff;
}

.members-panel,
.project-settings-panel {
  display: none;
}

.members-panel.active,
.project-settings-panel.active {
  display: block;
}

/* =========================================================================
   Legacy component styling — markup rendered by app.js, mapped onto the new
   tokens so no existing feature loses its shape (spec 0.1).
   ========================================================================= */
.data-list {
  display: flex;
  flex-direction: column;
}

.data-list > p {
  color: var(--faint);
  font-size: .85rem;
  padding: 14px 0;
}

.data-item {
  border-bottom: 1px solid var(--line-soft);
  padding: 11px 0;
  font-size: .87rem;
}

.data-item:last-child {
  border-bottom: none;
}

.data-item strong {
  font-weight: 600;
}

.data-item small,
.data-item .meta {
  color: var(--faint);
  font-size: .76rem;
}

/* Clickable rows produced by app.js */
.cockpit-item,
.home-project-row,
.overview-action,
.overview-list-row,
.commercial-project-row,
.work-inbox-main,
.email-row,
.email-action,
.note-row,
.planning-row,
.deliverable-row,
.opportunity-row,
.index-row,
.storage-browser-row,
.mailbox-import-row,
.member-card,
.external-card,
.access-card,
.keyword-item,
.admin-user-row,
.admin-group-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 11px 14px;
  border: none;
  border-bottom: 1px solid var(--line-soft);
  font-size: .87rem;
  background: none;
  color: inherit;
  border-radius: 0;
  font-weight: 400;
  justify-content: flex-start;
  white-space: normal;
}

.cockpit-item:hover,
.home-project-row:hover,
.overview-action:hover,
.overview-list-row:hover,
.commercial-project-row:hover,
.work-inbox-main:hover,
.email-row:hover,
.note-row:hover,
.planning-row:hover,
.deliverable-row:hover,
.opportunity-row:hover,
.index-row:hover,
.storage-browser-row:hover,
.mailbox-import-row:hover,
.member-card:hover,
.admin-user-row:hover,
.admin-group-row:hover {
  background: var(--paper);
}

.cockpit-item strong,
.home-project-row strong,
.overview-action strong,
.overview-list-row strong,
.work-inbox-main strong,
.opportunity-row strong,
.planning-row strong,
.deliverable-row strong {
  font-weight: 600;
}

.cockpit-item,
.overview-action {
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.cockpit-item span,
.cockpit-item small {
  color: var(--faint);
  font-size: .76rem;
}

.cockpit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.cockpit-tile-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.cockpit-tile-head h3 {
  flex: 1;
}

.cockpit-badge {
  font-family: var(--mono);
  font-size: .72rem;
  color: var(--faint);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 1px 8px;
}

.cockpit-badge.has-items {
  background: var(--red-soft);
  border-color: #EDCDC6;
  color: var(--red);
}

.hp-main,
.member-main,
.email-action-main {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.action-groups {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.action-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .74rem;
  font-weight: 600;
  color: var(--mut);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 4px;
}

.action-group-head span:last-child {
  font-family: var(--mono);
  color: var(--faint);
  font-weight: 400;
  letter-spacing: 0;
}

.overview-action.is-overdue strong {
  color: var(--red);
}

.overview-list-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.commercial-project-list {
  display: flex;
  flex-direction: column;
  margin-top: 12px;
}

.commercial-project-row {
  justify-content: space-between;
}

.commercial-project-row > span:first-child {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.commercial-project-row small,
.opportunity-row small,
.member-card small {
  color: var(--faint);
  font-size: .74rem;
}

.work-inbox-item {
  border-bottom: 1px solid var(--line-soft);
  padding: 4px 0 10px;
}

.work-inbox-item:last-child {
  border-bottom: none;
}

.work-inbox-main {
  flex-wrap: wrap;
  align-items: center;
}

.work-inbox-item .row-actions {
  padding: 0 14px;
}

/* Mail table (legacy list) */
.mail-table {
  display: flex;
  flex-direction: column;
}

.mail-table-head {
  display: none;
}

.mail-table-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mail-icon-col {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

.mail-party {
  width: 140px;
  flex: none;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.mail-party strong {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-party small,
.mail-subject small {
  color: var(--faint);
  font-size: .72rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-subject {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.mail-subject strong {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mailbox-party-select {
  min-width: 126px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: .8rem;
}

.mail-date {
  font-family: var(--mono);
  font-size: .73rem;
  color: var(--faint);
  flex: none;
}

.mail-attachments {
  display: none;
}

.mail-status {
  font-size: .72rem;
  color: var(--faint);
  flex: none;
}

.mail-action-summary,
.mail-action-meta {
  font-size: .8rem;
  color: var(--mut);
  margin-bottom: 12px;
}

/* Keyword lists */
.keyword-list {
  display: flex;
  flex-direction: column;
  margin-top: 10px;
}

.keyword-item {
  justify-content: space-between;
}

.mail-rule-form,
.admin-inline-form,
.inline-form,
.estimate-form,
.task-filter-form,
.mailbox-import-toolbar,
.admin-member-form,
.admin-permission-form,
.admin-tenant-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 12px;
}

.mail-rule-form input,
.admin-inline-form input,
.inline-form input {
  flex: 1;
  min-width: 160px;
}

.task-filter-form label,
.mailbox-import-toolbar label {
  margin-bottom: 0;
}

.approval-panel,
.ledger-panel,
.estimate-panel,
.access-section {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
}

.mail-keyword-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* Form grids used by the project tabs */
.task-form,
.planning-form,
.deliverable-form,
.finance-form,
.acquisition-form,
.ledger-form,
.time-entry-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.note-form,
.task-form {
  grid-template-columns: 1fr;
}

.task-form-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.planning-wide,
.deliverable-wide,
.acquisition-wide,
.ledger-wide,
.time-entry-wide,
.finance-notes,
.estimate-wide,
.file-detail-wide,
.finance-actions,
.acquisition-actions {
  grid-column: 1 / -1;
}

.kanban-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.kanban-column {
  background: var(--paper);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  padding: 10px;
}

.kanban-head {
  font-size: .74rem;
  font-weight: 600;
  color: var(--mut);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 8px;
}

.kanban-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.planning-list,
.deliverables-list,
.acquisition-list,
.ledger-list,
.members-list,
.index-list,
.admin-scroll-list,
.storage-browser-list,
.mailbox-import-list,
.member-search-results,
.talk-messages,
.chat-log,
.action-list,
.file-index-status-list {
  display: flex;
  flex-direction: column;
}

.admin-scroll-list,
.index-list,
.mailbox-import-list,
.storage-browser-list,
.talk-messages {
  max-height: 380px;
  overflow-y: auto;
}

.storage-browser-list:empty,
.member-search-results:empty,
.assistant-suggestions:empty {
  display: none;
}

/* Chat / assistant bubbles */
.chat-log {
  gap: 10px;
  margin-bottom: 12px;
}

.chat-form,
.talk-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.chat-form input,
.talk-form input {
  flex: 1;
}

.bubble {
  border-radius: 0 10px 10px 10px;
  padding: 9px 12px;
  font-size: .86rem;
  background: var(--paper);
  border: 1px solid var(--line-soft);
}

.bubble.user {
  border-radius: 10px 0 10px 10px;
  background: var(--teal-soft);
  border-color: var(--teal-mid);
  align-self: flex-end;
}

.sources {
  font-size: .74rem;
  color: var(--faint);
  margin-top: 6px;
}

.assistant-empty {
  color: var(--faint);
  font-size: .84rem;
}

.assistant-head {
  margin-bottom: 12px;
}

.assistant-scope {
  font-size: .8rem;
  color: var(--mut);
  margin-top: 2px;
}

/* Talk / Teams */
.talk-message {
  margin-bottom: 14px;
}

.talk-message-meta {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 3px;
}

.talk-message-meta strong {
  font-weight: 600;
  font-size: .84rem;
}

.talk-message-meta span,
.talk-message-meta time {
  font-family: var(--mono);
  font-size: .7rem;
  color: var(--faint);
}

.talk-message .body,
.talk-message p {
  background: var(--paper);
  border: 1px solid var(--line-soft);
  border-radius: 0 10px 10px 10px;
  padding: 9px 12px;
  font-size: .86rem;
}

.talk-body {
  font-size: .82rem;
  color: var(--mut);
  margin-bottom: 12px;
}

.talk-chip-list,
.storage-capability-chips,
.admin-chip-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.talk-chip,
.admin-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .76rem;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--mut);
}

.talk-chip-action {
  color: var(--red);
  font-weight: 600;
}

.talk-summary-grid,
.members-summary,
.talk-participants-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.talk-summary-grid > *,
.members-summary > *,
.talk-participants-summary > * {
  background: var(--paper);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  font-size: .8rem;
}

.talk-missing {
  color: var(--red);
}

.talk-details {
  margin-top: 10px;
}

.talk-room-name {
  font-family: var(--mono);
  font-size: .76rem;
}

.talk-sync-list {
  font-size: .8rem;
  color: var(--mut);
}

/* Member / access cards */
.member-card,
.external-card,
.access-card,
.estimate-card {
  justify-content: space-between;
}

.member-avatar,
.external-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--teal-soft);
  color: var(--teal-dark);
  display: grid;
  place-items: center;
  font-size: .7rem;
  font-weight: 600;
  flex: none;
}

.role-badge {
  font-size: .72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.member-role-control {
  display: flex;
  gap: 6px;
  align-items: center;
}

.member-role-control select {
  width: auto;
  font-size: .8rem;
  padding: 4px 8px;
}

.member-result {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line-soft);
  font-size: .84rem;
  cursor: pointer;
}

.member-result:hover {
  background: var(--paper);
}

/* Index / audit tables */
.index-table,
.estimate-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}

.index-table th,
.index-table td,
.estimate-table th,
.estimate-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-soft);
}

.index-table th,
.estimate-table th,
.index-table-head {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--faint);
  font-weight: 600;
}

.index-config {
  margin-bottom: 12px;
}

.index-status-section {
  margin-top: 14px;
}

.file-index-status-row {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: .8rem;
}

/* File detail pane */
.file-detail-head {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.file-detail-icon {
  color: var(--amber);
  flex: none;
}

.file-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  font-size: .8rem;
}

.file-detail-grid strong {
  display: block;
  color: var(--faint);
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.file-detail-actions {
  margin-top: 14px;
}

.file-link {
  color: var(--teal-dark);
  font-weight: 500;
  text-decoration: none;
}

.file-link:hover {
  text-decoration: underline;
}

.file-row-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.folder .fico,
.folder {
  color: var(--amber);
}

.copied {
  color: var(--teal-dark);
}

/* Calendar */
.calendar-widget {
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  overflow: hidden;
}

.calendar-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--paper);
}

.calendar-weekday {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--faint);
  font-weight: 600;
  padding: 6px;
  text-align: center;
}

.calendar-cell-date {
  font-family: var(--mono);
  font-size: .72rem;
  color: var(--faint);
}

.calendar-events {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* Notes */
.note-preview {
  margin-top: 14px;
  border-top: 1px solid var(--line-soft);
  padding-top: 12px;
}

.note-preview-body {
  font-size: .86rem;
  line-height: 1.6;
}

.note-preview-body h1,
.note-preview-body h2,
.note-preview-body h3 {
  margin: 12px 0 6px;
}

.note-preview-body ul,
.note-preview-body ol {
  list-style: revert;
  padding-left: 20px;
}

.note-editor-form textarea {
  font-family: var(--mono);
  font-size: .82rem;
}

.email-body {
  background: var(--paper);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  padding: 14px;
  font-family: var(--mono);
  font-size: .8rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 50vh;
  overflow-y: auto;
}

.email-detail-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
  font-size: .8rem;
}

.email-action-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Admin */
.admin-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.admin-user-row,
.admin-group-row {
  flex-wrap: wrap;
}

.admin-group-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  width: 100%;
}

.admin-group-meta,
.admin-user-stats {
  font-size: .76rem;
  color: var(--faint);
}

/* Estimate builder */
.estimate-result {
  margin-top: 14px;
}

.estimate-editor {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.builder-apply-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.builder-apply-status,
.summary-status {
  font-size: .8rem;
  color: var(--faint);
}

.summary-block {
  margin-bottom: 12px;
}

.summary-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.summary-objective {
  font-size: .86rem;
  color: var(--mut);
}

.split-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.form-section {
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  padding: 14px;
  margin-bottom: 12px;
}

.form-section legend {
  font-size: .76rem;
  font-weight: 600;
  color: var(--mut);
  padding: 0 6px;
}

.extra-folder-settings {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.disabled-communication,
.secondary-communication {
  opacity: .6;
}

.primary-communication {
  border-color: var(--teal-mid);
}

/* The Talk/Teams drawer panes carry these provider classes too; a drawer pane
   the user explicitly opened must never render dimmed. */
.dpane.disabled-communication,
.dpane.secondary-communication {
  opacity: 1;
}

.storage-capability-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0;
}

.sharepoint-picker {
  margin: 10px 0;
}

/* =========================================================================
   Spec 6 — Responsive
   ========================================================================= */

/* Tablet 901–1100px: the drawer overlays content (it is absolutely
   positioned, so it already does) — tighten padding only. */
@media (max-width: 1100px) {
  .view,
  .project-shell {
    padding: 22px;
  }

  .files-browser-layout,
  .files-grid {
    grid-template-columns: 240px 1fr;
  }
}

/* Mobile <=900px */
@media (max-width: 900px) {
  html {
    font-size: 14px;
  }

  .app-shell,
  .app-shell.rail {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 264px;
    z-index: 95;
    transform: translateX(-105%);
    transition: transform .22s ease;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.openm {
    transform: none;
  }

  .railbtn {
    display: none;
  }

  .menubtn {
    display: grid;
  }

  .topbar {
    padding: 10px 14px;
    gap: 8px;
  }

  .topbar-search {
    max-width: none;
    min-width: 0;
  }

  .view,
  .project-shell {
    padding: 16px 14px;
  }

  .section-head {
    flex-wrap: wrap;
    gap: 8px;
  }

  .filters {
    flex-wrap: wrap;
    margin-left: 0;
  }

  /* The crumb duplicates the page heading and starves the search box at
     narrow widths; the hamburger and the heading carry the context. */
  .crumb {
    display: none;
  }

  /* ＋ Create shrinks to its glyph so search keeps usable width. */
  #create-menu-btn {
    padding: 6px 10px;
    font-size: 1rem;
  }

  #create-menu-btn .create-label {
    display: none;
  }

  .topbar-search {
    flex: 1 1 auto;
    min-width: 120px;
  }

  /* Inbox/work row actions always visible on touch (spec 6) */
  .row {
    padding: 12px 14px;
    flex-wrap: wrap;
    row-gap: 8px;
  }

  /* Line 1 is the icon and the title; the timestamp and actions wrap onto
     line 2, otherwise the title truncates to a couple of characters. */
  .row .body {
    flex: 1 1 auto;
    min-width: 0;
  }

  .row .when {
    flex-basis: 100%;
  }

  .row .acts {
    opacity: 1;
    margin-left: auto;
  }

  .row .t {
    white-space: normal;
  }

  /* Chips scroll rather than stacking into four rows. */
  .section-head .filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    width: 100%;
  }

  .section-head .filters::-webkit-scrollbar {
    display: none;
  }

  .section-head .filters .fchip {
    white-space: nowrap;
  }

  .row-more {
    right: 0;
    left: auto;
  }

  .workspace-head,
  .phead {
    padding: 16px 14px 0;
  }

  .titleline {
    flex-wrap: wrap;
    row-gap: 8px;
  }

  /* All 2-column grids stack (spec 6) */
  .ov-grid,
  .overview-row,
  .files-browser-layout,
  .files-grid,
  .grid-2,
  .settings-grid,
  .mail-keyword-panel,
  .task-form,
  .planning-form,
  .deliverable-form,
  .finance-form,
  .acquisition-form,
  .ledger-form,
  .time-entry-form,
  .extra-folder-settings,
  .task-form-row,
  .file-detail-grid,
  .summary-cols {
    grid-template-columns: 1fr;
  }

  .kpis,
  .finance-summary-grid {
    grid-template-columns: 1fr 1fr;
  }

  .drawer {
    width: 100%;
  }

  .set-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .set-grid > nav {
    display: flex;
    overflow-x: auto;
    gap: 4px;
    padding-bottom: 4px;
    scrollbar-width: none;
  }

  .snav {
    white-space: nowrap;
    width: auto;
  }

  .snav-label {
    display: none;
  }

  /* Mail rows reflow with subject on its own line (spec 6) */
  .mailrow,
  .mail-table-row {
    flex-wrap: wrap;
    row-gap: 6px;
  }

  .mailrow .who,
  .mail-party {
    width: auto;
  }

  .mailrow .subj,
  .mail-subject {
    flex-basis: 100%;
    order: 9;
  }

  .atabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }

  .atabs .fchip {
    white-space: nowrap;
  }

  .project-form,
  .members-dialog-body,
  .project-settings-dialog-body,
  .admin-dialog-content,
  .weaviate-dialog-content,
  .mailbox-import-form,
  .global-settings-form {
    width: 100%;
  }

  dialog {
    width: 96vw;
  }

  /* Touch targets >= 40px (spec 6) */
  .mini,
  .compact-button,
  .fchip,
  .tab,
  .menu-item,
  .wide-button,
  .snav {
    min-height: 40px;
  }

  .iconbtn {
    width: 40px;
    height: 40px;
  }
}
