/* Shared palette/layout, aligned with docs/添乗員モニタリング画面_UIご提案v1.0.md
   (main branch, staff-monitering/*.html mockups). Brand text and sample
   data in those mockups reference the real client by name - none of that
   text is reproduced here; only the visual language (palette, components,
   layout) is shared. */
:root {
  --paper: #eaf6ff;
  --surface: #ffffff;
  --surface-alt: #e1f2fd;
  --ink: #12202c;
  --muted: #55708a;
  --line: #c9e8fb;
  --accent: #0ea5e9;
  --accent-strong: #0284c7;
  --accent-ink: #ffffff;
  --accent-soft: #d9f0fd;
  --good: #16a34a;
  --good-soft: #dcf7e6;
  --bad: #ef4444;
  --bad-soft: #fde3e3;
  --pending: #90aec8;
  --pending-soft: #e8f4fc;
  --radius: 6px;

  --st-done: #16a34a;
  --st-done-bg: #eaf9ef;
  --st-wait: #5b7690;
  --st-wait-bg: #eef3f7;
  --st-calling: #d97706;
  --st-calling-bg: #fef3e0;
  --st-escalated: #dc2626;
  --st-escalated-bg: #fdeaea;
  --st-staffack: #7c3aed;
  --st-staffack-bg: #f2ecfe;
  --st-queued: #0e7490;
  --st-queued-bg: #e0f7fa;

  --grp-kishou: #0284c7;
  --grp-kishou-soft: #e0f2fe;
  --grp-syuppatsu: #0d9488;
  --grp-syuppatsu-soft: #dcf6f1;
  --grp-standby: #7c3aed;
  --grp-standby-soft: #ede6fd;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN",
    "Yu Gothic UI", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.mono {
  font-family: ui-monospace, "SF Mono", "Cica", "SFMono-Regular", Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

a { color: var(--accent-strong); }

.brand-mark { width: 34px; height: 34px; flex: none; color: var(--accent-ink); }

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 24px;
  background: linear-gradient(120deg, var(--accent), var(--accent-strong));
  color: var(--accent-ink);
}
.topbar .brand { display: flex; align-items: center; gap: 12px; }
.topbar .brand-text h1 { margin: 0; font-size: 17px; font-weight: 700; }
.topbar .brand-text p { margin: 2px 0 0; font-size: 12px; color: rgba(255,255,255,0.85); }
.topbar nav { display: flex; gap: 16px; align-items: center; font-size: 13px; margin-left: auto; }
.topbar nav a { color: var(--accent-ink); text-decoration: none; }
.topbar nav a:hover { text-decoration: underline; }
.topbar .user-tag { font-size: 12px; color: rgba(255,255,255,0.85); }
.admin-tag {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.4);
  white-space: nowrap;
}

.container { max-width: 1180px; margin: 0 auto; padding: 24px; }

.breadcrumb {
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-alt);
  font-size: 12.5px;
}
.breadcrumb a { color: var(--accent-strong); text-decoration: none; font-weight: 600; }
.breadcrumb a:hover { text-decoration: underline; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px;
  box-shadow: 0 6px 20px rgba(18,32,44,0.05);
}

.error-box {
  background: var(--bad-soft);
  color: var(--bad);
  border: 1px solid var(--bad);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 14px;
}
.notice-box {
  background: var(--good-soft);
  color: var(--good);
  border: 1px solid var(--good);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 14px;
}

/* ============================================================
   Login (PC: two-panel brand+form / mobile: single-column card)
   ============================================================ */
.login-app-pc {
  display: grid;
  grid-template-columns: 1fr 460px;
  min-height: 100vh;
}

.brand-panel {
  background: linear-gradient(155deg, var(--accent), var(--accent-strong) 65%, #075985);
  color: #fff;
  padding: 64px 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.brand-panel .brand-mark-row { display: flex; align-items: center; gap: 14px; }
.brand-panel .brand-mark-row span { font-size: 16px; font-weight: 700; letter-spacing: 0.02em; }
.brand-panel h2 { font-size: 28px; line-height: 1.5; font-weight: 700; max-width: 480px; margin: 48px 0 0; }
.brand-features { display: flex; flex-direction: column; gap: 14px; font-size: 13.5px; color: rgba(255,255,255,0.9); }
.brand-features .item { display: flex; align-items: center; gap: 10px; }
.brand-features .dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,0.85); flex: none; }
.brand-panel footer { font-size: 11.5px; color: rgba(255,255,255,0.7); }

