/* CRM workspace: shared visual tokens and responsive application components. */
:root {
  --bg: #f5f6f8;
  --panel-alt: #f8fafb;
  --border: #e2e6eb;
  --border-strong: #cbd2db;
  --text: #202b3a;
  --text-soft: #465365;
  --muted: #626f80;
  --primary: #b9530b;
  --primary-dark: #913b06;
  --primary-soft: #fff1e5;
  --radius: 12px;
  --radius-sm: 8px;
  --ring: 0 0 0 3px #b9530b35;
}
body { font-family: 'Segoe UI', 'Yu Gothic UI', Meiryo, system-ui, sans-serif; }
button, input, select, textarea { font-family: inherit; }
button, a, input, select, textarea { touch-action: manipulation; }
a:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.app-main { background: var(--bg); }
.sidebar { width: 224px; height: 100dvh; }
.sidebar-brand { padding: 24px 20px 21px; font-size: .91rem; }
.sidebar-brand a { display: block; border-left: 4px solid var(--primary); padding-left: 11px; }
.sidebar-brand .brand-sub { letter-spacing: .16em; margin-top: 4px; }
.sidebar-nav { padding: 14px 12px; }
.nav-group { font-size: .7rem; padding-top: 17px; letter-spacing: .04em; }
.nav-item { min-height: 40px; font-size: .84rem; border: 1px solid transparent; }
.nav-item.active { border-color: #efd9c7; }
.nav-item.active .nav-ico { color: var(--primary); }
.nav-ico { opacity: 1; }
.sidebar-foot { padding: 16px; }
.workspace-bar { display: flex; align-items: center; gap: 24px; min-height: 68px; padding: 12px 32px; border-bottom: 1px solid var(--border); background: #fff; }
.workspace-label { font-size: .72rem; font-weight: 600; color: var(--muted); white-space: nowrap; letter-spacing: .04em; }
.workspace-label > span { margin: 0 10px; color: #a3adba; }
.workspace-role { font-size: .75rem; color: var(--muted); white-space: nowrap; }
.workspace-search { margin: 0 0 0 auto; display: flex; align-items: center; gap: 10px; width: min(360px, 45%); padding: 5px 6px 5px 12px; background: var(--panel-alt); border: 1px solid var(--border); border-radius: 8px; }
.workspace-search svg { width: 18px; height: 18px; flex: none; color: var(--muted); }
.workspace-search input { border: 0; background: transparent; min-width: 0; width: 100%; font-size: .81rem; padding: 4px 0; color: var(--text); }
.workspace-search button { padding: 5px 9px; border: 0; background: #fff; border-radius: 5px; color: var(--text-soft); white-space: nowrap; cursor: pointer; }
.workspace-search:focus-within { outline: 2px solid var(--primary); outline-offset: 2px; }
.nav-toggle { display: none; }
.skip-link { position: fixed; top: -100px; left: 16px; z-index: 100; padding: 12px 18px; background: #fff; border: 2px solid var(--primary); }
.skip-link:focus { top: 12px; }
.container { max-width: 1440px; padding: 32px 36px 64px; }
.page-head { align-items: center; margin-bottom: 26px; }
h1 { font-size: 1.6rem; letter-spacing: -.035em; line-height: 1.5; }
.page-sub, .page-head .page-sub { color: var(--muted); line-height: 1.7; }
.eyebrow { font-size: .76rem; color: var(--primary-dark); font-weight: 700; margin: 0 0 8px; }
.actions { flex-wrap: wrap; flex-shrink: 0; }
.btn { min-height: 38px; justify-content: center; font-weight: 600; }
.btn.primary { box-shadow: none; }
.btn:disabled, button:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.selection-count { color: var(--text-soft); font-size: .8rem; white-space: nowrap; }
.list-meta { flex-wrap: wrap; gap: 8px; }
.unsaved-status { margin: 0 0 16px; padding: 10px 14px; background: var(--warn-soft); color: #85420b; border-radius: var(--radius-sm); font-size: .84rem; }
.bulk-confirm-dialog { max-width: min(460px, calc(100vw - 32px)); padding: 24px; color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.bulk-confirm-dialog::backdrop { background: #202b3a66; }
.bulk-confirm-dialog h2 { margin: 0; font-size: 1.12rem; }
.bulk-confirm-dialog p { margin: 14px 0 22px; color: var(--text-soft); }
.bulk-confirm-dialog .actions { justify-content: flex-end; }
.priority-panel { display: flex; justify-content: space-between; align-items: center; gap: 28px; padding: 28px 32px; background: #fffaf5; border: 1px solid #edd8c6; border-radius: 14px; }
.priority-copy { max-width: 630px; }
.priority-copy h2 { margin: 0; font-size: 1.3rem; }
.priority-copy p:not(.eyebrow) { color: var(--text-soft); font-size: .84rem; margin: 10px 0 20px; }
.priority-copy .btn { gap: 24px; }
.priority-metric { padding-left: 32px; border-left: 1px solid #ead8c8; min-width: 210px; display: flex; flex-direction: column; color: var(--text-soft); font-size: .75rem; }
.priority-metric strong { font-size: 3.5rem; font-weight: 650; line-height: 1.4; color: var(--primary-dark); font-variant-numeric: tabular-nums; letter-spacing: -.05em; }
.priority-metric small { font-size: .85rem; margin-left: 10px; font-weight: 500; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 28px 0 12px; }
.section-heading h2 { margin: 0; }
.section-heading > span, .section-heading > a { font-size: .76rem; color: var(--muted); }
.cards { gap: 12px; }
.task-cards { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.task-cards .card { padding: 17px 18px; }
.card-value { font-variant-numeric: tabular-nums; line-height: 1.35; }
.card-label { color: var(--text-soft); }
.card-hint { margin-top: 8px; line-height: 1.6; }
.card-link:hover { transform: none; border-color: #d4a784; }
.card:not(a):hover::before { opacity: 0; }
.overview-cards { grid-template-columns: repeat(auto-fit, minmax(125px, 1fr)); gap: 0; background: white; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.overview-cards .card { border: 0; border-right: 1px solid var(--border); border-radius: 0; box-shadow: none; padding: 18px 22px; }
.overview-cards .card:last-child { border-right: 0; }
.overview-cards .card-value { font-size: 1.55rem; }
.grid th { font-size: .76rem; color: var(--text-soft); letter-spacing: 0; padding-top: 12px; padding-bottom: 12px; }
.grid td { padding-top: 16px; padding-bottom: 16px; vertical-align: middle; }
.grid td a { color: #354e70; }
.grid td a:hover { color: var(--primary-dark); }
.grid tbody tr:nth-child(even) { background: #fff; }
.grid tbody tr:hover, .grid tbody tr:focus-within { background: #faf5ef; }
.grid td.empty { text-align: center; padding: 48px 24px; }
.filter { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; gap: 12px; }
.filter label { display: flex; flex-direction: column; gap: 6px; color: var(--text-soft); font-size: .75rem; font-weight: 600; }
.filter .search-field { flex: 1 1 260px; }
.filter input[type=text] { min-width: 0; width: 100%; }
.filter:has(label) { align-items: flex-end; }
.result-count { font-variant-numeric: tabular-nums; }
.badge.is-muted { color: #596579; }
.company-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.company-summary .card-value { font-size: 1.4rem; }
.company-summary .card-note { overflow-wrap: anywhere; }
.section-nav { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 12px 0; margin-bottom: 0; border-bottom: 1px solid var(--border); }
section[id] { scroll-margin-top: 92px; }
.section-nav a { background: #fff; font-size: .8rem; }
.section-nav a.active { background: var(--primary-soft); border-color: #dba984; color: var(--primary-dark); }
.timeline .tl-title, .view-subject, .detail-grid > div { overflow-wrap: anywhere; }
.mail-ws { height: calc(100dvh - 108px); grid-template-columns: 190px minmax(250px, .95fr) minmax(320px, 1.6fr); }
.mail-rail { background: #fafbfc; }
.mrow-body { padding-top: 14px; padding-bottom: 14px; }
.mail-view .mailbody { line-height: 1.85; background: white; }
.mail-back-link { display: none; }
.cal-shell.is-fixed { height: calc(100dvh - 132px); }
.login-page { background: #f5f6f8; }
.login-card { width: min(420px, 100%); border: 1px solid var(--border); border-top: 4px solid var(--primary); box-shadow: 0 16px 48px #202b3a0d; padding: 36px; }
@media (max-width: 1240px) {
  .mail-ws { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); height: auto; }
  .mail-rail { grid-column: 1 / -1; }
  .mail-rail .rail-views, .mail-rail .rail-filters { flex-direction: row; flex-wrap: wrap; }
  .mail-list, .mail-view { max-height: 75vh; }
  .workspace-label { display: none; }
  .workspace-search { width: min(420px, 80%); margin-left: 0; }
  .workspace-role { margin-left: auto; }
  .container { padding: 28px 24px 56px; }
  .priority-panel { padding: 24px; }
}
@media (max-width: 820px) {
  .workspace-bar { padding: 10px 16px; gap: 12px; min-height: 64px; }
  .nav-toggle { display: inline-flex; min-height: 42px; white-space: nowrap; }
  .workspace-search { flex: 1; width: auto; }
  .workspace-role { display: none; }
  .sidebar { width: 100%; height: auto; position: static; display: flex; flex-direction: column; align-items: stretch; }
  .sidebar-brand, .sidebar-foot { display: none; }
  .sidebar-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 12px 16px; }
  .nav-group { display: none; }
  .js-enabled .sidebar { display: none; }
  .js-enabled .sidebar.is-open { display: flex; }
  .js-enabled .sidebar.is-open .sidebar-foot { display: flex; margin: 0; border-top: 1px solid var(--border); }
  .container, .container.wide { padding: 22px 16px 48px; }
  .page-head { align-items: flex-start; flex-wrap: wrap; gap: 14px; }
  h1 { font-size: 1.4rem; }
  .priority-panel { align-items: stretch; gap: 18px; }
  .priority-metric { min-width: 140px; padding-left: 18px; }
  .priority-metric strong { font-size: 2.7rem; }
  .priority-metric > span:last-child { display: none; }
  .company-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .company-summary .card { padding: 16px; }
  .company-summary .card-value { font-size: 1.2rem; }
  .mail-ws { grid-template-columns: minmax(0, 1fr); }
  .mail-list { max-height: 62vh; }
  .mail-view { max-height: none; overflow: visible; }
  .mail-back-link { display: inline-block; align-self: flex-start; margin-bottom: 14px; padding: 6px 0; font-size: .85rem; }
  .cal-shell.is-fixed { height: auto; }
  .note-form { flex-wrap: wrap; }
  .note-form label { min-width: 100%; }
  .tabs { overflow-x: auto; }
  .tabs .tab { white-space: nowrap; }
  .filter label { flex: 1 1 130px; min-width: 0; }
  .filter select { max-width: 100%; }
  .section-nav { flex-wrap: nowrap; overflow-x: auto; }
  .section-nav a { flex: none; }
}
@media (max-width: 480px) {
  .priority-panel { flex-direction: column-reverse; padding: 20px; }
  .priority-metric { border: 0; padding: 0 0 14px; border-bottom: 1px solid #ead8c8; }
  .priority-metric strong { font-size: 2.7rem; }
  .task-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .task-cards .card { padding: 14px; }
  .card-label { font-size: .74rem; }
  .card-value { font-size: 1.7rem; }
  .section-heading > span { display: none; }
  .workspace-search svg { display: none; }
  .overview-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter { padding: 12px; }
  .inline-row { gap: 12px; }
  .inline-row label { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
/* Mail composition and sent records */
.sent-body, .send-confirm-details { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; }
.send-confirm-details { max-height: 50vh; overflow-y: auto; }
.mail-copies, .mail-attachments { display: grid; gap: 12px; min-width: 0; }
.mail-attachments { padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.mail-attachments p { margin: 0; }
.mail-attachments .btn { justify-self: start; }
.mail-attachments [hidden] { display: none; }
.mail-file-list { margin: 0; padding-left: 22px; overflow-wrap: anywhere; }
.mail-file-list:empty { display: none; }
.mail-rail .rail-tool .btn { margin-bottom: .5rem; }
