:root {
    --brand: #339C54;
    --brand-hover: #2a8045;
    --bg: #f7f7f5;
    --border: #f3f4f6;
    --border-mid: #e5e7eb;
    --text: #111827;
    --text-mid: #374151;
    --text-soft: #6b7280;
    --text-faint: #9ca3af;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

/* ---------- App shell ---------- */
.app-shell {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.app-header {
    flex: none;
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.app-header .logo {
    height: 56px;
    object-fit: contain;
}

.logout-btn {
    font-size: 12px;
    color: var(--text-soft);
    border: 1px solid var(--border-mid);
    border-radius: 8px;
    padding: 6px 12px;
    background: #fff;
    text-decoration: none;
    cursor: pointer;
}

.logout-btn:hover {
    background: #f9fafb;
}

.app-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
}

.card {
    background: #fff;
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    padding: 20px;
    min-height: 100%;
}

/* ---------- Bottom nav ---------- */
.bottom-nav {
    flex: none;
    background: #fff;
    border-top: 1px solid var(--border-mid);
    padding: 8px;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
    display: flex;
}

.tab-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 0;
    border: none;
    background: transparent;
    border-radius: 12px;
    color: var(--text-faint);
    cursor: pointer;
    transition: color 0.15s;
}

.tab-btn.active {
    color: var(--brand);
}

.tab-icon {
    display: flex;
}

.tab-label {
    font-size: 10px;
    font-weight: 500;
    line-height: 1.2;
    text-align: center;
}

/* ---------- Forms ---------- */
.calc-stack > * + * {
    margin-top: 16px;
}

.section-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}

.field-row {
    display: flex;
    gap: 12px;
}

.field-row .field {
    flex: 1;
}

.field label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-mid);
    margin-bottom: 6px;
}

.input {
    width: 100%;
    height: 44px;
    border-radius: 12px;
    border: 1px solid var(--border-mid);
    padding: 0 12px;
    font-size: 14px;
    background: #fff;
    color: var(--text);
}

.input:focus {
    outline: 2px solid var(--brand);
    outline-offset: -1px;
}

.primary-btn {
    width: 100%;
    height: 48px;
    border: none;
    border-radius: 12px;
    background: var(--brand);
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.primary-btn:hover:not(:disabled) {
    background: var(--brand-hover);
}

.primary-btn:disabled {
    opacity: 0.7;
    cursor: default;
}

.link-btn {
    width: auto;
    height: 44px;
    padding: 0 24px;
    text-decoration: none;
}

.secondary-btn {
    width: 100%;
    height: 40px;
    border-radius: 12px;
    border: 1px solid #d1d5db;
    background: #f9fafb;
    color: var(--text-mid);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s;
}

.secondary-btn:hover {
    background: #f3f4f6;
}

.error-box {
    border-radius: 16px;
    background: #fef2f2;
    border: 1px solid #fee2e2;
    padding: 16px;
    font-size: 14px;
    color: #dc2626;
}

.public-test {
    padding-top: 8px;
}

.public-result {
    margin-top: 8px;
    padding: 12px;
    border-radius: 12px;
    background: #f9fafb;
    border: 1px solid var(--border-mid);
    font-size: 12px;
    color: var(--text-mid);
    white-space: pre-wrap;
    word-break: break-all;
}

.version {
    text-align: center;
    font-size: 12px;
    color: #000;
    padding-top: 8px;
}

/* ---------- Result table ---------- */
.result-table-wrap {
    background: #fff;
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    overflow-x: auto;
}

.result-table {
    width: 100%;
    font-size: 14px;
    border-collapse: collapse;
}

.result-table th {
    background: #f9fafb;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border-mid);
}

.result-table .db-header {
    text-align: left;
    border-right: 1px solid var(--border);
}

.result-table .db-value {
    color: #1f2937;
    text-transform: none;
}

.result-table .cv-header {
    text-align: center;
}

.result-table .col-left {
    text-align: left;
    white-space: nowrap;
}

.result-table .col-right {
    text-align: right;
    white-space: nowrap;
}

.result-table th.col-left,
.result-table th.col-right:not(.yr) {
    padding: 12px 16px;
}

.result-table td {
    padding: 12px 16px;
    color: var(--text-mid);
}

.result-table td.label {
    font-weight: 500;
    color: #1f2937;
    border-right: 1px solid var(--border);
}

.result-table td:nth-child(2) {
    border-right: 1px solid var(--border);
}

.result-table tr.odd {
    background: rgba(249, 250, 251, 0.5);
}

.result-card.empty {
    font-size: 14px;
    color: var(--text-soft);
}

.raw-body {
    font-size: 11px;
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    color: var(--text-soft);
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 256px;
    overflow: auto;
    margin: 0;
}

/* ---------- Start Application / Claim ---------- */
.start-app {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 40px 0;
    text-align: center;
}

.start-app-text p {
    font-size: 14px;
    color: var(--text-soft);
    max-width: 320px;
    margin: 8px auto 0;
}

.claim-redirect .claim-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 48px 0;
    text-align: center;
}

.claim-spinner p {
    font-size: 14px;
    color: var(--text-soft);
    margin: 0;
}

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

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