:root {
  --ink: #1f2327;
  --muted: #6d747b;
  --quiet: #91989e;
  --canvas: #f5f5f3;
  --surface: #ffffff;
  --surface-alt: #f0f1ee;
  --line: #e3e4e0;
  --line-strong: #d5d7d1;
  --accent: #2c665d;
  --accent-soft: #e4f0ec;
  --red: #bf4f45;
  --red-soft: #f9e9e7;
  --amber: #996d20;
  --amber-soft: #fbf2df;
  --blue: #426a9f;
  --blue-soft: #e8eff8;
  --violet: #7662a6;
  --violet-soft: #eeeaf8;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --radius-sm: 6px;
  --radius: 10px;
  --shadow: 0 8px 24px rgb(32 39 35 / 6%);
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--canvas); font: 14px/1.45 Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: var(--space-6); background: var(--surface); border-right: 1px solid var(--line); }
.logo-link { display: inline-flex; align-items: center; width: 108px; height: 44px; margin: 0 0 var(--space-10); }
.logo-link img { display: block; width: 100%; height: auto; }
.nav-group { display: grid; gap: var(--space-1); }
.nav-item { display: flex; align-items: center; gap: var(--space-3); min-height: 40px; padding: 0 var(--space-3); color: var(--muted); background: transparent; border: 0; border-radius: var(--radius-sm); text-align: left; }
.nav-item:hover { color: var(--ink); background: var(--surface-alt); }
.nav-item.is-active { color: var(--ink); background: var(--surface-alt); font-weight: 650; }
.nav-icon { width: 20px; color: var(--quiet); font-size: 17px; text-align: center; }
.nav-nested { display: grid; gap: 2px; margin: var(--space-1) 0 var(--space-2) var(--space-8); }
.nav-nested .nav-item { min-height: 34px; padding: 0 var(--space-2); font-size: 13px; }
.sidebar-footer { display: grid; gap: var(--space-4); margin-top: auto; padding-top: var(--space-6); border-top: 1px solid var(--line); }
.sidebar-footer button { width: 100%; }
.sidebar-comm-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-2); color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.sidebar-comm-list { display: grid; gap: var(--space-1); }
.sidebar-comm-item { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); width: 100%; padding: var(--space-2); color: var(--ink); background: transparent; border: 0; border-radius: var(--radius-sm); text-align: left; }
.sidebar-comm-item:hover { background: var(--surface-alt); }
.sidebar-comm-name { overflow: hidden; font-size: 12px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-comm-meta { flex-shrink: 0; color: var(--muted); font-size: 11px; }
.sidebar-comm-more { width: 100%; padding: var(--space-1) var(--space-2); color: var(--muted); background: transparent; border: 0; text-align: left; font-size: 11px; }
.sidebar-comm-more:hover { color: var(--ink); }
.sidebar-comm-empty { margin: 0; color: var(--muted); font-size: 12px; }

.main { min-width: 0; padding: var(--space-8) var(--space-10) var(--space-12); }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-6); margin-bottom: var(--space-8); }
.eyebrow { margin: 0 0 var(--space-2); color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
h1 { margin: 0; font-size: 28px; font-weight: 730; letter-spacing: -.035em; line-height: 1.2; }
h2 { margin: 0; font-size: 18px; letter-spacing: -.02em; }
h3 { margin: 0; font-size: 15px; letter-spacing: -.01em; }
.page-subtitle { max-width: 680px; margin: var(--space-2) 0 0; color: var(--muted); }
.head-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--space-2); }

