:root {
    --color-primary: #2563eb;
    --color-primary-dark: #1d4ed8;
    --color-danger: #d41d3c;
    --color-danger-dark: #b01830;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 15px;
}

header h1 {
    color: var(--color-primary);
    font-size: 1.8rem;
}

nav {
    display: flex;
    gap: 10px;
}

nav a {
    padding: 8px 16px;
    text-decoration: none;
    color: #555;
    border-radius: 6px;
    transition: all 0.2s;
}

nav a:hover {
    background-color: #e9ecef;
}

nav a.active {
    background-color: var(--color-primary);
    color: white;
}

.card {
    background: white;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    margin-bottom: 20px;
}

h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.4rem;
}

h3 {
    color: #555;
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.alert-error {
    background-color: #fee;
    border: 1px solid #fcc;
    color: #c00;
}

.alert-success {
    background-color: #efe;
    border: 1px solid #cfc;
    color: #060;
}

.success-message {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
    padding: 15px 20px;
    border-radius: 8px;
}

.error-message {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
    padding: 15px 20px;
    border-radius: 8px;
}

.upload-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 500px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-weight: 500;
    color: #555;
    font-size: 0.9rem;
}

.form-group input[type="file"],
.form-group input[type="text"],
.form-group input[type="number"] {
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
}

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

.helper-text {
    color: #888;
    font-size: 0.85rem;
}

.btn {
    display: inline-block;
    padding: 12px 24px;
    font-size: 1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: all 0.2s;
}

.btn-primary {
    background-color: var(--color-primary);
    color: white;
}

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

.btn-success {
    background-color: #28a745;
    color: white;
}

.btn-success:hover {
    background-color: #218838;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85rem;
}

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

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #555;
    font-size: 0.85rem;
    text-transform: uppercase;
}

tr:hover {
    background-color: #f8f9fa;
}

.numeric {
    text-align: right;
    font-family: 'SF Mono', 'Monaco', 'Menlo', monospace;
}

.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success {
    background-color: #d4edda;
    color: #155724;
}

.badge-warning {
    background-color: #fff3cd;
    color: #856404;
}

.badge-neutral {
    background-color: #e9ecef;
    color: #6c757d;
}

.badge-uk {
    background-color: #cce5ff;
    color: #004085;
}

.badge-intl {
    background-color: #d4edda;
    color: #155724;
}

.badge-fees {
    background-color: #fff3cd;
    color: #856404;
}

.badge-adj {
    background-color: #f8d7da;
    color: #721c24;
}

.badge-x {
    background-color: #e9ecef;
    color: #6c757d;
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: #666;
}

.empty-state a {
    color: var(--color-primary);
}

.invoice-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.invoice-header .date {
    color: #666;
    font-size: 0.9rem;
}

.recon-banner {
    padding: 12px 20px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.recon-pass {
    background-color: #d4edda;
    color: #155724;
}

.recon-check {
    background-color: #fff3cd;
    color: #856404;
}

.tabs {
    display: flex;
    gap: 5px;
    border-bottom: 2px solid #eee;
    margin-bottom: 25px;
}

.tab {
    padding: 12px 20px;
    text-decoration: none;
    color: #666;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.tab:hover {
    color: var(--color-primary);
}

.tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
    font-weight: 500;
}

.tab-content {
    padding-top: 10px;
}

.totals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.totals-section {
    background-color: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
}

.totals-table {
    width: 100%;
}

.totals-table td {
    padding: 8px 0;
    border-bottom: 1px solid #e9ecef;
}

.totals-table .total-row td {
    border-top: 2px solid #333;
    border-bottom: none;
    padding-top: 12px;
}

.actions {
    margin-bottom: 20px;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    align-items: center;
}

.filter-group input,
.filter-group select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
}

.filter-group input:focus,
.filter-group select:focus {
    outline: none;
    border-color: var(--color-primary);
}

.table-wrapper {
    overflow-x: auto;
}

.service-raw {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.helper-note {
    margin-top: 12px;
    font-size: 0.8rem;
    color: #888;
    font-style: italic;
}

@media (max-width: 768px) {
    header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .totals-grid {
        grid-template-columns: 1fr;
    }
    
    .filters {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-group input,
    .filter-group select {
        width: 100%;
    }
}

.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-card {
    max-width: 400px;
    width: 100%;
    text-align: center;
}

.auth-card h1 {
    color: var(--color-primary);
    font-size: 1.5rem;
    margin-bottom: 5px;
}

.auth-card h2 {
    margin-bottom: 25px;
    font-size: 1.2rem;
}

.auth-form {
    text-align: left;
}

.auth-form .form-group {
    margin-bottom: 18px;
}

.auth-form .form-control {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
}

.auth-form .form-control:focus {
    outline: none;
    border-color: var(--color-primary);
}

.btn-full {
    width: 100%;
    margin-top: 10px;
}

.auth-link {
    margin-top: 20px;
    color: #666;
    font-size: 0.9rem;
}

.auth-link a {
    color: var(--color-primary);
    text-decoration: none;
}

.auth-link a:hover {
    text-decoration: underline;
}

.field-error {
    color: #dc3545;
    font-size: 0.85rem;
    display: block;
    margin-top: 4px;
}

.user-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
    color: #666;
}

.user-indicator a {
    color: #d41d3c;
    text-decoration: none;
}

.user-indicator a:hover {
    text-decoration: underline;
}

.btn-loading {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-loading:hover {
    background-color: var(--color-primary);
}

.btn-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-left: 8px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
}

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

.parsing-hint {
    margin-top: 12px;
    color: #666;
    font-size: 0.9rem;
    font-style: italic;
}

.link-button {
    background: none;
    border: none;
    color: var(--color-primary);
    cursor: pointer;
    font-size: inherit;
    vertical-align: baseline;
    padding: 0;
    text-decoration: none;
    padding: 0;
}

.link-button:hover {
    text-decoration: underline;
}

.subscription-card {
    max-width: 500px;
    margin: 40px auto;
    text-align: center;
}

.subscription-card h2 {
    color: var(--color-primary);
    margin-bottom: 15px;
}

.subscription-card p {
    margin-bottom: 20px;
    color: #666;
}

.plan-details {
    background-color: #f8f9fa;
    padding: 25px;
    border-radius: 8px;
    margin-bottom: 25px;
    text-align: left;
}

.plan-details h3 {
    margin-bottom: 10px;
    color: #333;
}

.plan-details .price {
    font-size: 1.1rem;
    color: var(--color-primary);
    font-weight: 600;
    margin-bottom: 15px;
}

.features-list {
    list-style: none;
    padding: 0;
}

.features-list li {
    padding: 8px 0;
    padding-left: 25px;
    position: relative;
    color: #555;
}

.features-list li::before {
    content: "\2713";
    position: absolute;
    left: 0;
    color: #28a745;
    font-weight: bold;
}

.btn-large {
    padding: 15px 40px;
    font-size: 1.1rem;
}

.subscription-card .note {
    font-size: 0.85rem;
    color: #888;
    margin-top: 20px;
}

.success-card {
    max-width: 500px;
    margin: 40px auto;
    text-align: center;
}

.success-icon {
    font-size: 60px;
    color: #28a745;
    margin-bottom: 20px;
}

.success-card h2 {
    color: #28a745;
    margin-bottom: 15px;
}

.success-card p {
    color: #666;
    margin-bottom: 25px;
}

.action-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}
