/* 猪野組ポータル — 配色は日報・備品アプリと同じロゴ実測値（#EB072A）＋落ち着いた地色 */
:root {
  --red: #EB072A;
  --red-dark: #C00622;
  --red-soft: #FDE7E9;
  --dark: #4F4F4F;
  --gray: #CACACA;
  --bg-soft: #F7F6F2;
  --text: #3A3A3A;
  --muted: #7A7A76;
  --white: #FFFFFF;
  --green: #2E7D32;
  --green-soft: #E6F4EA;
  --blue: #1D5A99;
  --blue-soft: #E3F0FA;
  --yellow: #F5C400;
  --warn-bg: #FFF6D9;
  --warn-fg: #8A6D00;
  --line: #E3E0D8;
  --radius: 12px;
  --shadow: 0 1px 4px rgba(0,0,0,.08);
  --nav-h: 60px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  background: var(--bg-soft); color: var(--text); font-size: 16px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; font-size: 16px; }
a { color: var(--blue); }
img { max-width: 100%; }
h1, h2, h3 { margin: 0 0 8px; color: var(--dark); line-height: 1.3; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 16px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); font-size: 14px; }
.sub { color: var(--muted); font-size: 14px; }
.small { font-size: 13px; }
.right { text-align: right; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.mt { margin-top: 12px; } .mb { margin-bottom: 12px; }

/* ---------- ヘッダー ---------- */
header.app-header {
  position: sticky; top: 0; z-index: 30; background: var(--white);
  border-bottom: 3px solid var(--red); display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; box-shadow: var(--shadow); height: 56px;
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--dark); }
.brand-logo { height: 26px; width: auto; }
.brand-name { font-weight: 700; font-size: 15px; white-space: nowrap; }
@media (max-width: 520px) {
  .brand-name { display: none; }                  /* 狭い画面はロゴだけ（名前を出すと折り返して重なる） */
  .person-badge { max-width: 46vw; overflow: hidden; text-overflow: ellipsis; }
}
.header-spacer { flex: 1; }
.person-badge { background: var(--bg-soft); border: 1px solid var(--line); border-radius: 999px; padding: 3px 12px; font-size: 13px; color: var(--dark); white-space: nowrap; }
.icon-btn { position: relative; background: none; border: none; font-size: 20px; cursor: pointer; padding: 4px 6px; text-decoration: none; color: var(--dark); line-height: 1; }
.badge { position: absolute; top: -4px; right: -6px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; min-width: 18px; height: 18px; line-height: 18px; text-align: center; padding: 0 5px; }
.badge.inline { position: static; display: inline-block; margin-left: 4px; }
.badge.dot { min-width: 10px; height: 10px; padding: 0; top: 0; right: -4px; }

/* ---------- レイアウト（PC＝左ナビ／スマホ＝下ナビ） ---------- */
.layout { display: flex; min-height: calc(100vh - 56px); }
.side-nav { display: none; }
.main { flex: 1; padding: 14px; padding-bottom: calc(var(--nav-h) + 20px); max-width: 1100px; width: 100%; margin: 0 auto; }
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: var(--white); border-top: 1px solid var(--line);
  display: flex; height: var(--nav-h); padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; color: var(--muted); text-decoration: none; }
.bottom-nav a .ic { font-size: 20px; position: relative; line-height: 1; }
.bottom-nav a.active { color: var(--red); font-weight: 700; }
@media (min-width: 900px) {
  .side-nav {
    display: flex; flex-direction: column; width: 220px; background: var(--white); border-right: 1px solid var(--line);
    padding: 12px 0; position: sticky; top: 56px; height: calc(100vh - 56px);
  }
  .side-nav a { display: block; padding: 10px 18px; color: var(--dark); text-decoration: none; font-size: 15px; border-left: 4px solid transparent; }
  .side-nav a:hover { background: var(--bg-soft); }
  .side-nav a.active { border-left-color: var(--red); background: var(--red-soft); font-weight: 700; }
  .side-foot { margin-top: auto; padding: 12px 18px; font-size: 13px; }
  .bottom-nav { display: none; }
  .main { padding: 24px; padding-bottom: 40px; }
}