.button { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: 40px; padding: 0 var(--space-4); color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); font-weight: 650; white-space: nowrap; }
.button:hover { border-color: #bfc3bc; background: #fbfbfa; }
.button.primary { color: white; background: var(--ink); border-color: var(--ink); }
.button.primary:hover { background: #383d3f; }
.button.small { min-height: 32px; padding: 0 var(--space-3); font-size: 12px; }
.button.ghost { border-color: transparent; background: transparent; }
.button.danger { color: var(--red); }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); margin-bottom: var(--space-8); }
.metric { min-height: 136px; padding: var(--space-5); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.metric-label { color: var(--muted); font-size: 13px; font-weight: 600; }
.metric-value { margin-top: var(--space-4); font-size: 34px; font-weight: 720; letter-spacing: -.045em; line-height: 1; }
.metric-detail { margin-top: var(--space-3); color: var(--muted); font-size: 12px; }
.metric.is-alert .metric-value { color: var(--red); }
.metric.is-warn .metric-value { color: var(--amber); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr); gap: var(--space-6); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-5); border-bottom: 1px solid var(--line); }
.panel-head .button { margin: -4px 0; }
.panel-body { padding: var(--space-5); }
.panel + .panel { margin-top: var(--space-6); }
.project-summary-list { display: grid; }
.summary-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: var(--space-4); padding: var(--space-4) 0; border-bottom: 1px solid var(--line); }
.summary-row:first-child { padding-top: 0; }
.summary-row:last-child { padding-bottom: 0; border-bottom: 0; }
.summary-name { display: block; color: var(--ink); font-weight: 650; text-align: left; background: none; border: 0; padding: 0; }
.summary-name:hover { text-decoration: underline; }
.summary-meta { margin-top: var(--space-1); color: var(--muted); font-size: 12px; }
.progress-wrap { width: 124px; }
.progress-label { display: flex; justify-content: space-between; margin-bottom: var(--space-1); color: var(--muted); font-size: 11px; }
.progress-bar { height: 6px; overflow: hidden; background: var(--surface-alt); border-radius: 99px; }
.progress-bar > span { display: block; height: 100%; background: var(--accent); border-radius: inherit; }

.hierarchy-list { display: grid; gap: var(--space-5); }
.hierarchy-project { padding: var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.hierarchy-project-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); }
.hierarchy-product { margin-top: var(--space-3); padding-left: var(--space-4); border-left: 2px solid var(--line); }
.hierarchy-product-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin-bottom: var(--space-2); }
.hierarchy-product-name { font-size: 13px; font-weight: 650; }

.task-list { display: grid; gap: var(--space-2); }
.task-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: var(--space-3); padding: var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.task-dot { width: 9px; height: 9px; background: var(--blue); border-radius: 50%; }
.task-dot.done { background: var(--accent); }
.task-name { min-width: 0; overflow: hidden; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; text-align: left; background: none; border: 0; padding: 0; }
.task-name:hover { text-decoration: underline; }
.task-when { color: var(--muted); font-size: 12px; white-space: nowrap; }
.empty { display: grid; place-items: center; min-height: 148px; padding: var(--space-6); color: var(--muted); text-align: center; }
.empty p { max-width: 280px; margin: var(--space-2) 0 0; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); padding: var(--space-3); margin-bottom: var(--space-6); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.toolbar .search { flex: 1 1 220px; }
.input, select, textarea { width: 100%; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); outline: none; }
.input, select { height: 40px; padding: 0 var(--space-3); }
.toolbar select { width: auto; max-width: 160px; min-width: 114px; height: 36px; font-size: 12px; }
.search { position: relative; }
.search span { position: absolute; left: var(--space-3); top: 9px; color: var(--quiet); }
.search .input { padding-left: 36px; }
.input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgb(44 102 93 / 12%); }
textarea { min-height: 96px; padding: var(--space-3); resize: vertical; }

