/* webharu-platform 管理画面 デザインシステム
   トーン: 和紙のような温かみのある白 × 墨色 × 春の若葉のアクセント */

:root {
  --bg: #faf9f6;
  --surface: #ffffff;
  --ink: #211f1c;
  --ink-2: #55524b;
  --muted: #8b877e;
  --line: #e8e5de;
  --accent: #3d7a5a;
  --accent-soft: #e7f1ea;
  --danger: #b4443c;
  --danger-soft: #f7e9e8;
  --warn: #a07322;
  --warn-soft: #f6efe0;
  --info-soft: #e8eef6;
  --info: #3a5f8a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(33, 31, 28, 0.04), 0 4px 16px rgba(33, 31, 28, 0.05);
  --font: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Hiragino Kaku Gothic ProN', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 15px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- レイアウト ---- */
.layout { display: flex; min-height: 100vh; }
/* サイドバー開閉トグル（admin.jsが生成・状態はlocalStorage） */
.sb-toggle {
  position: fixed; left: 224px; top: 14px; z-index: 60;
  width: 24px; height: 34px; padding: 0;
  border: 1px solid var(--line); border-left: none; border-radius: 0 8px 8px 0;
  background: var(--surface); color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: left 0.16s ease;
}
.sb-toggle svg { width: 15px; height: 15px; stroke: currentColor; }
.sb-toggle:hover { color: var(--ink); }
body.sb-closed .sidebar { display: none; }
body.sb-closed .sb-toggle { left: 0; }
@media (max-width: 860px) { .sb-toggle { display: none; } }
.sidebar {
  width: 224px; flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 28px 16px;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand {
  font-weight: 700; font-size: 1.05rem; letter-spacing: 0.04em;
  padding: 0 12px 20px; color: var(--ink);
}
.sidebar .brand small { display: block; font-weight: 400; font-size: 0.7rem; color: var(--muted); letter-spacing: 0.12em; margin-top: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px;
  color: var(--ink-2); font-size: 0.92rem;
}
.nav-item svg { width: 17px; height: 17px; stroke: currentColor; flex-shrink: 0; }
.nav-item:hover { background: var(--bg); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item .grow { flex: 1; }
.sidebar .spacer { flex: 1; }

/* ---- 2段式サイドバー: 全体 / クライアント ---- */
.nav-group {
  font-size: 0.66rem; font-weight: 600; letter-spacing: 0.16em;
  color: var(--muted); padding: 16px 12px 5px; user-select: none;
}
.tenant-list { flex: 1; min-height: 48px; overflow-y: auto; overscroll-behavior: contain; margin: 0 -6px; padding: 0 6px; }
.tenant-row {
  display: flex; align-items: center; gap: 7px; width: 100%;
  padding: 8px 10px; border: none; border-radius: 8px;
  background: none; font-family: var(--font); font-size: 0.9rem;
  color: var(--ink-2); cursor: pointer; text-align: left;
}
.tenant-row:hover { background: var(--bg); }
.tenant-row .chev { width: 11px; height: 11px; stroke: currentColor; opacity: 0.5; flex-shrink: 0; transition: transform 0.16s; }
.tenant-row.open .chev { transform: rotate(90deg); }
.tenant-row .t-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; color: var(--ink); }
.tenant-sub { display: none; margin: 1px 0 8px 15px; padding-left: 10px; border-left: 2px solid var(--line); }
.tenant-sub.open { display: block; }
.tenant-sub .nav-item { padding: 6px 10px; font-size: 0.87rem; }
.tenant-sub .nav-item svg { width: 15px; height: 15px; }
.tenant-filter {
  width: 100%; margin: 2px 0 8px; padding: 6px 10px !important;
  font-size: 0.83rem !important; border-radius: 8px;
}

/* ---- 外出モード（サイドバー常設カード）---- */
.away-card {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px 9px; margin: 10px 2px 8px; background: var(--bg);
}
.away-card .row1 { display: flex; align-items: center; gap: 8px; }
.away-card .t { font-size: 0.82rem; font-weight: 600; flex: 1; }
.away-card .d { font-size: 0.72rem; color: var(--muted); line-height: 1.55; margin-top: 4px; }
.away-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); flex-shrink: 0; transition: background 0.2s; }
.away-card.on { border-color: var(--accent-soft); background: var(--accent-soft); }
.away-card.on .away-dot { background: var(--accent); box-shadow: 0 0 0 3px rgba(61, 122, 90, 0.18); }
.switch {
  width: 34px; height: 20px; border-radius: 999px; border: none;
  background: var(--line); cursor: pointer; position: relative;
  flex-shrink: 0; transition: background 0.16s; padding: 0;
}
.switch::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%; background: var(--surface);
  box-shadow: 0 1px 2px rgba(33, 31, 28, 0.25); transition: left 0.16s;
}
.switch.on { background: var(--accent); }
.switch.on::after { left: 16px; }
.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  .tenant-row .chev, .switch, .switch::after, .away-dot { transition: none; }
}

