/* ============================================================
   FinScope - 財務分析プロフェッショナル
   Modern Financial Analysis Platform CSS
   ============================================================ */

:root {
    --primary: #1a56db;
    --primary-dark: #1040a0;
    --primary-light: #e8efff;
    --accent: #0ea5e9;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #6366f1;

    --bg: #f8fafc;
    --bg-card: #ffffff;
    --bg-sidebar: #0f172a;
    --bg-input: #f1f5f9;

    --text: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-inverse: #f8fafc;

    --border: #e2e8f0;
    --border-focus: #1a56db;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);

    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    --sidebar-width: 260px;
    --header-height: 64px;

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 14px; scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* Typography */
h1 { font-size: 1.875rem; font-weight: 700; letter-spacing: -0.025em; }
h2 { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.025em; }
h3 { font-size: 1.25rem; font-weight: 600; }
h4 { font-size: 1.125rem; font-weight: 600; }

a { color: var(--primary); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--primary-dark); }

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.52);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 90;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background:
        radial-gradient(circle at top, rgba(59,130,246,0.15), transparent 32%),
        linear-gradient(180deg, #0f172a 0%, #111827 100%);
    color: var(--text-inverse);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.02);
    backdrop-filter: blur(8px);
}

.sidebar-logo {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.03em;
}

.sidebar-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.sidebar-nav {
    padding: 14px 12px;
}

.nav-section {
    padding: 12px 12px 6px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255,255,255,0.34);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
    padding: 10px 12px;
    color: rgba(255,255,255,0.74);
    cursor: pointer;
    transition: all 0.15s;
    font-size: 0.9rem;
    border: 1px solid transparent;
    border-radius: 12px;
}

.nav-item:hover {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.08);
    color: #fff;
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(37,99,235,0.2), rgba(14,165,233,0.14));
    color: #dbeafe;
    border-color: rgba(96,165,250,0.35);
    box-shadow: inset 0 0 0 1px rgba(96,165,250,0.12);
}

.nav-item svg, .nav-item .nav-icon {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    font-size: 0.95rem;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.06);
}

.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid rgba(255,255,255,0.08);
    margin-top: auto;
}

.nav-section-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}

.nav-sub-section {
    padding-left: 10px;
    margin-bottom: 8px;
}

.nav-sub-section.collapsed {
    display: none;
}

.nav-toggle-icon {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.55);
}

/* ============================================================
   Collapsible Nav Section (for Profit Plan)
   ============================================================ */
.nav-section-collapsible {
    padding: 8px 24px 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255,255,255,0.35);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    transition: color 0.15s;
}

.nav-section-collapsible:hover {
    color: rgba(255,255,255,0.6);
}

.nav-section-collapsible .collapse-icon {
    font-size: 0.6rem;
    transition: transform 0.2s;
}

.nav-section-collapsible.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

.nav-group {
    overflow: hidden;
    max-height: 500px;
    transition: max-height 0.3s ease;
}

.nav-group.collapsed {
    max-height: 0;
}

