:root {
  --ink: #241707;
  --ink-2: #35250f;
  --cardboard: #d2a15f;
  --cardboard-deep: #c28f4c;
  --paper: #fffdf8;
  --paper-2: #f8f5ee;
  --paper-3: #f1ede4;
  --line: #e4dfd5;
  --line-strong: #d1cabd;
  --text: #26231f;
  --muted: #777169;
  --muted-2: #a49d92;
  --yellow: #ffd83e;
  --yellow-2: #f4c821;
  --blue: #2383e2;
  --blue-soft: #dcecfb;
  --green: #2f8d65;
  --green-soft: #dceee4;
  --red: #c84e3f;
  --red-soft: #f8dfdc;
  --pink: #c94d86;
  --pink-soft: #f5ddea;
  --purple: #8559a5;
  --purple-soft: #eadff1;
  --shadow: 0 14px 40px rgba(36, 23, 7, .13);
  --sidebar: 272px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; color: var(--text); background: var(--cardboard); }
body { min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.boot-screen {
  min-height: 100vh; display: grid; place-items: center; align-content: center; gap: 12px;
  background:
    repeating-linear-gradient(135deg, rgba(36,23,7,.055) 0 1px, transparent 1px 46px),
    var(--cardboard);
  color: var(--ink); font-weight: 700;
}
.boot-logo { width: 72px; height: 72px; object-fit: contain; filter: drop-shadow(0 8px 5px rgba(36,23,7,.18)); }
.spinner { width: 27px; height: 27px; border: 3px solid rgba(36,23,7,.15); border-top-color: var(--ink); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Auth / setup */
.auth-shell, .setup-shell { min-height: 100vh; display: grid; grid-template-columns: 1.08fr .92fr; background: var(--paper); }
.auth-art {
  padding: clamp(34px, 5vw, 70px);
  background:
    repeating-linear-gradient(135deg, rgba(36,23,7,.055) 0 1px, transparent 1px 48px),
    var(--cardboard);
  display: flex; flex-direction: column; justify-content: space-between; color: var(--ink); position: relative; overflow: hidden;
}
.auth-art::after { content: ""; position: absolute; right: -90px; bottom: -120px; width: 360px; height: 360px; border: 2px dashed rgba(36,23,7,.18); transform: rotate(8deg); border-radius: 28px; }
.auth-brand { display: flex; align-items: center; gap: 12px; font-weight: 950; letter-spacing: .08em; font-size: 18px; position: relative; z-index: 1; }
.brand-image { display: grid; place-items: center; overflow: hidden; }
.brand-image img { width: 100%; height: 100%; object-fit: contain; }
.brand-mark { width: 42px; height: 42px; }
.auth-art h1 { font-family: "Arial Black", Impact, sans-serif; font-size: clamp(50px, 6.2vw, 92px); line-height: .9; margin: 0; max-width: 760px; letter-spacing: -.055em; text-transform: uppercase; position: relative; z-index: 1; }
.auth-art p { color: rgba(36,23,7,.78); font-size: 18px; max-width: 650px; line-height: 1.55; position: relative; z-index: 1; }
.preview-card { width: min(690px, 100%); padding: 15px; border: 2px solid var(--ink); background: rgba(255,253,248,.82); border-radius: 12px; box-shadow: 7px 7px 0 rgba(36,23,7,.18); position: relative; z-index: 1; }
.preview-row { display: grid; grid-template-columns: 1fr 105px 110px; align-items: center; gap: 10px; padding: 12px; border-bottom: 1px solid var(--line); }
.preview-row:last-child { border-bottom: 0; }
.auth-panel { display: grid; place-items: center; padding: 42px; background: var(--paper); }
.auth-card { width: min(430px, 100%); }
.auth-card::before { content: "BOXED UP GAMES • EST. 2026"; display: inline-block; margin-bottom: 22px; padding: 7px 10px; border: 2px solid var(--ink); border-radius: 999px; font-size: 10px; font-weight: 900; letter-spacing: .12em; color: var(--ink); }
.auth-card h2 { font-size: 32px; letter-spacing: -.035em; margin: 0 0 8px; }
.auth-card > p { color: var(--muted); margin: 0 0 26px; }
.auth-tabs { display: flex; gap: 5px; background: var(--paper-3); padding: 4px; border-radius: 9px; margin-bottom: 22px; }
.auth-tabs button { flex: 1; border: 0; background: transparent; padding: 9px 12px; border-radius: 7px; color: var(--muted); }
.auth-tabs button.active { background: white; color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.setup-shell { grid-template-columns: 1fr; place-items: center; padding: 34px; background: repeating-linear-gradient(135deg, rgba(36,23,7,.055) 0 1px, transparent 1px 48px), var(--cardboard); }
.setup-card { width: min(760px, 100%); background: var(--paper); border: 2px solid var(--ink); border-radius: 14px; padding: 30px; box-shadow: 8px 8px 0 rgba(36,23,7,.15); }
.setup-logo { display: block; width: 86px; height: 76px; margin-bottom: 12px; }
.setup-logo img { width: 100%; height: 100%; object-fit: contain; }
.setup-card h1 { margin: 0 0 8px; font-size: 34px; letter-spacing: -.035em; }
.setup-card code { background: var(--paper-3); border: 1px solid var(--line); padding: 2px 5px; border-radius: 5px; }
.setup-steps { padding-left: 20px; color: #555047; line-height: 1.75; }
.eyebrow { display: inline-flex; align-items: center; width: max-content; border: 1.5px solid var(--ink); border-radius: 999px; padding: 5px 9px; font-size: 10px; font-weight: 900; letter-spacing: .12em; color: var(--ink); margin-bottom: 12px; }
.eyebrow.dark { background: var(--ink); color: var(--yellow); border-color: var(--ink); }

/* Forms */
.field { display: grid; gap: 7px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 700; color: #4b4740; }
.input, .select, .textarea { width: 100%; border: 1px solid var(--line-strong); background: white; color: var(--text); border-radius: 7px; padding: 10px 11px; outline: none; transition: border .15s, box-shadow .15s; }
.input:focus, .select:focus, .textarea:focus { border-color: #c99a30; box-shadow: 0 0 0 3px rgba(255,216,62,.22); }
.input[readonly] { background: var(--paper-2); color: var(--muted); }
.textarea { resize: vertical; min-height: 100px; }
.btn { border: 1px solid var(--line-strong); background: white; color: var(--text); padding: 9px 13px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; }
.btn:hover { background: var(--paper-2); }
.btn.primary, .btn.brand-primary { background: var(--yellow); color: var(--ink); border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); }
.btn.primary:hover, .btn.brand-primary:hover { background: #ffe15d; transform: translate(-1px,-1px); box-shadow: 3px 3px 0 var(--ink); }
.btn.brand-secondary { background: transparent; color: var(--ink); border: 2px solid var(--ink); box-shadow: 2px 2px 0 rgba(36,23,7,.28); }
.btn.danger { color: var(--red); border-color: #e6b6b0; background: white; box-shadow: none; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); box-shadow: none; }
.btn.ghost:hover { background: var(--paper-2); color: var(--text); }
.btn.block { width: 100%; }
.btn.small { padding: 6px 9px; font-size: 12px; box-shadow: none; border-width: 1px; }
.help { color: var(--muted); font-size: 12px; line-height: 1.5; }
.error-box, .info-box { border-radius: 9px; padding: 12px 14px; font-size: 13px; margin: 12px 0; }
.error-box { background: var(--red-soft); color: #8a2e2a; border: 1px solid #e7bdb8; }
.info-box { background: #fff6c8; color: #6a5411; border: 1px solid #e7cf69; }

/* App chrome */
.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar) 1fr; background: var(--cardboard); }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--ink); color: #f9efdb; border-right: 1px solid rgba(255,255,255,.05); padding: 10px 8px; display: flex; flex-direction: column; overflow: hidden; box-shadow: 8px 0 22px rgba(36,23,7,.12); z-index: 50; }
.workspace-switcher { display: flex; align-items: center; gap: 10px; padding: 8px 10px 12px; border-radius: 8px; font-weight: 950; margin-bottom: 6px; letter-spacing: .05em; cursor: pointer; }
.workspace-switcher:hover { background: rgba(255,255,255,.07); }
.ws-icon { width: 34px; height: 31px; flex: 0 0 auto; }
.workspace-name { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13px; }
.workspace-caret { color: #baa887; }
.sidebar-scroll { flex: 1; overflow-y: auto; padding-right: 2px; }
.side-label { color: #9e8c6d; font-size: 10px; text-transform: uppercase; letter-spacing: .13em; padding: 16px 11px 6px; font-weight: 800; }
.nav-item { width: 100%; border: 0; background: transparent; display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 7px; color: #d9cbb3; text-align: left; min-width: 0; }
.nav-item:hover { background: rgba(255,255,255,.07); color: white; }
.nav-item.active { background: var(--yellow); color: var(--ink); font-weight: 800; }
.nav-icon { width: 22px; text-align: center; flex: 0 0 auto; }
.nav-text { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; flex: 1; }
.nav-drag { opacity: 0; color: inherit; font-size: 12px; }
.nav-item:hover .nav-drag { opacity: .65; }
.new-tracker { color: #ae9e81; }
.sidebar-footer { border-top: 1px solid rgba(255,255,255,.1); padding-top: 7px; }
.user-row { display: flex; align-items: center; gap: 9px; padding: 8px 9px; border-radius: 7px; }
.user-row:hover { background: rgba(255,255,255,.06); }
.user-details { min-width: 0; flex: 1; }
.user-name { font-size: 13px; font-weight: 800; color: white; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-email { font-size: 10px; color: #aa997d; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-signout { color: #bdaa8a !important; }
.avatar { width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center; background: #587d8d; color: white; font-size: 11px; font-weight: 800; flex: 0 0 auto; overflow: hidden; border: 1px solid rgba(255,255,255,.35); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 22px; height: 22px; font-size: 9px; }
.avatar.lg { width: 40px; height: 40px; font-size: 14px; }

.main { min-width: 0; background: var(--cardboard); }
.topbar { height: 58px; display: flex; align-items: center; gap: 10px; padding: 0 20px; position: sticky; top: 0; z-index: 40; background: var(--ink); color: white; border-bottom: 3px solid var(--yellow); }
.topbar-logo { width: 30px; height: 28px; }
.topbar-logo img { width: 100%; height: 100%; object-fit: contain; }
.breadcrumb { font-size: 12px; color: #d8c9ae; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; gap: 8px; align-items: center; }
.breadcrumb strong { color: white; letter-spacing: .03em; }
.breadcrumb span { color: #7f7057; }
.top-actions { display: flex; gap: 6px; align-items: center; }
.icon-btn { width: 32px; height: 32px; border: 0; background: transparent; border-radius: 7px; display: grid; place-items: center; color: #d8c9ae; }
.icon-btn:hover { background: rgba(255,255,255,.08); color: white; }
.top-chip { border: 1px solid #6c5938; background: #372810; color: #f5e6ca; border-radius: 7px; padding: 7px 10px; font-size: 11px; font-weight: 800; }
.top-chip:hover { border-color: var(--yellow); color: var(--yellow); }
.install-action { display: none !important; }
body.can-install .install-action { display: inline-flex !important; }
.kraft-stage { min-height: calc(100vh - 58px); padding: 22px; background: repeating-linear-gradient(135deg, rgba(36,23,7,.055) 0 1px, transparent 1px 48px), var(--cardboard); }
.workspace-page { min-height: calc(100vh - 102px); background: var(--paper); border: 1px solid rgba(36,23,7,.18); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.content { padding: 44px clamp(28px, 5vw, 78px) 80px; max-width: 1700px; }
.content.wide { padding-left: 42px; padding-right: 42px; max-width: none; }

/* Dashboard */
.dashboard-content { max-width: none; padding: 0 0 80px; }
.hq-hero { display: grid; grid-template-columns: 1.05fr .95fr; gap: 50px; align-items: center; padding: clamp(46px, 6vw, 86px) clamp(34px, 6vw, 90px) 60px; background: repeating-linear-gradient(135deg, rgba(36,23,7,.055) 0 1px, transparent 1px 48px), var(--cardboard); border-bottom: 1px solid rgba(36,23,7,.18); color: var(--ink); }
.hero-copy h1 { font-family: "Arial Black", Impact, sans-serif; font-size: clamp(58px, 7vw, 102px); line-height: .86; letter-spacing: -.06em; margin: 16px 0 20px; text-transform: uppercase; }
.hero-copy h1 span { color: var(--paper); text-shadow: 3px 3px 0 var(--ink), -1px -1px 0 var(--ink), 1px -1px 0 var(--ink), -1px 1px 0 var(--ink); }
.hero-copy p { max-width: 620px; line-height: 1.55; color: rgba(36,23,7,.78); font-size: 17px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 28px; }
.ship-card { min-height: 310px; border: 3px solid var(--ink); border-radius: 18px; background: rgba(255,253,248,.18); box-shadow: 8px 8px 0 rgba(36,23,7,.35); display: grid; place-items: center; align-content: center; padding: 40px; transform: rotate(-1.5deg); position: relative; }
.ship-card::before { content: ""; position: absolute; inset: 9px; border: 2px dashed rgba(36,23,7,.35); border-radius: 11px; pointer-events: none; }
.ship-logo { width: 142px; height: 130px; position: relative; z-index: 2; }
.ship-logo img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(3px 7px 0 rgba(36,23,7,.42)); }
.ship-line { width: 85%; border-top: 2px dashed rgba(36,23,7,.38); margin: 24px 0 14px; }
.ship-card strong { font-size: 11px; letter-spacing: .14em; }
.tape { position: absolute; width: 120px; height: 30px; background: rgba(242,229,184,.88); border: 1px solid rgba(36,23,7,.15); box-shadow: 0 3px 4px rgba(36,23,7,.16); }
.tape-top { top: -17px; left: 34%; transform: rotate(-3deg); }
.tape-bottom { bottom: -15px; left: 5%; transform: rotate(5deg); }
.approval-stamp { position: absolute; right: -15px; top: -18px; width: 82px; height: 82px; border: 3px solid var(--red); color: var(--red); border-radius: 50%; display: grid; place-items: center; text-align: center; font-size: 9px; font-weight: 900; transform: rotate(8deg); background: rgba(255,253,248,.35); }
.brand-metrics { margin: 0 clamp(34px, 6vw, 90px); transform: translateY(-1px); border: 2px solid var(--ink); background: var(--ink); border-radius: 0 0 10px 10px; overflow: hidden; display: grid; grid-template-columns: repeat(4,1fr); gap: 0; }
.brand-metrics .metric { background: var(--ink); color: white; border: 0; border-right: 1px solid #514328; border-radius: 0; padding: 18px 20px; }
.brand-metrics .metric:last-child { border-right: 0; }
.brand-metrics .metric-value { color: var(--yellow); }
.brand-metrics .metric-label { color: #b7a98c; font-size: 9px; letter-spacing: .11em; font-weight: 800; }
.metric-value { font-size: 28px; font-weight: 900; letter-spacing: -.03em; }
.metric-label { color: var(--muted); font-size: 12px; margin-top: 4px; }
.reminder-card { margin: 34px clamp(34px, 6vw, 90px) 52px; border: 1px solid var(--line); border-left: 5px solid var(--yellow-2); border-radius: 9px; padding: 16px 18px; display: flex; align-items: center; gap: 14px; background: white; }
.reminder-card.urgent { border-left-color: var(--red); background: #fff9f8; }
.reminder-icon { width: 38px; height: 38px; border-radius: 9px; display: grid; place-items: center; background: #fff3b2; }
.reminder-copy { flex: 1; min-width: 0; display: grid; gap: 3px; }
.reminder-copy span { color: var(--muted); font-size: 13px; }
.section-kicker { margin: 0 clamp(34px, 6vw, 90px); width: max-content; padding: 5px 9px; border: 1.5px solid var(--ink); border-radius: 999px; font-size: 10px; font-weight: 900; letter-spacing: .12em; }
.catalog-title { margin: 20px clamp(34px, 6vw, 90px) 28px; font-family: "Arial Black", Impact, sans-serif; font-size: clamp(34px, 4vw, 54px); letter-spacing: -.04em; color: var(--ink); }
.dashboard-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 54px; margin: 0 clamp(34px, 6vw, 90px); max-width: 1200px; }
.section-title { font-size: 21px; margin: 0; padding-bottom: 12px; border-bottom: 1px solid var(--line); letter-spacing: -.02em; }
.resource-list { display: grid; gap: 8px; margin-top: 14px; }
.resource-card { display: flex; gap: 11px; align-items: center; padding: 11px; border-radius: 8px; border: 1px solid transparent; color: var(--text); }
button.resource-card { width: 100%; background: none; text-align: left; }
.resource-card:hover { border-color: var(--line); background: var(--paper-2); }
.resource-icon { width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center; background: var(--paper-3); font-size: 19px; }
.resource-card > div { flex: 1; min-width: 0; }
.resource-arrow { color: var(--muted-2); font-size: 20px; }

/* Tracker pages */
.page-icon { font-size: 42px; line-height: 1; margin-bottom: 18px; }
.page-title { font-size: clamp(32px, 3.3vw, 48px); letter-spacing: -.045em; margin: 0 0 8px; line-height: 1.1; }
.page-subtitle { color: var(--muted); margin: 0 0 26px; }
.page-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 18px; }
.page-head .page-icon { margin: 0; font-size: 38px; }
.page-head-copy { flex: 1; }
.page-head-copy .page-title { font-size: 34px; margin: 0 0 5px; }
.page-head-copy .page-subtitle { margin: 0; }
.page-head-actions { display: flex; gap: 8px; align-items: center; }
.branded-page-head { padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.toolbar { display: flex; align-items: center; gap: 6px; margin: 22px 0 12px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.view-tab { border: 0; background: transparent; color: var(--muted); padding: 8px 11px; border-radius: 8px; font-weight: 650; }
.view-tab:hover, .view-tab.active { background: var(--paper-3); color: var(--text); }
.toolbar-icon { border: 0; width: 31px; height: 31px; border-radius: 7px; background: transparent; color: var(--muted); }
.toolbar-icon:hover { background: var(--paper-3); color: var(--text); }
.new-btn { border: 1px solid #1674cc; background: var(--blue); color: white; padding: 8px 13px; border-radius: 7px; font-weight: 700; }

.table-wrap { overflow-x: auto; border-top: 1px solid var(--line); }
.data-table { width: 100%; border-collapse: collapse; min-width: 1180px; font-size: 13px; table-layout: fixed; background: white; }
.data-table th { height: 39px; text-align: left; color: var(--muted); font-weight: 500; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 0 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: #fffdfa; }
.data-table th:last-child, .data-table td:last-child { border-right: 0; }
.data-table td { min-height: 39px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 7px 9px; vertical-align: middle; }
.data-table tr:hover td { background: #fbfaf7; }
.title-cell { font-weight: 650; cursor: pointer; }
.title-cell:hover { text-decoration: underline; }
.empty-cell { color: var(--muted-2); }
.inline-select { border: 0; background: transparent; outline: none; color: inherit; max-width: 100%; }
.new-row { color: var(--muted-2); cursor: pointer; }
.new-row:hover { color: var(--text); }

.pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 6px; padding: 3px 7px; line-height: 1.15; white-space: nowrap; font-size: 12px; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .65; }
.pill.gray { background: #e7e4de; color: #56514a; }
.pill.blue { background: var(--blue-soft); color: #2466a3; }
.pill.green { background: var(--green-soft); color: #277451; }
.pill.red { background: var(--red-soft); color: #a33d37; }
.pill.yellow { background: #faedba; color: #80600c; }
.pill.pink { background: var(--pink-soft); color: #9b3f6e; }
.pill.purple { background: var(--purple-soft); color: #76528f; }
.pill.no-dot::before { display: none; }

.kanban { display: grid; grid-template-columns: repeat(3, minmax(285px, 1fr)); gap: 12px; align-items: start; min-width: 930px; }
.kanban-wrap { overflow-x: auto; padding-bottom: 20px; }
.kanban-column { border-radius: 10px; padding: 8px; background: #f4f2ec; min-height: 160px; border: 1px solid #ebe6dc; }
.kanban-column[data-status="In progress"] { background: #eef6fc; }
.kanban-column[data-status="Done"] { background: #eef7f2; }
.kanban-head { display: flex; align-items: center; gap: 8px; padding: 5px 3px 9px; font-size: 13px; }
.kanban-count { color: var(--muted); }
.kanban-list { min-height: 60px; }
.kanban-card { background: white; border: 1px solid var(--line); border-radius: 9px; padding: 12px; margin-bottom: 7px; box-shadow: 0 1px 2px rgba(36,23,7,.04); cursor: grab; }
.kanban-card:hover { border-color: #cfc8bc; box-shadow: 0 3px 10px rgba(36,23,7,.07); }
.kanban-card:active { cursor: grabbing; }
.card-title { font-weight: 700; margin-bottom: 10px; }
.card-meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.progress { height: 4px; background: #ece8df; border-radius: 999px; overflow: hidden; margin-top: 10px; }
.progress > span { height: 100%; background: var(--blue); display: block; }
.card-new { border: 1px dashed #cbc4b7; color: var(--muted); background: transparent; width: 100%; border-radius: 8px; padding: 10px; text-align: left; }
.card-new:hover { background: rgba(255,255,255,.7); color: var(--text); }
.sortable-ghost { opacity: .35; }

/* Team / permissions */
.team-content { max-width: 1300px; }
.brand-box { border: 2px solid var(--ink) !important; box-shadow: 4px 4px 0 rgba(36,23,7,.12); background: #fffaf0 !important; }
.invite-box { margin: 20px 0 34px; padding: 18px; background: var(--paper-2); border: 1px solid var(--line); border-radius: 10px; max-width: 980px; }
.invite-row { display: grid; grid-template-columns: 1fr 170px auto; gap: 8px; margin-top: 14px; }
.invite-list { margin-top: 14px; display: grid; gap: 7px; }
.invite-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.invite-item > span { flex: 1; }
.invite-item > div { display: flex; gap: 6px; }
.team-section { margin-top: 34px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 12px; }
.section-heading h2 { margin: 0 0 4px; font-size: 23px; }
.section-heading p { margin: 0; color: var(--muted); font-size: 13px; }
.team-grid { display: grid; max-width: 1000px; border-top: 1px solid var(--line); }
.member-row { display: grid; grid-template-columns: minmax(260px,1fr) 180px 110px; gap: 12px; align-items: center; border-bottom: 1px solid var(--line); padding: 12px 4px; }
.member-main { display: flex; gap: 10px; align-items: center; min-width: 0; }
.member-copy { min-width: 0; }
.member-copy strong, .member-copy span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-copy span { color: var(--muted); font-size: 12px; }
.member-role-select { min-width: 150px; }
.owner-lock, .locked-role { color: #8a6b13; background: #fff1bc; border-radius: 999px; padding: 5px 8px; font-size: 10px; font-weight: 800; white-space: nowrap; }
.roles-section { margin-top: 54px; padding-top: 28px; border-top: 2px solid var(--ink); }
.roles-grid { display: grid; gap: 16px; }
.role-card { border: 1px solid var(--line); border-radius: 10px; background: white; overflow: hidden; }
.role-card-head { display: flex; justify-content: space-between; gap: 20px; padding: 16px 18px; background: var(--paper-2); border-bottom: 1px solid var(--line); }
.role-card-head p { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.role-card-actions { display: flex; align-items: flex-start; }
.permission-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); }
.permission-row { padding: 13px 16px; display: flex; align-items: center; gap: 14px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); cursor: pointer; }
.permission-row:nth-child(even) { border-right: 0; }
.permission-row span { flex: 1; display: grid; gap: 2px; }
.permission-row strong { font-size: 13px; }
.permission-row small { color: var(--muted); font-size: 11px; }
.permission-row input { width: 18px; height: 18px; accent-color: var(--ink); }
.permission-row.locked { cursor: default; opacity: .72; background: #fffdf4; }
.role-save-row { display: flex; justify-content: flex-end; padding: 12px 16px; background: #fffcf3; }

/* Modals */
.modal-backdrop { position: fixed; inset: 0; background: rgba(36,23,7,.38); display: grid; place-items: center; padding: 18px; z-index: 1000; backdrop-filter: blur(2px); }
.modal { width: min(640px, 100%); max-height: calc(100vh - 36px); overflow-y: auto; background: var(--paper); border: 2px solid var(--ink); border-radius: 12px; box-shadow: 8px 8px 0 rgba(36,23,7,.28); }
.modal.wide { width: min(840px, 100%); }
.modal-head { padding: 18px 20px 12px; display: flex; align-items: center; gap: 10px; }
.modal-head h3 { margin: 0; font-size: 20px; flex: 1; }
.modal-body { padding: 8px 20px 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--paper); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.form-grid .field { margin: 0; }
.form-grid .span-2 { grid-column: span 2; }

#toast-root { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 1200; }
.toast { background: var(--ink); color: white; border-radius: 8px; padding: 11px 13px; box-shadow: var(--shadow); font-size: 13px; max-width: 360px; animation: toastIn .18s ease-out; border-left: 4px solid var(--yellow); }
.toast.error { background: #7e2f27; border-left-color: #ffb2a8; }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } }

.mobile-toggle { display: none; }
@media (max-width: 1050px) {
  .hq-hero { grid-template-columns: 1fr; }
  .ship-card { max-width: 620px; width: 100%; }
  .permission-grid { grid-template-columns: 1fr; }
  .permission-row { border-right: 0; }
}
@media (max-width: 900px) {
  :root { --sidebar: 238px; }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .dashboard-grid { grid-template-columns: 1fr; gap: 36px; }
  .content { padding-left: 26px; padding-right: 26px; }
  .brand-metrics { grid-template-columns: repeat(2,1fr); }
  .brand-metrics .metric:nth-child(2) { border-right: 0; }
  .brand-metrics .metric:nth-child(-n+2) { border-bottom: 1px solid #514328; }
}
@media (max-width: 700px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 100; width: min(88vw, 300px); transform: translateX(-102%); transition: transform .2s ease; box-shadow: 20px 0 50px rgba(36,23,7,.25); }
  .sidebar.open { transform: translateX(0); }
  .mobile-toggle { display: grid; }
  .topbar-logo { display: none; }
  .kraft-stage { padding: 9px; }
  .workspace-page { min-height: calc(100vh - 76px); border-radius: 9px; }
  .content, .content.wide { padding: 26px 16px 60px; }
  .dashboard-content { padding: 0 0 60px; }
  .hq-hero { padding: 38px 20px 44px; gap: 34px; }
  .hero-copy h1 { font-size: clamp(48px, 15vw, 74px); }
  .ship-card { min-height: 250px; }
  .brand-metrics, .reminder-card, .section-kicker, .catalog-title, .dashboard-grid { margin-left: 20px; margin-right: 20px; }
  .brand-metrics { grid-template-columns: 1fr 1fr; }
  .page-head { flex-wrap: wrap; }
  .page-head-actions { width: 100%; }
  .member-row { grid-template-columns: 1fr; }
  .invite-row { grid-template-columns: 1fr; }
  .invite-item { align-items: flex-start; flex-direction: column; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
  .top-chip { display: none; }
}

/* ===== Mobile usability pass (iPhone-first) ===== */
.sidebar-backdrop,
.mobile-dock,
.mobile-signout { display: none; }

@media (max-width: 700px) {
  html { background: var(--paper); }
  body { min-height: 100dvh; overscroll-behavior-y: none; }
  body.sidebar-open { overflow: hidden; }

  .topbar {
    height: calc(54px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 10px 0;
    gap: 6px;
  }
  .mobile-toggle,
  .mobile-signout { display: grid; width: 42px; height: 42px; font-size: 18px; }
  .breadcrumb { font-size: 11px; gap: 5px; }
  .breadcrumb > span { display: none; }
  .breadcrumb strong { overflow: hidden; text-overflow: ellipsis; }
  .top-actions { gap: 2px; }
  .top-actions > .icon-btn:not(.mobile-signout) { display: none; }

  .sidebar {
    top: 0;
    height: 100dvh;
    width: min(86vw, 330px);
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 90;
    border: 0;
    background: rgba(20, 12, 3, .42);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }
  body.sidebar-open .sidebar-backdrop { display: block; }
  .nav-item { min-height: 48px; padding: 10px 12px; border-radius: 10px; }
  .workspace-switcher { min-height: 52px; }
  .sidebar-footer .user-row { min-height: 58px; }
  .sidebar-signout { width: 44px; height: 44px; }

  .kraft-stage {
    min-height: calc(100dvh - 54px - env(safe-area-inset-top));
    padding: 0;
    padding-bottom: calc(76px + env(safe-area-inset-bottom));
    background: var(--paper);
  }
  .workspace-page {
    min-height: calc(100dvh - 54px - env(safe-area-inset-top));
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .content, .content.wide { padding: 22px 14px 34px; }
  .dashboard-content { padding: 0 0 34px; }
  .hq-hero {
    display: block;
    padding: 24px 18px 26px;
    border-bottom: 1px solid rgba(36,23,7,.14);
  }
  .hero-copy h1 {
    font-size: clamp(42px, 13vw, 58px);
    line-height: .9;
    margin: 10px 0 18px;
  }
  .hero-actions { margin-top: 0; }
  .hero-actions .btn { min-height: 46px; width: 100%; }
  .ship-card { display: none; }

  .reminder-card,
  .section-kicker,
  .catalog-title,
  .dashboard-grid {
    margin-left: 14px;
    margin-right: 14px;
  }
  .reminder-card {
    margin-top: 18px;
    margin-bottom: 30px;
    align-items: flex-start;
    padding: 14px;
  }
  .reminder-icon { flex: 0 0 36px; }
  .reminder-card > .pill,
  .reminder-card > .btn { margin-left: auto; }
  .catalog-title { font-size: 34px; margin-top: 14px; margin-bottom: 18px; }
  .dashboard-grid { gap: 28px; }
  .resource-card { min-height: 52px; padding: 12px 10px; }

  .page-head { margin-bottom: 8px; }
  .page-head .page-icon { font-size: 30px; }
  .page-head-copy .page-title { font-size: 28px; }
  .page-subtitle { font-size: 13px; }
  .toolbar {
    position: sticky;
    top: calc(54px + env(safe-area-inset-top));
    z-index: 20;
    margin: 10px -14px 12px;
    padding: 8px 12px;
    background: rgba(255,253,248,.96);
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    overflow-x: auto;
    flex-wrap: nowrap;
  }
  .toolbar .spacer { display: none; }
  .view-tab, .new-btn, .toolbar-icon { min-height: 42px; flex: 0 0 auto; }
  .new-btn { margin-left: auto; }

  /* Tables become stacked task cards instead of a 1180px sideways spreadsheet. */
  .table-wrap { overflow: visible; border-top: 0; }
  .data-table { min-width: 0; display: block; background: transparent; }
  .data-table colgroup,
  .data-table thead { display: none; }
  .data-table tbody { display: grid; gap: 10px; }
  .data-table tr {
    display: grid;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: white;
    padding: 4px 12px;
    box-shadow: 0 1px 3px rgba(36,23,7,.05);
    overflow: hidden;
  }
  .data-table td {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    min-height: 42px;
    padding: 8px 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    word-break: break-word;
  }
  .data-table td:last-child { border-bottom: 0; }
  .data-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
  }
  .data-table td.title-cell {
    display: block;
    font-size: 16px;
    padding: 12px 0 10px;
  }
  .data-table td.title-cell::before { display: none; }
  .data-table tr.new-row { padding: 0; border-style: dashed; }
  .data-table tr.new-row td { display: block; padding: 13px; border: 0; }
  .data-table tr.new-row td::before { display: none; }
  .inline-select { min-height: 30px; font-size: 14px; }

  /* Kanban is vertical on phones: no sideways fighting with Safari. */
  .kanban-wrap { overflow: visible; padding-bottom: 0; }
  .kanban { display: grid; grid-template-columns: 1fr; min-width: 0; gap: 14px; }
  .kanban-column { min-height: 100px; padding: 10px; }
  .kanban-card { padding: 14px; margin-bottom: 9px; touch-action: manipulation; }
  .card-new { min-height: 44px; }

  .invite-box { padding: 14px; }
  .member-row { padding: 14px 0; }
  .member-role-select { min-height: 44px; width: 100%; }
  .permission-row { padding: 14px 10px; }
  .role-card-head { padding: 14px; }

  .modal-backdrop {
    padding: 0;
    align-items: end;
  }
  .modal, .modal.wide {
    width: 100%;
    max-height: min(92dvh, calc(100dvh - env(safe-area-inset-top)));
    border-radius: 16px 16px 0 0;
    border-width: 1px 0 0;
    box-shadow: 0 -12px 40px rgba(36,23,7,.25);
  }
  .modal-head { padding: 16px 16px 10px; }
  .modal-body { padding: 8px 16px 18px; }
  .modal-actions {
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    flex-wrap: wrap;
  }
  .modal-actions .btn { min-height: 44px; }
  .input, .select, .textarea { min-height: 46px; font-size: 16px; }

  #toast-root {
    left: 12px;
    right: 12px;
    bottom: calc(82px + env(safe-area-inset-bottom));
  }
  .toast { max-width: none; }

  .mobile-dock {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 80;
    min-height: calc(64px + env(safe-area-inset-bottom));
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 2px;
    background: rgba(36,23,7,.97);
    border-top: 2px solid var(--yellow);
    box-shadow: 0 -8px 22px rgba(36,23,7,.16);
  }
  .mobile-dock button {
    border: 0;
    background: transparent;
    color: #e8dcc6;
    min-width: 0;
    min-height: 48px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 2px;
    padding: 3px;
  }
  .mobile-dock button:active { background: rgba(255,255,255,.08); }
  .mobile-dock button span { font-size: 20px; line-height: 1; }
  .mobile-dock button small { font-size: 9px; font-weight: 800; letter-spacing: .02em; }
  .mobile-dock .dock-add { color: var(--ink); background: var(--yellow); }
  .mobile-dock .dock-add:active { background: #ffe46c; }
}