.project-table { overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.table-head, .project-row { display: grid; grid-template-columns: minmax(200px, 1.6fr) 128px 102px 130px 120px 100px 96px; gap: var(--space-3); align-items: center; padding: var(--space-4) var(--space-5); }
.table-head { color: var(--muted); background: #fafaf8; border-bottom: 1px solid var(--line); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.project-row { min-height: 76px; border-bottom: 1px solid var(--line); }
.project-row:last-child { border-bottom: 0; }
.project-row:hover { background: #fcfcfa; }
.project-link { display: block; overflow: hidden; color: var(--ink); font-weight: 700; text-align: left; text-overflow: ellipsis; white-space: nowrap; background: none; border: 0; padding: 0; }
.project-link:hover { text-decoration: underline; }
.cell-muted { color: var(--muted); font-size: 12px; }

.badge { display: inline-flex; align-items: center; width: fit-content; min-height: 24px; padding: 0 var(--space-2); color: var(--muted); background: var(--surface-alt); border-radius: 99px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge.request { color: var(--blue); background: var(--blue-soft); }
.badge.working { color: var(--violet); background: var(--violet-soft); }
.badge.sample { color: var(--amber); background: var(--amber-soft); }
.badge.making { color: #9b5652; background: #f8e9e8; }
.badge.complete, .badge.sent { color: var(--accent); background: var(--accent-soft); }
.badge.unsent { color: var(--red); background: var(--red-soft); }
.avatar-stack { display: flex; align-items: center; min-width: 64px; }
.avatar { display: grid; place-items: center; width: 26px; height: 26px; margin-right: -5px; color: #435e59; background: #dce9e5; border: 2px solid var(--surface); border-radius: 50%; font-size: 10px; font-weight: 750; }
.avatar:nth-child(2n) { color: #725e94; background: #ebe4f6; }
.avatar:nth-child(3n) { color: #94664f; background: #f4e6df; }

.board { display: grid; grid-template-columns: repeat(5, minmax(220px, 1fr)); gap: var(--space-4); align-items: start; overflow-x: auto; min-height: calc(100vh - 206px); padding-bottom: var(--space-4); }
.board-column { min-width: 220px; background: #ebede9; border: 1px solid #e1e3df; border-radius: var(--radius); }
.board-column.is-over { background: #dfe7e3; outline: 2px solid rgb(44 102 93 / 28%); outline-offset: -2px; }
.column-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); padding: var(--space-4); }
.column-title { display: flex; align-items: center; gap: var(--space-2); font-size: 14px; font-weight: 750; }
.column-count { display: grid; place-items: center; min-width: 24px; height: 24px; color: var(--muted); background: var(--surface); border-radius: 99px; font-size: 11px; }
.drop-zone { display: grid; gap: var(--space-3); min-height: 160px; padding: 0 var(--space-3) var(--space-3); }
.board-card { padding: var(--space-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: 0 2px 4px rgb(32 39 35 / 3%); }
.board-card[draggable="true"] { cursor: grab; }
.board-card[draggable="true"]:active { cursor: grabbing; }
.board-card.is-dragging { opacity: .4; }
.board-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-2); }
.card-title { margin: 0; color: var(--ink); font-size: 14px; font-weight: 750; line-height: 1.35; text-align: left; background: none; border: 0; padding: 0; }
.card-title:hover { text-decoration: underline; }
.card-category { margin-top: var(--space-2); color: var(--muted); font-size: 11px; }
.card-separator { height: 1px; margin: var(--space-3) 0; background: var(--line); }
.card-meta { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); color: var(--muted); font-size: 11px; }
.card-meta + .card-meta { margin-top: var(--space-2); }
.card-progress { margin-top: var(--space-3); }
.card-actions { display: flex; gap: var(--space-1); }
.icon-button { display: inline-grid; place-items: center; width: 30px; height: 30px; color: var(--muted); background: transparent; border: 0; border-radius: var(--radius-sm); }
.icon-button:hover { color: var(--ink); background: var(--surface-alt); }

.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 288px; gap: var(--space-6); align-items: start; }
.detail-main { min-width: 0; }
.detail-aside { position: sticky; top: var(--space-6); }
.detail-section { padding: var(--space-6); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.detail-section + .detail-section { margin-top: var(--space-6); }
.detail-section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-5); }
.detail-kv { display: grid; grid-template-columns: 124px 1fr; gap: var(--space-3) var(--space-4); }
.detail-kv dt { color: var(--muted); font-size: 12px; }
.detail-kv dd { margin: 0; font-weight: 600; }
.note { padding: var(--space-4); background: #fafaf8; border-radius: var(--radius-sm); color: #4e5558; white-space: pre-wrap; }
.communication { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-4); background: var(--red-soft); border-radius: var(--radius-sm); }
.communication.is-sent { background: var(--accent-soft); }
.communication input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent); }
.communication-label { display: block; font-weight: 700; }
.communication-meta { display: block; margin-top: var(--space-1); color: var(--muted); font-size: 12px; }
.mini-board { display: grid; grid-template-columns: repeat(5, minmax(180px, 1fr)); gap: var(--space-3); overflow-x: auto; }
.mini-board .board-column { min-width: 180px; }
.mini-board .drop-zone { min-height: 120px; }
.product-card .card-title { font-size: 13px; }
.product-task-count { margin-top: var(--space-2); color: var(--muted); font-size: 11px; }
.task-section { display: grid; gap: var(--space-3); }
.product-task-group { padding: var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.group-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); }

.aside-status { display: grid; gap: var(--space-2); }
.aside-status select { font-weight: 700; }
.stat-line { display: flex; justify-content: space-between; gap: var(--space-4); padding: var(--space-3) 0; border-bottom: 1px solid var(--line); color: var(--muted); }
.stat-line strong { color: var(--ink); }
.aside-status .progress-wrap { width: 100%; }

.people-list { display: grid; gap: var(--space-2); }
.person-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto auto; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.person-row .avatar { width: 32px; height: 32px; margin: 0; font-size: 11px; }
.person-name { font-weight: 700; }
.person-detail { color: var(--muted); font-size: 12px; }
.switch { position: relative; width: 42px; height: 24px; padding: 0; background: var(--line-strong); border: 0; border-radius: 99px; }
.switch span { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; background: white; border-radius: 50%; transition: transform .15s ease; }
.switch.on { background: var(--accent); }
.switch.on span { transform: translateX(18px); }
.settings-note { max-width: 620px; color: var(--muted); }
.category-list { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-5); }
.category-list .badge { min-height: 30px; padding: 0 var(--space-3); }

