/* =========================================================
   Technophere Ops —「帳場」
   紙と墨だけで静かに組む。色が付くのは判断が要るもの（期限切れ・レビュー待ち・
   危険な操作）だけで、それは朱の「印」として出す。リンクだけが静かな藍。
   面は枠で囲まず、紙の地に白い面を置くだけで区切る。罫は表と見出しの下だけ。
   ========================================================= */

:root {
  color-scheme: light dark;

  /* 基調 */
  --paper: #f3f4f2;        /* 紙: 画面の地 */
  --surface: #ffffff;      /* 面: 表・カード・入力 */
  --surface-2: #f8f8f6;    /* 一段沈んだ面: 表の見出し行・補助パネル */
  --hover: #f5f5f2;        /* 行に指を置いたとき */
  --sumi: #23252a;         /* 墨: 本文・見出し・主ボタン */
  --usuzumi: #63676f;      /* 薄墨: 補足 */
  --placeholder: #707479;
  --field-border: #8a8e94;  /* 入力欄の枠は地に対して 3:1 以上 */
  --rule: #e1e2df;         /* 罫 */
  --rule-strong: #c9cbc7;
  --lane: #e9eae7;         /* 紙より一段濃い面: ボードの列・サイドバーの現在地 */
  --ring: rgba(35, 37, 42, 0.07);  /* 白い面の薄い輪郭（影の代わり） */

  /* 意味のある色 */
  --shu: #c2381f;          /* 朱: 判断が要るものだけ */
  --shu-bg: #fbede9;
  --shu-line: #ebb5a8;
  --ai: #2f4a73;           /* 藍: リンク */
  --ai-bg: #edf0f5;
  --rokusho: #3a7860;      /* 緑青: 完了 */
  --rokusho-bg: #e8f2ed;

  /* グラフの系列（朱は判断用に取っておくので使わない） */
  --chart-1: var(--ai);
  --chart-2: #a3782a;      /* 黄土 */
  --chart-3: var(--rokusho);

  --btn-fill: var(--sumi);
  --on-ink: #ffffff;       /* 墨塗りの上の文字 */
  --scrim: rgba(28, 29, 32, 0.45);

  /* 旧名（ops.css などが参照）。新しいコードは上の名前を使う */
  --bg: var(--paper);
  --text: var(--sumi);
  --ink: var(--sumi);
  --muted: var(--usuzumi);
  --border: var(--rule);
  --border-strong: var(--rule-strong);
  --primary: var(--ai);
  --primary-dark: #22385a;
  --primary-ring: var(--ai);  /* フォーカス枠。地に対して 3:1 以上 */
  --danger: var(--shu);
  --danger-bg: var(--shu-bg);
  --warn: var(--shu);
  --warn-bg: var(--shu-bg);
  --ok: var(--rokusho);
  --ok-bg: var(--rokusho-bg);
  --sent: var(--ai-bg);
  --received: var(--rokusho-bg);

  /* 形 */
  --radius-s: 6px;         /* 入力・ボタン */
  --radius: 10px;          /* カード・パネル */
  --radius-l: 12px;
  --radius-seal: 2px;      /* 朱印 */
  --shadow: none;          /* 影は浮いているもの（ドラッグ中・メニュー）だけ */
  --shadow-lift: 0 1px 2px rgba(24, 26, 30, 0.06), 0 8px 20px -6px rgba(24, 26, 30, 0.16);

  /* 書体 */
  --font-sans: "Zen Kaku Gothic New", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  --font-display: var(--font-sans);  /* 見出しも同じ書体。太さと大きさで分ける */
  --font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --sidebar-w: 224px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1c1d20;
    --surface: #25272b;
    --surface-2: #212226;
    --hover: #2b2d32;
    --sumi: #e7e6e2;
    --usuzumi: #a2a5ac;
    --placeholder: #8f9299;
    --field-border: #71757c;
    --rule: #34363b;
    --rule-strong: #4a4d53;
    --lane: #2a2c30;
    --ring: rgba(255, 255, 255, 0.06);
    --shu: #f0765a;
    --shu-bg: #3a2420;
    --shu-line: #6e3c30;
    --ai: #94b3e2;
    --ai-bg: #26303f;
    --rokusho: #7cc2a4;
    --rokusho-bg: #1f3129;
    --chart-2: #d4b066;
    --on-ink: #1c1d20;
    --primary-dark: #b8cdee;
    --scrim: rgba(0, 0, 0, 0.55);
    --shadow-lift: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 24px -6px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  /* 和文の字間を詰める（Zen Kaku Gothic New は素のままだと間延びして見える） */
  font-feature-settings: "palt" 1;
}

