*{box-sizing:border-box;margin:0;padding:0}
:root{
  --bg:#f3f5f8;--panel:#fff;--panel-soft:#f8fafc;--line:#dbe2ea;--line-strong:#c7d1dd;
  --text:#172334;--sub:#647386;--navy:#111c2e;--navy-soft:#1c2b43;
  --accent:#3157d5;--accent2:#233fa7;--accent-soft:#eef2ff;
  --ok:#138a57;--ok-soft:#e8f7ef;--warn:#b96d07;--warn-soft:#fff7df;--err:#c83c43;--err-soft:#fff0f0;
  --shadow:0 8px 24px rgba(24,38,59,.06);
}
html{scroll-behavior:smooth}
body{font-family:"Hiragino Kaku Gothic ProN","Yu Gothic UI","Meiryo",sans-serif;background:var(--bg);color:var(--text);font-size:14px;line-height:1.55}
a{color:var(--accent);text-decoration:none}
a:hover{text-decoration:underline}

.topbar{display:flex;align-items:center;gap:12px;background:var(--navy);color:#fff;padding:0 20px;height:54px;position:sticky;top:0;z-index:80;box-shadow:0 1px 0 rgba(255,255,255,.08)}
.topbar .brand{color:#fff;font-weight:700;font-size:15px;text-decoration:none;letter-spacing:.01em}
.menu-btn{display:none;background:none;border:none;color:#fff;font-size:20px;cursor:pointer}
.user-box{margin-left:auto;font-size:12px;display:flex;align-items:center;gap:5px}
.badge{background:var(--navy-soft);border-radius:999px;padding:3px 9px;font-size:10px;margin-left:2px}

.wrap{display:flex;min-height:calc(100vh - 54px)}
.sidebar{width:224px;background:#fff;border-right:1px solid var(--line);padding:14px 10px;flex-shrink:0}
.sidebar a{display:block;padding:9px 12px;color:#344256;font-size:13px;border-radius:8px;margin:1px 0;transition:background .12s,color .12s}
.sidebar a:hover{background:#f0f3f7;text-decoration:none}
.sidebar a.active{background:var(--accent-soft);color:var(--accent2);font-weight:700;box-shadow:inset 3px 0 var(--accent)}
.nav-sec{padding:16px 12px 5px;font-size:10px;font-weight:700;text-transform:uppercase;color:#8a96a5;letter-spacing:.12em}
.main{flex:1;padding:24px;min-width:0;max-width:1800px;margin:0 auto}

h1{font-size:22px;line-height:1.3;margin-bottom:14px;letter-spacing:-.02em}
h2{font-size:17px;line-height:1.35;margin:18px 0 8px;letter-spacing:-.01em}
.page-head{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin-bottom:14px}
.page-head h1{margin:0}
.spacer{flex:1}
.eyebrow{font-size:10px;line-height:1.2;font-weight:800;letter-spacing:.14em;color:var(--accent);margin-bottom:5px}
.section-head{display:flex;align-items:end;justify-content:space-between;gap:12px;margin:22px 0 10px}
.section-head h2,.section-head.compact h2{margin:0}
.section-head.compact{align-items:center;margin:0 0 10px}

.card{background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:18px;margin-bottom:18px;box-shadow:var(--shadow)}
.cards{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:10px;margin-bottom:16px}
.stat{display:block;background:var(--panel);border:1px solid var(--line);border-radius:11px;padding:13px 15px;color:var(--text);text-decoration:none;transition:transform .12s,border-color .12s,box-shadow .12s}
.stat:hover{transform:translateY(-1px);border-color:#b8c6db;box-shadow:var(--shadow);text-decoration:none}
.stat .lbl{font-size:12px;color:var(--sub)}
.stat .val{font-size:20px;font-weight:700;margin-top:2px}
.stat .val small{font-size:12px;font-weight:400;color:var(--sub)}
.status-cards{grid-template-columns:repeat(7,minmax(115px,1fr))}
.stock-stats{grid-template-columns:repeat(6,minmax(135px,1fr))}

.table-wrap{overflow-x:auto;background:var(--panel);border:1px solid var(--line);border-radius:10px;scrollbar-color:#aeb9c6 transparent;scrollbar-width:thin}
.table-wrap.list-scroll{max-height:calc(100vh - 245px);overflow:auto}
table{border-collapse:collapse;width:100%;font-size:13px}
th,td{border-bottom:1px solid #e5eaf0;padding:9px 11px;text-align:left;white-space:nowrap}
th{background:#f5f7fa;color:#59687a;font-weight:700;font-size:11px;letter-spacing:.02em;position:sticky;top:0;z-index:5}
tbody tr:last-child td{border-bottom:0}
tr:hover td{background:#f8faff}
td.num,th.num{text-align:right}
td.wrap-text{white-space:normal;min-width:180px}
.compact-table th,.compact-table td{padding:8px 9px}
th .sort-link{display:inline-block;color:inherit;text-decoration:none}
th .sort-link:hover{color:var(--accent);text-decoration:none}
th .sort-link.is-sorted{color:var(--accent)}

.btn{display:inline-flex;align-items:center;justify-content:center;gap:5px;min-height:34px;background:var(--accent);color:#fff;border:1px solid var(--accent);border-radius:8px;padding:7px 13px;font-size:12.5px;font-weight:650;line-height:1.2;cursor:pointer;text-decoration:none;white-space:nowrap}
.btn:hover{background:var(--accent2);text-decoration:none;color:#fff}
.btn.sub{background:#fff;color:#344256;border:1px solid var(--line-strong)}
.btn.sub:hover{background:#f1f5f9}
.btn.danger{background:var(--err)}
.btn.ghost{background:transparent;color:var(--sub);border-color:transparent}
.btn.sm{min-height:27px;padding:4px 9px;font-size:11.5px}
.btn:disabled{opacity:.5;cursor:not-allowed}

.flash{display:flex;align-items:flex-start;gap:10px;padding:11px 14px;border:1px solid;border-radius:9px;margin-bottom:14px;box-shadow:var(--shadow)}
.flash.ok{background:var(--ok-soft);border-color:#b9e6ce;color:#125c3d}
.flash.err{background:var(--err-soft);border-color:#f2c6c9;color:#8f252b}
.flash ul{margin-left:18px}

form.filters{display:flex;gap:8px;flex-wrap:wrap;align-items:end;margin-bottom:14px}
.field{display:flex;flex-direction:column;gap:4px}
.field label{font-size:11px;font-weight:650;color:#657487}
input,select,textarea{min-height:36px;border:1px solid var(--line-strong);border-radius:8px;padding:7px 10px;font-size:13px;font-family:inherit;background:#fff;color:var(--text);transition:border-color .12s,box-shadow .12s}
input:focus,select:focus,textarea:focus{outline:2px solid #bfdbfe;border-color:var(--accent)}
input.num{text-align:right}
.form-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:12px}
.form-actions{margin-top:16px;display:flex;gap:8px;flex-wrap:wrap}

.status{display:inline-block;border-radius:999px;padding:3px 9px;font-size:11px;font-weight:700;white-space:nowrap}
.status.s準備中{background:#fef9c3;color:#854d0e}
.status.s発注済{background:#e0e7ff;color:#3730a3}
.status.s入荷待ち{background:#fce7f3;color:#9d174d}
.status.s進行中{background:#dbeafe;color:#1e40af}
.status.s完了{background:#dcfce7;color:#14532d}
.status.s保留{background:#f3f4f6;color:#374151}
.status.s中止{background:#fee2e2;color:#7f1d1d}

.tag{display:inline-block;background:#eef2f7;border-radius:999px;padding:2px 8px;font-size:10.5px;color:var(--sub)}
.tag.warn{background:#fef3c7;color:#92400e}
.minus{color:var(--err);font-weight:600}
.plus{color:var(--ok)}
.muted{color:var(--sub);font-size:12px}

.pagination{display:flex;gap:4px;margin-top:12px;flex-wrap:wrap}
.pagination a,.pagination span{padding:5px 10px;border:1px solid var(--line);border-radius:6px;background:#fff;font-size:13px}
.pagination .active span{background:var(--accent);color:#fff;border-color:var(--accent)}
.pagination svg{width:14px;height:14px}

.item-table td{padding:4px 6px}
.item-table input,.item-table select{width:100%;min-width:60px;padding:5px 7px}
.item-table input[name$="[product_name]"]{min-width:220px}
.item-table .drag{cursor:grab;color:var(--sub)}

.autocomplete{position:relative}
.autocomplete .ac-list{position:absolute;top:100%;left:0;right:0;background:#fff;border:1px solid var(--line);border-radius:0 0 8px 8px;max-height:240px;overflow-y:auto;z-index:40;box-shadow:0 6px 16px rgba(0,0,0,.12)}
.ac-list div{padding:7px 10px;cursor:pointer;font-size:13px}
.ac-list div:hover,.ac-list div.sel{background:#e5edff}
.ac-list .meta{color:var(--sub);font-size:11px;margin-left:6px}

dialog{border:none;border-radius:12px;padding:0;max-width:640px;width:92vw;box-shadow:0 20px 50px rgba(0,0,0,.25)}
dialog::backdrop{background:rgba(0,0,0,.4)}
dialog .dlg-head{padding:14px 18px;border-bottom:1px solid var(--line);font-weight:700}
dialog .dlg-body{padding:18px}
dialog .dlg-foot{padding:12px 18px;border-top:1px solid var(--line);display:flex;justify-content:flex-end;gap:8px}

.check-cell{width:34px;text-align:center}
.summary-bar{display:grid;grid-template-columns:repeat(7,minmax(112px,1fr));gap:1px;overflow:auto;background:var(--line);border:1px solid var(--line);border-radius:10px;margin-bottom:10px}
.summary-bar>span{display:flex;flex-direction:column;gap:1px;min-width:110px;padding:8px 11px;background:#fff}
.summary-bar small{font-size:10px;color:var(--sub)}
.summary-bar b{font-size:15px}
.summary-bar em{font-style:normal;margin-left:4px}
.summary-bar .needs-action{background:var(--warn-soft)}
.summary-note{display:flex;gap:10px;flex-wrap:wrap;margin:-3px 3px 7px;color:var(--sub);font-size:10px}

/* 不足と多い分が同時に出る理由の説明 */
.why-box{padding:11px 14px;margin:0 0 12px;background:var(--warn-soft,#fef3c7);border:1px solid #f0d9a0;border-radius:10px;font-size:11.5px;line-height:1.7}
.why-box>b{display:block;margin-bottom:4px;font-size:12.5px}
.why-box ul{margin:0 0 4px 18px}
.why-note{margin:6px 0 2px;font-weight:700}
.why-cols{display:grid;grid-template-columns:1fr 1fr;gap:4px 18px}
@media (max-width:720px){.why-cols{grid-template-columns:1fr}}

.attention-grid{display:grid;grid-template-columns:repeat(3,minmax(210px,1fr));gap:10px}
.attention-card{display:grid;grid-template-columns:36px 1fr auto;align-items:center;gap:11px;min-height:72px;padding:12px 14px;background:#fff;border:1px solid var(--line);border-radius:11px;color:var(--text);text-decoration:none;box-shadow:var(--shadow)}
.attention-card:hover{text-decoration:none;border-color:#aebbd0}
.attention-icon{display:grid;place-items:center;width:34px;height:34px;border-radius:9px;background:#edf1f6;color:#556476;font-size:12px;font-weight:800}
.attention-card small,.activity-row small{display:block;color:var(--sub);font-size:11px}
.attention-card strong{display:block;font-size:18px;line-height:1.35}
.attention-arrow{color:#8a96a5}
.attention-card.is-danger .attention-icon{background:var(--err-soft);color:var(--err)}
.attention-card.is-warning .attention-icon{background:var(--warn-soft);color:var(--warn)}
.attention-card.is-info .attention-icon{background:var(--accent-soft);color:var(--accent)}
.dashboard-grid{display:grid;grid-template-columns:1.35fr 1fr;gap:14px}
.dashboard-grid.three{grid-template-columns:1.2fr 1fr 1fr}
.activity-list{display:flex;flex-direction:column}
.activity-row{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:9px 2px;border-bottom:1px solid #e8edf2;color:var(--text)}
.activity-row:last-child{border-bottom:0}
.activity-row:hover{text-decoration:none}
.activity-main{min-width:0}
.activity-main b{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12.5px}
.empty-state{padding:18px;text-align:center;color:var(--sub);font-size:12px}

.filter-panel{background:#fff;border:1px solid var(--line);border-radius:11px;margin-bottom:12px;box-shadow:var(--shadow)}
.filter-panel>summary{display:flex;align-items:center;gap:8px;padding:11px 14px;font-weight:700;cursor:pointer;list-style:none}
.filter-panel>summary::-webkit-details-marker{display:none}
.filter-panel>summary::after{content:"⌄";margin-left:auto;color:var(--sub)}
.filter-panel[open]>summary{border-bottom:1px solid var(--line)}
.filter-panel[open]>summary::after{transform:rotate(180deg)}
.filter-count{padding:2px 8px;border-radius:999px;background:var(--accent-soft);color:var(--accent);font-size:10px}
.filter-grid{display:grid!important;grid-template-columns:2fr repeat(4,minmax(145px,1fr));padding:14px;margin:0!important}
.filter-keyword{grid-column:span 2}
.filter-actions{grid-column:1/-1;display:flex;justify-content:flex-end;gap:8px;margin-top:2px}
.list-meta{display:flex;align-items:center;gap:9px;margin:9px 2px}
.project-name-cell{min-width:250px}
.project-name-cell small{display:block;color:var(--sub);font-size:10px;margin-top:2px}
.money-primary{font-weight:700;color:#203e8e}
.is-overdue{color:var(--err);font-weight:700}

.sticky-key-cols th:first-child,.sticky-key-cols td:first-child{position:sticky;left:0;z-index:4;background:#fff}
.sticky-key-cols th:first-child{z-index:8;background:#f5f7fa}
.sticky-key-cols th:nth-child(2),.sticky-key-cols td:nth-child(2){position:sticky;left:54px;z-index:4;background:#fff;box-shadow:5px 0 8px -8px rgba(20,35,55,.55)}
.sticky-key-cols th:nth-child(2){z-index:8;background:#f5f7fa}
.project-table th:first-child,.project-table td:first-child{width:54px;min-width:54px}
.stock-table th:first-child,.stock-table td:first-child{width:44px;min-width:44px}
.stock-table th:nth-child(2),.stock-table td:nth-child(2){left:44px;min-width:240px}
.stock-move-table th:first-child,.stock-move-table td:first-child{position:sticky;left:0;z-index:4;min-width:240px;background:#fff;box-shadow:5px 0 8px -8px rgba(20,35,55,.55)}
.stock-move-table th:first-child{z-index:8;background:#f5f7fa}

.action-menu{position:relative}
.action-menu>summary{list-style:none}
.action-menu>summary::-webkit-details-marker{display:none}
.action-popover{width:220px;margin-top:5px;padding:6px;background:#fff;border:1px solid var(--line);border-radius:9px}
.action-popover>a,.action-popover form>button{display:block;width:100%;padding:8px 9px;border:0;background:transparent;border-radius:6px;text-align:left;color:var(--text);font:inherit;font-size:12px;cursor:pointer}
.action-popover>a:hover,.action-popover form>button:hover{background:#f2f5f9;text-decoration:none}
.action-popover .danger-text{color:var(--err)}
.danger-text{color:var(--err)}
button.btn.sub.danger-text{color:var(--err);border-color:color-mix(in srgb, var(--err) 40%, transparent)}
.list-meta form[data-bulk-form]{margin-left:auto}
.inline-status{display:grid;grid-template-columns:1fr auto;gap:5px;padding:5px}
.inline-status select{min-height:30px;padding:4px 6px;font-size:11px}
.inline-status button{width:auto!important;background:var(--accent-soft)!important;color:var(--accent)!important}

.project-command{margin:-8px -8px 14px;padding:8px;background:rgba(243,245,248,.96)}
.project-title-row{margin-bottom:9px}
.project-meta{display:flex;gap:8px;flex-wrap:wrap;margin-top:5px;color:var(--sub);font-size:11px}
.project-meta span+span::before{content:"•";margin-right:8px;color:#a4afbc}
.project-tabs{display:flex;gap:4px;overflow-x:auto;background:#fff;border:1px solid var(--line);border-radius:9px;padding:4px}
.project-tabs a{flex:0 0 auto;padding:6px 11px;border-radius:6px;color:#46566a;font-size:11.5px;font-weight:650}
.project-tabs a:hover{background:var(--accent-soft);color:var(--accent);text-decoration:none}
#items,#purchases,#pdf-history,#project-history{scroll-margin-top:205px}
.section-title-row{align-items:flex-end;margin-bottom:12px}
.section-title-row h2{margin:0}
.recent-products{display:flex;align-items:center;gap:6px;overflow-x:auto;padding:9px 10px;margin-bottom:10px;background:var(--panel-soft);border:1px solid var(--line);border-radius:9px}
.recent-products>span{flex:0 0 auto;font-size:10px;font-weight:700;color:var(--sub)}
.recent-product{flex:0 0 auto;border:1px solid var(--line);border-radius:999px;background:#fff;padding:5px 9px;color:var(--text);font:inherit;font-size:11px;cursor:pointer}
.recent-product:hover{border-color:var(--accent);color:var(--accent)}
.recent-product small{color:var(--sub)}
.live-total{align-self:center;padding:7px 10px;border-radius:8px;background:var(--accent-soft);color:#30405a;font-size:12px}
.sticky-item-table th{top:0}

.bulk-bar{display:flex;align-items:end;gap:8px;flex-wrap:wrap;padding:10px;margin-bottom:9px;background:var(--panel-soft);border:1px solid var(--line);border-radius:9px}
.bulk-bar .selection-count{align-self:center;min-width:68px;font-weight:700;color:var(--accent)}
.bulk-bar .field{min-width:135px}
.purchase-type,.order-status,.document-state{display:inline-block;padding:3px 8px;border-radius:999px;font-size:10.5px;font-weight:700}
.purchase-type{background:#eef2f7;color:#586779}
.type-lump{background:#fff2dc;color:#8d560a}
.type-set{background:#f0eefe;color:#5c45a6}
.order-status{background:#f1f3f6;color:#526175}
.os-未発注{background:var(--warn-soft);color:var(--warn)}
.os-発注済,.os-入荷待ち{background:var(--accent-soft);color:var(--accent)}
.os-入荷済{background:var(--ok-soft);color:var(--ok)}
.document-state{background:var(--ok-soft);color:var(--ok)}
.copy-value{word-break:break-all}
.copy-button{margin-left:4px;padding:2px 6px;border:1px solid var(--line);border-radius:5px;background:#fff;color:var(--accent);font-size:10px;cursor:pointer}
.copy-button.is-copied{background:var(--ok-soft);color:var(--ok)}
.copy-link{font-size:11px}
.timeline{display:flex;flex-direction:column}
.timeline-row{display:grid;grid-template-columns:12px 1fr auto;align-items:center;gap:10px;padding:9px 2px;border-bottom:1px solid #e8edf2}
.timeline-row:last-child{border-bottom:0}
.timeline-dot{width:8px;height:8px;border-radius:50%;background:var(--accent)}
.timeline-body b{display:block;font-size:12.5px}
.timeline-body small{display:block;color:var(--sub);font-size:11px}

.context-banner{display:flex;align-items:center;gap:14px;flex-wrap:wrap;padding:11px 14px;margin-bottom:12px;background:var(--accent-soft);border:1px solid #cbd5ff;border-radius:10px}
.context-banner span:first-child{display:flex;flex-direction:column}
.context-banner small{font-size:10px;color:var(--sub)}
.context-banner a{margin-left:auto}
.sticky-form-actions{position:sticky;bottom:10px;z-index:10;padding:10px;background:rgba(255,255,255,.95);border:1px solid var(--line);border-radius:10px;box-shadow:var(--shadow)}

@media (max-width:820px){
  .menu-btn{display:block}
  .sidebar{position:fixed;left:-244px;top:54px;bottom:0;z-index:70;transition:left .16s;overflow-y:auto;box-shadow:8px 0 24px rgba(0,0,0,.12)}
  .sidebar.open{left:0}
  .main{padding:12px}
  .form-grid{grid-template-columns:1fr 1fr}
  table{font-size:12.5px}
  th,td{padding:6px 7px}
  .status-cards{grid-template-columns:repeat(4,1fr)}
  .stock-stats{grid-template-columns:repeat(3,1fr)}
  .attention-grid{grid-template-columns:repeat(2,1fr)}
  .dashboard-grid,.dashboard-grid.three{grid-template-columns:1fr}
  .filter-grid{grid-template-columns:repeat(2,1fr)}
  .filter-keyword{grid-column:1/-1}
  .project-command{top:54px}
  .project-title-row .project-meta{display:none}
  .project-title-row h1{font-size:18px}
  .summary-bar{grid-template-columns:repeat(7,112px)}
  .bulk-bar{align-items:end}
}
@media (max-width:520px){
  .topbar{padding:0 12px}
  .topbar .brand{max-width:190px;font-size:13px}
  .user-box{gap:2px}
  .user-box>span.badge{display:none}
  .form-grid{grid-template-columns:1fr}
  .cards{grid-template-columns:1fr 1fr}
  .status-cards,.stock-stats{grid-template-columns:1fr 1fr}
  .attention-grid{grid-template-columns:1fr}
  .filter-grid{grid-template-columns:1fr}
  .filter-keyword{grid-column:auto}
  .page-head{align-items:flex-start}
  .page-head>.spacer{display:none}
  .project-command{margin:-4px -4px 12px;padding:4px}
  .project-title-row form:first-of-type{display:none}
  .project-title-row .btn{padding:6px 9px}
  .project-command .summary-bar>span{min-width:102px}
  #items,#purchases,#pdf-history,#project-history{scroll-margin-top:190px}

  .responsive-cards{display:block}
  .responsive-cards thead{display:none}
  .responsive-cards tbody{display:grid;gap:10px;padding:8px;background:var(--bg)}
  .responsive-cards tr{display:grid;grid-template-columns:1fr 1fr;background:#fff;border:1px solid var(--line);border-radius:10px;padding:10px;box-shadow:var(--shadow)}
  .responsive-cards td{display:flex;flex-direction:column;align-items:flex-start;gap:1px;min-width:0!important;padding:6px!important;border:0;white-space:normal;background:#fff!important;position:static!important;box-shadow:none!important;text-align:left!important}
  .responsive-cards td::before{content:attr(data-label);font-size:9px;font-weight:700;color:#8793a2;text-transform:uppercase}
  .responsive-cards .project-name-cell{grid-column:1/-1;order:-3;font-size:14px}
  .responsive-cards td[data-label="No."]{display:none}
  .responsive-cards td[data-label="ステータス"]{grid-column:2;grid-row:1;align-items:flex-end;order:-2}
  .responsive-cards td[data-label="卸金額"],.responsive-cards td[data-label="仕入金額"],
  .responsive-cards td[data-label="粗利"],.responsive-cards td[data-label="粗利率"]{background:#f8fafc!important;border-radius:6px}
  .responsive-cards .row-actions{grid-column:1/-1}
  .responsive-cards .action-menu{width:100%}
  .responsive-cards .action-menu>summary{width:100%}
  .responsive-cards .action-popover{position:static;width:100%;margin-top:5px;box-shadow:none}
  .responsive-cards .empty-row{display:block}
  .responsive-cards .empty-row td{display:block;text-align:center!important}
  .table-wrap.list-scroll{max-height:none;overflow:visible;border:0;background:transparent}
  .bulk-bar .field{min-width:calc(50% - 4px);flex:1}
  .bulk-bar .btn{width:100%}
  .recent-products{margin-left:-4px;margin-right:-4px}
}
@media print{
  .topbar,.sidebar,.btn,form.filters{display:none!important}
  .main{padding:0}
}

/* =========================================================
   YORO Operations UI v3 — app-like shared design system
   ========================================================= */
:root{
  --bg:#f3f6fb;--panel:#fff;--panel-soft:#f7f9fd;--line:#e2e8f2;--line-strong:#ccd5e3;
  --text:#182238;--sub:#68758a;--navy:#121c38;--navy-soft:#253255;
  --accent:#5368e8;--accent2:#3e50c6;--accent-soft:#eef0ff;
  --ok:#119b68;--ok-soft:#e9f9f2;--warn:#d68018;--warn-soft:#fff7e7;--err:#db4b5d;--err-soft:#fff0f2;
  --shadow:0 12px 34px rgba(29,43,76,.08);--shadow-strong:0 24px 70px rgba(20,31,62,.2);
  --radius:20px;--radius-sm:13px;--topbar:68px;
}
html{background:var(--bg);scroll-padding-top:calc(var(--topbar) + 14px)}
body{
  min-width:320px;background:
    radial-gradient(circle at 90% -20%,rgba(106,126,244,.14),transparent 38%),
    linear-gradient(180deg,#f8faff 0,#f3f6fb 260px);
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Hiragino Sans","Hiragino Kaku Gothic ProN","Yu Gothic UI","Meiryo",sans-serif;
  color:var(--text);font-size:14px;letter-spacing:.005em;
}
button,input,select,textarea{font:inherit}
button{-webkit-tap-highlight-color:transparent}

.topbar{
  height:var(--topbar);padding:0 24px;gap:16px;background:linear-gradient(110deg,#111a35,#1d2b54);
  border-bottom:1px solid rgba(255,255,255,.08);box-shadow:0 8px 30px rgba(17,26,53,.18);
}
.brand{display:flex;align-items:center;gap:11px!important;min-width:0}
.brand-mark{
  display:grid;place-items:center;width:38px;height:38px;border-radius:13px;
  background:linear-gradient(145deg,#7d8cff,#5368e8);box-shadow:0 7px 18px rgba(83,104,232,.42);
  color:#fff;font-size:18px;font-weight:900;
}
.brand>span:last-child{display:flex;flex-direction:column;line-height:1.05}
.brand strong{font-size:14px;letter-spacing:.1em}
.brand small{margin-top:4px;color:#aeb9d7;font-size:10px;font-weight:600;letter-spacing:.08em}
.menu-btn{
  width:44px;height:44px;padding:11px;border-radius:14px;background:rgba(255,255,255,.08);
  flex-direction:column;align-items:center;justify-content:center;gap:5px;
}
.menu-btn span{display:block;width:20px;height:2px;border-radius:2px;background:#fff}
.user-box{gap:8px;font-size:12px}
.user-avatar{
  display:grid;place-items:center;width:34px;height:34px;border:1px solid rgba(255,255,255,.2);
  border-radius:50%;background:rgba(255,255,255,.1);font-weight:800;
}
.user-name{max-width:130px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.badge{margin:0;padding:5px 10px;background:rgba(255,255,255,.1);color:#dbe3ff;font-size:10px;font-weight:700}
.logout-btn{min-height:34px;padding:6px 10px;border:1px solid rgba(255,255,255,.16);border-radius:10px;background:transparent;color:#eef2ff;font-size:11px;cursor:pointer}
.logout-btn:hover{background:rgba(255,255,255,.1)}

.wrap{min-height:calc(100dvh - var(--topbar))}
.sidebar{
  width:252px;padding:20px 14px 30px;background:rgba(255,255,255,.92);border-right:1px solid rgba(221,228,240,.9);
  box-shadow:8px 0 30px rgba(29,43,76,.035);
}
.sidebar-caption{padding:0 13px 10px;color:#9aa5b8;font-size:10px;font-weight:800;letter-spacing:.16em}
.sidebar a{display:flex;align-items:center;min-height:44px;margin:3px 0;padding:10px 13px;border-radius:13px;color:#536075;font-size:13px;font-weight:600}
.sidebar a:hover{background:#f3f5fb;color:var(--text);text-decoration:none}
.sidebar a.active{background:linear-gradient(120deg,#edf0ff,#f4f5ff);color:#3e50c6;box-shadow:none}
.sidebar a.active::after{content:"";width:7px;height:7px;margin-left:auto;border-radius:50%;background:var(--accent)}
.nav-sec{padding:23px 13px 7px;color:#9aa5b8;font-size:9px;letter-spacing:.16em}
.main{width:100%;max-width:1680px;padding:28px 30px 50px}
.nav-backdrop,.mobile-tabs{display:none}

h1{font-size:26px;font-weight:800;letter-spacing:-.035em}
h2{font-size:18px;font-weight:780;letter-spacing:-.02em}
.page-head{margin-bottom:18px}
.eyebrow{margin-bottom:7px;color:#6274e7;font-size:10px;letter-spacing:.18em}
.section-head{margin:28px 0 12px}
.card{
  margin-bottom:22px;padding:22px;border:1px solid rgba(226,232,242,.9);border-radius:var(--radius);
  box-shadow:var(--shadow);
}
.filter-panel{border:1px solid rgba(226,232,242,.9);border-radius:17px;box-shadow:var(--shadow)}
.filter-panel>summary{min-height:52px;padding:13px 17px}

.btn{
  min-height:44px;padding:10px 16px;border:0;border-radius:13px;
  background:linear-gradient(135deg,#6073ed,#4d61dd);box-shadow:0 7px 16px rgba(83,104,232,.18);
  font-size:13px;font-weight:750;transition:transform .12s,box-shadow .12s,background .12s;
}
.btn:hover{background:linear-gradient(135deg,#5266e3,#4053cb);box-shadow:0 9px 20px rgba(83,104,232,.24);transform:translateY(-1px)}
.btn:active{transform:translateY(0)}
.btn.sub{border:1px solid var(--line-strong);background:#fff;color:#46536a;box-shadow:none}
.btn.sub:hover{background:#f5f7fb;color:#26334b}
.btn.ghost{background:transparent;color:#5d6a80;box-shadow:none}
.btn.danger{background:linear-gradient(135deg,#e95b6b,#d94659);box-shadow:0 7px 16px rgba(217,70,89,.17)}
.btn.sm{min-height:36px;padding:7px 11px;border-radius:10px;font-size:12px}

input,select,textarea{
  min-height:46px;border:1px solid var(--line-strong);border-radius:13px;padding:10px 12px;background:#fff;
  color:var(--text);font-size:14px;box-shadow:inset 0 1px 2px rgba(24,34,56,.025);
}
input:hover,select:hover,textarea:hover{border-color:#b9c4d5}
input:focus,select:focus,textarea:focus{outline:3px solid rgba(83,104,232,.14);border-color:#7080e8;box-shadow:0 0 0 1px #7080e8}
input[readonly]{background:#f8f9fc;color:#303b50;cursor:pointer}
textarea{resize:vertical}
.field{gap:6px}
.field label,.picker-filters label>span{color:#69768a;font-size:11px;font-weight:750}
.form-grid{gap:16px}
.form-actions{align-items:center;margin-top:20px;gap:10px}

.table-wrap{border:1px solid var(--line)!important;border-radius:17px;background:#fff;box-shadow:0 8px 24px rgba(29,43,76,.035)}
table{font-size:13px}
th,td{padding:11px 13px;border-bottom-color:#e9edf4}
th{height:42px;background:#f7f9fc;color:#67758b;font-size:10.5px;letter-spacing:.045em}
tbody tr:hover td{background:#fafbfe}
.sticky-key-cols th:first-child,.sticky-key-cols th:nth-child(2),.stock-move-table th:first-child{background:#f7f9fc}
.summary-bar{gap:2px;border:0;border-radius:17px;background:#e7ebf3;box-shadow:var(--shadow)}
.summary-bar>span{padding:11px 13px}
.summary-bar small{font-size:10px}
.summary-bar b{font-size:17px;letter-spacing:-.02em}
.cards{gap:13px}
.stat,.attention-card{border:1px solid rgba(226,232,242,.9);border-radius:17px;box-shadow:var(--shadow)}
.stat{padding:16px 17px}
.stat .val{font-size:23px;letter-spacing:-.03em}
.attention-card{min-height:82px;padding:15px 16px}
.attention-icon{width:40px;height:40px;border-radius:13px}
.activity-row,.timeline-row{padding:12px 3px}
.dashboard-grid{grid-template-columns:minmax(0,1.35fr) minmax(0,1fr)}
.dashboard-grid.three{grid-template-columns:minmax(0,1.2fr) minmax(0,1fr) minmax(0,1fr)}
.dashboard-grid>*{min-width:0}

.status,.purchase-type,.order-status,.document-state,.tag{border-radius:999px;font-weight:750}
.status{padding:5px 10px;font-size:10.5px}
.status.s準備中{background:#fff3d7;color:#a05f06}
.status.s進行中,.status.s発注済{background:#e9edff;color:#4458cf}
.status.s入荷待ち{background:#fff0f5;color:#bd416c}
.status.s完了{background:#e7f8f0;color:#087c51}
.status.s保留{background:#eef1f5;color:#586579}
.status.s中止{background:#ffedef;color:#bd3447}

.flash{
  position:sticky;top:calc(var(--topbar) + 10px);z-index:55;min-height:58px;margin:0 0 18px;padding:12px 14px;
  border:0;border-radius:16px;box-shadow:0 15px 35px rgba(29,43,76,.14);
}
.flash>div{display:flex;flex:1;flex-direction:column}
.flash-icon{display:grid;place-items:center;flex:0 0 30px;width:30px;height:30px;border-radius:10px;background:rgba(255,255,255,.75);font-weight:900}
.flash-close{align-self:center;width:34px;height:34px;border:0;border-radius:10px;background:transparent;color:inherit;font-size:20px;cursor:pointer}
.flash.ok{background:#e7f8f0;color:#08754d}
.flash.err{background:#ffedf0;color:#a82d40}

.project-command{margin:-10px -10px 18px;padding:10px;border-radius:0 0 18px 18px;background:rgba(243,246,251,.9)}
.project-tabs{gap:6px;padding:6px;border:0;border-radius:14px;box-shadow:0 6px 20px rgba(29,43,76,.06)}
.project-tabs a{min-height:36px;padding:8px 13px;border-radius:10px}
.recent-products{min-height:56px;padding:10px 12px;border:0;border-radius:15px;background:#f6f7fc}
.recent-product{min-height:36px;padding:7px 11px;border-radius:12px}
.bulk-bar{padding:13px;border:0;border-radius:15px;background:#f6f7fb}
.context-banner{padding:14px 16px;border:0;border-radius:16px}

dialog{border-radius:22px;box-shadow:var(--shadow-strong)}
dialog::backdrop{background:rgba(15,23,45,.58);backdrop-filter:blur(4px)}
dialog .dlg-head{min-height:64px;padding:15px 20px;border-bottom:1px solid var(--line)}
dialog .dlg-body{padding:20px}
dialog .dlg-foot{min-height:68px;padding:12px 20px;border-top:1px solid var(--line)}
.icon-btn{display:grid;place-items:center;width:40px;height:40px;border:0;border-radius:12px;background:#f0f2f7;color:#526076;font-size:21px;cursor:pointer}
.product-picker{width:min(760px,94vw);max-width:760px;max-height:min(780px,90dvh);overflow:hidden}
.product-picker .dlg-head{display:flex;align-items:center;justify-content:space-between}
.product-picker .dlg-head>div{display:flex;flex-direction:column}
.product-picker .dlg-head small{color:#7181df;font-size:9px;font-weight:850;letter-spacing:.16em}
.product-picker .dlg-head strong{font-size:19px}
.product-picker .dlg-body{max-height:calc(90dvh - 132px);overflow-y:auto}
.picker-lead{margin-bottom:15px;color:var(--sub);font-size:12px}
.picker-filters{display:grid;grid-template-columns:2fr 1fr 130px;gap:10px}
.picker-filters label{display:flex;flex-direction:column;gap:5px}
.picker-state{min-height:40px;padding:15px 2px 8px;color:var(--sub);font-size:12px}
.picker-state.is-error{color:var(--err)}
.product-results{display:grid;gap:8px}
.product-result{
  display:flex;align-items:center;justify-content:space-between;gap:15px;width:100%;min-height:70px;
  padding:12px 14px;border:1px solid var(--line);border-radius:15px;background:#fff;color:var(--text);
  text-align:left;cursor:pointer;transition:border-color .12s,background .12s,transform .12s;
}
.product-result:hover{border-color:#aeb9f0;background:#f8f9ff;transform:translateY(-1px)}
.product-result-main{display:flex;min-width:0;flex-direction:column;gap:6px}
.product-result-main strong{overflow:hidden;text-overflow:ellipsis;font-size:14px;white-space:nowrap}
.product-result-meta{display:flex;flex-wrap:wrap;gap:5px}
.product-result-meta span,.product-result-meta em{padding:2px 7px;border-radius:999px;background:#f0f2f7;color:#647188;font-size:9.5px;font-style:normal}
.product-result-meta em{background:#e9f8f1;color:#0b8658}
.product-result-note{
  display:-webkit-box;overflow:hidden;color:#657386;font-size:11px;line-height:1.45;
  -webkit-line-clamp:2;-webkit-box-orient:vertical;
}
.product-result-price{display:flex;flex:0 0 auto;flex-direction:column;align-items:flex-end}
.product-result-price small{color:var(--sub);font-size:9px}
.product-result-price b{color:#3044be;font-size:17px}
.picker-foot{justify-content:space-between!important}

.product-selection-control{display:grid;grid-template-columns:minmax(170px,1fr) auto;align-items:center;gap:7px;min-width:310px}
.product-selection-control>input{grid-column:1;width:100%!important;min-width:0!important}
.product-select-btn{grid-column:2;grid-row:1;min-height:40px;padding:8px 11px}
.product-link-state{grid-column:1/-1;justify-self:start;padding:2px 8px;border-radius:999px;font-size:9.5px;font-weight:750}
.product-link-state.is-linked{background:var(--ok-soft);color:var(--ok)}
.product-link-state.is-legacy{background:var(--warn-soft);color:#a45f08}
.product-link-state.is-empty{background:#eef1f5;color:#788497}
.product-select-help{margin:-3px 0 10px}

.row-move-actions{display:inline-flex;align-items:center;gap:4px;margin-right:6px;vertical-align:middle}
.row-move{
  width:30px;height:30px;min-height:30px;border-radius:9px;background:#f4f6fb;color:#556276;
  font-size:15px;box-shadow:none;
}
.row-move:hover{background:var(--accent-soft);color:var(--accent)}
.row-move:disabled{opacity:.35;cursor:not-allowed}
.row-moved td{background:#f3f6ff!important;transition:background .6s}

.confirm-dialog{width:min(430px,92vw);padding:25px;text-align:center}
.confirm-dialog form{display:flex;flex-direction:column;align-items:center}
.confirm-dialog .confirm-symbol{display:grid;place-items:center;width:52px;height:52px;margin-bottom:13px;border-radius:17px;background:var(--warn-soft);color:var(--warn);font-size:24px;font-weight:900}
.confirm-dialog h2{margin:0 0 8px}
.confirm-dialog p{max-width:340px;color:var(--sub);white-space:pre-line}
.confirm-dialog .dlg-foot{width:100%;margin-top:20px;padding:0;border:0;justify-content:center}

.mobile-tabs{position:fixed;z-index:75}

.login-page{min-height:100dvh;display:grid;place-items:center;padding:24px;background:linear-gradient(145deg,#111a35,#273665)}
.login-shell{width:min(430px,100%)}
.login-brand{display:flex;align-items:center;justify-content:center;gap:12px;margin-bottom:20px;color:#fff}
.login-brand .brand-mark{width:48px;height:48px;border-radius:16px;font-size:22px}
.login-brand>span:last-child{display:flex;flex-direction:column}
.login-brand strong{font-size:17px;letter-spacing:.09em}
.login-brand small{color:#b8c2e2;font-size:11px}
.login-card{padding:28px!important;border:1px solid rgba(255,255,255,.25)!important;box-shadow:0 30px 80px rgba(4,10,30,.3)!important}
.login-card h1{margin-bottom:7px;text-align:center;font-size:23px}
.login-card>.muted{margin-bottom:22px;text-align:center}
.login-card .btn{width:100%;margin-top:3px}
.error-card{text-align:center}

@media (max-width:820px){
  :root{--topbar:60px}
  body{padding-bottom:78px}
  .topbar{height:var(--topbar);padding:0 14px}
  .menu-btn{display:flex}
  .brand-mark{width:34px;height:34px;border-radius:11px;font-size:16px}
  .brand strong{font-size:12px}.brand small{font-size:9px}
  .sidebar{
    top:var(--topbar);bottom:0;left:0;width:min(320px,86vw);padding:20px 14px 100px;
    transform:translateX(-105%);transition:transform .2s ease;box-shadow:20px 0 55px rgba(15,23,45,.2);
  }
  .sidebar.open{left:0;transform:translateX(0)}
  .nav-backdrop{position:fixed;inset:var(--topbar) 0 0;z-index:68;background:rgba(14,22,43,.45);backdrop-filter:blur(2px)}
  .menu-open .nav-backdrop{display:block}
  .menu-open{overflow:hidden}
  .main{padding:20px 18px 100px}
  .mobile-tabs{
    display:grid;grid-template-columns:repeat(5,1fr);left:10px;right:10px;bottom:max(8px,env(safe-area-inset-bottom));
    height:66px;padding:7px 7px 5px;border:1px solid rgba(224,229,240,.9);border-radius:20px;
    background:rgba(255,255,255,.94);box-shadow:0 16px 45px rgba(22,33,62,.2);backdrop-filter:blur(16px);
  }
  .mobile-tabs a,.mobile-tabs button{
    display:flex;min-width:0;flex-direction:column;align-items:center;justify-content:center;gap:2px;
    border:0;border-radius:14px;background:transparent;color:#7b879a;font-size:9.5px;font-weight:750;text-decoration:none;
  }
  .mobile-tabs span{font-size:18px;line-height:1}
  .mobile-tabs a.active{background:var(--accent-soft);color:var(--accent)}
  .project-command{top:var(--topbar)}
  .flash{top:calc(var(--topbar) + 8px)}
}

@media (max-width:520px){
  body{font-size:13.5px}
  .topbar{padding:0 10px;gap:9px}
  .brand{gap:8px!important}.brand small{display:none}
  .user-name,.user-box>.badge,.logout-btn{display:none}
  .user-avatar{width:34px;height:34px}
  .main{padding:14px 12px 96px}
  h1{font-size:22px}
  .card{margin-bottom:15px;padding:16px;border-radius:18px}
  .page-head{gap:8px;margin-bottom:14px}
  .page-head .btn{min-height:40px;padding:8px 11px}
  .btn{min-height:44px}
  input,select,textarea{min-height:48px;font-size:16px}
  .filter-panel{border-radius:16px}
  .filter-grid{padding:13px}
  .filter-actions{flex-direction:column}
  .filter-actions .btn{width:100%}
  .summary-bar{grid-template-columns:repeat(7,104px);border-radius:15px}
  .summary-bar>span{min-width:104px;padding:10px}
  .summary-bar b{font-size:16px}
  .summary-bar,.project-tabs,.recent-products{
    -ms-overflow-style:none;
    scrollbar-width:none;
  }
  .summary-bar::-webkit-scrollbar,
  .project-tabs::-webkit-scrollbar,
  .recent-products::-webkit-scrollbar{display:none}
  .stat{padding:14px;border-radius:16px}
  .stat .val{font-size:20px}
  .attention-card{border-radius:16px}
  .project-command{margin:-6px -4px 14px;padding:5px 4px 8px}
  .project-tabs{border-radius:13px}
  .project-tabs a{min-height:40px}
  .form-actions{display:grid;grid-template-columns:1fr 1fr}
  .form-actions>.spacer{display:none}
  .form-actions .btn{width:100%}
  .form-actions .live-total{grid-column:1/-1;order:-1}
  .bulk-bar{align-items:stretch}
  .bulk-bar .field{min-width:100%;width:100%}

  .responsive-cards tbody{gap:12px;padding:0;background:transparent}
  .responsive-cards tr{border:1px solid rgba(226,232,242,.9);border-radius:18px;padding:11px;box-shadow:var(--shadow)}
  .responsive-cards td{padding:7px!important}
  .responsive-cards td::before{margin-bottom:2px;color:#8b96a8;font-size:9px;letter-spacing:.05em}
  .responsive-cards td[data-label="商品名"],
  .responsive-cards td[data-label="商品マスタから選択"],
  .responsive-cards td[data-label*="商品名"],
  .responsive-cards td.wrap-text,
  .responsive-cards td:last-child{grid-column:1/-1}
  .responsive-cards td:last-child{flex-direction:row;flex-wrap:wrap}
  .responsive-cards input,.responsive-cards select,.responsive-cards textarea{width:100%;min-width:0!important}
  .item-table.responsive-cards .product-selection-control{width:100%;min-width:0;grid-template-columns:minmax(0,1fr) auto}
  .item-table.responsive-cards td[data-label="商品マスタから選択"],
  .item-table.responsive-cards td[data-label="商品名"]{order:-2}
  .item-table.responsive-cards td[data-label="賞"],
  .item-table.responsive-cards td[data-label="賞ランク"]{order:-1}
  .table-wrap{overflow:visible;border:0!important;background:transparent;box-shadow:none}
  .table-wrap:not(.list-scroll) table:not(.responsive-cards){display:block;overflow-x:auto;border:1px solid var(--line);border-radius:16px}

  .product-picker{
    width:100vw;max-width:none;height:100dvh;max-height:none;margin:0;border-radius:0;
  }
  .product-picker .dlg-head{height:68px;padding:13px 16px}
  .product-picker .dlg-body{height:calc(100dvh - 142px);max-height:none;padding:15px 14px}
  .picker-filters{grid-template-columns:1fr 1fr}
  .picker-search{grid-column:1/-1}
  .product-result{min-height:76px;padding:12px}
  .picker-foot{height:74px;padding:10px 14px!important}
  .picker-foot .muted{max-width:65%}
  .confirm-dialog{padding:22px 18px;border-radius:22px}
  .confirm-dialog .dlg-foot{display:grid;grid-template-columns:1fr 1fr}
}

@media (max-width:390px){
  .brand strong{font-size:11px;letter-spacing:.065em}
  .brand-mark{width:32px;height:32px}
  .menu-btn{width:40px;height:40px}
  .cards,.status-cards,.stock-stats{gap:8px}
  .card{padding:14px}
  .product-selection-control{grid-template-columns:1fr}
  .product-select-btn{grid-column:1;grid-row:2}
  .product-link-state{grid-row:3}
  .picker-foot .btn{padding:8px 10px;font-size:11px}
}

@media print{
  .mobile-tabs,.nav-backdrop,.product-picker,.confirm-dialog{display:none!important}
}

/* チェックボックス/ラジオ: 通常inputの装飾(枠・余白・36px高)を打ち消してネイティブ表示にする */
input[type="checkbox"],input[type="radio"]{
  appearance:auto;-webkit-appearance:auto;min-height:0;width:16px;height:16px;
  padding:0;border:none;border-radius:3px;background:none;box-shadow:none;
  accent-color:var(--accent);cursor:pointer;vertical-align:middle;
}
input[type="checkbox"]:hover,input[type="radio"]:hover{border:none;box-shadow:none}
input[type="checkbox"]:focus,input[type="radio"]:focus{outline:2px solid rgba(83,104,232,.35);outline-offset:2px;border:none;box-shadow:none}

/* ===== 明細行の並び替え・複製 ===== */
.item-table .row-no{white-space:nowrap}
.row-drag{display:inline-block;margin-right:5px;color:#9aa7b8;cursor:grab;font-size:14px;line-height:1;user-select:none;touch-action:none}
.row-drag:active{cursor:grabbing;color:var(--accent)}
.row-no-value{font-variant-numeric:tabular-nums;color:var(--sub)}
.row-tools{display:inline-flex;gap:3px;margin-right:3px}
.row-tools .btn.sm,.item-table .row-del{min-width:28px;padding:4px 6px}
.row-copy{font-size:13px}
.item-table tbody tr.is-dragging{opacity:.45;background:var(--accent-soft)}
.item-table tbody tr.row-moved{animation:rowFlash .6s ease-out}
@keyframes rowFlash{from{background:#fff6d8}to{background:transparent}}
.row-tools-help{display:flex;align-items:center;gap:6px;flex-wrap:wrap;margin:6px 2px 0;font-size:11.5px;color:var(--sub)}
.row-tools-help code{background:#eef2f7;border-radius:4px;padding:1px 5px;font-size:11px}
@media (max-width:820px){
  .row-drag{display:none} /* モバイルは ↑↓ ボタンで並び替え */
  .row-tools{gap:2px}
}

/* ===== 案件明細の仕入原価・粗利 ===== */
.item-table td.cost-col{white-space:nowrap;font-variant-numeric:tabular-nums}
.item-table td.cost-col b{display:block;font-size:12.5px;line-height:1.3}
.item-table td.cost-col small{display:block;color:var(--sub);font-size:10.5px;line-height:1.3}
.item-table td.cost-col .tag{margin-top:2px}
.item-table th.cost-col{background:#f2f5fa}
.cost-summary{display:flex;flex-wrap:wrap;gap:10px 22px;margin:12px 0 4px;padding:12px 14px;
  border:1px solid var(--line);border-radius:12px;background:var(--panel-soft)}
.cost-summary span{display:flex;flex-direction:column;gap:2px}
.cost-summary small{font-size:10.5px;color:var(--sub)}
.cost-summary b{font-size:15px;font-variant-numeric:tabular-nums}
.cost-summary em{font-style:normal;align-self:flex-start}
@media (max-width:820px){
  .cost-summary{gap:8px 14px;padding:10px}
  .cost-summary b{font-size:14px}
}

/* ===== レシピから一括追加 (賞ごとの入れ方) ===== */
.recipe-apply{margin:0 0 12px;padding:10px 13px;background:#f7f9fc;border:1px solid var(--line);border-radius:11px}
.recipe-apply>summary{cursor:pointer;font-weight:700;font-size:13px}
.recipe-apply .rank-merge-list{grid-template-columns:repeat(auto-fit,minmax(290px,1fr))}
.recipe-apply .rank-merge-row label{min-width:0;font-size:12.5px}
/* 独立したチェックボックス1行 */
.inline-check{display:flex;align-items:center;gap:6px;margin-top:10px;font-size:13px;font-weight:600}

/* ===== PDFの見せ方 (賞のまとめ方・並び順) ===== */
.rank-merge-list{display:grid;grid-template-columns:repeat(auto-fit,minmax(210px,1fr));gap:6px 10px}
.rank-merge-row{display:flex;align-items:center;gap:6px}
.rank-merge-row label{display:flex;align-items:center;gap:4px;min-width:74px;margin:0;
  font-size:13px;font-weight:700;white-space:nowrap}
.rank-merge-row input[type=text],.rank-merge-row input:not([type]){flex:1;min-width:0;font-size:12.5px;padding:5px 7px}
#pdfRowTable td.pdf-row-no{width:38px;color:var(--sub);font-variant-numeric:tabular-nums}
#pdfRowTable td:last-child{white-space:nowrap}
/* 項目数の少ない集計バー */
.summary-bar.cols-4{grid-template-columns:repeat(4,minmax(112px,1fr))}
@media (max-width:820px){
  .summary-bar.cols-4{grid-template-columns:repeat(4,112px)}
  .rank-merge-list{grid-template-columns:1fr}
}

/* ===== 表示する項目の切り替え (セクション・表の列) ===== */
.is-view-hidden{display:none!important}
.view-toggle{background:#fff;border:1px solid var(--line);border-radius:11px;margin:10px 0;box-shadow:var(--shadow)}
.view-toggle>summary{display:flex;align-items:center;gap:8px;padding:9px 13px;font-weight:700;font-size:13px;cursor:pointer;list-style:none}
.view-toggle>summary::-webkit-details-marker{display:none}
.view-toggle>summary::before{content:"👁";font-size:13px}
.view-toggle>summary::after{content:"⌄";margin-left:auto;color:var(--sub)}
.view-toggle[open]>summary{border-bottom:1px solid var(--line)}
.view-toggle[open]>summary::after{transform:rotate(180deg)}
.view-toggle-count{font-size:11px;font-weight:600;color:var(--sub);background:var(--panel-soft);border-radius:999px;padding:2px 8px}
.view-toggle-body{padding:11px 13px 13px}
.view-toggle-list{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:4px 12px}
.view-toggle-item{display:flex;align-items:center;gap:6px;font-size:12.5px;font-weight:600;
  padding:5px 7px;border-radius:8px;cursor:pointer;min-height:34px}
.view-toggle-item:hover{background:var(--accent-soft)}
.view-toggle-hint{margin-top:8px;font-size:11px;color:var(--sub);line-height:1.5}
.view-toggle-actions{display:flex;gap:8px;margin-top:9px}
@media (max-width:820px){
  .view-toggle-list{grid-template-columns:1fr 1fr}
  .view-toggle-item{min-height:38px}
}

/* ===== わからない言葉の「?」ヘルプ ===== */
.has-term-help{white-space:nowrap}
.term-help{
  display:inline-grid;place-items:center;width:16px;height:16px;margin-left:4px;padding:0;
  border:1px solid var(--line-strong);border-radius:50%;background:#fff;color:var(--sub);
  font-size:10px;font-weight:800;line-height:1;cursor:pointer;vertical-align:middle;min-height:0}
.term-help:hover,.term-help[aria-expanded="true"]{background:var(--accent);border-color:var(--accent);color:#fff}
.term-bubble{
  position:fixed;z-index:120;display:none;padding:12px 32px 12px 14px;background:#fff;
  border:1px solid var(--line);border-radius:12px;box-shadow:0 14px 36px rgba(19,32,54,.22);
  font-size:12.5px;line-height:1.7;color:var(--text)}
.term-bubble.is-open{display:block}
.term-bubble b{display:block;margin-bottom:3px;font-size:13px;color:var(--accent2)}
.term-bubble-close{
  position:absolute;top:5px;right:6px;width:24px;height:24px;min-height:0;padding:0;border:0;border-radius:8px;
  background:none;color:var(--sub);font-size:16px;line-height:1;cursor:pointer}
.term-bubble-close:hover{background:var(--panel-soft);color:var(--text)}

.glossary{background:#fff;border:1px solid var(--line);border-radius:12px;box-shadow:var(--shadow);margin-bottom:18px}
.glossary>summary{padding:12px 15px;font-size:13px;font-weight:700;cursor:pointer}
.glossary[open]>summary{border-bottom:1px solid var(--line)}
.glossary-list{margin:0;padding:12px 15px 15px;font-size:12.5px;line-height:1.7}
.glossary-list dt{font-weight:800;color:var(--accent2);margin-top:9px}
.glossary-list dt:first-child{margin-top:0}
.glossary-list dd{margin:0;color:var(--sub)}

/* ===== 上に戻る ===== */
.back-to-top{
  position:fixed;right:18px;bottom:22px;z-index:70;display:none;align-items:center;gap:4px;
  padding:9px 14px;border:1px solid var(--line-strong);border-radius:999px;background:#fff;color:#344256;
  font-size:12px;font-weight:700;cursor:pointer;box-shadow:0 10px 26px rgba(19,32,54,.18)}
.back-to-top.is-shown{display:inline-flex}
.back-to-top span{font-size:14px;line-height:1}
@media (max-width:820px){.back-to-top{bottom:calc(70px + env(safe-area-inset-bottom,0px))}}

/* ===== 今見ているところをメニューで光らせる ===== */
.project-tabs a.is-current{background:var(--accent);color:#fff}
.project-tabs a.is-current:hover{background:var(--accent2);color:#fff}

/* ===== 次にやることガイド ===== */
.next-steps{
  background:#fff;border:1px solid var(--line);border-radius:12px;box-shadow:var(--shadow);
  padding:14px 16px;margin-bottom:14px}
.next-steps-head{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-bottom:11px}
.next-steps-head h2{margin:0;font-size:15px}
.next-steps-head .muted{margin-left:auto}
.step-list{display:grid;grid-template-columns:repeat(auto-fit,minmax(210px,1fr));gap:9px}
.step{
  display:flex;gap:10px;align-items:flex-start;padding:11px 12px;border:1px solid var(--line);
  border-radius:11px;background:var(--panel-soft)}
.step-num{
  flex:0 0 auto;display:grid;place-items:center;width:24px;height:24px;border-radius:50%;
  background:#e3e8f0;color:var(--sub);font-size:11.5px;font-weight:800}
.step-body{display:flex;flex-direction:column;gap:3px;min-width:0}
.step-body b{font-size:13px}
.step-body small{color:var(--sub);font-size:11.5px;line-height:1.6}
.step-body .btn{align-self:flex-start;margin-top:4px}
.step.is-done{background:var(--ok-soft);border-color:#bfe6d1}
.step.is-done .step-num{background:var(--ok);color:#fff}
.step.is-now{background:#fff;border-color:var(--accent);box-shadow:0 0 0 2px var(--accent-soft)}
.step.is-now .step-num{background:var(--accent);color:#fff}
.step-state{font-size:11px;font-weight:800}
.step.is-done .step-state{color:var(--ok)}
.step.is-now .step-state{color:var(--accent)}
.step.is-todo .step-state{color:var(--sub)}

/* ===== 何もないときの案内 ===== */
.empty-guide{display:flex;flex-direction:column;align-items:center;gap:8px;padding:26px 18px;text-align:center}
.empty-guide-mark{display:grid;place-items:center;width:44px;height:44px;border-radius:15px;
  background:var(--accent-soft);color:var(--accent);font-size:20px}
.empty-guide b{font-size:14px}
.empty-guide p{max-width:420px;color:var(--sub);font-size:12.5px;line-height:1.7}
.empty-guide-actions{display:flex;gap:8px;flex-wrap:wrap;justify-content:center;margin-top:3px}
td .empty-guide{white-space:normal}

/* ===== ダッシュボードのよく使う操作 ===== */
.quick-actions{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:10px;margin-bottom:18px}
.quick-action{
  display:flex;align-items:center;gap:11px;padding:13px 15px;background:#fff;border:1px solid var(--line);
  border-radius:12px;color:var(--text);box-shadow:var(--shadow);transition:transform .12s,border-color .12s}
.quick-action:hover{transform:translateY(-1px);border-color:var(--accent);text-decoration:none}
.quick-action-mark{display:grid;place-items:center;flex:0 0 auto;width:36px;height:36px;border-radius:12px;
  background:var(--accent-soft);color:var(--accent);font-size:17px}
.quick-action span:last-child{display:flex;flex-direction:column;min-width:0}
.quick-action b{font-size:13.5px}
.quick-action small{color:var(--sub);font-size:11px}

/* ===== すべて片づいているときの合図 ===== */
.all-clear{display:flex;align-items:center;gap:10px;padding:12px 15px;margin-bottom:16px;
  background:var(--ok-soft);border:1px solid #bfe6d1;border-radius:12px;color:#125c3d;font-size:12.5px}
.all-clear b{font-size:13.5px}

/* 足りないときの次の一手 */
.shortage-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin:0 0 12px;
  padding:10px 13px;background:var(--warn-soft);border:1px solid #f0d9a0;border-radius:11px;
  font-size:12.5px;color:#7a4d06}
@media (max-width:820px){
  /* 「該当なし」の行には項目名を出さない */
  .responsive-cards .empty-row td::before{content:none}
  .responsive-cards .empty-row td{padding:0!important}
}
.step-list{list-style:none;margin:0;padding:0}

/* ===== 画面上部の「まとめて探す」窓 ===== */
.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
.topbar-search{position:relative;flex:1 1 260px;max-width:420px;margin-left:8px}
.topbar-search-mark{position:absolute;left:11px;top:50%;transform:translateY(-50%);font-size:13px;opacity:.75;pointer-events:none}
.topbar-search input{
  width:100%;min-height:34px;padding:6px 12px 6px 32px;border:1px solid rgba(255,255,255,.18);border-radius:999px;
  background:rgba(255,255,255,.12);color:#fff;font-size:12.5px}
.topbar-search input::placeholder{color:rgba(255,255,255,.62)}
.topbar-search input:focus{outline:2px solid rgba(255,255,255,.45);border-color:transparent;background:rgba(255,255,255,.2)}

/* ===== 検索結果 ===== */
.search-page-form{align-items:end}
.search-page-field{flex:1 1 320px;max-width:520px}
.search-page-field input{width:100%}
.search-total{margin:0 0 12px;font-size:13px;color:var(--sub)}
.search-groups{display:grid;grid-template-columns:repeat(auto-fit,minmax(330px,1fr));gap:14px;align-items:start}
.search-group{margin-bottom:0;padding:15px}
.search-group-head{display:flex;align-items:center;gap:10px;margin-bottom:10px}
.search-group-mark{display:grid;place-items:center;flex:0 0 auto;width:34px;height:34px;border-radius:12px;
  background:var(--accent-soft);font-size:16px}
.search-group-title{display:flex;flex-direction:column;min-width:0}
.search-group-title b{display:flex;align-items:center;gap:7px;font-size:14px}
.search-group-title small{color:var(--sub);font-size:11.5px}
.search-hits{display:flex;flex-direction:column;gap:5px}
.search-hit{display:flex;align-items:center;gap:9px;padding:9px 11px;border:1px solid var(--line);border-radius:10px;
  background:var(--panel-soft);color:var(--text)}
.search-hit:hover{border-color:var(--accent);background:var(--accent-soft);text-decoration:none}
.search-hit-body{display:flex;flex-direction:column;gap:1px;min-width:0;flex:1}
.search-hit-body b{font-size:13px;overflow-wrap:anywhere}
.search-hit-body small{color:var(--sub);font-size:11px;overflow-wrap:anywhere}
.search-hit-arrow{flex:0 0 auto;color:var(--sub);font-size:13px}
.search-more{display:inline-block;margin-top:9px;font-size:12px;font-weight:650}
@media (max-width:820px){
  .topbar-search{display:none}
  .search-groups{grid-template-columns:1fr}
  .search-hit{min-height:52px}
}

/* 「?」は見た目は小さいまま、指で押せる範囲を広げる */
.term-help{position:relative}
.term-help::after{content:"";position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);
  width:34px;height:34px;border-radius:50%}
@media (max-width:820px){
  .term-help{width:18px;height:18px;font-size:11px}
  .term-help::after{width:42px;height:42px}
  .term-bubble{padding:14px 36px 14px 15px;font-size:13px}
  .term-bubble-close{width:30px;height:30px;font-size:18px}
  /* 「次にやること」はスマホでは1件ずつ縦に並べる */
  .step-list{grid-template-columns:1fr}
  .step{padding:12px 13px}
  .step-body .btn{min-height:38px}
  .next-steps-head .muted{margin-left:0;flex-basis:100%}
  .quick-action{min-height:58px}
}
/* 検索窓を足しても上部のロゴ・名前がつぶれないようにする */
.topbar .brand{flex:0 0 auto}
.topbar .user-box{flex:0 0 auto}
@media (max-width:1100px){
  .topbar .brand small{display:none}
  .user-name{max-width:90px}
}

/* 入れなかった理由をはっきり見せる */
.auth-reason{margin:10px auto;padding:10px 13px;max-width:340px;border-radius:10px;
  background:var(--err-soft);border:1px solid #f2c6c9;color:#8f252b;font-size:12.5px;line-height:1.7}
.error-card .empty-guide-actions{justify-content:center}
