:root {
    --primary-color: #1a73e8;
    --error-color: #d93025;
    --text-color: #202124;
    --border-color: #dadce0;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    padding: 2rem;
}

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

.language-selector {
    text-align: right;
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.document-type-selector {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.document-type-selector label {
    font-weight: 500;
    margin-right: 0.5rem;
}

.language-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.form-section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.form-section h2 {
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-group {
    margin-bottom: 1rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

input, select, textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
}

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

button {
    background-color: var(--primary-color);
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.2s;
}

button:hover {
    background-color: #1557b0;
}

.calculations {
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 4px;
    margin-top: 1rem;
}

.calculations div {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.items-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.items-table th,
.items-table td {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    text-align: left;
}

.items-table th {
    background-color: #f8f9fa;
}

.items-table input {
    width: 100%;
    padding: 0.25rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.add-item-btn {
    margin-top: 1rem;
    background-color: #34a853;
}

.delete-item-btn {
    background-color: var(--error-color);
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.move-item-btn {
    background-color: var(--primary-color);
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    margin: 0 0.25rem;
}

.items-section {
    margin-bottom: 2rem;
}

.tax-section {
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 4px;
    margin: 1rem 0;
}

.tax-presets {
    margin-bottom: 1rem;
}

.tax-presets select {
    width: auto;
    min-width: 200px;
}

.tax-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.tax-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tax-input {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tax-input input {
    width: 80px;
}

.tax-input span {
    color: var(--text-color);
}

/* Modal dialog styles */
.modal-dialog {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

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

.modal-header h3 {
    margin: 0;
    color: var(--primary-color);
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--text-color);
}

.modal-body {
    padding: 1rem;
    overflow-y: auto;
}

.series-list {
    margin-bottom: 1rem;
}

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

.series-table th,
.series-table td {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    text-align: left;
}

.series-table th {
    background-color: #f8f9fa;
}

.series-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    padding: 1rem 0;
}

.history-filters {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.history-stats {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.history-list {
    max-height: 400px;
    overflow-y: auto;
}

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

.history-table th,
.history-table td {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    text-align: left;
}

.history-table th {
    background: var(--primary-color);
    color: white;
}

.modal-body .form-group {
    margin-bottom: 1rem;
}

.modal-body .form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.modal-body .form-group input,
.modal-body .form-group textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.modal-body .form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1rem;
}

.error-message {
    color: var(--error-color);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.invoice-preview {
    background: #f8f9fa;
    padding: 0.5rem;
    border-radius: 4px;
    margin-top: 0.5rem;
    font-family: monospace;
}

.number-controls {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.number-controls button {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

/* Cloud sync styles */
.sync-section {
    background-color: #f0f7ff;
    border: 1px solid #b3d4fc;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 2rem;
}

.sync-section h3 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.sync-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.sync-controls input {
    width: auto;
    max-width: 200px;
    font-family: monospace;
}

.sync-status {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-left: 0.5rem;
}

.sync-status.synced { background-color: #34a853; }
.sync-status.pending { background-color: #fbbc04; }
.sync-status.offline { background-color: var(--error-color); }
.sync-status.none { background-color: #dadce0; }

/* --- Toast notifications --- */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    font-size: 0.9rem;
    color: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: toast-in 0.25s ease-out, toast-out 0.3s ease-in forwards;
    animation-delay: 0s, 3s;
    max-width: 360px;
}

.toast.success { background-color: #34a853; }
.toast.error   { background-color: var(--error-color); }
.toast.warning { background-color: #e37400; }
.toast.info    { background-color: var(--primary-color); }

@keyframes toast-in {
    from { opacity: 0; transform: translateX(40px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
    from { opacity: 1; }
    to   { opacity: 0; transform: translateY(-10px); }
}

/* --- Confirm / prompt dialog --- */
.dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fade-in 0.15s ease-out;
}

@keyframes fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.dialog-box {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    min-width: 320px;
    max-width: 440px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
}

.dialog-box p {
    margin-bottom: 1rem;
    font-size: 0.95rem;
    line-height: 1.5;
}

.dialog-box input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

.dialog-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.dialog-buttons button {
    padding: 0.5rem 1.25rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
}

.dialog-buttons .btn-primary {
    background: var(--primary-color);
    color: #fff;
}

.dialog-buttons .btn-danger {
    background: var(--error-color);
    color: #fff;
}

.dialog-buttons .btn-cancel {
    background: #f1f3f4;
    color: var(--text-color);
}
