.nth-app {
    --nth-bg-page: #fafaf6;
    --nth-bg-primary: #ffffff;
    --nth-bg-secondary: #f1efe8;
    --nth-bg-info: #E6F1FB;
    --nth-bg-warning: #FAEEDA;
    --nth-bg-success: #E1F5EE;
    --nth-text-primary: #2C2C2A;
    --nth-text-secondary: #5F5E5A;
    --nth-text-tertiary: #888780;
    --nth-text-warning: #854F0B;
    --nth-text-success: #0F6E56;
    --nth-border-tertiary: rgba(0,0,0,0.10);
    --nth-border-secondary: rgba(0,0,0,0.20);
    --nth-border-primary: rgba(0,0,0,0.35);
    --nth-radius-md: 8px;

    max-width: 480px;
    margin: 24px auto;
    padding: 16px;
    background: var(--nth-bg-page);
    border-radius: var(--nth-radius-md);
    color: var(--nth-text-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    -webkit-font-smoothing: antialiased;
    box-sizing: border-box;
}

@media (prefers-color-scheme: dark) {
    .nth-app {
        --nth-bg-page: #1a1a18;
        --nth-bg-primary: #2C2C2A;
        --nth-bg-secondary: #232321;
        --nth-bg-info: #042C53;
        --nth-bg-warning: #412402;
        --nth-bg-success: #04342C;
        --nth-text-primary: #F1EFE8;
        --nth-text-secondary: #B4B2A9;
        --nth-text-tertiary: #888780;
        --nth-text-warning: #FAC775;
        --nth-text-success: #9FE1CB;
        --nth-border-tertiary: rgba(255,255,255,0.12);
        --nth-border-secondary: rgba(255,255,255,0.25);
        --nth-border-primary: rgba(255,255,255,0.40);
    }
}

.nth-app *, .nth-app *::before, .nth-app *::after {
    box-sizing: border-box;
}

.nth-sr-only {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

.nth-container {
    position: relative;
    padding: 0;
}

.nth-warning-banner {
    position: absolute;
    top: 0; left: 0; right: 0;
    z-index: 10;
    background: var(--nth-bg-warning);
    color: var(--nth-text-warning);
    padding: 10px 12px;
    border-radius: var(--nth-radius-md);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    margin: 0;
}
.nth-warning-banner.nth-visible { opacity: 1; }
.nth-warning-banner svg { flex-shrink: 0; }

.nth-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    background: var(--nth-bg-primary);
    border: 0.5px solid var(--nth-border-tertiary);
    border-radius: var(--nth-radius-md);
    overflow: hidden;
    margin: 0;
}
.nth-table th {
    background: var(--nth-bg-secondary);
    padding: 10px 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--nth-text-secondary);
    border-bottom: 0.5px solid var(--nth-border-tertiary);
    text-align: center !important;
}
.nth-table td {
    padding: 0 !important;
    border-bottom: 0.5px solid var(--nth-border-tertiary);
    text-align: center;
    overflow: hidden;
    vertical-align: middle !important;
}
.nth-table tbody tr:last-child td { border-bottom: none; }
.nth-table tbody tr.nth-section-end td {
    border-bottom: 0.5px solid var(--nth-border-primary);
}
.nth-table input {
    width: 100%;
    box-sizing: border-box;
    text-align: center !important;
    border: none;
    background: transparent;
    height: 44px;
    font-size: 16px;
    color: var(--nth-text-primary) !important;
    -webkit-text-fill-color: var(--nth-text-primary);
    border-radius: 0;
    box-shadow: none;
    padding: 0 4px;
    font-family: inherit;
    -moz-appearance: textfield;
    margin: 0;
    line-height: normal;
    min-width: 0;
}
.nth-table input::-webkit-outer-spin-button,
.nth-table input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.nth-table input::placeholder { color: var(--nth-text-tertiary); opacity: 1; }
.nth-table input:focus {
    outline: none;
    background: var(--nth-bg-info);
    box-shadow: none;
}

.nth-num-cell {
    text-align: center !important;
    font-size: 11px;
    color: var(--nth-text-tertiary);
    font-weight: 400;
    height: 44px;
    line-height: 44px;
    background: var(--nth-bg-secondary);
}
.nth-diff-cell {
    text-align: center !important;
    font-size: 16px;
    font-weight: 500;
    color: var(--nth-text-primary);
    height: 44px;
    line-height: 44px;
}
.nth-diff-cell.nth-empty { color: var(--nth-text-tertiary); font-weight: 400; }
.nth-diff-cell.nth-bonus { color: var(--nth-text-success); }

.nth-table tfoot td {
    background: var(--nth-bg-secondary);
    padding: 14px 6px !important;
    border-top: 0.5px solid var(--nth-border-secondary);
    vertical-align: middle !important;
}
.nth-total-label {
    text-align: right !important;
    font-size: 14px;
    color: var(--nth-text-secondary);
    font-weight: 500;
}
.nth-total-value {
    text-align: center !important;
    font-size: 20px;
    font-weight: 500;
    color: var(--nth-text-primary);
}

.nth-button-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    gap: 8px;
}
.nth-add-group { display: flex; gap: 6px; }
.nth-btn {
    background: transparent;
    border: 0.5px solid var(--nth-border-secondary);
    border-radius: var(--nth-radius-md);
    cursor: pointer;
    padding: 9px 14px;
    font-size: 13px;
    color: var(--nth-text-secondary);
    white-space: nowrap;
    font-family: inherit;
    transition: background 0.15s ease, color 0.15s ease;
    line-height: 1;
    text-decoration: none;
    margin: 0;
}
.nth-btn:hover {
    color: var(--nth-text-primary);
    background: var(--nth-bg-secondary);
}
.nth-btn:active { transform: scale(0.98); }
.nth-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.nth-btn:disabled:hover {
    color: var(--nth-text-secondary);
    background: transparent;
}
.nth-btn-add { min-width: 44px; font-weight: 500; }
.nth-icon {
    width: 14px; height: 14px;
    vertical-align: -2px;
    margin-right: 4px;
    display: inline-block;
}
