:root {
  --blue:#185FA5;
  --blue-dark:#0f3d6b;
  --blue-light:#dbeafe;
  --border:#d8dde4;
  --text:#1f2937;
  --muted:#6b7280;
  --bg:#f5f7fa;
  --white:#fff;
  --red:#dc2626;
  --green:#166534;
  --amber:#b45309;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Hiragino Sans", "Meiryo", "Yu Gothic", "Noto Sans JP", sans-serif;
  font-size: 14px; color: var(--text); background: var(--bg); line-height: 1.55;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── ヘッダー ── */
.top-bar { background: var(--blue); color: #fff; border-bottom: 1px solid var(--blue-dark); position: sticky; top: 0; z-index: 20; }
.top-inner { display: flex; align-items: center; gap: 14px; padding: 8px 16px; flex-wrap: wrap; }
.brand { color: #fff; font-weight: bold; font-size: 16px; }
.brand:hover { text-decoration: none; opacity: 0.9; }
.top-nav { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
.nav-link { color: rgba(255,255,255,0.85); padding: 6px 12px; border-radius: 4px; font-size: 13px; }
.nav-link:hover { background: rgba(255,255,255,0.12); text-decoration: none; color: #fff; }
.nav-link.on { background: rgba(255,255,255,0.22); color: #fff; font-weight: bold; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.btn { padding: 6px 14px; border-radius: 4px; font-size: 13px; font-weight: bold; border: 1px solid transparent; cursor: pointer; display: inline-block; }
.btn-primary { background: #fff; color: var(--blue); }
.btn-primary:hover { background: #e5efff; text-decoration: none; }
.btn-secondary { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-ghost { background: #fff; color: var(--muted); border-color: var(--border); }
.btn-danger { background: var(--red); color: #fff; }
.link-button { background: none; border: none; color: inherit; font: inherit; cursor: pointer; padding: 0; }

.user-menu { position: relative; }
.user-menu .user-name { color: #fff; padding: 6px 10px; border: 1px solid rgba(255,255,255,0.3); border-radius: 4px; cursor: pointer; font-size: 13px; }
.user-dropdown { position: absolute; right: 0; top: 100%; margin-top: 4px; background: #fff; border: 1px solid var(--border); border-radius: 4px; min-width: 150px; display: none; box-shadow: 0 4px 12px rgba(0,0,0,0.1); z-index: 25; }
.user-menu:hover .user-dropdown, .user-menu:focus-within .user-dropdown { display: block; }
.user-dropdown a, .user-dropdown button { display: block; padding: 8px 14px; color: var(--text); font-size: 13px; width: 100%; text-align: left; border: none; background: #fff; }
.user-dropdown a:hover, .user-dropdown button:hover { background: var(--bg); text-decoration: none; }

/* ── メッセージ ── */
.messages-box { max-width: 1400px; margin: 8px auto 0; padding: 0 16px; }
.msg { padding: 8px 14px; border-radius: 4px; margin-bottom: 6px; font-size: 13px; }
.msg-success { background: #dcfce7; color: #14532d; }
.msg-error   { background: #fee2e2; color: #7f1d1d; }
.msg-info, .msg-warning { background: #fef3c7; color: #78350f; }

.main-wrap { max-width: 1400px; margin: 0 auto; padding: 16px; }
.foot { text-align: center; font-size: 11px; color: var(--muted); padding: 14px; }

/* ── ツールバー ── */
.toolbar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: #fff; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.toolbar .title { font-weight: bold; font-size: 15px; color: var(--text); }
.toolbar .sp { flex: 1; }
.toolbar .btn { font-size: 12px; padding: 5px 10px; }

/* ── グループビュー ── */
.group-view { background: #fff; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.gv-dept-head {
  background: #f1f5f9; color: var(--blue-dark); font-weight: bold; font-size: 13px;
  padding: 6px 12px; border-top: 1px solid var(--border);
}
.gv-dept-head:first-child { border-top: none; }
.gv-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 12px; }
.gv-table th, .gv-table td { border: 1px solid var(--border); padding: 3px 4px; vertical-align: top; }
.gv-table thead th { background: #f8fafc; color: var(--muted); font-weight: bold; font-size: 11px; text-align: center; padding: 5px 2px; }
.gv-table thead th.today { background: var(--blue-light); color: var(--blue-dark); }
.gv-table thead th.sat   { color: var(--blue); }
.gv-table thead th.sun   { color: var(--red); }
.gv-table th.member-col { width: 130px; background: #f8fafc; text-align: left; padding: 4px 6px; }
.gv-table td.member-cell { background: #fafbfc; padding: 5px 8px; font-size: 12px; }
.gv-table td.today { background: #f0f7ff; }
.gv-table td.sat, .gv-table td.sun { background: #f8fafc; }
.member { display: flex; align-items: center; gap: 6px; }
.avatar { width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: bold; color: #1f2937; flex-shrink: 0; }
.member-name { font-size: 12px; font-weight: bold; }
.member-position { font-size: 10px; color: var(--muted); }
.ev-chip {
  display: block; padding: 2px 5px; border-radius: 3px;
  font-size: 11px; font-weight: bold;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 2px; cursor: pointer; border: 1px solid transparent;
}
.ev-chip:hover { text-decoration: none; filter: brightness(0.95); }
.ev-time { font-size: 9px; font-weight: normal; opacity: 0.7; margin-right: 3px; }
.gv-table td:hover { outline: 1px solid var(--blue-light); }
.cell-link { display: block; min-height: 44px; color: inherit; }
.cell-link:hover { text-decoration: none; background: #eff6ff; }

/* ── 個人ビュー ── */
.uv-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.uv-table th, .uv-table td { border-bottom: 1px solid var(--border); padding: 10px 12px; font-size: 13px; text-align: left; }
.uv-table th.dh { width: 120px; background: #f8fafc; color: var(--muted); vertical-align: top; }
.uv-ev { padding: 6px 10px; border-radius: 4px; margin-bottom: 5px; }
.uv-ev .time { font-size: 11px; color: var(--muted); margin-right: 8px; }

/* ── 予定フォーム ── */
.form-wrap { max-width: 860px; margin: 0 auto; background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 20px; }
.form-wrap h1 { font-size: 18px; margin-bottom: 16px; color: var(--blue-dark); }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; font-weight: bold; color: var(--muted); margin-bottom: 4px; }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 4px;
  font-size: 14px; font-family: inherit; background: #fff;
}
.form-textarea { resize: vertical; }
.form-row { display: flex; gap: 14px; }
.form-row .form-group { flex: 1; }
.form-help { font-size: 11px; color: var(--muted); margin-top: 2px; }
.form-error { font-size: 12px; color: var(--red); margin-top: 2px; }
.form-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; border-top: 1px solid var(--border); padding-top: 14px; }

/* ── 予定詳細 ── */
.detail-wrap { max-width: 760px; margin: 0 auto; background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 20px; }
.detail-title { font-size: 20px; font-weight: bold; margin-bottom: 10px; }
.detail-chip { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 11px; font-weight: bold; margin-right: 6px; }
.detail-row { display: flex; gap: 14px; padding: 8px 0; border-bottom: 1px solid #f1f5f9; font-size: 14px; }
.detail-row .label { width: 110px; color: var(--muted); font-size: 12px; }
.detail-row .value { flex: 1; }
.participants-list { list-style: none; padding: 0; }
.participants-list li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid #f1f5f9; font-size: 13px; }
.st-pill { font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: bold; }
.st-pending { background: #fef3c7; color: #78350f; }
.st-accepted { background: #dcfce7; color: #14532d; }
.st-declined { background: #fee2e2; color: #7f1d1d; }
.st-tentative { background: #e0e7ff; color: #3730a3; }
.rsvp-group { display: flex; gap: 6px; margin-top: 12px; }

/* ── 行動予定表 ── */
.board-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: #fff; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.board-date { font-size: 15px; font-weight: bold; }
.dept-pill { display: inline-block; padding: 4px 12px; border-radius: 16px; font-size: 12px; border: 1px solid var(--border); color: var(--muted); background: #fff; }
.dept-pill.on { background: var(--blue-light); color: var(--blue-dark); border-color: #93c5fd; font-weight: bold; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px; }
.kpi-card { background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 10px 14px; }
.kpi-label { font-size: 11px; color: var(--muted); }
.kpi-value { font-size: 24px; font-weight: bold; margin-top: 2px; }
.kpi-unit  { font-size: 12px; color: var(--muted); font-weight: normal; margin-left: 3px; }
.board-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.board-table th, .board-table td { border-bottom: 1px solid var(--border); padding: 10px 14px; text-align: left; font-size: 13px; }
.board-table th { background: #f1f5f9; color: var(--muted); font-weight: bold; font-size: 12px; }
.status-pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: bold; padding: 3px 10px; border-radius: 12px; white-space: nowrap; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.s-office { background: #dcfce7; color: #14532d; } .s-office .dot { background: #16a34a; }
.s-remote { background: #dbeafe; color: #1e40af; } .s-remote .dot { background: #2563eb; }
.s-out { background: #fef3c7; color: #78350f; } .s-out .dot { background: #d97706; }
.s-trip { background: #ede9fe; color: #4c1d95; } .s-trip .dot { background: #7c3aed; }
.s-meeting { background: #fce7f3; color: #831843; } .s-meeting .dot { background: #db2777; }
.s-half_leave { background: #ffedd5; color: #9a3412; } .s-half_leave .dot { background: #dc2626; }
.s-leave { background: #f1f5f9; color: #475569; } .s-leave .dot { background: #64748b; }

/* ── 空き時間 ── */
.fb-body { display: grid; grid-template-columns: 220px 1fr; gap: 10px; }
.fb-side { background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 10px; font-size: 12px; max-height: 650px; overflow-y: auto; }
.fb-side .fl { font-weight: bold; color: var(--muted); margin-top: 10px; margin-bottom: 4px; font-size: 11px; }
.fb-side label { display: flex; align-items: center; gap: 5px; padding: 2px 0; font-size: 12px; }
.fb-main { background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 10px; }
.fb-grid { display: grid; font-size: 11px; }
.fb-h { text-align: center; font-weight: bold; padding: 4px; background: #f1f5f9; border: 1px solid var(--border); color: var(--muted); font-size: 11px; }
.fb-h.today { background: var(--blue-light); color: var(--blue-dark); }
.fb-t { padding: 4px; text-align: right; font-size: 10px; color: var(--muted); background: #f8fafc; border: 1px solid var(--border); }
.fb-c { height: 24px; border: 1px solid var(--border); }
.fb-c.free { background: #dcfce7; }
.fb-c.busy_full { background: #fecaca; }
.fb-c.busy_partial { background: #fef3c7; }
.fb-legend { display: flex; gap: 14px; margin-top: 8px; font-size: 11px; color: var(--muted); }
.fb-legend .box { width: 12px; height: 12px; border-radius: 2px; margin-right: 4px; display: inline-block; vertical-align: middle; }
.fb-sugg { margin-top: 12px; display: flex; gap: 6px; flex-wrap: wrap; }
.fb-sugg a { padding: 4px 10px; background: #dcfce7; color: #14532d; border-radius: 4px; border: 1px solid #86efac; font-size: 12px; font-weight: bold; }

/* ── 休暇申請 ── */
.leave-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.leave-table th, .leave-table td { border-bottom: 1px solid var(--border); padding: 10px 12px; font-size: 13px; text-align: left; }
.leave-table th { background: #f1f5f9; color: var(--muted); font-weight: bold; font-size: 12px; }
.st-leave { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 11px; font-weight: bold; }
.sl-submitted { background: #fef3c7; color: #78350f; }
.sl-approved_1 { background: #e0e7ff; color: #3730a3; }
.sl-approved { background: #dcfce7; color: #14532d; }
.sl-rejected { background: #fee2e2; color: #7f1d1d; }
.sl-canceled { background: #f1f5f9; color: #475569; }
.sl-draft { background: #f1f5f9; color: #475569; }

/* ── ログイン ── */
.login-wrap { max-width: 360px; margin: 60px auto; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 28px 24px; box-shadow: 0 2px 12px rgba(0,0,0,0.04); }
.login-wrap h1 { font-size: 20px; text-align: center; color: var(--blue-dark); margin-bottom: 20px; }
.login-wrap .btn { width: 100%; padding: 10px; font-size: 14px; }
.btn-login { background: var(--blue); color: #fff; }
.btn-login:hover { background: var(--blue-dark); text-decoration: none; }

/* ── 常時表示モード ── */
.screen-mode .top-bar, .screen-mode .foot { display: none; }
.screen-mode .main-wrap { max-width: 100%; padding: 10px; }
.screen-mode .kpi-value { font-size: 36px; }
.screen-mode .board-table th, .screen-mode .board-table td { padding: 14px 18px; font-size: 16px; }
.screen-mode .status-pill { font-size: 14px; }

/* ── レスポンシブ ── */
@media (max-width: 900px) {
  .top-inner { flex-wrap: wrap; gap: 8px; }
  .top-nav { width: 100%; order: 3; overflow-x: auto; flex-wrap: nowrap; }
  .nav-link { white-space: nowrap; }
  .fb-body { grid-template-columns: 1fr; }
  .gv-table th.member-col { width: 100px; }
  .gv-table { font-size: 11px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { flex-direction: column; }
  .detail-row { flex-direction: column; gap: 4px; }
  .detail-row .label { width: auto; }
}
@media (max-width: 600px) {
  .top-inner { padding: 6px 10px; }
  .main-wrap { padding: 8px; }
  .brand { font-size: 14px; }
  .btn { padding: 5px 10px; font-size: 12px; }
  .nav-link { padding: 5px 8px; font-size: 12px; }
  .user-name { font-size: 12px; padding: 5px 8px; }
  .ev-chip { font-size: 10px; padding: 1px 3px; }
  .gv-table { font-size: 10px; }
}