a { color: var(--ai); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

h1, h2, h3 { line-height: 1.35; font-weight: 700; }

.icon { vertical-align: -0.18em; flex-shrink: 0; }

:focus-visible { outline: 2px solid var(--primary-ring); outline-offset: 2px; }

/* 金額・件数・日付は桁を揃える */
td, th, .num, .nav-count { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------
   朱印: 判断が要るものだけに付く小さな判子。
   ops.css の該当クラス（レビュー待ち・期限切れ・ブロック中など）もここに寄せる。
   --------------------------------------------------------- */

.seal,
.status-badge.status-review,
.chip.chip-danger,
.chip.chip-warn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 0 6px;
  border: 1px solid var(--shu-line);
  border-radius: var(--radius-seal);
  background: var(--shu-bg);
  color: var(--shu);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.65;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* ---------------------------------------------------------
   アプリシェル: 紙のサイドバー + 本文
   --------------------------------------------------------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border-right: 1px solid var(--rule);
  color: var(--sumi);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 22px 22px;
  color: var(--sumi);
}
.brand:hover { text-decoration: none; }
/* Technophere の電球マーク。線が黒なので、暗い表示では白い台に載せる */
.brand-mark { display: block; flex: none; object-fit: contain; }
@media (prefers-color-scheme: dark) {
  .brand-mark { background: #ffffff; border-radius: 6px; padding: 2px; }
}
.brand-name {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.005em;
}

.sidenav { flex: 1; padding: 0 12px 16px; display: flex; flex-direction: column; gap: 22px; }
.sidenav-group { display: flex; flex-direction: column; gap: 1px; }
.sidenav-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--usuzumi);
  padding: 0 10px 6px;
}
.sidenav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 6px 10px;
  border-radius: var(--radius-s);
  color: var(--usuzumi);
  font-size: 13px;
  font-weight: 500;
  transition: background-color 0.12s ease, color 0.12s ease;
}
.sidenav-link .icon { color: currentColor; stroke-width: 1.6; }
.sidenav-link:hover { background: var(--hover); color: var(--sumi); text-decoration: none; }
.sidenav-link.active { background: var(--lane); color: var(--sumi); font-weight: 700; }
.sidenav-text { flex: 1; min-width: 0; }
.nav-count {
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  color: var(--usuzumi);
}
.sidenav-link.active .nav-count { color: var(--sumi); }
.nav-alert { color: var(--shu); display: inline-flex; }

.sidebar-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 12px;
  padding: 14px 10px 18px;
  border-top: 1px solid var(--rule);
  font-size: 13px;
}
.sidebar-user-name { color: var(--sumi); font-weight: 500; }
.sidebar-logout {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--usuzumi);
  font-size: 12px;
}
.sidebar-logout:hover { color: var(--sumi); }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.mobile-bar { display: none; }
.backdrop { display: none; }

.container {
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px 44px 80px;
}

/* 未ログイン（ログイン・共有リンク）: 紙の地にそのまま置く */
body.auth .container { max-width: none; padding: 0; }