.form-panel {
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 32px 28px;
  box-shadow: 0 12px 32px rgba(18, 32, 44, 0.08);
}
.login-card .kicker { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; color: var(--accent-strong); margin-bottom: 6px; }
.login-card h1 { font-size: 18px; margin: 0 0 4px; }
.login-card p.sub { margin: 0 0 20px; font-size: 12px; color: var(--muted); }

.mobile-login-topbar {
  padding: 40px 24px 32px;
  background: linear-gradient(150deg, var(--accent), var(--accent-strong));
  color: #fff;
  text-align: center;
}
.mobile-login-topbar .brand-mark { width: 44px; height: 44px; margin: 0 auto 14px; }
.mobile-login-topbar h1 { margin: 0; font-size: 18px; font-weight: 700; }
.mobile-login-topbar p { margin: 6px 0 0; font-size: 12.5px; color: rgba(255,255,255,0.85); }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 11.5px; font-weight: 700; color: var(--muted); margin-bottom: 6px; letter-spacing: 0.02em; }
.field .note { font-weight: 400; color: var(--muted); margin-left: 4px; }

.input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface);
}
.input-wrap svg { flex: none; color: var(--muted); }
.input-wrap input {
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 13.5px;
  color: var(--ink);
  width: 100%;
}
.input-wrap input::placeholder { color: var(--pending); }
.input-wrap:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }

.field input, .field select {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 9px 10px;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--surface);
}
.field input:focus-visible, .field select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.field input[disabled] { background: var(--surface-alt); color: var(--muted); }
.field .hint { margin-top: 5px; font-size: 11px; color: var(--muted); }

.login-btn, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--accent-strong);
  color: #fff;
  border-radius: 8px;
  padding: 10px 18px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}
.login-btn:hover, .btn:hover { background: var(--accent); }
.login-btn.full, .btn.full { width: 100%; }
.btn.danger { background: var(--bad); }
.btn.secondary { background: var(--surface); color: var(--accent-strong); border: 1px solid var(--accent); }

.hint { margin-top: 16px; text-align: center; font-size: 11px; color: var(--muted); }
.login-switch { margin: 18px 0 0; text-align: center; font-size: 12px; color: var(--muted); }

/* ============================================================
   Toolbar / search / filter panel (PC data view)
   ============================================================ */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-alt);
  flex-wrap: wrap;
}

.filter-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  border-radius: var(--radius);
  padding: 7px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.filter-toggle:hover { background: var(--accent-soft); }
.filter-toggle.is-open, .filter-toggle.is-active { color: var(--accent-strong); border-color: var(--accent); background: var(--accent-soft); }
.filter-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: 10px; font-weight: 700;
}
.filter-count[hidden] { display: none; }

.search {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px 12px;
  color: var(--muted);
  width: 100%;
  max-width: 360px;
}
.search input { border: none; background: transparent; color: var(--ink); font: inherit; font-size: 13px; width: 100%; }
.search input::placeholder { color: var(--muted); }

.filter-panel { display: none; border-bottom: 1px solid var(--line); background: var(--surface-alt); padding: 16px 24px; }
.filter-panel.is-open { display: block; }
.filter-panel-inline { display: block; }

.filter-panel-inner {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px 16px;
}
.filter-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.filter-field label { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: 0.04em; }
.filter-panel-inner input {
  width: 100%; box-sizing: border-box; border: 1px solid var(--line); border-radius: 4px;
  padding: 7px 8px; font: inherit; font-size: 13px; color: var(--ink); background: var(--surface);
}
.range-filter { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.range-filter input { flex: 1 1 128px; min-width: 128px; }
.range-filter .range-sep { font-size: 12px; color: var(--muted); flex: none; }
.filter-panel-actions { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 14px; }
.filter-clear { color: var(--accent-strong); font-size: 12.5px; font-weight: 600; text-decoration: none; background: none; border: none; cursor: pointer; }
.filter-clear:hover { text-decoration: underline; }

/* ============================================================
   Table (shared: user list / pivot table)
   ============================================================ */
.table-wrap { overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }

table { border-collapse: collapse; width: 100%; font-size: 13px; }

thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-alt);
  text-align: left;
  font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: 0.04em;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
thead th.num, td.num { text-align: center; }

