:root {
    --bg: #f4efe7;
    --surface: #fffaf3;
    --surface-strong: #ffffff;
    --line: #e5d8c8;
    --text: #1f1a17;
    --muted: #6d6258;
    --accent: #b3522d;
    --accent-strong: #8f3f21;
    --accent-soft: #f3d8c8;
    --success: #2a7c5f;
    --shadow: 0 18px 50px rgba(88, 53, 22, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family:
        "Source Sans Pro", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top right, rgba(179, 82, 45, 0.12), transparent 24%),
        linear-gradient(180deg, #fbf6ef 0%, #f4efe7 100%);
}

button,
input {
    font: inherit;
}

.page-shell {
    max-width: 1400px;
    margin: 0 auto;
    padding: 32px 20px 48px;
}

.professional-page .page-shell,
.customer-page .page-shell {
    max-width: 1680px;
}

.hero {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: end;
    padding: 28px;
    background: linear-gradient(135deg, rgba(255, 250, 243, 0.95), rgba(246, 226, 207, 0.9));
    border: 1px solid rgba(179, 82, 45, 0.14);
    border-radius: 28px;
    box-shadow: var(--shadow);
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--accent);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.82rem;
}

h1 {
    margin: 0;
    font-size: clamp(2rem, 4vw, 3.6rem);
    line-height: 0.96;
}

.hero-copy {
    max-width: 720px;
    margin: 14px 0 0;
    color: var(--muted);
    font-size: 1.02rem;
}

.hero-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.hero-actions-nav {
    justify-content: flex-end;
    align-items: center;
}

.layout {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 20px;
    margin-top: 20px;
}

.sticky-action-bar {
    position: sticky;
    top: 14px;
    z-index: 20;
    margin-top: 18px;
    display: grid;
    grid-template-columns: 1.2fr 0.9fr auto;
    gap: 12px;
    align-items: end;
    padding: 16px 18px;
    background: rgba(255, 250, 243, 0.92);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(179, 82, 45, 0.16);
    border-radius: 22px;
    box-shadow: 0 14px 28px rgba(88, 53, 22, 0.1);
}

.sticky-action-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.sticky-action-summary {
    padding: 12px 14px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(179, 82, 45, 0.12);
    min-height: 52px;
}

.sticky-action-label {
    display: block;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
}

.sticky-action-summary strong {
    display: block;
    margin-top: 4px;
    line-height: 1.45;
}

.sticky-action-note {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 0.84rem;
}

.sticky-action-buttons {
    display: flex;
    align-items: end;
}

.sticky-action-buttons-dual {
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.sticky-action-buttons-dual .button {
    min-width: 132px;
}

.panel {
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(10px);
    border: 1px solid var(--line);
    border-radius: 24px;
    padding: 22px;
    box-shadow: var(--shadow);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
}

.panel-header-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
}

.panel-header h2,
.section-block h3 {
    margin: 0;
}

.panel-intro {
    margin-bottom: 16px;
    padding: 14px 16px;
    border-radius: 18px;
    background: rgba(255, 250, 243, 0.82);
    border: 1px solid rgba(179, 82, 45, 0.12);
    color: var(--muted);
    line-height: 1.62;
}

.section-block + .section-block {
    margin-top: 26px;
}

