:root {
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --bg-color: #F9FAFB;
    --card-bg: #FFFFFF;
    --text-main: #111827;
    --text-muted: #6B7280;
    --border-color: #E5E7EB;
    --success: #10B981;
    --error: #EF4444;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius: 12px;
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

header {
    background-color: var(--card-bg);
    box-shadow: var(--shadow-sm);
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    height: 64px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 40px;
    height: 100%;
}

.main-nav {
    display: flex;
    gap: 0;
    height: 100%;
    align-items: center;
}

.nav-link {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.875rem;
    padding: 0 20px;
    height: 100%;
    display: flex;
    align-items: center;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
}

.nav-link:hover {
    color: var(--primary);
    background-color: rgba(79, 70, 229, 0.05);
}

.nav-link.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-main);
    text-decoration: none;
    letter-spacing: -0.025em;
}

.logo svg {
    width: 28px;
    height: 28px;
    color: var(--primary);
    flex-shrink: 0;
}

.logo span {
    color: var(--primary);
}

/* Footer Styling */
.app-footer {
    width: 100%;
    max-width: 1400px;
    margin: 40px auto 20px;
    padding: 16px 24px 8px;
    border-top: 1px solid var(--border-color, #e2e8f0);
    font-size: 0.8125rem;
    color: var(--text-muted, #64748b);
}

.footer-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.footer-left {
    text-align: left;
}

.footer-center {
    text-align: center;
}

.footer-center a {
    color: var(--primary, #4f46e5);
    text-decoration: none;
    font-weight: 500;
}

.footer-center a:hover {
    text-decoration: underline;
}

.footer-right {
    text-align: right;
}

@media (max-width: 768px) {
    .footer-content {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }
    .footer-left, .footer-center, .footer-right {
        text-align: center;
    }
}



main {
    width: 100%;
    max-width: 1400px;
    margin: 104px auto 40px;
    /* Increased margin-top for fixed header */
    padding: 0 24px;
}

h1 {
    font-size: 1.875rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-main);
}

.text-mono-off {
    font-family: inherit !important;
}

h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 16px;
}

p.subtitle {
    color: var(--text-muted);
    margin-bottom: 24px;
}

.card {
    background-color: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    padding: 32px;
    margin-bottom: 32px;
}

/* Form Styles */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-main);
}

.form-control {
    padding: 10px 12px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    font-size: 0.875rem;
    font-family: inherit;
    background-color: white;
    color: var(--text-main);
    width: 100%;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2);
}

.form-control:disabled {
    background-color: #F3F4F6;
    color: var(--text-muted);
    cursor: not-allowed;
}

/* Button Styles */
.btn {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

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

.btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    background-color: var(--text-muted);
}

.btn-sm {
    padding: 4px 12px;
    font-size: 0.75rem;
}

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

.btn-error:hover {
    background-color: #DC2626;
}

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

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

.btn-outline {
    background-color: white;
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-outline:hover {
    background-color: #F9FAFB;
}

/* Table Styles */
.table-container {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    overflow: hidden;
}

.invoice-group-header+.table-container,
.invoice-group-header+.summary-card {
    border-top: none;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    margin-bottom: 0;
}

table.invoice-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    background: white;
}

table.invoice-table th,
table.invoice-table td {
    padding: 12px 16px;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border-color);
}

table.invoice-table th {
    background-color: #F9FAFB;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.8125rem;
}

table.invoice-table tbody tr:hover {
    background-color: #F9FAFB;
}

tr.child-row {
    background-color: #F8FAFC !important;
}

tr.child-row td:first-child {
    border-left: 3px solid var(--primary);
}

tr.child-row td:nth-child(2) {
    padding-left: 32px;
}

table.polozky-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    background: white;
    border-top: 1px solid var(--border-color);
}

table.polozky-table th,
table.polozky-table td {
    padding: 8px 16px;
    font-size: 0.8125rem;
    border-bottom: 1px solid var(--border-color);
}

table.polozky-table th {
    background-color: #EEF2FF;
    font-weight: 600;
    color: var(--text-muted);
}

/* Badge Styles */
.badge {
    display: inline-block;
    vertical-align: middle;
    text-align: center;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: normal;
    margin-right: 16px;
}

.badge-pending {
    background-color: #FEF3C7;
    color: #D97706;
}

.badge-processing {
    background-color: #DBEAFE;
    color: #2563EB;
}

.badge-completed {
    background-color: #D1FAE5;
    color: #059669;
}

.badge-failed {
    background-color: #FEE2E2;
    color: #DC2626;
}

.badge-warning {
    background-color: #FEF3C7;
    color: #D97706;
}

.badge-uploaded {
    background-color: #D1FAE5;
    color: #059669;
    border: 1px solid #10B981;
}

/* Upload Section */
.upload-section {
    background-color: #F3F4F6;
    border: 2px dashed #D1D5DB;
    padding: 48px 24px;
    border-radius: var(--radius);
    text-align: center;
    transition: all 0.2s ease;
    position: relative;
}

.upload-section.dragover {
    background-color: #EEF2FF;
    border-color: var(--primary);
}

.upload-icon {
    font-size: 48px;
    margin-bottom: 16px;
    display: inline-block;
}

.upload-instructions {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-main);
    margin-bottom: 8px;
}

.upload-subtext {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 24px;
}