tbody td { padding: 9px 14px; border-bottom: 1px solid var(--line); color: var(--ink); white-space: nowrap; }
tbody tr:hover td { background: var(--surface-alt); }

.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 24px; height: 20px; padding: 0 6px; border-radius: 5px;
  font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 12px; font-weight: 700;
}
.badge.o { color: var(--good); }
.badge.x { color: var(--bad); background: var(--bad-soft); }
.badge.dash { color: var(--pending); }

.time-empty { color: var(--pending); }

.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; }
.section-head h2 { margin: 0; font-size: 15px; }
.count-info { font-size: 12.5px; color: var(--muted); font-weight: 600; }

.role-badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.role-badge.admin { background: #fdeee3; color: #b45309; }
.role-badge.normal { background: var(--surface-alt); color: var(--muted); }
.role-tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 4px; border: 1px solid var(--line); color: var(--muted); }
.role-tag.admin { color: var(--accent-strong); border-color: var(--accent); }

.corp-tag {
  display: inline-block;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.03em;
  padding: 1px 6px; border-radius: 4px; border: 1px solid var(--accent); color: var(--accent-strong);
}

footer.page-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 24px; border-top: 1px solid var(--line); background: var(--surface-alt);
  font-size: 11.5px; color: var(--muted); flex-wrap: wrap;
}
.legend { display: flex; gap: 16px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 6px; }

/* ---------- pivot table (PC 21-column data view) ---------- */
.pivot-table { min-width: 1900px; }
.pivot-table thead th { text-align: center; }
.pivot-table thead th.id-col { text-align: left; }
.pivot-table thead th.id-col:first-child { position: sticky; left: 0; z-index: 3; }
.pivot-table th.grp-kishou { background: var(--grp-kishou-soft); color: var(--grp-kishou); }
.pivot-table th.grp-syuppatsu { background: var(--grp-syuppatsu-soft); color: var(--grp-syuppatsu); }
.pivot-table th.grp-standby { background: var(--grp-standby-soft); color: var(--grp-standby); }
.pivot-table td.id-col:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; }
.pivot-table tbody tr:hover td.id-col:first-child { background: var(--surface-alt); }
.pivot-table .name-cell { font-weight: 700; }
.pivot-table td.na { color: var(--pending); }

.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 16px 0; font-size: 13px; color: var(--muted); }
.pagination a { font-weight: 700; }

/* ============================================================
   User edit form extras (role toggle / meta row / danger zone / modal)
   ============================================================ */
.meta-row {
  display: flex; gap: 18px; font-size: 11.5px; color: var(--muted);
  padding: 10px 12px; background: var(--surface-alt); border-radius: var(--radius); margin-bottom: 20px;
}
.meta-row div strong { display: block; color: var(--ink); font-size: 12.5px; margin-top: 2px; }