.grid-two {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.primary-action-grid {
    display: grid;
    gap: 10px;
    margin-top: 12px;
}

.workflow-grid {
    display: grid;
    gap: 10px;
    margin-top: 12px;
}

.workflow-card {
    background: linear-gradient(180deg, #fffdf8 0%, #f8ece2 100%);
    border: 1px solid rgba(179, 82, 45, 0.14);
    border-radius: 18px;
    padding: 14px 16px;
}

.workflow-card strong {
    display: block;
    color: var(--accent);
    font-size: 0.95rem;
}

.workflow-card p {
    margin: 8px 0 0;
    color: var(--muted);
    line-height: 1.55;
    font-size: 0.94rem;
}

.token-mode-box {
    margin-top: 12px;
    background: #fff;
    border: 1px dashed rgba(179, 82, 45, 0.26);
    border-radius: 18px;
    padding: 14px 16px;
    color: var(--muted);
    line-height: 1.6;
}

.template-grid {
    display: grid;
    gap: 10px;
    margin-top: 12px;
}

.template-card {
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface);
    padding: 14px 16px;
    cursor: pointer;
    transition:
        transform 160ms ease,
        border-color 160ms ease,
        box-shadow 160ms ease,
        background 160ms ease;
}

.template-card:hover {
    transform: translateY(-1px);
    border-color: rgba(179, 82, 45, 0.28);
}

.template-card.is-active {
    border-color: rgba(179, 82, 45, 0.4);
    background: linear-gradient(180deg, #fffdf8 0%, #f6e8dd 100%);
    box-shadow: 0 10px 24px rgba(179, 82, 45, 0.12);
}

.template-card strong {
    display: block;
    font-size: 1rem;
}

.template-card p {
    margin: 8px 0 0;
    color: var(--muted);
    line-height: 1.55;
    font-size: 0.94rem;
}

.template-data-box {
    margin-top: 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 14px 16px;
    color: var(--muted);
    white-space: pre-wrap;
    line-height: 1.65;
}

.scan-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.scan-summary-card {
    background: linear-gradient(180deg, #fffdf8 0%, #f9efe6 100%);
    border: 1px solid rgba(179, 82, 45, 0.14);
    border-radius: 18px;
    padding: 14px 16px;
}

.scan-summary-card strong {
    display: block;
    color: var(--muted);
    font-size: 0.9rem;
}

.scan-summary-card span {
    display: block;
    margin-top: 6px;
    font-size: 1.5rem;
    font-weight: 800;
}

.recommended-template-box {
    margin-bottom: 12px;
    background: linear-gradient(180deg, #f7efe3 0%, #f3dfd0 100%);
    border: 1px solid rgba(179, 82, 45, 0.18);
    border-radius: 18px;
    padding: 14px 16px;
    white-space: pre-wrap;
    line-height: 1.6;
}

.report-batch-grid {
    display: grid;
    gap: 14px;
}

.report-tabs {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    padding: 8px;
    border: 1px solid rgba(179, 82, 45, 0.12);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.62);
}

.report-tab-button {
    border: 1px solid rgba(179, 82, 45, 0.14);
    border-radius: 18px;
    background: #fffaf4;
    color: var(--muted);
    padding: 10px 14px;
    cursor: pointer;
    display: inline-flex;
    flex-direction: column;
    gap: 3px;
    align-items: flex-start;
    min-width: 138px;
    transition:
        background 160ms ease,
        border-color 160ms ease,
        color 160ms ease,
        transform 160ms ease;
}

.report-tab-button:hover {
    transform: translateY(-1px);
    border-color: rgba(179, 82, 45, 0.3);
}

.report-tab-button span {
    font-weight: 800;
    color: var(--text);
}

.report-tab-button small {
    color: inherit;
    font-weight: 700;
}

.report-tab-button.is-active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 14px 28px rgba(179, 82, 45, 0.22);
}

.report-tab-button.is-active span,
.report-tab-button.is-active small {
    color: #fff;
}

.report-tab-panels {
    display: grid;
    min-width: 0;
}

.report-tab-panel {
    display: none;
    min-width: 0;
}

.report-tab-panel.is-active {
    display: block;
}

.report-batch-card {
    border: 1px solid rgba(179, 82, 45, 0.14);
    border-radius: 22px;
    background: linear-gradient(180deg, #fffdf8 0%, #f8ece2 100%);
    padding: 18px;
    min-width: 0;
    overflow: hidden;
}

.report-batch-card-muted {
    background: linear-gradient(180deg, #fffaf7 0%, #f5ebe5 100%);
    border-style: dashed;
}

.report-batch-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
}

.report-batch-header strong {
    display: block;
    font-size: 1.06rem;
}

.report-batch-header p {
    margin: 8px 0 0;
    color: var(--muted);
    line-height: 1.55;
}

.report-batch-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(42, 124, 95, 0.14);
    color: var(--success);
    font-size: 0.84rem;
    font-weight: 700;
    white-space: nowrap;
}

.report-batch-status-muted {
    background: rgba(109, 98, 88, 0.14);
    color: var(--muted);
}

.report-batch-status-warn {
    background: rgba(179, 82, 45, 0.14);
    color: var(--accent-strong);
}

.report-batch-overview,
.report-batch-note,
.report-batch-reason {
    margin-top: 12px;
    padding: 12px 14px;
    border-radius: 16px;
    line-height: 1.62;
}

.report-batch-overview {
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(179, 82, 45, 0.1);
    color: var(--muted);
}

.report-batch-note {
    background: rgba(243, 216, 200, 0.44);
    border: 1px solid rgba(179, 82, 45, 0.14);
    color: var(--text);
}

.report-batch-reason {
    background: rgba(109, 98, 88, 0.08);
    border: 1px dashed rgba(109, 98, 88, 0.18);
    color: var(--muted);
}

.report-batch-narrative {
    margin-top: 14px;
}

.report-batch-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 12px;
    color: var(--muted);
    font-size: 0.88rem;
}

.report-batch-meta span {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(179, 82, 45, 0.1);
}

.generation-badge,
.history-item .generation-badge {
    display: inline-flex;
    width: fit-content;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
}

.generation-badge-llm,
.history-item .generation-badge-llm {
    color: #216047;
    background: rgba(68, 155, 116, 0.13);
    border: 1px solid rgba(68, 155, 116, 0.24);
}

.generation-badge-fallback,
.history-item .generation-badge-fallback {
    color: #8a4b19;
    background: rgba(210, 138, 60, 0.14);
    border: 1px solid rgba(210, 138, 60, 0.25);
}

.generation-badge-mixed,
.history-item .generation-badge-mixed {
    color: #5b4d8e;
    background: rgba(118, 104, 177, 0.13);
    border: 1px solid rgba(118, 104, 177, 0.25);
}

.generation-badge-unknown,
.history-item .generation-badge-unknown {
    color: var(--muted);
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid var(--line);
}

.report-batch-data-list {
    margin: 14px 0 0;
    padding-left: 18px;
    color: var(--muted);
    line-height: 1.6;
}

.report-batch-data-list li + li {
    margin-top: 6px;
}

.report-visuals {
    margin-top: 16px;
    display: grid;
    gap: 12px;
}

.report-visuals-title {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: end;
}

.report-visuals-title strong {
    font-size: 1rem;
}

.report-visuals-title span {
    color: var(--muted);
    font-size: 0.9rem;
}

.visual-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    min-width: 0;
}

