:root {
    --bg: #eef2f6;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --line: #d9e0ea;
    --soft: #f7f9fc;
    --soft-2: #edf3f8;
    --accent: #14532d;
    --accent-2: #dcfce7;
    --danger: #991b1b;
    --shadow: 0 18px 45px rgba(15, 23, 42, 0.10);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: radial-gradient(circle at top left, #dbeafe 0, transparent 32%), var(--bg);
    color: var(--text);
    padding: 24px;
}

.container {
    max-width: 1060px;
    margin: auto;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(217, 224, 234, 0.9);
    border-radius: 24px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.header {
    padding: 24px 26px;
    background: linear-gradient(135deg, #102a1d, #14532d);
    color: white;
}

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

.title-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.back-btn {
    width: 38px;
    height: 38px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.12);
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 22px;
    font-weight: 800;
    line-height: 1;
    transition: background 0.15s ease, transform 0.15s ease;
}

.back-btn:hover { background: rgba(255, 255, 255, 0.20); }
.back-btn:active { transform: translateY(1px); }

.header h1 {
    margin: 0;
    font-size: 28px;
    letter-spacing: -0.04em;
}

.version {
    margin-top: 4px;
    font-size: 12px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.72);
    letter-spacing: 0.04em;
}

.import-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.import-btn {
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.12);
    color: white;
    border-radius: 999px;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.06em;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
}

.import-btn:hover { background: rgba(255, 255, 255, 0.20); }
.import-btn:active { transform: translateY(1px); }

#importStatus {
    min-height: 18px;
    color: rgba(255, 255, 255, 0.82);
    font-size: 12px;
    text-align: right;
}

#importPdf { display: none; }

.content { padding: 22px; }

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 22px;
}

.summary-card {
    border: 1px solid var(--line);
    background: var(--soft);
    border-radius: 16px;
    padding: 14px;
}

.summary-card span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.summary-card strong {
    display: block;
    margin-top: 8px;
    font-size: 22px;
    letter-spacing: -0.03em;
}

.section {
    margin-top: 18px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: white;
    overflow: hidden;
}

.section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--soft-2);
    border-bottom: 1px solid var(--line);
    font-weight: 800;
    color: #243449;
}


table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
}

th, td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    text-align: right;
    font-size: 14px;
}

th {
    background: #fbfcfe;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

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

td.label, th:first-child {
    text-align: left;
    width: 48%;
}

td.label {
    font-weight: 700;
    color: #2f3c4e;
}

td[contenteditable="true"] {
    outline: none;
    background: #ffffff;
    cursor: text;
    transition: background 0.15s ease, box-shadow 0.15s ease;
}

td[contenteditable="true"]:hover { background: #fbfdff; }

td[contenteditable="true"]:focus {
    background: #f0fdf4;
    box-shadow: inset 0 0 0 2px var(--accent);
}

.result-row td {
    font-weight: 800;
    background: #f8fafc;
}

.result-row.profit td {
    background: var(--accent-2);
    color: #12351f;
    font-size: 15px;
}

.money::before { content: "$"; color: var(--muted); margin-right: 2px; }

.negative { color: var(--danger) !important; }

@media (max-width: 860px) {
    body { padding: 12px; }
    .header { padding: 20px; }
    .content { padding: 14px; }
    .summary-grid { grid-template-columns: repeat(2, 1fr); }
    .section { overflow-x: auto; }
    .section-title { min-width: 620px; }
    table { min-width: 620px; }
}

@media (max-width: 520px) {
    .summary-grid { grid-template-columns: 1fr; }
    .header h1 { font-size: 24px; }
    .header-top { flex-direction: column; }
    .import-wrap { align-items: stretch; width: 100%; }
    #importStatus { text-align: left; }
}