.main { flex: 1; padding: 36px 44px 80px; max-width: 1160px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 28px; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 1.45rem; font-weight: 700; letter-spacing: 0.02em; }
.page-head .sub { color: var(--muted); font-size: 0.88rem; margin-top: 4px; }

/* ---- カード ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}
.card h2 { font-size: 1.02rem; font-weight: 700; margin-bottom: 16px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }

.stat { padding: 20px 24px; }
.stat .label { font-size: 0.8rem; color: var(--muted); letter-spacing: 0.06em; }
.stat .value { font-size: 1.9rem; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .value.accent { color: var(--accent); }

/* ---- テーブル ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th {
  text-align: left; font-weight: 600; color: var(--muted); font-size: 0.78rem;
  letter-spacing: 0.08em; padding: 8px 12px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--bg); }

/* ---- バッジ ---- */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 0.75rem; font-weight: 600; white-space: nowrap;
}
.badge.green { background: var(--accent-soft); color: var(--accent); }
.badge.gray { background: #f0eee9; color: var(--ink-2); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.amber { background: var(--warn-soft); color: var(--warn); }
.badge.blue { background: var(--info-soft); color: var(--info); }

/* ---- ボタン ---- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 18px; border-radius: 8px; border: 1px solid transparent;
  font-family: var(--font); font-size: 0.88rem; font-weight: 600;
  cursor: pointer; background: var(--ink); color: #fff;
  transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn.secondary:hover { background: var(--bg); opacity: 1; }
.btn.danger { background: var(--surface); color: var(--danger); border-color: var(--danger-soft); }
.btn.accent { background: var(--accent); }
.btn.sm { padding: 5px 12px; font-size: 0.8rem; }

/* ---- フォーム ---- */
label.field { display: block; margin-bottom: 14px; }
label.field .name { display: block; font-size: 0.82rem; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
input[type='text'], input[type='email'], input[type='password'], input[type='url'], input[type='date'], input[type='time'], input[type='number'], select, textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 8px;
  font-family: var(--font); font-size: 0.9rem; color: var(--ink);
  background: var(--surface);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { min-height: 110px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.help { font-size: 0.78rem; color: var(--muted); margin-top: 4px; }

/* ---- モーダル ---- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(33, 31, 28, 0.35);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 8vh 20px; z-index: 100;
}
.modal {
  background: var(--surface); border-radius: 14px; box-shadow: 0 24px 64px rgba(0, 0, 0, 0.18);
  width: 100%; max-width: 560px; padding: 28px; max-height: 84vh; overflow-y: auto;
}
.modal h2 { font-size: 1.1rem; margin-bottom: 18px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* ---- トースト ---- */
#toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 22px; border-radius: 999px;
  font-size: 0.87rem; box-shadow: var(--shadow); z-index: 200;
  opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
#toast.show { opacity: 1; }
#toast.error { background: var(--danger); }

/* ---- 空状態 ---- */
.empty { text-align: center; color: var(--muted); padding: 44px 20px; font-size: 0.9rem; }

/* ---- ログイン ---- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow); padding: 44px 40px; width: 100%; max-width: 400px;
}
.login-card .brand { text-align: center; font-weight: 700; font-size: 1.2rem; letter-spacing: 0.05em; margin-bottom: 4px; }
.login-card .sub { text-align: center; color: var(--muted); font-size: 0.8rem; letter-spacing: 0.1em; margin-bottom: 30px; }

/* ---- タブ ---- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tab {
  padding: 8px 18px; font-size: 0.9rem; font-weight: 600; color: var(--muted);
  border: none; background: none; cursor: pointer; font-family: var(--font);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---- ユーティリティ ---- */
.mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 0.82em; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.flex { display: flex; align-items: center; gap: 10px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
code.pill {
  background: #f0eee9; padding: 2px 8px; border-radius: 6px;
  font-family: ui-monospace, Menlo, monospace; font-size: 0.8em;
}

@media (max-width: 800px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; padding: 14px; }
  .sidebar .brand { padding: 4px 12px 12px; }
  .tenant-list { max-height: 40vh; flex: none; }
  .main { padding: 20px; }
  .form-row { grid-template-columns: 1fr; }
}