.visual-card {
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(179, 82, 45, 0.12);
    border-radius: 18px;
    padding: 14px;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

.visual-table-card {
    grid-column: span 2;
}

.visual-card-header {
    display: grid;
    gap: 4px;
    margin-bottom: 12px;
}

.visual-card-header strong {
    font-size: 0.98rem;
}

.visual-card-header p {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
    font-size: 0.9rem;
}

.mini-bar-chart {
    display: grid;
    gap: 10px;
    min-width: 0;
}

.mini-bar-row {
    display: grid;
    gap: 6px;
}

.mini-bar-label {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--text);
    font-weight: 700;
    font-size: 0.9rem;
    min-width: 0;
}

.mini-bar-label span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mini-bar-track {
    overflow: hidden;
    height: 12px;
    border-radius: 999px;
    background: rgba(179, 82, 45, 0.12);
}

.mini-bar-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #d57d4b 0%, #b3522d 100%);
}

.mini-line-chart {
    display: grid;
    gap: 10px;
    min-width: 0;
}

.mini-line-series {
    display: grid;
    gap: 8px;
}

.mini-line-series-title {
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 700;
}

.mini-line-points {
    display: flex;
    align-items: end;
    gap: 8px;
    min-height: 92px;
    padding: 10px 8px 0;
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(248, 236, 226, 0.36), rgba(255, 255, 255, 0.7));
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