/* ---------------------------------------------------------
   ページ見出し・パンくず
   --------------------------------------------------------- */

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--rule);
  flex-wrap: wrap;
}
.page-head h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--sumi);
  letter-spacing: -0.01em;
}
.page-head h1 .muted { font-size: 14px; font-weight: 400; letter-spacing: 0; }
.page-head-side { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--usuzumi);
  margin-bottom: 10px;
}
.breadcrumb a { color: var(--usuzumi); }
.breadcrumb a:hover { color: var(--sumi); }
.breadcrumb-sep { color: var(--rule-strong); }
.breadcrumb-current { color: var(--sumi); }

/* ---------------------------------------------------------
   カード・テーブル
   --------------------------------------------------------- */

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 0 0 1px var(--ring);
  padding: 22px 24px;
  margin-bottom: 20px;
}
.card h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 16px;
  font-size: 15px;
  font-weight: 700;
  color: var(--sumi);
  letter-spacing: -0.005em;
  flex-wrap: wrap;
}
.card h2 .icon { color: var(--usuzumi); }
.card h2 .muted { font-size: 12px; font-weight: 400; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
thead th {
  font-size: 12px;
  color: var(--usuzumi);
  font-weight: 500;
  white-space: nowrap;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 8px;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--hover); }

.muted { color: var(--usuzumi); font-weight: 400; }
.warn { color: var(--shu); font-weight: 700; }
.danger { color: var(--shu); }
.nowrap { white-space: nowrap; }
.inline { display: inline; }

/* ---------------------------------------------------------
   ボタン・リンク
   主＝墨塗り、副＝白い面と薄い輪郭、危険＝朱の文字（塗らない）
   --------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 6px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-s);
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--rule-strong);
  color: var(--sumi);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.12s ease, box-shadow 0.12s ease, transform 0.08s ease;
}
.btn:hover { background: var(--hover); box-shadow: 0 0 0 1px var(--field-border); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--btn-fill); box-shadow: none; color: var(--on-ink); }
.btn-primary:hover { background: var(--btn-fill); box-shadow: none; opacity: 0.86; }
.btn-small { min-height: 28px; padding: 3px 10px; font-size: 12px; }
.btn-block { width: 100%; }

.link-button {
  background: none;
  border: none;
  padding: 0;
  color: var(--ai);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
}
.link-button:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------------------------------------------------------
   フォーム
   --------------------------------------------------------- */

input:not([type]), input[type="text"], input[type="email"], input[type="password"], input[type="url"],
input[type="search"], input[type="number"], input[type="date"], input[type="time"], input[type="datetime-local"],
input[type="month"], input[type="file"], select, textarea {
  width: 100%;
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid var(--field-border);
  border-radius: var(--radius-s);
  font: inherit;
  background: var(--surface);
  color: var(--sumi);
  transition: border-color 0.12s ease;
}
input:hover, select:hover, textarea:hover { border-color: var(--usuzumi); }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--primary-ring);
  outline-offset: 1px;
  border-color: var(--ai);
}
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--placeholder); opacity: 1; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--sumi); }
label { display: block; font-size: 12.5px; font-weight: 500; color: var(--usuzumi); }
label input, label select, label textarea { margin-top: 5px; font-weight: 400; }
.input-narrow { width: 80px; }

.search-form { display: flex; gap: 8px; align-items: center; }
.search-form input[type="search"] { width: 260px; }
.search-form select { width: auto; }

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 16px 2px 0;
  font-size: 13px;
  color: var(--sumi);
}
.checkbox-line input { width: auto; margin-top: 0; }

.field-hint { font-weight: 400; font-size: 12px; }

/* searchable-select の絞り込み入力 */
.select-filter { width: 130px; margin-right: 6px; }

/* ---------------------------------------------------------
   フラッシュ
   --------------------------------------------------------- */

.flash {
  padding: 11px 16px;
  border-radius: var(--radius-s);
  margin-bottom: 18px;
  background: var(--rokusho-bg);
  border: 1px solid transparent;
  color: var(--sumi);
  font-size: 13px;
}
.flash-error { background: var(--shu-bg); border-color: var(--shu-line); color: var(--shu); font-weight: 700; }