.modal-backdrop { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: var(--space-4); background: rgb(20 25 24 / 42%); }
.modal { width: min(680px, 100%); max-height: calc(100vh - 64px); overflow: auto; background: var(--surface); border-radius: 12px; box-shadow: 0 24px 72px rgb(0 0 0 / 24%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-5) var(--space-6); border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 20px; }
.modal-form { padding: var(--space-6); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.field { display: grid; gap: var(--space-2); }
.full { grid-column: 1 / -1; }
.field label, fieldset legend { font-size: 12px; font-weight: 700; }
.required { color: var(--red); }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.assignee-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); max-height: 176px; overflow: auto; padding: var(--space-2); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); }
.check-option { display: flex; align-items: center; gap: var(--space-2); min-height: 32px; padding: var(--space-1); border-radius: var(--radius-sm); }
.check-option:hover { background: var(--surface-alt); }
.check-option input { width: 16px; height: 16px; accent-color: var(--accent); }
.form-help { margin: 0; color: var(--muted); font-size: 11px; }
.form-error { margin: var(--space-4) 0 0; color: var(--red); font-size: 12px; font-weight: 650; }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--space-2); padding: var(--space-4) var(--space-6); border-top: 1px solid var(--line); }
.modal-actions .delete-button { margin-right: auto; }

.toast { position: fixed; right: var(--space-6); bottom: var(--space-6); z-index: 30; max-width: 340px; padding: var(--space-3) var(--space-4); color: white; background: var(--ink); border-radius: var(--radius-sm); box-shadow: var(--shadow); font-weight: 600; }

@media (max-width: 1120px) {
  .main { padding: var(--space-6); }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-layout { grid-template-columns: 1fr; }
  .detail-aside { position: static; }
  .table-head, .project-row { grid-template-columns: minmax(180px, 1.5fr) 116px 96px 96px 100px; }
  .table-head > :nth-child(4), .project-row > :nth-child(4), .table-head > :nth-child(6), .project-row > :nth-child(6) { display: none; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: static; height: auto; padding: var(--space-4); border-right: 0; border-bottom: 1px solid var(--line); }
  .logo-link { margin-bottom: var(--space-4); }
  .nav-group { display: flex; overflow-x: auto; }
  .nav-item { flex: 0 0 auto; }
  .nav-nested { display: flex; margin: 0; }
  .sidebar-footer { display: none; }
  .main { padding: var(--space-5) var(--space-4) var(--space-8); }
  .page-head, .panel-head { align-items: flex-start; flex-direction: column; }
  .head-actions { justify-content: flex-start; }
  .metric-grid, .dashboard-grid, .form-grid { grid-template-columns: 1fr; }
  .table-head { display: none; }
  .project-row { grid-template-columns: 1fr auto; gap: var(--space-2); padding: var(--space-4); }
  .project-row > :nth-child(2), .project-row > :nth-child(3), .project-row > :nth-child(5), .project-row > :nth-child(7) { display: none; }
  .assignee-options { grid-template-columns: 1fr; }
}