.mini-line-point {
    flex: 1;
    min-width: 12px;
    border-radius: 999px 999px 0 0;
    background: linear-gradient(180deg, #d57d4b 0%, #b3522d 100%);
    position: relative;
}

.mini-line-point i {
    display: none;
}

.mini-line-labels {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    color: var(--muted);
    font-size: 0.78rem;
    min-width: 0;
    overflow: hidden;
}

.mini-line-labels span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.compact-table {
    padding: 0;
    overflow-x: auto;
    overflow-y: hidden;
    background: rgba(255, 255, 255, 0.68);
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
}

.compact-table table {
    min-width: 620px;
}

.compact-table th,
.compact-table td {
    padding: 10px 12px;
    font-size: 0.9rem;
}

.client-summary-box {
    background: linear-gradient(180deg, #fffdf8 0%, #f8ece2 100%);
    border: 1px solid rgba(179, 82, 45, 0.14);
    border-radius: 18px;
    padding: 16px;
    color: var(--muted);
    white-space: pre-wrap;
    line-height: 1.68;
}

.client-summary-box-compact {
    white-space: normal;
}

.client-summary-box-compact p {
    margin: 0;
}

.client-summary-box-compact p + p {
    margin-top: 10px;
}

.customer-page .layout {
    grid-template-columns: 1fr;
}

.professional-page .layout,
.customer-page .layout {
    grid-template-columns: minmax(0, 1fr);
}

.professional-page .report-panel,
.customer-page .report-panel {
    min-width: 0;
    padding: 26px;
}

.professional-page .report-batch-card,
.customer-page .report-batch-card {
    min-width: 0;
}

.customer-scope-grid {
    display: grid;
    gap: 10px;
}

.scope-card,
.scope-note-card {
    border-radius: 18px;
    padding: 14px 16px;
    border: 1px solid rgba(179, 82, 45, 0.14);
    background: linear-gradient(180deg, #fffdf8 0%, #f8ece2 100%);
}

.scope-card strong,
.scope-note-card strong {
    display: block;
    color: var(--accent);
    font-size: 0.94rem;
}

.scope-card p,
.scope-note-card p {
    margin: 8px 0 0;
    line-height: 1.62;
    color: var(--text);
}

.scope-card span {
    display: block;
    margin-top: 8px;
    color: var(--muted);
    line-height: 1.58;
    font-size: 0.93rem;
}

.scope-card-ok {
    border-color: rgba(42, 124, 95, 0.18);
    background: linear-gradient(180deg, #fbfdfb 0%, #edf7f1 100%);
}

.scope-card-link {
    border-color: rgba(179, 82, 45, 0.18);
}

.customer-limit-list {
    display: grid;
    gap: 10px;
}

.login-shell {
    max-width: 1120px;
}

.login-hero {
    align-items: center;
}

.login-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-top: 20px;
}

.login-panel {
    min-height: 100%;
}

.login-textarea {
    width: 100%;
    border: 1px solid var(--line);
    background: var(--surface-strong);
    color: var(--text);
    border-radius: 18px;
    padding: 14px 16px;
    resize: vertical;
    min-height: 168px;
}

.login-message-box {
    margin-top: 14px;
    margin-bottom: 0;
}

.field {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-weight: 600;
}

.field input {
    width: 100%;
    border: 1px solid var(--line);
    background: var(--surface-strong);
    color: var(--text);
    border-radius: 14px;
    padding: 12px 14px;
}

.member-toolbar {
    margin-top: 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.member-toolbar h3 {
    margin: 0;
}

.member-toolbar p {
    margin: 4px 0 0;
    color: var(--muted);
    line-height: 1.5;
}

.toolbar-actions {
    display: flex;
    gap: 8px;
}

.members-section {
    margin-top: 18px;
}

.member-selection-strip {
    padding: 16px 18px;
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(10px);
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: 0 12px 26px rgba(88, 53, 22, 0.08);
}

.member-selection-strip .member-toolbar {
    margin-top: 0;
}

.member-selection-strip .selection-box {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(220px, 340px);
    gap: 14px;
    align-items: end;
    margin-top: 12px;
    border-radius: 8px;
}

.member-selection-strip .member-search-field {
    margin-top: 0;
}

.member-selection-strip .members-list {
    min-height: auto;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

.member-selection-strip .member-card-grid {
    display: flex;
    grid-template-columns: none;
    gap: 10px;
    align-items: stretch;
}

.member-selection-strip .member-card-option {
    flex: 0 0 220px;
}

.selection-box {
    margin-top: 12px;
    background: rgba(255, 250, 243, 0.82);
    border: 1px solid rgba(179, 82, 45, 0.12);
    border-radius: 18px;
    padding: 14px 16px;
    color: var(--muted);
    line-height: 1.6;
}

.inline-tool-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 14px;
}

.inline-tool-row-tight {
    margin-top: 10px;
}

.history-list-box {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.history-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 250, 243, 0.7);
}

.history-filter-bar span {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
}

.history-items-list {
    display: grid;
    gap: 8px;
}

.history-filter-empty {
    margin-top: 0;
}

.history-item {
    display: grid;
    gap: 4px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.history-item strong {
    font-size: 0.95rem;
}

.history-item span {
    color: var(--muted);
    font-size: 0.82rem;
}

.history-item a {
    color: var(--accent);
    font-weight: 700;
    text-decoration: none;
}

.history-generation-check {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.history-export-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.history-feedback {
    display: grid;
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--line);
}

.history-feedback-header,
.history-feedback-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.history-feedback-header {
    justify-content: space-between;
    color: var(--muted);
    font-size: 0.82rem;
}

.history-feedback-note {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 0.82rem;
}

.history-feedback-note textarea {
    width: 100%;
    resize: vertical;
    min-height: 58px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 10px;
    color: var(--text);
    background: var(--surface-strong);
    font: inherit;
}

.history-feedback-save,
.history-feedback-clear {
    justify-self: start;
}

.app-dialog {
    border: 0;
    padding: 0;
    background: transparent;
    max-width: min(760px, calc(100vw - 32px));
}

.app-dialog-wide {
    width: min(1120px, calc(100vw - 32px));
    max-width: min(1120px, calc(100vw - 32px));
}

.app-dialog::backdrop {
    background: rgba(31, 26, 23, 0.36);
    backdrop-filter: blur(6px);
}

.app-dialog-card {
    background: rgba(255, 250, 243, 0.98);
    border: 1px solid rgba(179, 82, 45, 0.18);
    border-radius: 24px;
    box-shadow: 0 24px 48px rgba(31, 26, 23, 0.18);
    padding: 22px;
}

.app-dialog-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
}

.app-dialog-header h2 {
    margin: 0;
    font-size: 1.2rem;
}

.app-dialog-body {
    margin-top: 14px;
    display: grid;
    gap: 12px;
    color: var(--muted);
    line-height: 1.7;
}

.app-dialog-panel-body {
    max-height: min(76vh, 760px);
    overflow: auto;
    padding-right: 4px;
}

.app-dialog-panel-body .panel,
.app-dialog-panel-body .fold-card,
.app-dialog-panel-body > .section-block {
    margin: 0;
}

.app-dialog-panel-body .panel {
    box-shadow: none;
    background: rgba(255, 255, 255, 0.72);
}

.app-dialog-panel-body .history-list-box {
    margin-top: 14px;
}

.app-dialog-panel-body .history-items-list {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    align-items: start;
}

.app-dialog-body p {
    margin: 0;
}

.dialog-note-card {
    border: 1px solid rgba(179, 82, 45, 0.12);
    border-radius: 18px;
    background: #fff;
    padding: 14px 16px;
}

.dialog-note-card strong {
    display: block;
    color: var(--text);
    margin-bottom: 6px;
}

.dialog-note-card p {
    margin: 0;
}

.members-list {
    margin-top: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    min-height: 220px;
    max-height: 340px;
    overflow: auto;
    padding: 12px;
    background: var(--surface);
}

.member-picker-summary {
    display: grid;
    gap: 4px;
}

.member-picker-summary strong {
    color: var(--text);
}

.member-search-field {
    display: grid;
    gap: 6px;
    margin-top: 12px;
}

.member-search-field span {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text);
}

.member-search-field input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 11px 12px;
    font: inherit;
    background: #fff;
    color: var(--text);
}

.member-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    align-content: start;
}

