/* === THEME VARS V6 (Final Optimized) === */
:root {
  --bg: #0b1020;
  --panel: rgba(255, 255, 255, .07);
  --panel2: rgba(255, 255, 255, .05);
  --text: #e5e7eb;
  --muted: rgba(229, 231, 235, .72);
  --line: rgba(255, 255, 255, .14);
  --lineb: rgb(29, 80, 247);
  --chip: rgba(255, 255, 255, .10);
  --shadow: 0 10px 25px rgba(0,0,0,.35);
  --input-bg: rgba(255, 255, 255, .08);
  --input-text: var(--text);
  --link: color-mix(in srgb, var(--text) 80%, #7c3aed);
  --radius2: 22px;
  
  /* Button Standard (Dark) */
  --btn-bg: rgba(255, 255, 255, .06);
  --btn-border: rgba(255, 255, 255, .12);
  --btn-text: var(--text);
  --btn-hover: rgba(255, 255, 255, .1);

  /* Notice (Dark) */
  --notice-bg: rgba(245, 158, 11, .15);
  --notice-border: rgba(245, 158, 11, .35);
  --notice-text: #ffe7bd;
}

html[data-theme="light"] {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --panel2: #f1f3f8;
  --text: #111827;
  --muted: #4b5563;
  --line: rgba(17, 24, 39, .12);
  --chip: #eef2ff;
  --shadow: 0 10px 25px rgba(0,0,0,.10);
  --input-bg: #ffffff;
  --input-text: #111827;
  --link: #4f46e5;

  /* Button Standard (Light) */
  --btn-bg: #ffffff;
  --btn-border: #d1d5db;
  --btn-text: #374151;
  --btn-hover: #f3f4f6;

  /* Notice (Light) */
  --notice-bg: #fff7ed;       /* Orange 50 */
  --notice-border: #fdba74;   /* Orange 300 */
  --notice-text: #9a3412;     /* Orange 800 (Dark Brown) */
}

/* Base Layout */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; overflow-x: hidden; font-family: sans-serif; }
body { background: var(--bg); color: var(--text); letter-spacing: .02em; }
a { text-decoration: none; color: inherit; transition: opacity .2s; }
a:hover { opacity: 0.8; }

/* Grid & Layout */
.container { display: flex; min-height: 100vh; }
.main { flex: 1; padding: 18px 16px 90px 16px; position: relative; width: 100%; }

/* Sidebar */
.sidebar {
  width: 280px; padding: 18px; border-right: 1px solid var(--line);
  background: var(--panel2); position: sticky; top: 0; height: 100vh;
  display: none; flex-direction: column; z-index: 50;
}
@media (min-width: 1180px) {
  .sidebar { display: flex; }
  .main { padding-bottom: 24px; }
  @media (max-width: 1300px) { .sidebar { width: 240px; } }
}

/* Header */
.header { margin-bottom: 12px; background: var(--panel); padding: 16px; border-radius: 16px; border: 1px solid var(--line); }
.header-top { display: flex; justify-content: space-between; align-items: flex-start; }
.header-bottom { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; flex-wrap: wrap; gap: 10px; }
.title h2 { margin: 0; font-size: 1.25rem; }
.title p { margin: 4px 0 0; color: var(--muted); font-size: 0.85rem; }

/* Components */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius2); padding: 16px; margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 768px) {
  .grid.cols-2 { grid-template-columns: 1fr 1fr; }
  .grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
}

/* UI Elements */
/* === Button Styles Updated === */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 16px; border-radius: 12px; cursor: pointer; font-size: 0.9rem;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  color: var(--btn-text);
  font-weight: 500;
  transition: all 0.2s ease;
}
.btn:hover {
  background: var(--btn-hover);
}

.btn.primary { 
  background: #6d28d9; /* Purple 700 */
  border: 1px solid rgba(255,255,255,0.1); 
  color: #ffffff; 
}
html[data-theme="light"] .btn.primary {
  background: #4f46e5; /* Indigo 600 */
  border-color: transparent;
  color: #ffffff;
}
.btn.primary:hover { filter: brightness(1.1); }

.btn.small { padding: 4px 10px; font-size: 0.8rem; }

