/* dMemo — モバイルファーストCSS */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-border: #e2e8f0;
  --color-text: #1e293b;
  --color-text-muted: #64748b;
  --color-success: #16a34a;
  --color-warning: #d97706;
  --color-error: #dc2626;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1);
}

body { font-family: system-ui, -apple-system, sans-serif; background: var(--color-bg); color: var(--color-text); font-size: 16px; line-height: 1.5; }

/* ── ナビゲーション ── */
.nav { background: var(--color-surface); border-bottom: 1px solid var(--color-border); box-shadow: var(--shadow); position: sticky; top: 0; z-index: 100; }
.nav-inner { max-width: 1100px; margin: 0 auto; padding: 0 1rem; display: flex; align-items: center; justify-content: space-between; height: 56px; }
.nav-brand { font-weight: 700; font-size: 1.1rem; color: var(--color-primary); text-decoration: none; }
.nav-brand span { font-weight: 400; font-size: 0.75rem; color: var(--color-text-muted); margin-left: 4px; }
.nav-links { display: flex; gap: 1.5rem; list-style: none; }
.nav-links a { text-decoration: none; color: var(--color-text-muted); font-size: 0.9rem; transition: color .15s; }
.nav-links a:hover, .nav-links a.active { color: var(--color-primary); }
.nav-user { display: flex; align-items: center; gap: .75rem; }
.nav-user span { font-size: .85rem; color: var(--color-text-muted); }

/* ハンバーガー（モバイル） */
.nav-toggle { display: none; background: none; border: none; cursor: pointer; padding: 4px; }
.nav-toggle span { display: block; width: 24px; height: 2px; background: var(--color-text); margin: 5px 0; transition: transform .2s; }

/* ── メインレイアウト ── */
.main { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem; }

/* ── フラッシュメッセージ ── */
.flash { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: .9rem; }
.flash-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.flash-error { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }

/* ── カード ── */
.card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem; margin-bottom: 1rem; }
.card-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 1rem; }

/* ── フォーム ── */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: .35rem; color: var(--color-text); }
.form-control { width: 100%; padding: .5rem .75rem; border: 1px solid var(--color-border); border-radius: var(--radius); font-size: 1rem; color: var(--color-text); background: var(--color-surface); transition: border-color .15s; }
.form-control:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
textarea.form-control { min-height: 120px; resize: vertical; }
.form-hint { font-size: .78rem; color: var(--color-text-muted); margin-top: .25rem; }

/* ── ボタン ── */
.btn { display: inline-flex; align-items: center; justify-content: center; padding: .5rem 1.25rem; border-radius: var(--radius); font-size: .9rem; font-weight: 500; cursor: pointer; border: none; text-decoration: none; transition: background .15s, opacity .15s; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-secondary { background: var(--color-bg); color: var(--color-text); border: 1px solid var(--color-border); }
.btn-secondary:hover { background: var(--color-border); }
.btn-sm { padding: .3rem .75rem; font-size: .8rem; }

/* ── テーブル ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; padding: .6rem .75rem; background: var(--color-bg); border-bottom: 2px solid var(--color-border); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-muted); white-space: nowrap; }
td { padding: .6rem .75rem; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }

/* ── バッジ ── */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .5rem; border-radius: 99px; font-size: .75rem; font-weight: 500; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-done { background: #dcfce7; color: #166534; }
.badge-admin { background: #ede9fe; color: #6d28d9; }

/* ── ログイン画面 ── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login-card { width: 100%; max-width: 420px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 2rem; }
.login-logo { text-align: center; margin-bottom: 1.5rem; }
.login-logo h1 { font-size: 1.5rem; color: var(--color-primary); }
.login-logo p { font-size: .85rem; color: var(--color-text-muted); margin-top: .25rem; }

/* ── ダッシュボード ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 1rem 1.25rem; }
.stat-label { font-size: .78rem; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--color-primary); margin-top: .25rem; }

/* ── 業務履歴アコーディオン ── */
.log-group {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: .75rem;
  overflow: hidden;
}

.log-group-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
  cursor: pointer;
  user-select: none;
  list-style: none;
  background: var(--color-bg);
  border-bottom: 1px solid transparent;
  gap: 8px;
}

.log-group[open] > .log-group-summary {
  border-bottom-color: var(--color-border);
}

.log-group-summary::-webkit-details-marker { display: none; }

.log-group-summary::before {
  content: '＋';
  font-size: .85rem;
  font-weight: 700;
  color: var(--color-primary);
  flex-shrink: 0;
  width: 16px;
}

.log-group[open] > .log-group-summary::before {
  content: '－';
}

.log-group-label {
  flex: 1;
  font-size: .9rem;
  font-weight: 600;
  color: var(--color-text);
}

.log-group-count {
  font-size: .78rem;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.log-tag {
  display: inline-block;
  background: #e0e7ff;
  color: #3730a3;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: .75rem;
  margin-right: 2px;
}

.log-tag-ot {
  background: #fee2e2;
  color: #b91c1c;
}

/* ── フッター ── */
footer { text-align: center; padding: 1.5rem 1rem; font-size: .78rem; color: var(--color-text-muted); border-top: 1px solid var(--color-border); margin-top: 2rem; }

/* ── レスポンシブ（タブレット以上） ── */
@media (min-width: 640px) {
  .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
}

@media (max-width: 639px) {
  .nav-links { display: none; flex-direction: column; position: absolute; top: 56px; left: 0; right: 0; background: var(--color-surface); border-bottom: 1px solid var(--color-border); padding: 1rem; gap: .75rem; }
  .nav-links.open { display: flex; }
  .nav-toggle { display: block; }
  .nav-user span { display: none; }
  .main { padding: 1rem .75rem; }
  .card { padding: 1rem; }
}

/* ── 候補チップ（onboarding / chat 共通） ─────────────────── */
.chip {
  border: none;
  border-radius: 16px;
  padding: 5px 12px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  line-height: 1.4;
}
.chip:active { transform: scale(0.94); }
.chip-global {
  background: #e6f4ea;
  color: #1e6e37;
  font-weight: 500;
}
.chip-global:hover:not(:disabled) { background: #c8e6ce; }
.chip-global:disabled { cursor: default; }