.role-options { display: flex; gap: 10px; }
.role-options label {
  flex: 1; display: flex; align-items: center; gap: 7px;
  border: 1px solid var(--line); border-radius: var(--radius); padding: 9px 12px;
  font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer;
}
.role-options input { width: auto; accent-color: var(--accent-strong); }
.role-options label:has(input:checked) { border-color: var(--accent); color: var(--accent-strong); background: #eef8fe; }

.form-actions { display: flex; gap: 10px; margin-top: 22px; }
.form-actions .btn { flex: 1; }
.btn-cancel { background: var(--surface); color: var(--muted); border: 1px solid var(--line); }
.btn-cancel:hover { background: var(--surface-alt); }

.danger-zone { margin-top: 28px; padding-top: 20px; border-top: 1px dashed var(--line); }
.danger-zone h3 { margin: 0 0 4px; font-size: 12.5px; color: #b91c1c; }
.danger-zone p { margin: 0 0 12px; font-size: 11.5px; color: var(--muted); }
.btn-danger-outline {
  display: inline-block; border: 1px solid #f3b6b6; background: #fde3e3; color: #b91c1c;
  border-radius: var(--radius); padding: 9px 16px; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
}
.btn-danger-outline:hover { background: #fbd2d2; }

.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(18,32,44,0.35);
  align-items: center; justify-content: center; z-index: 10;
}
.modal-overlay.is-open { display: flex; }
.modal { width: 100%; max-width: 340px; background: var(--surface); border-radius: 12px; padding: 22px; box-shadow: 0 16px 40px rgba(18,32,44,0.18); }
.modal h3 { margin: 0 0 8px; font-size: 15px; }
.modal p { margin: 0 0 18px; font-size: 12.5px; color: var(--muted); }
.modal p strong { color: var(--ink); }
.modal-actions { display: flex; gap: 8px; }
.modal-actions .btn { flex: 1; }
.btn-confirm-delete { background: #dc2626; }
.btn-confirm-delete:hover { background: #b91c1c; }

/* ============================================================
   Mobile monitor (m/index.php)
   ============================================================ */
body.mobile { background: var(--paper); }
.m-app { max-width: 480px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }

.mobile-topbar { padding: 12px 16px 10px; }
.mobile-topbar h1 { margin: 0; font-size: 16px; font-weight: 700; }
.mobile-topbar .refresh-row { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; font-size: 11px; color: rgba(255,255,255,0.9); }
.mobile-topbar .refresh-row .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #baf7d0; margin-right: 5px; }
@media (prefers-reduced-motion: no-preference) {
  .mobile-topbar .refresh-row .dot { animation: pulse 2.4s ease-in-out infinite; }
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
#refreshBtn {
  appearance: none; border: 1px solid rgba(255,255,255,0.5); background: rgba(255,255,255,0.12);
  color: #fff; font: inherit; font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 999px; cursor: pointer;
}

.mobile-toolbar { padding: 8px 16px; background: var(--surface-alt); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.mobile-toolbar .search { flex: 1; max-width: none; padding: 8px 12px; }
.mobile-toolbar .search input { font-size: 13.5px; }

.seg { display: flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); flex: none; }
.seg-btn { appearance: none; border: none; background: transparent; color: var(--muted); font: inherit; font-size: 12px; font-weight: 600; padding: 8px 12px; cursor: pointer; }
.seg-btn.is-active { background: var(--accent); color: #fff; }

.mobile-list { flex: 1; margin: 8px 10px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.mobile-empty { text-align: center; color: var(--muted); font-size: 13px; padding: 40px 20px; }

.m-card { background: var(--surface); border-left: 4px solid var(--row-accent, var(--pending)); }
.m-card + .m-card { border-top: 1px solid var(--line); }
.m-card.is-hidden { display: none; }

.m-card-main { display: flex; align-items: center; gap: 10px; padding: 9px 10px; cursor: pointer; user-select: none; }

.m-card-time { flex: none; width: 40px; font-size: 13px; font-weight: 700; color: var(--ink); }
.m-card-time.is-past { color: var(--muted); font-weight: 600; }

.m-card-type-badge {
  flex: none; width: 22px; height: 22px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: var(--accent-strong); background: var(--accent-soft);
}

.m-card-body { flex: 1; min-width: 0; }
.m-card-name { display: flex; align-items: baseline; gap: 6px; font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-card-name .code { flex: none; font-size: 10.5px; color: var(--muted); font-weight: 400; }
.m-card-sub { margin-top: 1px; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.m-card-status { flex: none; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.status-waiting  { background: var(--st-wait-bg); color: var(--st-wait); }
.status-queued   { background: var(--st-queued-bg); color: var(--st-queued); }
.status-calling  { background: var(--st-calling-bg); color: var(--st-calling); }
.status-done     { background: var(--st-done-bg); color: var(--st-done); }
.status-confirmed{ background: var(--st-staffack-bg); color: var(--st-staffack); }
.status-urgent   { background: var(--st-escalated-bg); color: var(--st-escalated); }

.m-card-call {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent-strong); text-decoration: none; font-size: 13px;
}

.m-card-chevron { flex: none; color: var(--muted); transition: transform 0.15s ease; }
.m-card.is-open .m-card-chevron { transform: rotate(180deg); }

.m-card-detail {
  display: none; padding: 8px 14px 10px 60px; background: var(--surface-alt);
  border-top: 1px dashed var(--line); font-size: 11.5px; color: var(--muted);
}
.m-card.is-open .m-card-detail { display: block; }
.m-card-detail div + div { margin-top: 3px; }

footer.mobile-footer {
  padding: 12px 16px 18px; font-size: 11px; color: var(--muted);
  background: var(--surface-alt); border-top: 1px solid var(--line);
}
footer.mobile-footer .legend { display: flex; flex-wrap: wrap; gap: 10px 14px; margin-bottom: 6px; }
footer.mobile-footer .legend-item { display: flex; align-items: center; gap: 5px; }
footer.mobile-footer .legend-dot { width: 9px; height: 9px; border-radius: 3px; }