.nav-item.sub-item {
    padding-left: 36px;
    font-size: 0.82rem;
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-header {
    height: var(--header-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

.header-left { display: flex; align-items: center; gap: 16px; }
.header-right { display: flex; align-items: center; gap: 16px; }

.sidebar-toggle {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    border-radius: 12px;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

.sidebar-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    border-radius: 999px;
    background: #0f172a;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.breadcrumb span { color: var(--text-muted); }

.page-content {
    padding: 24px 32px;
    max-width: 1400px;
    width: 100%;
    flex: 1;
}

.app-footer {
    border-top: 1px solid var(--border);
    background: #ffffff;
    padding: 18px 32px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.app-footer-links {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.app-footer-links a {
    font-size: 0.83rem;
    color: var(--text-secondary);
}

.app-footer-copy {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.page-title {
    margin-bottom: 24px;
}

.page-title h1 { margin-bottom: 4px; }
.page-title p { color: var(--text-secondary); font-size: 0.9rem; }

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 { font-size: 1rem; }

.card-body { padding: 24px; }
.card-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg);
}

/* Grid */
.grid { display: grid; gap: 24px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* Stat Cards */
.stat-card {
    padding: 20px 24px;
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    border: 1px solid var(--border);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.stat-change {
    font-size: 0.8rem;
    font-weight: 500;
    margin-top: 4px;
}

.stat-change.positive { color: var(--success); }
.stat-change.negative { color: var(--danger); }

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text);
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: var(--font);
    background: var(--bg-card);
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(26,86,219,0.1);
}

.form-input.number {
    text-align: right;
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

.form-help {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-error {
    font-size: 0.75rem;
    color: var(--danger);
    margin-top: 4px;
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn-success {
    background: var(--success);
    color: #fff;
}
.btn-success:hover { background: #059669; }

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover { background: #dc2626; }

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}
.btn-outline:hover { background: var(--primary-light); }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn-block { width: 100%; }

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-group { display: flex; gap: 8px; }

/* Tables */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

th {
    background: var(--bg);
    font-weight: 600;
    color: var(--text-secondary);
    position: sticky;
    top: 0;
    z-index: 1;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(26,86,219,0.02); }

td.number {
    text-align: right;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

td.positive { color: var(--success); }
td.negative { color: var(--danger); }

.row-highlight td { background: var(--primary-light); font-weight: 600; }
.row-subtotal td { background: #f0fdf4; font-weight: 600; }
.row-total td { background: #fef3c7; font-weight: 700; }

/* Financial Input Table */
.fin-table {
    width: 100%;
}

.fin-table th {
    background: #1e293b;
    color: #fff;
    padding: 8px 12px;
    font-size: 0.8rem;
}

.fin-table td {
    padding: 4px 8px;
}

.fin-table .label-cell {
    background: #f8fafc;
    font-weight: 500;
    white-space: nowrap;
    min-width: 200px;
}

.fin-table .input-cell {
    padding: 2px 4px;
}

.fin-table .input-cell input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    text-align: right;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    background: #fff;
}

.fin-table .input-cell input:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 2px rgba(26,86,219,0.1);
}

.fin-table .calc-cell {
    text-align: right;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--primary);
    font-weight: 600;
    background: #f0f7ff;
}
.fin-table .calc-cell.negative {
    color: #dc2626;
}

.fin-table .pct-cell {
    text-align: right;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    margin-bottom: 24px;
    gap: 0;
}

.tab {
    padding: 12px 24px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s;
}

.tab:hover { color: var(--text); }
.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ============================================================
   Tab Navigation (New enhanced tab nav)
   ============================================================ */
.tab-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    background: var(--bg);
    border-radius: var(--radius);
    padding: 4px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
}

.tab-nav-item {
    padding: 8px 16px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.15s;
    white-space: nowrap;
    text-align: center;
}

.tab-nav-item:hover {
    background: rgba(26,86,219,0.08);
    color: var(--text);
}

.tab-nav-item.active {
    background: var(--primary);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef3c7; color: #b45309; }
.badge-danger { background: #fee2e2; color: #dc2626; }

/* Alert */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 12px; font-size: 0.9rem; }
.alert-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.alert-danger { background: #fee2e2; color: #dc2626; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }
.alert-info { background: #dbeafe; color: #1d4ed8; border: 1px solid #bfdbfe; }

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    overflow-y: auto;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-body { padding: 24px; }

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
}

/* Charts Container */
.chart-container {
    position: relative;
    width: 100%;
    height: 300px;
}

.chart-container.large { height: 400px; }

/* Radar Chart */
.radar-container {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 350px;
}

/* Toast */
.toast-container {
    position: fixed;
    top: 80px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 0.85rem;
    animation: slideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 280px;
}

.toast-success { background: #059669; color: #fff; }
.toast-error { background: #dc2626; color: #fff; }
.toast-info { background: var(--primary); color: #fff; }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Loading */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Auth Pages */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
    padding: 20px;
}

.auth-card {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 440px;
    padding: 40px;
}

.auth-logo {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo h1 {
    font-size: 2rem;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-logo p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 4px;
}

.auth-legal {
    margin-top: 22px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.auth-legal a {
    color: var(--text-secondary);
}

/* Dashboard */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.org-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.org-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.org-card h4 { margin-bottom: 8px; }
.org-card .org-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Guest Banner */
.guest-banner {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border: 1px solid #f59e0b;
    border-radius: var(--radius);
    padding: 12px 20px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.guest-banner p {
    font-size: 0.85rem;
    color: #92400e;
    font-weight: 500;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.empty-state h3 { margin-bottom: 8px; color: var(--text); }
.empty-state p { margin-bottom: 20px; }

/* Analysis Category Header */
.category-header {
    padding: 12px 16px;
    background: linear-gradient(135deg, #1e293b, #334155);
    color: #fff;
    border-radius: var(--radius) var(--radius) 0 0;
    font-weight: 600;
    font-size: 0.95rem;
}

/* Score Display */
.score-display {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.9rem;
}

.score-excellent { background: #dcfce7; color: #15803d; }
.score-good { background: #e0f2fe; color: #0369a1; }
.score-average { background: #fef3c7; color: #b45309; }
.score-poor { background: #fee2e2; color: #dc2626; }

/* Help Content */
.help-section {
    margin-bottom: 32px;
}

.help-section h3 {
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary);
    display: inline-block;
}

.help-item {
    padding: 16px;
    border-left: 3px solid var(--primary);
    background: var(--primary-light);
    border-radius: 0 var(--radius) var(--radius) 0;
    margin-bottom: 12px;
}

.help-item h4 { margin-bottom: 4px; }
.help-item p { font-size: 0.85rem; color: var(--text-secondary); }

.formula-box {
    background: #1e293b;
    color: #e2e8f0;
    padding: 12px 16px;
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    margin: 8px 0;
}

/* ============================================================
   Admin Dashboard Styles
   ============================================================ */
.admin-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}
@media (max-width: 1200px) { .admin-kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 768px)  { .admin-kpi-grid { grid-template-columns: 1fr; } }

.admin-kpi-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    border-radius: 16px;
    background: white;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    transition: transform 0.2s, box-shadow 0.2s;
}
.admin-kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
}
.kpi-icon {
    font-size: 2.2rem;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    flex-shrink: 0;
}
.kpi-blue .kpi-icon  { background: linear-gradient(135deg, #dbeafe, #bfdbfe); }
.kpi-green .kpi-icon { background: linear-gradient(135deg, #dcfce7, #bbf7d0); }
.kpi-purple .kpi-icon { background: linear-gradient(135deg, #ede9fe, #ddd6fe); }
.kpi-amber .kpi-icon  { background: linear-gradient(135deg, #fef3c7, #fde68a); }

.kpi-value {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1.1;
    color: #1e293b;
}
.kpi-label {
    font-size: 0.85rem;
    color: #64748b;
    font-weight: 500;
}
.kpi-sub {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 2px;
}

/* Rank badges */
.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    color: white;
}
.rank-1 { background: linear-gradient(135deg, #f59e0b, #d97706); }
.rank-2 { background: linear-gradient(135deg, #94a3b8, #64748b); }
.rank-3 { background: linear-gradient(135deg, #d97706, #b45309); }
.rank-other { background: #e2e8f0; color: #64748b; }

/* Activity timeline */
.activity-timeline { display: flex; flex-direction: column; gap: 0; }
.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.87rem;
}
.activity-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 5px;
}
.activity-content { flex: 1; }
.activity-action {
    background: #f1f5f9;
    padding: 1px 8px;
    border-radius: 4px;
    font-size: 0.78rem;
    margin: 0 4px;
}
.activity-time {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 2px;
}

/* Compact data table */
.data-table.compact td, .data-table.compact th {
    padding: 6px 10px;
    font-size: 0.85rem;
}

/* Small form select */
.form-select-sm {
    padding: 4px 8px;
    font-size: 0.8rem;
    border-radius: 6px;
}

/* ============================================================
   Monthly Grid Tables (Profit Planning)
   ============================================================ */
.monthly-grid-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.monthly-grid {
    min-width: 1200px;
    border-collapse: collapse;
    width: 100%;
}

.monthly-grid th,
.monthly-grid td {
    padding: 6px 10px;
    font-size: 0.8rem;
    border: 1px solid var(--border);
    white-space: nowrap;
}

.monthly-grid th {
    background: #1e293b;
    color: #fff;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 2;
}

.monthly-grid td:first-child,
.monthly-grid th:first-child {
    position: sticky;
    left: 0;
    z-index: 3;
    background: #f8fafc;
    min-width: 160px;
    font-weight: 500;
}

.monthly-grid th:first-child {
    z-index: 4;
    background: #1e293b;
}

.monthly-grid td.number {
    text-align: right;
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.monthly-grid .annual-total {
    background: #fef3c7;
    font-weight: 700;
}

.monthly-grid .input-cell input {
    width: 90px;
    padding: 4px 6px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    text-align: right;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    background: #fff;
}

.monthly-grid .input-cell input:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 2px rgba(26,86,219,0.1);
}

.monthly-grid .row-header {
    background: #f0f7ff;
    font-weight: 600;
}

.monthly-grid .row-subtotal td {
    background: #f0fdf4;
    font-weight: 600;
}

.monthly-grid .row-total td {
    background: #fef3c7;
    font-weight: 700;
}

/* ============================================================
   SWOT Analysis Grid
   ============================================================ */
.swot-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.swot-quadrant {
    padding: 20px;
    min-height: 200px;
}

.swot-quadrant h4 {
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid;
    font-size: 0.9rem;
}

.swot-quadrant.so {
    background: #f0fdf4;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}
.swot-quadrant.so h4 { border-color: var(--success); color: var(--success); }

.swot-quadrant.wo {
    background: #eff6ff;
    border-bottom: 1px solid var(--border);
}
.swot-quadrant.wo h4 { border-color: var(--primary); color: var(--primary); }

.swot-quadrant.st {
    background: #fefce8;
    border-right: 1px solid var(--border);
}
.swot-quadrant.st h4 { border-color: var(--warning); color: var(--warning); }

.swot-quadrant.wt {
    background: #fef2f2;
}
.swot-quadrant.wt h4 { border-color: var(--danger); color: var(--danger); }

.swot-quadrant textarea {
    width: 100%;
    min-height: 120px;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px;
    font-size: 0.85rem;
    font-family: var(--font);
    resize: vertical;
    background: rgba(255,255,255,0.8);
}

.swot-quadrant textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(26,86,219,0.1);
}

/* SWOT Item List */
.swot-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.swot-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.swot-item input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.85rem;
}

.swot-item input:focus {
    outline: none;
    border-color: var(--primary);
}

.swot-item .btn-remove {
    padding: 4px 8px;
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 1rem;
}

.swot-column {
    flex: 1;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
}

.swot-column h4 {
    margin-bottom: 12px;
    font-size: 0.9rem;
}

.swot-column.opportunities { border-top: 3px solid var(--success); }
.swot-column.threats { border-top: 3px solid var(--danger); }
.swot-column.strengths { border-top: 3px solid var(--primary); }
.swot-column.weaknesses { border-top: 3px solid var(--warning); }

/* ============================================================
   Normative Profit Gauge / Progress Bar
   ============================================================ */
.gauge-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
}

.gauge-bar {
    width: 100%;
    height: 24px;
    background: #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    margin: 12px 0;
}

.gauge-fill {
    height: 100%;
    border-radius: 12px;
    transition: width 0.5s ease;
    position: relative;
}

.gauge-fill.excellent { background: linear-gradient(90deg, #10b981, #059669); }
.gauge-fill.good { background: linear-gradient(90deg, #3b82f6, #1d4ed8); }
.gauge-fill.average { background: linear-gradient(90deg, #f59e0b, #d97706); }
.gauge-fill.poor { background: linear-gradient(90deg, #ef4444, #dc2626); }

.gauge-labels {
    display: flex;
    justify-content: space-between;
    width: 100%;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.gauge-value {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 4px;
}

.gauge-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ============================================================
   Phase Stepper / Indicator
   ============================================================ */
.phase-stepper {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 24px;
    padding: 16px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow-x: auto;
}

.phase-step {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius);
    transition: all 0.15s;
    white-space: nowrap;
}

.phase-step:hover {
    background: var(--primary-light);
    color: var(--text);
}

.phase-step.active {
    background: var(--primary);
    color: #fff;
}

.phase-step.completed {
    color: var(--success);
}

.phase-step .step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--border);
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    flex-shrink: 0;
}

.phase-step.active .step-number {
    background: rgba(255,255,255,0.2);
    color: #fff;
}

.phase-step.completed .step-number {
    background: var(--success);
    color: #fff;
}

.phase-connector {
    width: 24px;
    height: 2px;
    background: var(--border);
    flex-shrink: 0;
}

/* ============================================================
   Admin Read-Only Data Tables
   ============================================================ */
.readonly-table {
    width: 100%;
    border-collapse: collapse;
}

.readonly-table th {
    background: #1e293b;
    color: #fff;
    padding: 8px 12px;
    font-size: 0.8rem;
    text-align: left;
}

.readonly-table td {
    padding: 6px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

.readonly-table td.number {
    text-align: right;
    font-family: var(--font-mono);
}

.readonly-table tr:hover td {
    background: rgba(26,86,219,0.03);
}

.readonly-table .section-header td {
    background: linear-gradient(135deg, #f0f7ff, #e8efff);
    font-weight: 700;
    color: var(--primary);
    padding: 10px 12px;
}

.readonly-table .subtotal td {
    background: #f0fdf4;
    font-weight: 600;
}

.readonly-table .total td {
    background: #fef3c7;
    font-weight: 700;
}

/* Admin data clickable rows */
.clickable-row {
    cursor: pointer;
    transition: background 0.15s;
}

.clickable-row:hover td {
    background: var(--primary-light) !important;
}

/* ============================================================
   Profit Plan Specific
   ============================================================ */
.profit-plan-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding: 16px 20px;
    background: linear-gradient(135deg, #1e293b, #334155);
    border-radius: var(--radius-lg);
    color: #fff;
}

.profit-plan-header h2 {
    color: #fff;
    font-size: 1.2rem;
}

.profit-plan-header .phase-badge {
    padding: 4px 12px;
    background: rgba(255,255,255,0.15);
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Four-component calc display */
.calc-components {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 16px 0;
}

.calc-component {
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-align: center;
    min-width: 120px;
}

.calc-component .comp-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.calc-component .comp-value {
    font-size: 1.1rem;
    font-weight: 700;
    font-family: var(--font-mono);
}

.calc-operator {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-muted);
}

.calc-result {
    padding: 12px 20px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: var(--radius);
    color: #fff;
    text-align: center;
    min-width: 140px;
}

.calc-result .comp-label {
    font-size: 0.7rem;
    opacity: 0.8;
    margin-bottom: 4px;
}

.calc-result .comp-value {
    font-size: 1.2rem;
    font-weight: 800;
    font-family: var(--font-mono);
}

/* Quantitative targets table */
.quant-table {
    width: 100%;
    border-collapse: collapse;
}

.quant-table th {
    background: #1e293b;
    color: #fff;
    padding: 8px 12px;
    font-size: 0.8rem;
    text-align: center;
}

.quant-table td {
    padding: 6px 10px;
    border: 1px solid var(--border);
    font-size: 0.85rem;
}

.quant-table td:first-child {
    background: #f8fafc;
    font-weight: 500;
    min-width: 180px;
}

.quant-table td input {
    width: 100%;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    text-align: right;
    font-family: var(--font-mono);
    font-size: 0.82rem;
}

.quant-table td input:focus {
    border-color: var(--primary);
    outline: none;
}

.quant-table .calc-row td {
    background: #f0f7ff;
    color: var(--primary);
    font-weight: 600;
    text-align: right;
    font-family: var(--font-mono);
}

/* Department plan mini table */
.dept-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.dept-table th {
    background: #334155;
    color: #fff;
    padding: 6px 10px;
    font-size: 0.78rem;
}

.dept-table td {
    padding: 4px 8px;
    border: 1px solid var(--border);
}

.dept-table td input {
    width: 80px;
    padding: 3px 6px;
    border: 1px solid var(--border);
    border-radius: 3px;
    text-align: right;
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

/* Action plan */
.action-plan-table {
    width: 100%;
    border-collapse: collapse;
}

.action-plan-table th {
    background: #1e293b;
    color: #fff;
    padding: 8px 10px;
    font-size: 0.78rem;
    text-align: center;
}

.action-plan-table td {
    padding: 4px 6px;
    border: 1px solid var(--border);
    font-size: 0.82rem;
    vertical-align: top;
}

.action-plan-table input,
.action-plan-table textarea {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.8rem;
    font-family: var(--font);
}

.action-plan-table textarea {
    min-height: 40px;
    resize: vertical;
}

/* Quarter timeline cells */
.quarter-cell {
    text-align: center;
    min-width: 40px;
}

.quarter-cell input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1200px) {
    .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .swot-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.active {
        opacity: 1;
        pointer-events: auto;
    }
    .main-content { margin-left: 0; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .page-content { padding: 16px; }
    .main-header { padding: 0 16px; }
    .sidebar-toggle { display: inline-flex; }
    .auth-card { padding: 24px; }
    .tab-nav { flex-direction: column; }
    .phase-stepper { flex-direction: column; align-items: flex-start; }
    .phase-connector { width: 2px; height: 16px; margin-left: 11px; }
    .calc-components { flex-direction: column; align-items: stretch; }
    .guest-banner {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .app-footer {
        padding: 18px 16px 22px;
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ============================================================
   Print Styles
   ============================================================ */
@media print {
    .sidebar, .main-header, .btn, .nav-item,
    .guest-banner, .toast-container, .modal-overlay,
    .phase-stepper, .tab-nav { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .page-content { padding: 0 !important; max-width: none !important; }
    .card { break-inside: avoid; box-shadow: none !important; border: 1px solid #ddd !important; }
    .monthly-grid-wrapper { overflow: visible !important; }
    .monthly-grid { min-width: auto !important; }
    .monthly-grid td:first-child,
    .monthly-grid th:first-child { position: static !important; }
    .readonly-table { page-break-inside: auto; }
    .readonly-table tr { page-break-inside: avoid; }
    body { font-size: 11px; }
    h1 { font-size: 16px; }
    h2 { font-size: 14px; }
    h3 { font-size: 12px; }
    .fin-table td, .fin-table th,
    .monthly-grid td, .monthly-grid th,
    .readonly-table td, .readonly-table th {
        padding: 3px 6px !important;
        font-size: 9px !important;
    }
}

/* Utility */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.hidden { display: none !important; }

/* Inline Upload Box for PL/BS forms */
.upload-inline-area { margin-bottom: 12px; }
.upload-inline-box {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 12px 16px;
    background: #f8fafc;
    transition: all 0.2s;
    cursor: pointer;
}
.upload-inline-box:hover {
    border-color: var(--primary);
    background: #eff6ff;
}
.upload-inline-content {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-muted);
}
.upload-inline-icon { font-size: 1.3rem; }
.upload-inline-hint {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--text-muted);
}
.upload-inline-status {
    margin-top: 8px;
    font-size: 0.85rem;
    padding: 6px 10px;
    border-radius: 6px;
    background: #fff;
}
.spinner-sm {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 4px;
}

/* Nav section toggle */
.nav-section-toggle { cursor: pointer; user-select: none; display: flex; justify-content: space-between; align-items: center; }
.nav-toggle-icon { font-size: 0.65rem; transition: transform 0.2s; }
.nav-sub-section { overflow: hidden; transition: max-height 0.3s ease; max-height: 500px; }
.nav-sub-section.collapsed { max-height: 0; }

/* Tab navigation */
.tab-nav { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab-nav-item {
    padding: 10px 18px;
    cursor: pointer;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    transition: all 0.2s;
    font-weight: 500;
    font-size: 0.9rem;
}
.tab-nav-item:hover { color: var(--primary); }
.tab-nav-item.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

/* Monthly grid table */
.monthly-grid-wrapper { overflow-x: auto; }
.monthly-grid {
    min-width: 1200px;
    border-collapse: collapse;
}
.monthly-grid th, .monthly-grid td {
    padding: 6px 8px;
    border: 1px solid var(--border);
    text-align: right;
    font-size: 0.82rem;
    min-width: 85px;
}
.monthly-grid th { background: var(--primary); color: white; font-weight: 600; text-align: center; position: sticky; top: 0; z-index: 1; }
.monthly-grid th:first-child, .monthly-grid td:first-child {
    position: sticky;
    left: 0;
    background: #f1f5f9;
    text-align: left;
    font-weight: 600;
    min-width: 160px;
    z-index: 2;
}
.monthly-grid th:first-child { z-index: 3; }
.monthly-grid td:last-child { background: #eff6ff; font-weight: 600; }
.monthly-grid input {
    width: 100%;
    border: 1px solid transparent;
    background: transparent;
    text-align: right;
    font-size: 0.82rem;
    padding: 2px 4px;
}
.monthly-grid input:focus { border-color: var(--primary); background: white; outline: none; }

/* SWOT quadrant */
.swot-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.swot-quadrant {
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    min-height: 180px;
}
.swot-quadrant.so { border-color: #22c55e; background: #f0fdf4; }
.swot-quadrant.wo { border-color: #eab308; background: #fefce8; }
.swot-quadrant.st { border-color: #3b82f6; background: #eff6ff; }
.swot-quadrant.wt { border-color: #ef4444; background: #fef2f2; }
.swot-quadrant h4 { margin: 0 0 8px 0; font-size: 0.9rem; }
.swot-quadrant textarea {
    width: 100%;
    min-height: 120px;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 8px;
    font-size: 0.85rem;
    resize: vertical;
}

/* Phase stepper */
.phase-stepper { display: flex; gap: 4px; margin-bottom: 20px; }
.phase-step {
    flex: 1;
    text-align: center;
    padding: 8px 4px;
    background: #f1f5f9;
    border-radius: 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}
.phase-step.active { background: var(--primary); color: white; font-weight: 600; }
.phase-step:hover { background: #dbeafe; }

/* Normative profit gauge */
.gauge-container { display: flex; align-items: center; gap: 16px; margin: 16px 0; }
.gauge-bar { flex: 1; height: 24px; background: #e5e7eb; border-radius: 12px; overflow: hidden; }
.gauge-fill { height: 100%; border-radius: 12px; transition: width 0.5s ease; }
.gauge-fill.low { background: linear-gradient(90deg, #ef4444, #f97316); }
.gauge-fill.mid { background: linear-gradient(90deg, #f97316, #eab308); }
.gauge-fill.high { background: linear-gradient(90deg, #22c55e, #10b981); }

/* Read-only data tables (admin) */
.readonly-table td { background: #fafafa; }
.readonly-table .value-cell { text-align: right; font-family: 'Inter', monospace; }

/* Print styles */
/* Phase 1 - 当期着地予測 */
.forecast-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.forecast-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 20px; text-align: center; }
.forecast-card .fc-label { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 4px; }
.forecast-card .fc-value { font-size: 1.5rem; font-weight: 700; color: var(--text); }
.forecast-card .fc-value.positive { color: var(--success); }
.forecast-card .fc-value.negative { color: var(--danger); }
.forecast-card .fc-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }

/* Cost classification table */
.cost-classify-table { width: 100%; border-collapse: collapse; }
.cost-classify-table th { background: #f1f5f9; padding: 8px 12px; text-align: left; font-size: 0.85rem; border-bottom: 2px solid var(--border); }
.cost-classify-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.cost-classify-table td.number { text-align: right; font-family: 'Inter', monospace; }
.cost-classify-table select { padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.85rem; }
.cost-classify-table tr.subtotal { background: #fefce8; font-weight: 600; }
.cost-classify-table tr.total { background: var(--primary-light); font-weight: 700; }

/* Strategy cards */
.strategy-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.strategy-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.strategy-card h4 { color: var(--primary); margin-bottom: 8px; font-size: 0.95rem; }
.strategy-card textarea { width: 100%; min-height: 100px; border: 1px solid var(--border); border-radius: 8px; padding: 10px; font-size: 0.9rem; resize: vertical; }

/* Sales plan table */
.sales-plan-table { width: 100%; border-collapse: collapse; }
.sales-plan-table th { background: var(--primary); color: white; padding: 8px 12px; font-size: 0.85rem; }
.sales-plan-table td { padding: 6px 10px; border: 1px solid var(--border); }
.sales-plan-table td input { width: 100%; border: none; background: transparent; text-align: right; font-size: 0.9rem; padding: 4px; }
.sales-plan-table td input:focus { background: #eff6ff; outline: 2px solid var(--primary); border-radius: 4px; }
.sales-plan-table tfoot td { background: #f1f5f9; font-weight: 700; }

/* Extraordinary items */
.extra-section { margin-bottom: 16px; }
.extra-section h4 { color: var(--primary); padding: 8px 12px; background: var(--primary-light); border-radius: 8px 8px 0 0; margin-bottom: 0; font-size: 0.9rem; }

/* Consolidated budget */
.budget-summary-table { width: 100%; border-collapse: collapse; }
.budget-summary-table th { background: #1e3a5f; color: white; padding: 10px 12px; font-size: 0.85rem; }
.budget-summary-table td { padding: 8px 12px; border: 1px solid var(--border); }
.budget-summary-table td.number { text-align: right; font-family: 'Inter', monospace; }
.budget-summary-table tr.section-header td { background: #f1f5f9; font-weight: 600; color: var(--primary); }
.budget-summary-table tr.grand-total td { background: var(--primary); color: white; font-weight: 700; font-size: 1rem; }
.budget-summary-table .diff-positive { color: var(--success); }
.budget-summary-table .diff-negative { color: var(--danger); }

/* Phase 6 - Plan metrics */
.metrics-comparison-table { width: 100%; border-collapse: collapse; }
.metrics-comparison-table th { background: var(--primary); color: white; padding: 10px 14px; font-size: 0.85rem; position: sticky; top: 0; }
.metrics-comparison-table td { padding: 8px 14px; border-bottom: 1px solid var(--border); }
.metrics-comparison-table td.number { text-align: right; font-family: 'Inter', monospace; }
.metrics-comparison-table tr.domain-header td { background: #f8fafc; font-weight: 700; color: var(--primary); font-size: 0.95rem; border-top: 2px solid var(--primary); }
.metrics-comparison-table .eval-good { background: #dcfce7; color: #166534; padding: 2px 8px; border-radius: 12px; font-size: 0.8rem; }
.metrics-comparison-table .eval-warn { background: #fef9c3; color: #854d0e; padding: 2px 8px; border-radius: 12px; font-size: 0.8rem; }
.metrics-comparison-table .eval-bad { background: #fecaca; color: #991b1b; padding: 2px 8px; border-radius: 12px; font-size: 0.8rem; }

/* Trend chart area */
.trend-chart-container { position: relative; height: 300px; margin: 16px 0; }

/* Progress bar */
.progress-bar-container { background: #e2e8f0; border-radius: 8px; overflow: hidden; height: 24px; position: relative; }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: 8px; transition: width 0.5s ease; }
.progress-bar-label { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 0.8rem; font-weight: 600; color: white; text-shadow: 0 1px 2px rgba(0,0,0,0.3); }

@media print {
    .sidebar, .main-header, .btn, .upload-inline-area, .toast-container, .nav-item { display: none !important; }
    .main-content { margin-left: 0 !important; padding: 0 !important; }
    .page-content { padding: 0 !important; }
    .card { break-inside: avoid; box-shadow: none; border: 1px solid #ddd; }
}
