/* Hallmark · genre: modern-minimal · macrostructure: Workbench(app) · design-system: design.md · designed-as-app
 * ヘリックス社内システム共通 UI(helix-job / helix-billing / HC Guard で同じファイルを使う)。
 * 正は For_ClaudeCode/helix-design-system/helix-ui.css。tokens.css を先に読み込むこと。
 * 既存テンプレートのクラス名(.card .btn .badge .kpi table.list / .tile .side .tabs .kv ...)はそのまま効く。
 */

/* ---------- 基本 ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }
body { margin: 0; overflow-x: clip; background: var(--hx-paper); color: var(--hx-ink-2);
       font-family: var(--hx-font-body); font-size: 14px; line-height: 1.55;
       font-feature-settings: "palt"; -webkit-font-smoothing: antialiased; }
a { color: var(--hx-ink); text-decoration: underline; text-decoration-color: var(--hx-rule-strong);
    text-underline-offset: 3px; transition: text-decoration-color var(--hx-dur) var(--hx-ease-out); }
a:hover { text-decoration-color: var(--hx-ink); }
img { max-width: 100%; }
h1 { font-family: var(--hx-font-display); font-size: var(--hx-text-xl); font-weight: 700; letter-spacing: -0.01em;
     margin: 0 0 var(--hx-space-4); line-height: 1.3; overflow-wrap: anywhere; }
h2 { font-family: var(--hx-font-display); font-size: var(--hx-text-lg); font-weight: 700; letter-spacing: -0.005em;
     margin: var(--hx-space-6) 0 var(--hx-space-2); line-height: 1.35; }
h3 { font-size: var(--hx-text-md); font-weight: 700; margin: var(--hx-space-4) 0 var(--hx-space-2); }
.muted, .sub, .small { color: var(--hx-muted); }
.muted { font-size: var(--hx-text-sm); }
.sub { margin-bottom: var(--hx-space-5); overflow-wrap: anywhere; }
.small { font-size: 12px; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.mono { font-family: var(--hx-font-mono); font-size: 12px; overflow-wrap: anywhere; }
.nw, .nw-d { white-space: nowrap; }
:focus-visible { outline: 2px solid var(--hx-focus); outline-offset: 2px; }

/* ---------- ブランド(ロゴ＋アプリ名)。黒いバー・サイドバー共通 ---------- */
.hx-brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; min-width: 0; }
.hx-brand:hover { text-decoration: none; }
.hx-brand img { height: 20px; width: auto; display: block; flex-shrink: 0; }
.hx-brand .hx-app { display: flex; flex-direction: column; line-height: 1.1; padding-left: 12px;
                    border-left: 1px solid rgba(255,255,255,0.28); min-width: 0; }
.hx-brand .hx-app b { font-family: var(--hx-font-display); font-weight: 600; font-size: 10.5px;
                      letter-spacing: 0.16em; text-transform: uppercase; color: var(--hx-accent); }