/* ---------- 部品 ---------- */
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 14px; }
.card h2 { display: flex; align-items: center; gap: 8px; }
.card h2 .more { margin-left: auto; font-size: 13px; font-weight: 400; }
.btn { border: 1px solid var(--line); background: var(--white); color: var(--dark); border-radius: 10px; padding: 9px 16px; cursor: pointer; font-weight: 600; line-height: 1.3; }
.btn:hover { background: var(--bg-soft); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); }
.btn-danger { color: var(--red-dark); border-color: var(--red-soft); background: var(--red-soft); }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; display: block; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--blue); }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field input[type=text], .field input[type=date], .field input[type=email], .field input[type=tel], .field input[type=number], .field input[type=url], .field select, .field textarea {
  width: 100%; border: 1px solid var(--gray); border-radius: 8px; padding: 9px 10px; background: #fff;
}
.field textarea { min-height: 120px; resize: vertical; }
.field .check { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--text); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 600px) { .grid2 { grid-template-columns: 1fr; } }
.chip { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 700; background: var(--bg-soft); color: var(--dark); border: 1px solid var(--line); }
.chip.urgent { background: var(--red); color: #fff; border-color: var(--red); }
.chip.award { background: var(--yellow); color: #5A4500; border-color: var(--yellow); }
.chip.general { background: var(--blue-soft); color: var(--blue); border-color: var(--blue-soft); }
.chip.good { background: var(--green-soft); color: var(--green); border-color: var(--green-soft); }
.chip.hiyari { background: var(--warn-bg); color: var(--warn-fg); border-color: var(--warn-bg); }
.chip.done { background: var(--green-soft); color: var(--green); }
.chip.open { background: var(--red-soft); color: var(--red-dark); }
.chip.pin { background: var(--dark); color: #fff; border-color: var(--dark); }
.chip.new { background: var(--red); color: #fff; border-color: var(--red); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 14px; cursor: pointer; font-size: 14px; }
.tabs button.active { background: var(--dark); color: #fff; border-color: var(--dark); }
.empty { color: var(--muted); text-align: center; padding: 20px 0; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: none; }
.list a.item { display: block; color: inherit; text-decoration: none; }
.list a.item:hover .t { color: var(--red-dark); }
.list .t { font-weight: 600; }
.list .m { font-size: 13px; color: var(--muted); }
.table-wrap { overflow-x: auto; }
table.tbl { border-collapse: collapse; width: 100%; font-size: 14px; }
table.tbl th, table.tbl td { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: left; vertical-align: top; white-space: nowrap; }
table.tbl th { color: var(--muted); font-weight: 600; font-size: 12px; background: var(--bg-soft); }
.alert { border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; }
.alert.urgent { background: var(--red); color: #fff; font-weight: 700; }
.alert.urgent a { color: #fff; }
.alert.warn { background: var(--warn-bg); color: var(--warn-fg); }
.alert.info { background: var(--blue-soft); color: var(--blue); }

/* Markdown 本文 */
.md h1 { font-size: 20px; margin: 18px 0 8px; border-left: 5px solid var(--red); padding-left: 10px; }
.md h2 { font-size: 17px; margin: 16px 0 6px; }
.md h3 { font-size: 15px; margin: 12px 0 4px; }
.md ul, .md ol { padding-left: 22px; margin: 6px 0 10px; }
.md p { margin: 0 0 10px; }
.md hr { border: none; border-top: 1px solid var(--line); margin: 14px 0; }
.md blockquote { border-left: 4px solid var(--gray); margin: 8px 0; padding: 4px 12px; color: var(--muted); }
.md img { border-radius: 8px; }

/* ---------- ホーム上部：社長のイラスト＋吹き出し ---------- */
.boss-banner { display: flex; align-items: flex-end; gap: 10px; margin: 0 0 14px; padding: 0 4px; }
.boss-img {
  height: 132px; width: auto; flex: none; transform-origin: 50% 100%;
  animation: boss-in .7s cubic-bezier(.2,.9,.3,1.2) both, boss-bounce 6s ease-in-out 2s infinite;
  filter: drop-shadow(0 3px 4px rgba(0,0,0,.18));
}
.boss-bubble {
  position: relative; background: var(--white); border: 2px solid var(--red); border-radius: 16px;
  padding: 10px 14px; margin-bottom: 18px; font-weight: 700; font-size: 16px; color: var(--dark); line-height: 1.4;
  animation: bubble-in .5s ease-out .45s both;
}
.boss-bubble::before, .boss-bubble::after { content: ''; position: absolute; left: -14px; bottom: 16px; border: 7px solid transparent; }
.boss-bubble::before { border-right-color: var(--red); }
.boss-bubble::after { left: -10px; border-right-color: var(--white); }
.boss-name { display: block; font-size: 11px; color: var(--red-dark); font-weight: 700; margin-bottom: 2px; }
@keyframes boss-in { from { opacity: 0; transform: translateX(-40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes bubble-in { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: scale(1); } }
@keyframes boss-bounce {                 /* 6秒に1回、軽く弾む */
  0%, 6%, 100% { transform: translateY(0) scaleY(1); }
  2% { transform: translateY(-8px) scaleY(1.03); }
  4% { transform: translateY(0) scaleY(.97); }
}
@media (max-width: 600px) { .boss-img { height: 96px; } .boss-bubble { font-size: 14px; padding: 8px 12px; margin-bottom: 12px; } }
@media (prefers-reduced-motion: reduce) { .boss-img, .boss-bubble { animation: none; } }

/* ---------- ホーム上段：社長＋天気（PC は横並び・スマホは縦） ---------- */
.top-row { display: flex; flex-direction: column; gap: 0; }
@media (min-width: 900px) { .top-row { flex-direction: row; align-items: flex-end; gap: 14px; } .top-row .boss-banner { flex: 1; } .top-row .weather-card { width: 400px; flex: none; } }
.weather-card h2 { font-size: 16px; }
.wx-days { display: flex; gap: 8px; margin-bottom: 8px; }
.wx-day { flex: 1; background: var(--bg-soft); border-radius: 10px; padding: 8px 10px; }
.wx-label { font-size: 12px; color: var(--muted); font-weight: 700; }
.wx-icon { font-size: 26px; line-height: 1.2; }
.wx-text { font-size: 12px; color: var(--dark); min-height: 2.6em; line-height: 1.3; }
.wx-nums { font-size: 13px; display: flex; gap: 8px; margin-top: 4px; }
.wx-nums .hi { color: var(--red-dark); font-weight: 700; } .wx-nums .lo { color: var(--blue); font-weight: 700; } .wx-nums .pop { color: var(--muted); }
.wx-wbgt { color: #fff; border-radius: 8px; padding: 6px 10px; font-size: 13px; margin-bottom: 6px; line-height: 1.4; }
.wx-wbgt .small { display: block; font-size: 11px; opacity: .95; }
.wx-wbgt.off { background: var(--bg-soft); color: var(--muted); }
.wx-warn { margin-bottom: 4px; }

/* ---------- ホーム ---------- */
.home-grid { display: grid; grid-template-columns: 1fr; gap: 0; }
@media (min-width: 900px) { .home-grid { grid-template-columns: 1fr 1fr; gap: 0 14px; } .home-grid .span2 { grid-column: 1 / -1; } }
.links-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.link-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 12px; padding: 14px 8px; text-decoration: none; color: var(--dark); text-align: center; min-height: 92px; }
.link-tile:hover { background: var(--white); border-color: var(--red); }
.link-tile .ic { font-size: 28px; line-height: 1; }
.link-tile .t { font-weight: 700; font-size: 14px; }
.link-tile .d { font-size: 11px; color: var(--muted); }
.link-tile.off { opacity: .5; }

/* ---------- 無事故カウンター ---------- */
.safety-hero { text-align: center; padding: 8px 0 4px; }
.safety-days { font-size: 64px; font-weight: 800; color: var(--red); line-height: 1; letter-spacing: -1px; }
.safety-days small { font-size: 22px; color: var(--dark); margin-left: 4px; font-weight: 700; }
.safety-sub { color: var(--muted); font-size: 14px; }
.progress { background: var(--bg-soft); border: 1px solid var(--line); border-radius: 999px; height: 16px; overflow: hidden; margin: 8px 0 4px; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--red), #FF6B3D); border-radius: 999px; transition: width .5s; }
.milestones { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }
.ms { border-radius: 999px; padding: 4px 12px; font-size: 13px; border: 1px solid var(--line); background: #fff; color: var(--muted); }
.ms.done { background: var(--green-soft); color: var(--green); border-color: var(--green-soft); font-weight: 700; }
.ms.next { background: var(--red-soft); color: var(--red-dark); border-color: var(--red-soft); font-weight: 700; }
.stat-row { display: flex; gap: 10px; flex-wrap: wrap; }
.stat { flex: 1; min-width: 120px; background: var(--bg-soft); border-radius: 10px; padding: 10px 12px; text-align: center; }
.stat .n { font-size: 26px; font-weight: 800; color: var(--dark); line-height: 1.1; }
.stat .l { font-size: 12px; color: var(--muted); }
.stat.good .n { color: var(--green); }
.stat.hiyari .n { color: var(--warn-fg); }

/* ---------- カレンダー ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-dow { text-align: center; font-size: 12px; color: var(--muted); padding: 4px 0; }
.cal-dow.sat { color: var(--blue); } .cal-dow.sun { color: var(--red-dark); }
.cal-cell { min-height: 64px; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 3px 4px; font-size: 12px; }
.cal-cell.off { background: var(--blue-soft); }
.cal-cell.other { opacity: .35; }
.cal-cell.today { outline: 2px solid var(--red); }
.cal-cell .d { font-weight: 700; font-size: 13px; }
.cal-cell.off .d { color: var(--blue); }
.cal-cell .hol { font-size: 10px; color: var(--blue); }
.cal-ev { display: block; font-size: 11px; line-height: 1.3; margin-top: 2px; padding: 1px 4px; border-radius: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-ev.birthday { background: #FFE4EC; color: #A8134A; }
.cal-ev.hire { background: var(--green-soft); color: var(--green); }
.cal-ev.service { background: var(--yellow); color: #5A4500; font-weight: 700; }
@media (max-width: 600px) { .cal-cell { min-height: 52px; padding: 2px; } .cal-ev { font-size: 10px; padding: 0 2px; } }
.ev-list li { display: flex; gap: 10px; align-items: center; }
.ev-list .date { min-width: 64px; font-weight: 700; color: var(--dark); }

/* ---------- 写真 ---------- */
.album-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.album-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; text-decoration: none; color: inherit; display: block; }
.album-card .cover { aspect-ratio: 4/3; background: var(--bg-soft) center/cover no-repeat; display: flex; align-items: center; justify-content: center; font-size: 36px; color: var(--gray); }
.album-card .body { padding: 8px 10px; }
.album-card .t { font-weight: 700; font-size: 14px; }
.album-card .m { font-size: 12px; color: var(--muted); }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; }
.photo-grid .ph { aspect-ratio: 1; background: var(--bg-soft) center/cover no-repeat; border-radius: 8px; cursor: pointer; position: relative; }
.photo-grid .ph .cap { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.5); color: #fff; font-size: 11px; padding: 2px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upload-zone { border: 2px dashed var(--gray); border-radius: 12px; padding: 18px; text-align: center; color: var(--muted); cursor: pointer; }
.upload-zone:hover { border-color: var(--red); color: var(--dark); }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 60; display: flex; align-items: center; justify-content: center; }
.lightbox img { max-width: 96vw; max-height: 86vh; object-fit: contain; }
.lightbox button { position: absolute; background: rgba(255,255,255,.15); color: #fff; border: none; font-size: 28px; width: 44px; height: 44px; border-radius: 50%; cursor: pointer; }
.lb-close { top: 12px; right: 12px; } .lb-prev { left: 8px; top: 50%; } .lb-next { right: 8px; top: 50%; }
.lb-cap { position: absolute; bottom: 14px; left: 0; right: 0; text-align: center; color: #fff; font-size: 14px; }

/* ---------- Q&A ---------- */
.faq-item { border-bottom: 1px solid var(--line); padding: 10px 0; }
.faq-q { font-weight: 700; cursor: pointer; display: flex; gap: 8px; align-items: flex-start; }
.faq-q::before { content: 'Q'; color: var(--red); font-weight: 800; }
.faq-a { margin: 6px 0 0 22px; }
.secret { background: var(--dark); color: var(--dark); border-radius: 6px; padding: 2px 8px; cursor: pointer; user-select: none; }
.secret.show { background: var(--warn-bg); color: var(--text); font-family: ui-monospace, Menlo, Consolas, monospace; }

/* ---------- 書類 ---------- */
.doc-row { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.doc-row .ic { font-size: 24px; }
.doc-row .t { font-weight: 600; }
.doc-row .m { font-size: 12px; color: var(--muted); }

/* ---------- 名簿 ---------- */
.member-card { display: flex; gap: 12px; padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; }
.member-card .av { width: 44px; height: 44px; border-radius: 50%; background: var(--red-soft); color: var(--red-dark); font-weight: 800; display: flex; align-items: center; justify-content: center; flex: none; }
.member-card .n { font-weight: 700; }
.member-card .r { font-size: 13px; color: var(--muted); }
.member-card .c { font-size: 13px; margin-top: 4px; }
.member-card .c a { margin-right: 10px; }

/* ---------- モーダル・トースト ---------- */
.modal-wrap { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal-box { background: #fff; width: 100%; max-width: 640px; max-height: 92vh; border-radius: 16px 16px 0 0; display: flex; flex-direction: column; }
@media (min-width: 700px) { .modal-wrap { align-items: center; } .modal-box { border-radius: 16px; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 14px 16px; overflow-y: auto; }
.toast { position: fixed; bottom: calc(var(--nav-h) + 14px); left: 50%; transform: translateX(-50%); background: var(--dark); color: #fff; padding: 10px 18px; border-radius: 999px; z-index: 70; font-size: 14px; box-shadow: 0 2px 10px rgba(0,0,0,.3); max-width: 90vw; }
.toast.error { background: var(--red-dark); }
@media (min-width: 900px) { .toast { bottom: 24px; } }

/* ---------- 入れないとき ---------- */
.blocked-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.blocked-box { background: #fff; border-radius: 16px; padding: 28px 24px; max-width: 420px; width: 100%; text-align: center; box-shadow: var(--shadow); }
.blocked-logo { height: 40px; margin-bottom: 12px; }

/* ---------- メニュー画面（スマホ） ---------- */
.menu-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.menu-grid a { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px 12px; text-decoration: none; color: var(--dark); font-weight: 700; display: flex; gap: 8px; align-items: center; }