/* Chips & Pills */
.chip {
  display: inline-flex; align-items: center; padding: 4px 10px; font-size: 0.8rem;
  border-radius: 99px; background: var(--chip); border: 1px solid var(--line);
}
.client-pill {
  display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 14px;
  background: var(--chip); border-radius: 99px; border: 1px solid var(--line); font-weight: bold;
}

/* Badges */
.badge { font-size: 0.75rem; padding: 2px 6px; border-radius: 4px; background: rgba(255,255,255,0.1); }
.badge.good { background: rgba(34, 197, 94, 0.2); color: #86efac; }
.badge.warn { background: rgba(234, 179, 8, 0.2); color: #fde047; }
.badge.bad { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }

html[data-theme="light"] .badge.good { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
html[data-theme="light"] .badge.warn { background: #fef9c3; color: #a16207; border: 1px solid #fde047; }
html[data-theme="light"] .badge.bad { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }

/* Table & Inputs */
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th { text-align: left; color: var(--muted); padding: 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px 8px; border-bottom: 1px solid var(--line); }
.input, .select, .textarea {
  width: 100%; padding: 10px; border-radius: 8px;
  background: var(--input-bg); border: 2px solid var(--lineb); color: var(--input-text);
}
.textarea {height:150px;}
.label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 6px; }

/* Notice / Note Styles Updated */
.notice, .note {
  margin-top: 8px; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--notice-border);
  background: var(--notice-bg);
  color: var(--notice-text);
  font-size: 13px; line-height: 1.6;
}
.note strong { font-weight: 700; }

/* Help text */
.help { font-size: 12px; color: var(--muted); line-height: 1.5; }

/* Bottom Nav */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: rgba(11, 16, 32, 0.95); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); display: flex; justify-content: space-around; padding: 8px;
}
html[data-theme="light"] .bottomnav {
  background: rgba(255, 255, 255, 0.95);
  border-top: 1px solid #e5e7eb;
}
.bottomnav a { display: flex; flex-direction: column; align-items: center; color: var(--muted); font-size: 0.7rem; gap: 4px; }
.bottomnav a.active { color: var(--link); }

/* Hide Bottom Nav on PC (Sidebar visible) */
@media (min-width: 1180px) { .bottomnav { display: none; } }

/* Hide Bottom Nav on Mobile (Hamburger visible) */
@media (max-width: 718px) { .bottomnav { display: none; } }

