/* ==========================================================
   client-portal スタイル — 案B「ソフトグラス」
   淡いオーロラ背景 × すりガラスカード × インディゴ→スカイのグラデ
   HTML構造は初版から変更なし（クラス互換）
   ========================================================== */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink: #232046;
  --sub: #6a678c;
  --accent1: #6366f1;
  --accent2: #0ea5e9;
  --grad: linear-gradient(90deg, #6366f1, #0ea5e9);
  --glass: rgba(255, 255, 255, .62);
  --glass-strong: rgba(255, 255, 255, .8);
  --glass-line: rgba(255, 255, 255, .85);
  --ink-line: rgba(35, 32, 70, .08);
  --danger: #dc2626;
  --success: #0f9d6e;
  --warn-ink: #9a3412;
  --warn-bg: rgba(255, 237, 213, .85);
  --radius: 20px;
  --shadow: 0 4px 24px rgba(99, 102, 241, .08);
  --shadow-hover: 0 18px 44px rgba(99, 102, 241, .18);
}

body {
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif;
  background: #f4f4fb;
  color: var(--ink);
  line-height: 1.7;
  font-size: 14px;
  min-height: 100vh;
}

/* ---------- オーロラ背景（全ページ共通・固定レイヤー） ---------- */

body::before {
  content: "";
  position: fixed; inset: -20%;
  z-index: -1;
  background:
    radial-gradient(42% 38% at 14% 8%,  #c7d2fe 0%, transparent 65%),
    radial-gradient(36% 34% at 88% 20%, #bae6fd 0%, transparent 65%),
    radial-gradient(38% 36% at 45% 96%, #fbcfe8 0%, transparent 65%);
  opacity: .55;
  pointer-events: none;
}
@media (prefers-reduced-motion: no-preference) {
  body::before { animation: aurora 26s ease-in-out infinite alternate; }
  @keyframes aurora {
    from { transform: translate(0, 0) scale(1); }
    to   { transform: translate(3%, 2%) scale(1.06); }
  }
}

a { color: var(--accent1); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 21px; line-height: 1.4; font-weight: 800; letter-spacing: .01em; }
h2 { font-size: 16px; }

.muted { color: var(--sub); font-size: 12px; }
.ta-r { text-align: right; white-space: nowrap; }

/* ---------- ガラス面の共通定義 ---------- */

.panel, .project-card, .stat-card, .login-box, .topbar-inner, .sidebar,
.empty-state, .builder-card {
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-line);
  box-shadow: var(--shadow);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .panel, .project-card, .stat-card, .login-box, .topbar-inner, .sidebar,
  .empty-state, .builder-card { background: rgba(255, 255, 255, .92); }
}

/* ---------- レイアウト（クライアント側） ---------- */

.topbar { padding: 18px 20px 0; }
.topbar-inner {
  max-width: 960px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  height: 54px; padding: 0 12px 0 24px;
  border-radius: 999px;
}
.brand {
  font-size: 15px; font-weight: 800; letter-spacing: .01em;
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.brand:hover { text-decoration: none; }
.topnav { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.topnav a {
  color: var(--sub); padding: 7px 15px; border-radius: 999px; transition: all .15s;
}
.topnav a:hover { background: rgba(255, 255, 255, .75); color: var(--ink); text-decoration: none; }
.whoami { color: var(--sub); font-size: 12px; margin-right: 6px; }

.container { max-width: 960px; margin: 0 auto; padding: 30px 20px 48px; }
.footer { margin-top: 40px; }
.footer .container { padding: 16px 20px 28px; font-size: 12px; color: var(--sub); }

/* ---------- レイアウト（管理側） ---------- */

.admin-shell { display: flex; min-height: 100vh; padding: 16px; gap: 16px; }
.sidebar {
  width: 224px; flex-shrink: 0;
  display: flex; flex-direction: column;
  border-radius: 24px;
  position: sticky; top: 16px;
  align-self: flex-start;
  max-height: calc(100vh - 32px);
}
.sidebar-brand {
  padding: 20px 18px 14px; font-weight: 800; font-size: 15px;
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.badge-admin {
  display: inline-block; margin-left: 6px; padding: 1px 8px; font-size: 10px;
  background: linear-gradient(90deg, #f59e0b, #f97316); color: #fff;
  border-radius: 999px; vertical-align: middle; font-weight: 700;
  -webkit-background-clip: border-box; background-clip: border-box;
  -webkit-text-fill-color: #fff;
}
.sidebar-nav { display: flex; flex-direction: column; padding: 6px 10px; gap: 3px; flex: 1; }
.sidebar-nav a {
  color: var(--sub); padding: 9px 15px; border-radius: 999px; font-size: 13px;
  font-weight: 600; transition: all .15s;
}
.sidebar-nav a:hover { background: rgba(255, 255, 255, .8); color: var(--ink); text-decoration: none; }
.sidebar-nav a.active { background: var(--ink); color: #fff; font-weight: 700; }
.sidebar-foot {
  padding: 14px 18px 16px; border-top: 1px solid var(--ink-line);
  display: flex; align-items: center; justify-content: space-between; font-size: 12px;
}
.sidebar-foot .whoami { color: var(--sub); }
.admin-main { flex: 1; padding: 14px 12px 40px; max-width: 1100px; min-width: 0; }

@media (max-width: 760px) {
  .admin-shell { flex-direction: column; padding: 12px; }
  .sidebar { width: 100%; position: static; max-height: none; }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; padding-bottom: 10px; }
  .admin-main { padding: 8px 0 40px; }
}

/* ---------- 共通部品 ---------- */

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 20px;
}
.breadcrumb { font-size: 12px; color: var(--sub); margin-bottom: 12px; }

.panel {
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 18px;
}
.panel-desc { font-size: 13px; color: #454263; }
.panel-title { font-size: 14px; font-weight: 800; margin-bottom: 14px; }
.panel-title-row {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px;
}
.panel-title-row .panel-title { margin-bottom: 0; }

.flash {
  padding: 11px 18px; border-radius: 14px; margin-bottom: 14px; font-size: 13px;
  border: 1px solid transparent;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.flash-success { background: rgba(209, 250, 229, .8); border-color: rgba(16, 185, 129, .25); color: #05603a; }
.flash-error { background: rgba(254, 226, 226, .85); border-color: rgba(220, 38, 38, .25); color: #b91c1c; }

.empty-state {
  border-radius: var(--radius);
  border-style: dashed; border-color: rgba(99, 102, 241, .25);
  padding: 46px 20px; text-align: center; color: var(--sub); font-size: 13px;
}

/* ---------- ボタン・フォーム ---------- */

.btn {
  display: inline-block; padding: 8px 18px;
  border: 1px solid rgba(99, 102, 241, .2);
  border-radius: 999px;
  background: rgba(255, 255, 255, .75); color: var(--ink);
  font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit;
  vertical-align: middle;
  transition: all .15s ease;
}
.btn:hover {
  background: #fff; border-color: rgba(99, 102, 241, .45);
  text-decoration: none; transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(99, 102, 241, .15);
}
.btn-primary {
  background: var(--grad); border-color: transparent; color: #fff; font-weight: 700;
}
.btn-primary:hover { background: var(--grad); filter: brightness(1.08); box-shadow: 0 6px 18px rgba(99, 102, 241, .35); }
.btn-danger { color: var(--danger); border-color: rgba(220, 38, 38, .3); }
.btn-danger:hover { background: rgba(254, 226, 226, .9); border-color: rgba(220, 38, 38, .5); box-shadow: 0 4px 14px rgba(220, 38, 38, .12); }
.btn-sm { padding: 4px 13px; font-size: 12px; }
.btn-lg { padding: 12px 32px; font-size: 15px; }
.btn-block { display: block; width: 100%; }
.btn[disabled] { opacity: .4; cursor: not-allowed; transform: none; box-shadow: none; }

.linklike {
  background: none; border: 0; color: var(--accent1); cursor: pointer;
  font-size: inherit; font-family: inherit; padding: 0;
}
.linklike:hover { text-decoration: underline; }
.inline-form { display: inline; }
.inline-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

input[type=text], input[type=email], input[type=password], input[type=date],
input[type=number], input[type=file], select, textarea {
  width: 100%; padding: 10px 15px;
  border: 1px solid rgba(99, 102, 241, .22);
  border-radius: 13px;
  font-size: 14px; font-family: inherit;
  background: rgba(255, 255, 255, .85); color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent1);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .18);
}
input::placeholder, textarea::placeholder { color: #a3a0bd; }
.inline-row select { width: auto; min-width: 240px; }
.inline-form select { width: auto; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; }
.form-grid .field-wide { grid-column: 1 / -1; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }

.field { margin-bottom: 4px; }
.field label, .field-label {
  display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px;
}
.field-help { font-size: 12px; color: var(--sub); margin-bottom: 6px; }
.req {
  display: inline-block; margin-left: 6px; padding: 0 8px; font-size: 10px;
  background: linear-gradient(90deg, #f43f5e, #f97316); color: #fff;
  border-radius: 999px; vertical-align: middle; font-weight: 700;
}
form .field + .field, .panel form .field { margin-bottom: 16px; }

.choice-group { display: flex; flex-direction: column; gap: 7px; }
.choice { display: flex; align-items: center; gap: 9px; font-size: 14px; cursor: pointer; }
.choice input { width: auto; accent-color: var(--accent1); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent1); }

.upload-form { display: flex; flex-direction: column; gap: 10px; max-width: 480px; }
.upload-form .btn { align-self: flex-start; padding-left: 28px; padding-right: 28px; }

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

.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-box {
  width: 100%; max-width: 404px;
  border-radius: 26px;
  padding: 40px 34px;
  box-shadow: 0 20px 60px rgba(99, 102, 241, .18);
}
.login-brand {
  font-size: 21px; text-align: center; font-weight: 800;
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.login-brand .badge-admin { -webkit-text-fill-color: #fff; }
.login-sub { text-align: center; color: var(--sub); font-size: 12px; margin: 4px 0 26px; }
.login-box label { display: block; font-size: 13px; font-weight: 700; margin: 15px 0 6px; }
.login-box .btn-block { margin-top: 26px; }
.login-note { margin-top: 22px; font-size: 11px; color: var(--sub); text-align: center; }

/* ---------- タグ・ステータス ---------- */

.tag {
  display: inline-block; padding: 2px 12px; border-radius: 999px;
  font-size: 11px; font-weight: 700;
}
.tag-active { background: var(--grad); color: #fff; }
.tag-completed { background: rgba(16, 185, 129, .16); color: #047857; }
.tag-archived { background: rgba(35, 32, 70, .08); color: var(--sub); }
.tag-done { background: rgba(16, 185, 129, .16); color: #047857; }
.tag-pending { background: var(--warn-bg); color: var(--warn-ink); }
.tag-step-pending { background: rgba(35, 32, 70, .08); color: var(--sub); }
.tag-step-in_progress { background: rgba(99, 102, 241, .15); color: #4338ca; }
.tag-step-done { background: rgba(16, 185, 129, .16); color: #047857; }

.notice-chip {
  display: inline-block; background: var(--warn-bg); color: var(--warn-ink);
  padding: 3px 13px; border-radius: 999px; font-size: 11px; font-weight: 700;
}
.service-name { font-size: 12px; color: var(--sub); margin-left: 8px; }

/* ---------- 案件カード（クライアント） ---------- */

.project-list { display: flex; flex-direction: column; gap: 16px; }
.project-card {
  display: block;
  border-radius: 22px;
  padding: 22px 24px; color: var(--ink);
  transition: transform .2s ease, box-shadow .2s ease;
}
.project-card:hover {
  text-decoration: none;
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
}
.project-card-head { margin-bottom: 6px; }
.project-card-title { font-size: 16px; margin-bottom: 12px; font-weight: 700; }
.project-card-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px;
}

/* ---------- 進捗バー・タイムライン ---------- */

.progress-line { display: flex; align-items: center; gap: 12px; }
.progress-line-lg { margin-bottom: 26px; }
.progress-bar {
  flex: 1; height: 8px; background: rgba(99, 102, 241, .13); border-radius: 4px; overflow: hidden;
}
.progress-bar span { display: block; height: 100%; background: var(--grad); border-radius: 4px; }
.progress-pct { font-size: 12px; color: var(--sub); white-space: nowrap; font-variant-numeric: tabular-nums; }

.timeline { list-style: none; }
.timeline-item { position: relative; padding: 0 0 24px 34px; }
.timeline-item::before {
  /* 接続線：マーカー中心（left 8px）に正確に揃える */
  content: ""; position: absolute; left: 8px; top: 21px; bottom: -3px; width: 2px;
  background: rgba(99, 102, 241, .18); transform: translateX(-50%);
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item:last-child::before { display: none; }
.timeline-marker {
  position: absolute; left: 0; top: 4px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; border: 3px solid #cfcde4;
}
.timeline-item.st-in_progress .timeline-marker {
  border-color: var(--accent1);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, .16);
}
.timeline-item.st-done .timeline-marker {
  border-color: var(--accent1);
  background: var(--accent1);
}
.timeline-item.st-done::before { background: rgba(99, 102, 241, .45); }
.timeline-head { display: flex; align-items: center; gap: 10px; margin-bottom: 2px; }

/* ---------- テーブル ---------- */

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 11px 10px; border-bottom: 1px solid var(--ink-line); text-align: left; vertical-align: middle; }
.table thead th { font-size: 11.5px; color: var(--sub); font-weight: 700; letter-spacing: .04em; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: rgba(255, 255, 255, .55); }
.table tbody tr:last-child td { border-bottom: 0; }
.row-disabled td { opacity: .5; }
.table-response th { width: 34%; font-size: 12px; vertical-align: top; color: var(--sub); }

/* ---------- タブ ---------- */

.tabs {
  display: inline-flex; gap: 3px; flex-wrap: wrap;
  background: var(--glass);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border: 1px solid var(--glass-line);
  border-radius: 999px; padding: 5px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.tabs a {
  padding: 7px 17px; font-size: 12.5px; color: var(--sub);
  border-radius: 999px; font-weight: 600; transition: all .15s;
}
.tabs a:hover { text-decoration: none; color: var(--ink); background: rgba(255, 255, 255, .7); }
.tabs a.active { color: #fff; background: var(--ink); font-weight: 700; }

/* ---------- メッセージスレッド ---------- */

.thread { display: flex; flex-direction: column; gap: 14px; margin-bottom: 22px; }
.msg { max-width: 76%; }
.msg-me { align-self: flex-end; }
.msg-them { align-self: flex-start; }
.msg-meta { font-size: 11px; color: var(--sub); margin-bottom: 4px; }
.msg-me .msg-meta { text-align: right; }
.msg-body {
  padding: 10px 15px; border-radius: 6px 16px 16px 16px;
  font-size: 13px; word-break: break-word;
  background: rgba(255, 255, 255, .8);
  border: 1px solid var(--glass-line);
}
.msg-me .msg-body {
  background: linear-gradient(90deg, rgba(99, 102, 241, .14), rgba(14, 165, 233, .14));
  border-color: rgba(99, 102, 241, .2);
  border-radius: 16px 6px 16px 16px;
}
.msg-form { display: flex; flex-direction: column; gap: 10px; }
.msg-form .btn { align-self: flex-end; }

/* ---------- ダッシュボード統計（管理） ---------- */

.stat-row { display: flex; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.stat-card {
  flex: 1; min-width: 160px;
  border-radius: var(--radius);
  padding: 20px 22px;
}
.stat-num {
  font-size: 32px; font-weight: 800; line-height: 1.2;
  font-variant-numeric: tabular-nums;
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  display: inline-block;
}
.stat-label { font-size: 12px; color: var(--sub); margin-top: 2px; }

.filter-links { display: flex; gap: 4px; font-size: 12px; }
.filter-links a { color: var(--sub); padding: 4px 12px; border-radius: 999px; transition: all .12s; }
.filter-links a:hover { color: var(--ink); background: rgba(255, 255, 255, .7); text-decoration: none; }
.filter-links a.active { color: #fff; background: var(--ink); font-weight: 700; }

.select-status { font-size: 12px; padding: 6px 10px; border-radius: 999px; }
.select-status.st-done { border-color: rgba(16, 185, 129, .5); background: rgba(209, 250, 229, .7); }
.select-status.st-in_progress { border-color: rgba(99, 102, 241, .5); background: rgba(224, 231, 255, .7); }

/* ---------- ファイルプレビュー ---------- */

.file-name-cell { display: flex; align-items: center; gap: 12px; }
.file-thumb {
  width: 48px; height: 48px; object-fit: cover; border-radius: 12px;
  border: 1px solid var(--glass-line); background: rgba(255, 255, 255, .6);
  flex-shrink: 0; display: block;
  transition: transform .15s;
}
a:hover > .file-thumb { transform: scale(1.06); }

/* ---------- タイムライン（活動履歴） ---------- */

.feed { list-style: none; }
.feed-item {
  display: flex; align-items: baseline; gap: 12px; padding: 11px 4px;
  border-bottom: 1px solid var(--ink-line); font-size: 13px; flex-wrap: wrap;
}
.feed-item:last-child { border-bottom: 0; }
.feed-time { color: var(--sub); font-size: 12px; white-space: nowrap; min-width: 110px; font-variant-numeric: tabular-nums; }
.feed-actor {
  display: inline-block; padding: 1px 11px; border-radius: 999px;
  font-size: 11px; font-weight: 700; white-space: nowrap;
}
.feed-actor-staff { background: rgba(99, 102, 241, .15); color: #4338ca; }
.feed-actor-client { background: rgba(16, 185, 129, .16); color: #047857; }
.feed-text { flex: 1; min-width: 200px; word-break: break-word; }

/* ---------- フォームビルダー ---------- */

.builder-card {
  border-radius: 18px;
  padding: 16px 18px; margin-bottom: 12px;
}
.builder-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.builder-head select { width: auto; font-size: 13px; padding: 6px 12px; }
.builder-num {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--grad); color: #fff;
  font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.builder-req { display: flex; align-items: center; gap: 5px; font-size: 12px; cursor: pointer; }
.builder-req input { width: auto; }
.builder-spacer { flex: 1; }
.builder-label { font-weight: 700; margin-bottom: 8px; }
.builder-options, .builder-sub { margin-bottom: 8px; font-size: 13px; }

/* ---------- 管理画面の使い勝手部品 ---------- */

/* 新規作成フォームの折りたたみ */
details.create-box summary {
  cursor: pointer; font-size: 14px; font-weight: 800; color: var(--accent1);
  list-style: none; user-select: none; padding: 2px 0;
}
details.create-box summary::-webkit-details-marker { display: none; }
details.create-box summary:hover { opacity: .8; }
details.create-box[open] summary { margin-bottom: 16px; color: var(--ink); }
details.create-box summary:focus-visible { outline: 2px solid var(--accent1); outline-offset: 2px; border-radius: 6px; }

/* 検索バー */
.search-row { display: flex; gap: 8px; align-items: center; }
.search-row input[type=text] { width: 240px; padding: 7px 14px; font-size: 13px; }
.search-row-wide { margin-bottom: 14px; flex-wrap: wrap; }
.search-row-wide select { width: auto; min-width: 190px; padding: 7px 12px; font-size: 13px; }
.search-row .btn { flex-shrink: 0; }
@media (max-width: 700px) { .search-row input[type=text] { width: 100%; } }

/* パスワード自動生成 */
.pass-row { display: flex; gap: 8px; align-items: center; }
.pass-row .btn { flex-shrink: 0; white-space: nowrap; }

/* ---------- 案件管理（社内タスク・期日） ---------- */

.due { font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.due-over { color: var(--danger); font-weight: 700; }
.due-soon { color: var(--warn-ink); font-weight: 700; }

.attention-cell .notice-chip { margin: 1px 2px 1px 0; }
.chip-reply { background: rgba(224, 231, 255, .9); color: #4338ca; border: 0; }
.chip-task { background: rgba(35, 32, 70, .08); color: var(--sub); border: 0; }

.internal-mark {
  display: inline-block; margin-left: 8px; padding: 1px 10px; font-size: 10px; font-weight: 700;
  background: rgba(35, 32, 70, .08); color: var(--sub); border-radius: 999px; vertical-align: middle;
}
.internal-panel { border-style: dashed; border-color: rgba(99, 102, 241, .3); }

.task-add-row { align-items: stretch; }
.task-title-input { flex: 1; min-width: 220px; }
.task-add-row select, .task-add-row input[type=date] { width: auto; }

.stat-alert {
  background: linear-gradient(90deg, #f43f5e, #f97316);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ---------- メッセージ編集 ---------- */

.edited-mark { font-size: 10px; color: var(--sub); }
.msg-edit-link { font-size: 11px; }
.msg-edit-form { min-width: 320px; max-width: 100%; }
.msg-edit-form textarea { font-size: 13px; }
.msg-edit-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
@media (max-width: 500px) { .msg-edit-form { min-width: 0; } }

/* ---------- フォーカス（キーボード操作の可視化） ---------- */

.btn:focus-visible, .tabs a:focus-visible, .sidebar-nav a:focus-visible,
.topnav a:focus-visible, .linklike:focus-visible {
  outline: 2px solid var(--accent1); outline-offset: 2px;
}