/* ---------------------------------------------------------
   ダッシュボード・空の状態
   --------------------------------------------------------- */

.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}
.dash-grid > .card { margin-bottom: 20px; }

.empty-note {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--usuzumi);
  font-size: 13px;
  margin: 4px 0;
}
.empty-note .icon { color: var(--rokusho); }

/* ---------------------------------------------------------
   フィルタタブ
   --------------------------------------------------------- */

.filter-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 14px; }
.filter-tabs a {
  padding: 4px 12px;
  border-radius: var(--radius-s);
  color: var(--usuzumi);
  font-size: 13px;
  font-weight: 500;
}
.filter-tabs a:hover { background: var(--hover); color: var(--sumi); text-decoration: none; }
.filter-tabs a.active { background: var(--btn-fill); color: var(--on-ink); }

/* ---------------------------------------------------------
   ログイン
   --------------------------------------------------------- */

.login-box {
  max-width: 380px;
  margin: 16vh auto 0;
  background: var(--surface);
  border-radius: var(--radius-l);
  box-shadow: 0 0 0 1px var(--ring);
  padding: 36px 32px 30px;
}
.login-box h1 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 700;
  color: var(--sumi);
  letter-spacing: -0.01em;
}
.login-box .muted { margin: 0 0 22px; font-size: 13px; }
.login-box label { margin-bottom: 14px; }
.login-box .btn-block { margin-top: 8px; padding: 10px 14px; font-size: 14px; }

/* ---------------------------------------------------------
   役割と権限
   --------------------------------------------------------- */

.role-card .checkbox-line { margin-bottom: 4px; }

/* ---------------------------------------------------------
   モバイル
   --------------------------------------------------------- */

@media (max-width: 900px) {
  .shell { display: block; }

  .mobile-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 30;
    background: var(--paper);
    border-bottom: 1px solid var(--rule);
    color: var(--sumi);
    padding: 0 14px;
    height: 52px;
  }
  .mobile-brand { display: inline-flex; align-items: center; gap: 8px; color: var(--sumi); font-weight: 700; font-size: 14px; }
  .mobile-brand:hover { text-decoration: none; }
  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--sumi);
    padding: 6px;
    margin-left: -6px;
    cursor: pointer;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    height: 100%;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  body.nav-open .sidebar { transform: translateX(0); box-shadow: var(--shadow-lift); }
  body.nav-open { overflow: hidden; }
  .backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 40;
    background: var(--scrim);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }
  body.nav-open .backdrop { opacity: 1; pointer-events: auto; }

  .container { padding: 18px 16px 48px; }

  .dash-grid { grid-template-columns: 1fr; }
  .search-form { flex-wrap: wrap; }
  .search-form input[type="search"] { width: 100%; }

  .page-head h1 { font-size: 22px; }

  /* テーブルはカード内で横スクロール */
  .card { overflow-x: auto; padding: 16px; }
  .card table { min-width: 560px; }

  .login-box { margin: 8vh 16px 0; padding: 28px 22px 24px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Slack archive: all content and attachment access is checked on the server. */
.slack-search { display:flex; flex-wrap:wrap; gap:12px; align-items:end; }
.slack-search label { display:flex; flex-direction:column; gap:5px; flex:1 1 150px; }
.slack-search input { width:100%; min-width:0; }
.slack-message { margin-bottom:12px; }
.slack-image { display:block; max-width:100%; max-height:360px; object-fit:contain; margin-bottom:8px; border-radius:6px; }
.slack-identity-form { display:flex; gap:12px; align-items:end; padding:16px 0; border-bottom:1px solid var(--rule); }
.slack-identity-form label { display:flex; flex:1; min-width:0; flex-direction:column; gap:6px; }
.slack-identity-form small { overflow-wrap:anywhere; }
@media(max-width:760px) { .slack-identity-form { flex-direction:column; align-items:stretch; } }