/* Logo & Nav */
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.logo {
  width: 40px; height: 40px; border-radius: 10px; background: var(--link);
  display: grid; place-items: center; color: #fff; font-weight: 900;
}
.nav a { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; color: var(--muted); margin-bottom: 4px; }
.nav a.active { background: rgba(255,255,255,0.05); color: var(--text); font-weight: bold; }
html[data-theme="light"] .nav a.active { background: rgba(0,0,0,0.05); color: #000; }


/* Chart placeholder */
.chart{
  width:100%;
  border:1px solid var(--line);
  border-radius:14px;
  background: color-mix(in srgb, var(--panel) 80%, transparent);
  padding:12px;
}

/* Mobile Header & Modal Adjustments */
@media (max-width: 718px){
  .header-top{ flex-direction:column; align-items:stretch; }
  .header-bottom{ flex-direction:column; align-items:stretch; }
  .header-bottom .row{ justify-content:flex-start; }
  #themeToggle{ width:44px; padding:10px 0; }
  .modal .cols{ grid-template-columns:1fr; }
}

/* Mobile Hamburger */
.hamburger-fab{
  position:fixed; right:16px; bottom:16px; width:56px; height:56px;
  border-radius:999px; display:none; align-items:center; justify-content:center;
  z-index:9998; border:1px solid var(--line);
  background: var(--panel); box-shadow: var(--shadow); color: var(--text);
}
/* Show ONLY when <= 718px */
@media (max-width: 718px){ .hamburger-fab{ display:flex; } }

.mobile-menu-backdrop{
  position:fixed; inset:0; z-index:9999; display:none; background: rgba(0,0,0,.55);
}
.mobile-menu-panel{
  position:absolute; right:12px; bottom:88px;
  width: min(320px, calc(100vw - 24px));
  max-height: min(70vh, 520px); overflow:auto;
  border-radius:18px; border:1px solid var(--line);
  background: var(--panel); box-shadow: var(--shadow); padding:12px;
}
.mobile-menu-panel .nav a { padding: 10px; }/* Status pills (added) */
.status{display:inline-flex;align-items:center;justify-content:center;padding:4px 10px;border-radius:999px;border:1px solid var(--line);font-size:.8rem;}
.status.ok{background:rgba(34,197,94,.18);color:#86efac;}
html[data-theme="light"] .status.ok{background:#dcfce7;color:#15803d;border:1px solid #bbf7d0;}


/* ===== Actions v7: compact card grid + toolbar ===== */
.card.compact{ padding:12px; margin-bottom:10px; }
.sub.small{ font-size:11px; line-height:1.35; opacity:.78; }
.chip.small{ padding:6px 10px; font-size:12px; }
.btn.tiny{ padding:6px 10px; font-size:12px; border-radius:10px; }
.action-card.compact{
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius2);
  padding: 10px;
  box-shadow: var(--shadow);
}
.action-card .ac-title{ font-weight:800; font-size:13px; line-height:1.25; }
.action-card .ac-badges{ display:flex; gap:6px; flex-wrap:wrap; align-items:center; margin-top:6px; }
.badge.mini{ font-size:11px; padding:2px 6px; border-radius:8px; }
.role.mini{ font-size:11px; padding:2px 8px; border-radius:999px; }
.action-card .ac-desc{ margin-top:8px; font-size:12px; color: var(--muted); line-height:1.35; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.action-card .ac-actions{ margin-top:10px; display:flex; gap:8px; justify-content:flex-end; flex-wrap:wrap; }

.gap-sm{gap:10px;}

.chip.filter.active{ background: var(--link); color:#000; border-color: transparent; }


/* ===== Actions v8: inline detail expand ===== */
.ac-detail{ margin-top:10px; padding:10px; border:1px dashed var(--line); border-radius:12px; background: rgba(255,255,255,.03); }
.ac-detail-title{ font-weight:800; font-size:12px; margin-bottom:6px; }
.ac-detail-body{ font-size:12px; color: var(--muted); line-height:1.45; white-space:pre-wrap; }

/* v9 Actions density tuning (追記) */

/* グリッド：PC 3列、タブレット 2列、スマホ 1列 */
#actionsWrap.grid.cols-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1100px){
  #actionsWrap.grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px){
  #actionsWrap.grid.cols-3 { grid-template-columns: 1fr; }
}

.gap-sm { gap: 10px; }

/* カードを小さく、情報密度を上げる */
.action-card.compact{
  padding: 10px;
  border-radius: 14px;
}

/* タイトル・説明の行数を抑えて一覧性 */
.action-card .ac-title{
  font-size: 13px;
  line-height: 1.25;
  font-weight: 800;
}
.action-card .ac-desc{
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ボタンは誤タップしにくい最小サイズ */
.btn.tiny{
  padding: 7px 10px;
  font-size: 12px;
  border-radius: 10px;
}
.action-card .ac-actions{
  margin-top: 10px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* 詳細（カード内展開） */
.ac-detail{
  margin-top: 10px;
  padding: 10px;
  border-radius: 12px;
  border: 1px dashed var(--line);
  background: rgba(255,255,255,.03);
}
.ac-detail-title{
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 6px;
}
.ac-detail-body{
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  color: var(--muted);
}

/* legend just under title (top legend) */
.legend.top{
  margin: 8px 0 10px;
  flex-wrap: wrap;
  row-gap: 6px;
}

/* prevent legend text from colliding with chips */
.card > hr { margin-top: 10px; }

/* keep chart area stable */
.chartHost{ overflow:hidden; }
.chart{ padding:12px; }

.legend{
  display:flex;
  gap:14px;
  align-items:center;
  color: var(--muted);
  font-size: 12px;
}
.legend-item{ display:inline-flex; gap:8px; align-items:center; }
.dot{
  width:10px; height:10px; border-radius:999px;
  background: currentColor; opacity:.6;
}
.dot.is-new{ opacity:.35; }
.dot.is-ret{ opacity:.55; }
.legend.top{ margin: 8px 0 10px; flex-wrap: wrap; row-gap: 6px; }