.single-member-box {
    min-height: auto;
}

.single-member-card {
    display: grid;
    gap: 8px;
}

.single-member-card strong {
    font-size: 1rem;
}

.single-member-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

.member-option {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 10px 8px;
    border-bottom: 1px dashed rgba(109, 98, 88, 0.18);
}

.member-card-option {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 12px;
    min-height: 72px;
    cursor: pointer;
}

.member-card-option:last-child {
    border-bottom: 1px solid var(--line);
}

.member-card-option.is-selected {
    border-color: rgba(179, 82, 45, 0.6);
    background: rgba(255, 250, 243, 0.95);
    box-shadow: inset 0 0 0 1px rgba(179, 82, 45, 0.16);
}

.member-card-option input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

.member-card-option strong,
.member-card-option small {
    display: block;
}

.member-card-option small {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.78rem;
    overflow-wrap: anywhere;
}

.member-option:last-child {
    border-bottom: 0;
}

.member-option span {
    flex: 1;
}

.button {
    border: 0;
    border-radius: 999px;
    padding: 12px 18px;
    cursor: pointer;
    transition:
        transform 160ms ease,
        background 160ms ease,
        color 160ms ease,
        box-shadow 160ms ease;
}

.link-button {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.dev-only-link {
    display: inline-flex;
}

.local-dev .dev-only-link {
    display: inline-flex;
}

.button:hover {
    transform: translateY(-1px);
}

.button-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 14px 28px rgba(179, 82, 45, 0.24);
}

