* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #ffffff;
    min-height: 100vh;
    padding: 20px;
    color: #000000;
}

.container {
    width: 100%;
    margin: 0 auto;
    background: #ffffff;
    border: 1px solid #000000;
    box-shadow: none;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 40px);
}

header {
    background: #000000;
    color: #ffffff;
    padding: 20px 30px;
    flex-shrink: 0;
    border-bottom: 2px solid #000000;
}

header h1 {
    font-size: 1.8em;
    margin-bottom: 5px;
    font-weight: 600;
}

header p {
    font-size: 0.9em;
    opacity: 0.9;
}

.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    width: 100%;
}

.sidebar {
    width: 250px;
    background: #ffffff;
    padding: 20px;
    border-right: 1px solid #000000;
    overflow-y: auto;
    flex-shrink: 0;
}

.nav-menu {
    margin-bottom: 30px;
    border-bottom: 1px solid #000000;
    padding-bottom: 15px;
}

.nav-item {
    display: block;
    padding: 10px 15px;
    color: #000000;
    text-decoration: none;
    border: 1px solid #000000;
    margin-bottom: 8px;
    text-align: center;
    transition: all 0.2s;
    background: #ffffff;
}

.nav-item:hover {
    background: #000000;
    color: #ffffff;
}

.nav-item.active {
    background: #000000;
    color: #ffffff;
    font-weight: 600;
}

.sidebar h2 {
    margin-bottom: 15px;
    color: #000000;
    font-size: 1.1em;
    font-weight: 600;
    border-bottom: 1px solid #000000;
    padding-bottom: 8px;
}

.company-selector {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid #000000;
}

.company-selector h2 {
    margin-bottom: 10px;
    font-size: 1em;
}

.company-select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #000000;
    border-radius: 0;
    font-size: 13px;
    background: #ffffff;
    color: #000000;
    cursor: pointer;
}

.company-select:focus {
    outline: none;
    border-color: #000000;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
}

.template-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 20px;
}

.template-group-label {
    display: block;
    margin-top: 12px;
    margin-bottom: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #555;
}

.template-group-label:first-child {
    margin-top: 0;
}

.template-btn {
    padding: 10px 14px;
    background: #ffffff;
    border: 1px solid #000000;
    border-radius: 0;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
    text-align: left;
    font-weight: 400;
    color: #000000;
}

.template-btn:hover {
    background: #000000;
    color: #ffffff;
}

.template-btn.active {
    background: #000000;
    color: #ffffff;
    font-weight: 600;
}

.stamp-upload {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #000000;
}

.stamp-upload h3 {
    margin-bottom: 10px;
    color: #000000;
    font-size: 0.95em;
    font-weight: 600;
}

.stamp-upload input[type="file"] {
    width: 100%;
    padding: 6px;
    margin-bottom: 8px;
    border: 1px solid #000000;
    border-radius: 0;
    font-size: 12px;
    background: #ffffff;
}

#uploadStampBtn {
    width: 100%;
    padding: 8px;
    background: #000000;
    color: #ffffff;
    border: 1px solid #000000;
    border-radius: 0;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s;
    font-weight: 500;
}

#uploadStampBtn:hover {
    background: #333333;
}

#stampPreview {
    margin-top: 10px;
}

#stampPreview img {
    max-width: 100%;
    border: 1px solid #000000;
    padding: 3px;
}

.form-preview-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

.form-panel {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    border-right: none;
    background: #ffffff;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    max-height: 100%;
    max-width: none;
}

#pdfForm {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.form-panel.full-width {
    flex: 1;
    border-right: none;
}

.panel-header {
    padding: 15px 20px;
    background: #ffffff;
    border-bottom: 1px solid #000000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.panel-header h2 {
    font-size: 1.2em;
    color: #000000;
    font-weight: 600;
}

.preview-status {
    font-size: 11px;
    color: #000000;
    display: flex;
    align-items: center;
    gap: 5px;
}

.preview-status::before {
    content: "●";
    color: #000000;
}