.hx-brand .hx-app span { font-size: 12.5px; font-weight: 500; color: #fff; margin-top: 3px; white-space: nowrap; }

/* ---------- 上部バー型(helix-job / helix-billing) ---------- */
header.top { background: var(--hx-ink); color: #fff; display: flex; align-items: stretch; gap: var(--hx-space-6);
             padding: 0 var(--hx-space-5); height: var(--hx-bar-h); position: relative; }
header.top .logo { display: flex; align-items: center; }
header.top .menu { display: flex; align-items: stretch; gap: var(--hx-space-6); flex: 1; min-width: 0; }
header.top nav { display: flex; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
header.top nav::-webkit-scrollbar { display: none; }
header.top nav a { display: flex; align-items: center; color: var(--hx-placeholder); padding: 0 12px; font-size: 13px;
                   font-weight: 500; text-decoration: none; white-space: nowrap; position: relative;
                   transition: color var(--hx-dur) var(--hx-ease-out); }
header.top nav a:hover { color: #fff; }
header.top nav a.active { color: #fff; }
header.top nav a.active::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: 0; height: 2px;
                                 background: var(--hx-accent); }
header.top .user { display: flex; align-items: center; gap: 10px; color: var(--hx-placeholder); font-size: 12px; white-space: nowrap; }
header.top .user a { color: #fff; text-decoration: none; }
header.top .user a:hover { text-decoration: underline; text-decoration-color: var(--hx-accent); }
header.top .user .btn.sub { background: transparent; color: #fff; border-color: rgba(255,255,255,0.4); }
header.top .user .btn.sub:hover { background: #fff; color: var(--hx-ink); border-color: #fff; }
header.top .menu-toggle, header.top .burger { display: none; background: none; border: 0; color: #fff; font-size: 22px;
                                               line-height: 1; cursor: pointer; padding: 4px 10px; margin-left: auto; align-self: center; }
header.top #navToggle { display: none; }
main { max-width: 1240px; margin: var(--hx-space-6) auto; padding: 0 var(--hx-space-5); }

/* ---------- サイドバー型(HC Guard) ---------- */
.layout { display: flex; min-height: 100vh; }
.side { width: 224px; background: var(--hx-ink); color: #fff; padding: 18px 14px; flex-shrink: 0; display: flex; flex-direction: column; }
.side .brand { margin: 2px 6px 26px; }
.side a { display: block; color: var(--hx-placeholder); padding: 9px 12px; border-radius: var(--hx-radius); margin-bottom: 2px;
          font-size: 13.5px; font-weight: 500; text-decoration: none; position: relative;
          transition: color var(--hx-dur) var(--hx-ease-out), background var(--hx-dur) var(--hx-ease-out); }
.side a:hover { color: #fff; background: rgba(255,255,255,0.08); }
.side a.active { color: #fff; background: rgba(255,255,255,0.1); }
.side a.active::before { content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 2px; background: var(--hx-accent); }
.side .foot { margin-top: auto; padding-top: 14px; border-top: 1px solid rgba(255,255,255,0.18); font-size: 12px; color: var(--hx-placeholder); }
.side .foot a { display: inline; padding: 0; color: #fff; }
.topbar, .navtoggle { display: none; }
.main { flex: 1; min-width: 0; padding: 26px 32px 48px; max-width: 1320px; }

/* ---------- サイドバー内のブランドは縦積み(ロゴの下に英字キッカー＋和文) ---------- */
.side .hx-brand { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 0; margin: 2px 6px 26px; background: none; }
.side .hx-brand:hover { background: none; }
.side .hx-brand .hx-app { border-left: 0; padding-left: 0; }
.side .hx-brand .hx-app span { font-size: 12px; }
/* 上部バーのナビが多いアプリ(job は管理者で 11 項目)向けに 1200px 以下で詰める */
@media (max-width: 1200px) {
  header.top { gap: var(--hx-space-4); }
  header.top nav a { padding: 0 8px; font-size: 12.5px; }
  header.top .hx-brand .hx-app span { display: none; }
}

/* ---------- カード・KPI ---------- */
.card { background: var(--hx-paper); border: 1px solid var(--hx-rule); border-radius: var(--hx-radius-card);
        padding: 18px 20px; margin-bottom: var(--hx-space-4); min-width: 0; }
.kpi, .tiles { display: grid; gap: var(--hx-space-3); margin: var(--hx-space-4) 0 var(--hx-space-5); }
.kpi { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tiles { grid-template-columns: repeat(auto-fit, minmax(176px, 1fr)); }
.kpi .box, .tile { background: var(--hx-paper); border: 1px solid var(--hx-rule); border-radius: var(--hx-radius-card);
                   padding: 14px 16px 12px; min-width: 0; }
.kpi .box .t, .tile .k { font-size: var(--hx-text-xs); color: var(--hx-muted); font-weight: 500; letter-spacing: 0.02em; }
.kpi .box .v, .tile .v { font-family: var(--hx-font-display); font-size: var(--hx-text-2xl); font-weight: 600; letter-spacing: -0.02em;
                         margin-top: 6px; line-height: 1.15; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tile .s { font-size: 12px; color: var(--hx-muted); margin-top: 4px; overflow-wrap: anywhere; }
.grid { display: grid; gap: var(--hx-space-4); }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid2 { display: grid; grid-template-columns: 1.2fr 1fr; gap: var(--hx-space-4); }
.grid2.even { grid-template-columns: 1fr 1fr; }
.grid2 > * { min-width: 0; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: var(--hx-space-4); flex-wrap: wrap; }
.toolbar form { display: flex; gap: 8px; align-items: center; }

/* ---------- 表 ---------- */
.tw { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; font-size: 13px; }
table.list, .card > table, .tw > table { width: 100%; }
th { text-align: left; font-size: var(--hx-text-xs); font-weight: 600; color: var(--hx-muted); letter-spacing: 0.02em;
     padding: 8px 10px; border-bottom: 1px solid var(--hx-ink); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--hx-rule); vertical-align: top; overflow-wrap: anywhere; }
table.list td { padding: 8px 10px; }
tbody tr:hover td, table.list tr:hover td { background: var(--hx-paper-2); }
tr:last-child td { border-bottom-color: var(--hx-rule); }
td.sitecol { min-width: 260px; }
td .desc { color: var(--hx-faint); line-height: 1.4; margin-top: 3px; display: -webkit-box; -webkit-box-orient: vertical;
           -webkit-line-clamp: 2; overflow: hidden; }

/* ---------- ボタン ---------- */
.btn, button.btn, .main button, .login button { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--hx-ink); color: #fff; border: 1px solid var(--hx-ink); border-radius: var(--hx-radius);
  padding: 7px 15px; font-size: 13px; font-weight: 600; font-family: inherit; line-height: 1.3; cursor: pointer;
  text-decoration: none; white-space: nowrap;
  transition: background var(--hx-dur) var(--hx-ease-out), color var(--hx-dur) var(--hx-ease-out), border-color var(--hx-dur) var(--hx-ease-out); }
.btn:hover, .main button:hover, .login button:hover { background: var(--hx-ink-2); text-decoration: none; }
.btn:active, .main button:active { transform: translateY(1px); }
.btn.sub { background: var(--hx-paper); color: var(--hx-ink); border-color: var(--hx-ink); }
.btn.sub:hover { background: var(--hx-paper-2); }
.btn.sm { padding: 4px 10px; font-size: 12px; font-weight: 500; }
.btn.danger { background: var(--hx-paper); color: var(--hx-bad); border-color: var(--hx-bad); }
.btn.danger:hover { background: var(--hx-bad); color: #fff; }
.btn[disabled], .main button[disabled] { opacity: 0.45; cursor: default; transform: none; }

/* ---------- バッジ(四角寄り・小文字) ---------- */
.badge { display: inline-block; padding: 1px 7px; border-radius: 2px; font-size: var(--hx-text-xs); font-weight: 600;
         line-height: 1.6; white-space: nowrap; border: 1px solid transparent; }
.badge.ok,  .badge.paid, .badge.delivered, .badge.remote    { background: var(--hx-ok-bg);   color: var(--hx-ok);   border-color: var(--hx-ok-line); }
.badge.warn, .badge.ordered, .badge.standby, .badge.invoiced { background: var(--hx-warn-bg); color: var(--hx-warn); border-color: var(--hx-warn-line); }
.badge.bad, .badge.miss, .badge.lost, .badge.canceled, .badge.requoted { background: var(--hx-bad-bg); color: var(--hx-bad); border-color: var(--hx-bad-line); }
.badge.muted, .badge.draft, .badge.pending, .badge.open, .badge.waived { background: var(--hx-paper-2); color: var(--hx-muted); border-color: var(--hx-rule-strong); }
.badge.waived { text-decoration: line-through; }
.badge.submitted, .badge.acked, .badge.office, .badge.closed, .badge.misc { background: var(--hx-paper); color: var(--hx-ink); border-color: var(--hx-ink); }
.badge.closed { background: var(--hx-ink); color: #fff; }
.score { font-family: var(--hx-font-display); font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }

/* ---------- 通知 ---------- */
.flash, .note { padding: 10px 14px; border-left: 3px solid var(--hx-ink); background: var(--hx-paper-2);
                border-radius: 0 var(--hx-radius) var(--hx-radius) 0; margin: 0 0 var(--hx-space-4); font-size: 13px; }
.note { margin: 6px 0; border-left-color: var(--hx-warn); background: var(--hx-warn-bg); }
.errors, .note.bad, .err { padding: 10px 14px; border-left: 3px solid var(--hx-bad); background: var(--hx-bad-bg); color: var(--hx-bad);
                           border-radius: 0 var(--hx-radius) var(--hx-radius) 0; margin: 0 0 var(--hx-space-4); font-size: 13px; }
ul.plain { margin: 0; padding-left: 18px; }

/* ---------- フォーム ---------- */
label { display: block; font-size: var(--hx-text-sm); color: var(--hx-muted); margin-bottom: 3px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=month],
input[type=search], input[type=tel], input[type=url], select, textarea {
  width: 100%; border: 1px solid var(--hx-rule-strong); border-radius: var(--hx-radius); padding: 7px 10px;
  font-size: var(--hx-text-md); font-family: inherit; background: var(--hx-paper); color: var(--hx-ink-2);
  transition: border-color var(--hx-dur) var(--hx-ease-out); }
input::placeholder, textarea::placeholder { color: var(--hx-placeholder); opacity: 1; }
input:hover, select:hover, textarea:hover { border-color: var(--hx-muted); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--hx-focus); outline-offset: 0; border-color: var(--hx-ink); }
input[type=checkbox], input[type=radio] { accent-color: var(--hx-ink); width: auto; }

/* ---------- タブ・キー値(HC Guard) ---------- */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--hx-rule); margin: var(--hx-space-4) 0; overflow-x: auto;
        -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 8px 14px; color: var(--hx-muted); white-space: nowrap; flex-shrink: 0; text-decoration: none; font-weight: 500;
          border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--hx-ink); }
.tabs a.active { color: var(--hx-ink); border-bottom-color: var(--hx-ink); font-weight: 600; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 14px; font-size: 13px; }
.kv .k { color: var(--hx-muted); } .kv > div { min-width: 0; overflow-wrap: anywhere; }
.kv.wide { grid-template-columns: 220px 1fr; gap: 10px 16px; } .kv.wide .k { font-weight: 600; color: var(--hx-ink-2); }

/* ---------- ページネーション ---------- */
.pagination { display: flex; gap: 4px; margin-top: var(--hx-space-4); flex-wrap: wrap; }
.pagination a, .pagination span { padding: 4px 10px; border: 1px solid var(--hx-rule-strong); border-radius: var(--hx-radius);
                                  background: var(--hx-paper); text-decoration: none; font-size: 13px; }
.pagination a:hover { border-color: var(--hx-ink); }
.pagination .active span { background: var(--hx-ink); color: #fff; border-color: var(--hx-ink); }

/* ---------- ログイン(黒パネル＋白フォームの2列) ---------- */
body.hx-login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); background: var(--hx-paper); }
.hx-login-panel { background: var(--hx-ink); color: #fff; padding: 40px 44px; display: flex; flex-direction: column; justify-content: space-between; min-height: 100vh; }
.hx-login-panel img { height: 30px; width: auto; align-self: flex-start; }
.hx-login-panel .hx-kicker { font-family: var(--hx-font-display); font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase;
                             color: var(--hx-accent); font-weight: 600; margin-bottom: 14px; }
.hx-login-panel h1 { color: #fff; font-size: clamp(26px, 3vw, 36px); font-weight: 700; letter-spacing: -0.02em; margin: 0 0 10px; }
.hx-login-panel p { color: var(--hx-placeholder); font-size: 13.5px; margin: 0; max-width: 34em; }
.hx-login-panel .hx-foot { font-size: 11.5px; color: var(--hx-muted); }
.hx-login-form { display: flex; align-items: center; justify-content: center; padding: 48px 24px; }
.hx-login-form .box { width: 100%; max-width: 380px; }
.hx-login-form .box h1, .hx-login-form .box h2 { font-size: var(--hx-text-xl); margin: 0 0 4px; }
.hx-login-form p.sub { margin: 0 0 var(--hx-space-6); font-size: var(--hx-text-sm); }
.hx-login-form label { margin: var(--hx-space-4) 0 4px; }
.hx-login-form input:not([type=checkbox]) { padding: 10px 12px; font-size: 15px; }
.hx-login-form button, .hx-login-form .btn { width: 100%; margin-top: var(--hx-space-6); padding: 11px; font-size: 14px; }
.hx-login-form .remember { display: flex; align-items: center; gap: 8px; margin-top: var(--hx-space-3); font-size: var(--hx-text-sm); color: var(--hx-muted); }
.hx-login-form .remember input { width: auto; }
.hx-login-form .links { margin-top: var(--hx-space-4); font-size: var(--hx-text-sm); text-align: center; }
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 38px !important; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: 0; cursor: pointer;
             padding: 4px; line-height: 0; color: var(--hx-faint); width: auto !important; margin: 0 !important; }
.pw-toggle:hover { color: var(--hx-ink); }
.pw-toggle svg { width: 19px; height: 19px; }

/* ---------- レスポンシブ ---------- */
@media (max-width: 900px) {
  .grid.c2, .grid.c3, .grid.c4, .kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid2, .grid2.even { grid-template-columns: 1fr; }
  main { margin: var(--hx-space-4) auto; padding: 0 var(--hx-space-3); }
  .card { overflow-x: auto; }
  .toolbar form, .toolbar form > span { flex-wrap: wrap; }
  /* サイドバー → 上部バー＋開閉メニュー */
  .layout { display: block; }
  .topbar { display: flex; align-items: center; justify-content: space-between; background: var(--hx-ink); color: #fff;
            padding: 0 14px; height: var(--hx-bar-h); position: sticky; top: 0; z-index: 20; }
  .navtoggle { display: block; width: 40px; height: 40px; border: 0; background: transparent; padding: 8px; cursor: pointer; }
  .navtoggle span { display: block; height: 2px; background: #fff; margin: 6px 0; transition: transform var(--hx-dur) var(--hx-ease-out), opacity var(--hx-dur); }
  .side { display: none; width: auto; padding: 8px 14px 14px; position: sticky; top: var(--hx-bar-h); z-index: 19; }
  .side .brand { display: none; }
  .side .foot { margin-top: 12px; }
  #nav:checked ~ .side { display: block; }
  #nav:checked ~ .topbar .navtoggle span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
  #nav:checked ~ .topbar .navtoggle span:nth-child(2) { opacity: 0; }
  #nav:checked ~ .topbar .navtoggle span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }
  .main { padding: 16px 14px 40px; max-width: none; }
  body.hx-login { grid-template-columns: 1fr; }
  .hx-login-panel { min-height: 0; padding: 22px 20px; gap: 18px; }
  .hx-login-panel h1 { font-size: 22px; }
  .hx-login-panel .hx-foot { display: none; }
  .hx-login-form { padding: 28px 20px 40px; align-items: flex-start; }
}
@media (max-width: 840px) {
  header.top { flex-wrap: wrap; height: auto; min-height: var(--hx-bar-h); padding: 10px 14px; gap: 8px; align-items: center; }
  header.top .menu-toggle, header.top .burger { display: block; }
  header.top .menu, header.top nav { display: none; flex-direction: column; width: 100%; gap: 2px; }
  header.top nav.open, header.top #navToggle:checked ~ .menu { display: flex; }
  header.top .menu nav { display: flex; }
  header.top nav a { padding: 11px 12px; }
  header.top nav a.active::after { left: 0; right: auto; top: 10px; bottom: 10px; width: 2px; height: auto; }
  header.top .user { display: none; width: 100%; justify-content: space-between; border-top: 1px solid rgba(255,255,255,0.2); padding-top: 10px; }
  header.top .user.open, header.top #navToggle:checked ~ .menu .user { display: flex; }
}
@media (max-width: 640px) {
  body { font-size: 13.5px; }
  h1 { font-size: 18px; }
  .main { padding: 12px 10px 32px; }
  .kpi, .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr; }
  .kpi .box, .tile { padding: 10px 12px; } .kpi .box .v, .tile .v { font-size: 20px; }
  .card { padding: 12px; }
  table { font-size: 12.5px; } th { padding: 6px 8px; } td { padding: 7px 8px; }
  .kv, .kv.wide { grid-template-columns: 1fr; gap: 2px; } .kv .k { margin-top: 8px; } .kv .k:first-child { margin-top: 0; }
  .nw-d { white-space: normal; }
  .hx-brand .hx-app span { display: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: 0.01ms !important; } }
@media print { .side, .topbar, header.top, .noprint { display: none; } .main, main { padding: 0; max-width: none; margin: 0; }
               .card { break-inside: avoid; border-color: #999; } body { background: #fff; } }