.button-primary:hover {
    background: var(--accent-strong);
}

.button-secondary {
    background: #fff;
    color: var(--accent);
    border: 1px solid rgba(179, 82, 45, 0.2);
}

.button-ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--line);
}

.button-small {
    padding: 8px 12px;
    font-size: 0.92rem;
}

.button-wide {
    width: 100%;
    margin-top: 18px;
}

.button-wide-inline {
    width: 100%;
}

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 8px 12px;
    background: rgba(42, 124, 95, 0.12);
    color: var(--success);
    font-weight: 700;
    font-size: 0.88rem;
}

.badge-muted {
    background: rgba(109, 98, 88, 0.12);
    color: var(--muted);
}

.fold-card {
    margin-top: 18px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 250, 243, 0.72);
    overflow: hidden;
}

.fold-card summary {
    list-style: none;
    cursor: pointer;
    padding: 14px 16px;
    font-weight: 700;
    color: var(--text);
}

.fold-card summary::-webkit-details-marker {
    display: none;
}

.fold-card summary::after {
    content: '展開';
    float: right;
    color: var(--muted);
    font-weight: 600;
    font-size: 0.9rem;
}

.fold-card[open] summary::after {
    content: '收合';
}

.fold-card-body {
    padding: 0 16px 16px;
}

.message-box,
.narrative-box,
.table-wrap,
.chart-box,
.empty-state {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 16px;
}

.is-hidden {
    display: none !important;
}

.message-box {
    margin-bottom: 22px;
    color: var(--muted);
}

.pre-wrap-box {
    white-space: pre-wrap;
}

.narrative-box {
    line-height: 1.72;
}

.rich-heading-main,
.rich-heading,
.rich-subheading {
    margin: 0 0 12px;
    color: var(--text);
}

.rich-heading-main {
    font-size: 1.35rem;
    line-height: 1.3;
}

.rich-heading {
    font-size: 1.08rem;
    line-height: 1.45;
}

.rich-subheading {
    font-size: 1rem;
    color: var(--accent);
    line-height: 1.5;
}

.rich-paragraph {
    margin: 0 0 12px;
    color: inherit;
    line-height: 1.78;
}

.rich-list {
    margin: 0 0 14px;
    padding-left: 20px;
    display: grid;
    gap: 8px;
}