.btn-refresh {
    background: #000000;
    color: #ffffff;
    border: 1px solid #000000;
    padding: 6px 10px;
    border-radius: 0;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.btn-refresh:hover {
    background: #333333;
}

.form-fields-container {
    flex: 1 1 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    min-height: 0;
    position: relative;
    max-height: 100%;
}

.form-fields-container::-webkit-scrollbar {
    width: 8px;
}

.form-fields-container::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.form-fields-container::-webkit-scrollbar-thumb {
    background: #000000;
}

.form-fields-container::-webkit-scrollbar-thumb:hover {
    background: #333333;
}

#formFields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
    width: 100%;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    margin-bottom: 6px;
    color: #000000;
    font-weight: 500;
    font-size: 12px;
}

.form-group input,
.form-group textarea,
.form-group select {
    padding: 8px 10px;
    border: 1px solid #000000;
    border-radius: 0;
    font-size: 13px;
    transition: all 0.2s;
    background: #ffffff;
    color: #000000;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #000000;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 70px;
    font-family: inherit;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-actions {
    padding: 15px 20px;
    background: #ffffff;
    border-top: 1px solid #000000;
    flex-shrink: 0;
    display: flex;
    gap: 10px;
}

.btn-primary {
    flex: 1;
    padding: 12px 20px;
    background: #000000;
    color: #ffffff;
    border: 1px solid #000000;
    border-radius: 0;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-primary:hover {
    background: #333333;
}

.btn-secondary {
    padding: 12px 20px;
    background: #ffffff;
    color: #000000;
    border: 1px solid #000000;
    border-radius: 0;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #000000;
    color: #ffffff;
}

.btn-icon {
    font-size: 14px;
}

.preview-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #ffffff;
}

.preview-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #f5f5f5;
    border-left: 1px solid #000000;
}

.preview-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #666666;
}

.placeholder-icon {
    font-size: 48px;
    margin-bottom: 10px;
    opacity: 0.3;
}

.preview-placeholder p {
    font-size: 14px;
    color: #666666;
}

#previewFrame {
    width: 100%;
    height: 100%;
    border: none;
    background: #ffffff;
    transition: opacity 0.3s ease;
}

.array-field {
    border: 1px solid #000000;
    border-radius: 0;
    padding: 12px;
    margin-bottom: 12px;
    background: #ffffff;
}

.array-field-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.array-field-header h4 {
    color: #000000;
    font-size: 12px;
    font-weight: 600;
}

.remove-array-item {
    background: #000000;
    color: #ffffff;
    border: 1px solid #000000;
    padding: 4px 8px;
    border-radius: 0;
    cursor: pointer;
    font-size: 11px;
    transition: background 0.2s;
}

.remove-array-item:hover {
    background: #333333;
}

.add-array-item {
    background: #000000;
    color: #ffffff;
    border: 1px solid #000000;
    padding: 6px 12px;
    border-radius: 0;
    cursor: pointer;
    font-size: 12px;
    margin-top: 6px;
    transition: background 0.2s;
    font-weight: 500;
}

.add-array-item:hover {
    background: #333333;
}

.alert {
    padding: 10px 12px;
    border-radius: 0;
    margin-bottom: 12px;
    font-size: 13px;
    border: 1px solid #000000;
}

.alert-success {
    background: #ffffff;
    color: #000000;
    border-color: #000000;
}

.alert-error {
    background: #ffffff;
    color: #000000;
    border-color: #ff0000;
}

.preview-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #000000;
    font-size: 13px;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 10;
}

.preview-loading.show {
    opacity: 1;
}

.preview-loading::after {
    content: "...";
    animation: dots 1.5s infinite;
}

@keyframes dots {
    0%, 20% { content: "."; }
    40% { content: ".."; }
    60%, 100% { content: "..."; }
}

.preview-updating {
    opacity: 0.7;
    transition: opacity 0.2s;
}

@media (max-width: 1200px) {
    .form-preview-container {
        flex-direction: column;
    }
    
    .form-panel {
        flex: 1 1 auto;
    }
}

@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        max-height: 200px;
    }
    
    .form-panel {
        flex: 1 1 auto;
    }
    
    #formFields {
        grid-template-columns: 1fr;
    }
}