.file-input {
    opacity: 0;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.file-name-display {
    display: block;
    margin: 16px auto;
    font-weight: 600;
    color: var(--text-main);
    font-size: 0.875rem;
    background-color: white;
    padding: 8px 16px;
    border-radius: 9999px;
    border: 1px solid var(--border-color);
    width: fit-content;
    box-shadow: var(--shadow-sm);
}

/* mServer Section */
.mserver-section {
    background-color: #F8FAFC;
    border: 1px solid var(--border-color);
    padding: 24px;
    border-radius: var(--radius);
    margin-bottom: 32px;
}

.mserver-header {
    display: flex;
    align-items: center;
    margin-bottom: 16px;
}

.mserver-header h2 {
    margin-bottom: 0;
    font-size: 1.125rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.mserver-badge {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 9999px;
    font-weight: 600;
}

.mserver-badge.checking {
    background-color: #FEF3C7;
    color: #D97706;
}

.mserver-badge.connected {
    background-color: #D1FAE5;
    color: #059669;
}

.mserver-badge.error {
    background-color: #FEE2E2;
    color: #DC2626;
}

.mserver-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

@media (max-width: 768px) {
    .mserver-body {
        grid-template-columns: 1fr;
    }
}

.mserver-error {
    display: none;
    grid-column: span 1;
    background-color: #FEF2F2;
    border: 1px solid #FCA5A5;
    padding: 12px 16px;
    border-radius: 6px;
    color: var(--error);
    font-size: 0.875rem;
    margin-top: 8px;
}

.mserver-body .mserver-error {
    grid-column: span 2;
}

@media (max-width: 768px) {
    .mserver-body .mserver-error {
        grid-column: span 1;
    }
}

.mserver-error a {
    color: var(--error);
    font-weight: 600;
    text-decoration: underline;
}

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

.modal-content {
    background-color: var(--bg-color);
    padding: 0;
    border-radius: var(--radius);
    max-width: 900px;
    width: 95%;
    max-height: 90vh;
    overflow: hidden;
    position: relative;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
}

.modal-content.large {
    max-width: 1200px;
}

.modal-content.wide {
    max-width: 1400px;
}

.modal-card {
    background-color: white;
    border-radius: var(--radius);
    width: 100%;
    height: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.modal-body {
    padding: 24px;
    overflow-y: auto;
    overflow-x: hidden;
    flex-grow: 1;
}

.close-modal {
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.1s;
}

.close-modal:hover {
    color: var(--text-main);
}

/* Utility / Dynamic Styles */
.error-msg {
    background-color: #FEF2F2;
    color: var(--error);
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 16px;
    border: 1px solid #FCA5A5;
    display: none;
    text-align: left;
}

.pohoda-banner {
    margin: -24px -24px 24px -24px;
    padding: 16px 24px;
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.pohoda-banner.error {
    background-color: #FEF2F2;
    color: #991B1B;
}

.pohoda-banner.warning {
    background-color: #FFFBEB;
    color: #92400E;
}

.pohoda-banner.success {
    background-color: #ECFDF5;
    color: #065F46;
}

.inline-log {
    display: inline-block;
    font-size: 0.7rem;
    margin-top: 4px;
    padding: 2px 8px;
    border-radius: 4px;
    line-height: 1.2;
    font-weight: 500;
    max-width: 100%;
}

.invoice-group-header {
    background: #F3F4F6;
    padding: 6px 16px;
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border-color);
    border-bottom: none;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    margin-top: 16px;
}

.invoice-group-header:first-child {
    margin-top: 0;
}

.total-amount {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
    text-align: right;
}

.total-currency {
    font-size: 1rem;
    font-weight: 600;
    margin-left: 4px;
}

.invoice-summary-grid {
    display: flex;
    gap: 24px;
    align-items: stretch;
}

.invoice-summary-grid>div {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.summary-card {
    background: #F9FAFB;
    border: 1px solid var(--border-color);
    border-top: none;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    padding: 8px 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.invoice-wrapper {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 0;
}

.inline-log.error {
    background-color: #FEF2F2;
    color: #B91C1C;
    border: 1px solid #FEE2E2;
}

.inline-log.warning {
    background-color: #FFFBEB;
    color: #B45309;
    border: 1px solid #FEF3C7;
}

.spinner {
    border: 3px solid rgba(79, 70, 229, 0.2);
    border-radius: 50%;
    border-top: 3px solid var(--primary);
    width: 32px;
    height: 32px;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.email-body,
.invoice-detail-body {
    white-space: pre-wrap;
    font-size: 0.9rem;
    color: #374151;
    padding: 16px;
    background: #F9FAFB;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-top: 16px;
}

.action-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

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

/* Login Page Specific */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 16px;
}

.login-card {
    max-width: 448px;
    width: 100%;
    background-color: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header h2 {
    font-size: 1.875rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 8px;
}

.login-header p {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.login-form-group {
    margin-bottom: 24px;
}

.login-footer {
    text-align: center;
    margin-top: 24px;
}

.login-footer a {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

.login-footer a:hover {
    color: var(--text-main);
    text-decoration: underline;
}

/* Invoice Highlighting */
.invoice-wrapper>[id]:target {
    animation: highlight-pulse 2.5s ease-out;
    border: 2px solid var(--primary) !important;
    scroll-margin-top: 100px;
}

@keyframes highlight-pulse {
    0% {
        box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.4);
        background-color: rgba(79, 70, 229, 0.05);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(79, 70, 229, 0);
        background-color: transparent;
    }
}

.invoice-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
    padding: 12px;
    background: #F3F4F6;
    border-radius: 8px;
    align-items: center;
}

.invoice-nav-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-right: 8px;
}

.invoice-nav-link {
    font-size: 0.8125rem;
    padding: 4px 12px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    text-decoration: none;
    color: var(--text-main);
    transition: all 0.2s;
}

.invoice-nav-link:hover {
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}