.rich-list li {
    line-height: 1.72;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.highlight-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.highlight-card {
    background: linear-gradient(180deg, #fffdf8 0%, #f8ece2 100%);
    border: 1px solid rgba(179, 82, 45, 0.14);
    border-radius: 18px;
    padding: 16px;
}

.highlight-card strong {
    display: block;
    color: var(--accent);
    font-size: 0.92rem;
}

.highlight-card h4 {
    margin: 10px 0 6px;
    font-size: 1.08rem;
}

.highlight-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

.kpi-card {
    background: linear-gradient(180deg, #fffdf8 0%, #f9efe6 100%);
    border: 1px solid rgba(179, 82, 45, 0.14);
    border-radius: 18px;
    padding: 16px;
}

.kpi-card strong {
    display: block;
    color: var(--muted);
    font-size: 0.92rem;
}

.kpi-card span {
    display: block;
    margin-top: 8px;
    font-size: 1.4rem;
    font-weight: 800;
}

.chart-box canvas {
    display: block;
    width: 100%;
    min-height: 180px;
}

.bar-chart {
    display: grid;
    gap: 12px;
}

.quick-prompts {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.prompt-chip {
    white-space: nowrap;
}

.chat-messages {
    min-height: 380px;
    max-height: 58vh;
    overflow: auto;
    display: grid;
    gap: 12px;
    padding: 4px 0;
}

.chat-bubble {
    max-width: 88%;
    padding: 14px 16px;
    border-radius: 18px;
    border: 1px solid var(--line);
    white-space: pre-wrap;
    line-height: 1.68;
}

.chat-bubble .rich-paragraph:last-child,
.narrative-box .rich-paragraph:last-child {
    margin-bottom: 0;
}

.chat-assistant {
    background: var(--surface);
    justify-self: start;
}

.chat-user {
    background: linear-gradient(180deg, #f8ece2 0%, #f3dfd0 100%);
    justify-self: end;
    border-color: rgba(179, 82, 45, 0.18);
}

.chat-composer {
    margin-top: 18px;
    display: grid;
    gap: 12px;
}

.chat-composer textarea {
    width: 100%;
    border: 1px solid var(--line);
    background: var(--surface-strong);
    color: var(--text);
    border-radius: 18px;
    padding: 14px 16px;
    resize: vertical;
    min-height: 110px;
}

.chat-actions {
    display: flex;
    justify-content: flex-end;
}

.bar-row {
    display: grid;
    gap: 8px;
}

.bar-label {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-weight: 700;
}

.bar-track {
    overflow: hidden;
    height: 14px;
    border-radius: 999px;
    background: rgba(179, 82, 45, 0.12);
}

.bar-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #d57d4b 0%, #b3522d 100%);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.96rem;
}

th,
td {
    padding: 12px 10px;
    text-align: left;
    border-bottom: 1px solid rgba(109, 98, 88, 0.14);
}

th {
    color: var(--muted);
    font-weight: 700;
}

tr:last-child td {
    border-bottom: 0;
}

@media (max-width: 1080px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .login-layout {
        grid-template-columns: 1fr;
    }

    .sticky-action-bar {
        grid-template-columns: 1fr;
    }

    .sticky-action-group {
        grid-template-columns: 1fr 1fr;
    }

    .member-selection-strip .selection-box {
        grid-template-columns: 1fr;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .highlight-grid {
        grid-template-columns: 1fr;
    }

    .template-grid {
        grid-template-columns: 1fr;
    }

    .scan-summary-grid {
        grid-template-columns: 1fr;
    }

    .visual-grid {
        grid-template-columns: 1fr;
    }

    .visual-table-card {
        grid-column: auto;
    }
}

@media (max-width: 720px) {
    .page-shell {
        padding: 18px 14px 36px;
    }

    .hero {
        padding: 22px;
        flex-direction: column;
        align-items: start;
    }

    .grid-two,
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .sticky-action-group {
        grid-template-columns: 1fr;
    }

    .sticky-action-bar {
        top: 8px;
        padding: 14px;
    }

    .member-selection-strip {
        padding: 14px;
    }

    .member-selection-strip .member-toolbar {
        align-items: start;
        flex-direction: column;
    }

    .member-selection-strip .member-card-option {
        flex-basis: 190px;
    }

    .report-visuals-title {
        align-items: start;
        flex-direction: column;
    }
}

@media print {
    @page {
        size: A4;
        margin: 12mm;
    }

    body {
        background: #fff;
    }

    .page-shell {
        max-width: none;
        padding: 0;
    }

    .controls-panel,
    .hero-actions,
    .message-box {
        display: none;
    }

    .sticky-action-bar {
        display: none;
    }

    .layout {
        grid-template-columns: 1fr;
    }

    .report-tabs {
        display: none;
    }

    .report-tab-panel {
        display: block !important;
        break-inside: auto;
        page-break-inside: auto;
    }

    .report-tab-panel + .report-tab-panel {
        break-before: page;
        page-break-before: always;
    }

    .panel,
    .hero {
        box-shadow: none;
        border: 0;
        background: #fff;
        padding-left: 0;
        padding-right: 0;
    }

    .report-batch-card,
    .visual-card,
    .narrative-box,
    .table-wrap {
        break-inside: avoid;
        page-break-inside: avoid;
        box-shadow: none;
        overflow: visible;
    }

    .report-batch-card {
        border-color: #ddd;
        background: #fff;
        padding: 0;
    }

    .report-visuals {
        margin-top: 12px;
    }

    .visual-grid {
        display: block;
    }

    .visual-card {
        margin-bottom: 10px;
        background: #fff;
        border-color: #ddd;
    }

    .mini-line-points,
    .compact-table,
    .table-wrap {
        overflow: visible;
    }

    .compact-table table,
    .table-wrap table {
        min-width: 0;
        width: 100%;
        table-layout: fixed;
        font-size: 0.78rem;
    }

    .compact-table th,
    .compact-table td,
    .table-wrap th,
    .table-wrap td {
        padding: 6px 5px;
        word-break: break-word;
        overflow-wrap: anywhere;
    }
}
