* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.site-header {
    background: white;
    border-bottom: 1px solid #e0e0e0;
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand h1 {
    font-size: 24px;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 4px;
}

.brand p {
    font-size: 14px;
    color: #666;
}

.user-nav {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-dropdown {
    position: relative;
}

.user-dropdown-toggle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.user-dropdown-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.user-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    display: none;
    z-index: 1000;
    overflow: hidden;
}

.user-dropdown-menu.show {
    display: block;
}

.user-dropdown-header {
    padding: 12px 16px;
    font-weight: 600;
    color: #1a1a1a;
    border-bottom: 1px solid #e0e0e0;
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    color: #333;
    text-decoration: none;
    transition: background-color 0.2s;
}

.user-dropdown-item:hover {
    background-color: #f5f5f5;
}

.dropdown-icon {
    font-size: 16px;
}

.merge-field-link {
    color: #4a90e2;
    text-decoration: none;
    cursor: pointer;
    font-weight: 600;
}

.merge-field-link:hover {
    text-decoration: underline;
    color: #357abd;
}

.page {
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 20px;
}

.panel {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 30px;
    margin-bottom: 30px;
}

.panel.narrow {
    max-width: 500px;
    margin: 40px auto;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}

.panel-header h2 {
    font-size: 24px;
    font-weight: 600;
    color: #1a1a1a;
}

.panel-header p {
    font-size: 14px;
    color: #666;
    margin-top: 5px;
}

.setting-section {
    margin-top: 25px;
    padding: 0;
    background: white;
    border-radius: 8px;
    border: 1px solid #e8e8e8;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.setting-section:first-child {
    margin-top: 0;
}

.setting-section-header {
    background: #f8f9fa;
    padding: 15px 20px;
    border-bottom: 1px solid #e8e8e8;
}

.setting-section-content {
    padding: 20px;
}

.setting-section h3 {
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0;
    padding: 0;
}

.setting-section h4 {
    font-size: 15px;
    font-weight: 600;
    color: #333;
    margin-top: 20px;
    margin-bottom: 10px;
}

.setting-section > p.text-muted,
.setting-section-content > p.text-muted {
    margin-bottom: 20px;
    font-size: 0.9em;
}

.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
}

.alert-error {
    background: #fee;
    color: #c33;
    border: 1px solid #fcc;
}

.alert-success {
    background: #efe;
    color: #3c3;
    border: 1px solid #cfc;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 14px;
    color: #333;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
input[type="url"],
textarea,
select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
}

input[type="checkbox"] {
    width: auto;
    margin: 0;
    cursor: pointer;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

textarea {
    resize: vertical;
    min-height: 200px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.action-bar {
    display: flex;
    gap: 10px;
    margin-top: 25px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: #2563eb;
    color: white;
}

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-ghost {
    background: transparent;
    color: #4a90e2;
    border: 1px solid #4a90e2;
}

.btn-ghost:hover {
    background: #f0f7ff;
}

.btn-ghost.active {
    background: #2563eb;
    color: white;
    border-color: #2563eb;
}

.btn-ghost.active:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.text-muted {
    color: #666;
    font-size: 14px;
}

/* Modal styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 8px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Table styles */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.data-table th,
.data-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

.data-table th {
    background: #f8f8f8;
    font-weight: 600;
    color: #333;
}

.data-table tr:hover {
    background: #f9f9f9;
}

.data-table .btn-sm {
    margin-right: 5px;
}

/* Documents page: main tabs and sub-tabs */
.doc-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    border-bottom: 2px solid #e8e8e8;
}
.doc-tabs a {
    padding: 12px 20px;
    text-decoration: none;
    color: #666;
    font-weight: 600;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}
.doc-tabs a:hover {
    color: #333;
}
.doc-tabs a.active {
    color: #4a90e2;
    border-bottom-color: #4a90e2;
}
.doc-subtabs {
    display: flex;
    gap: 0;
    margin-bottom: 20px;
    border-bottom: 1px solid #e0e0e0;
}
.doc-subtabs a {
    padding: 10px 16px;
    text-decoration: none;
    color: #666;
    font-size: 14px;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.doc-subtabs a:hover {
    color: #333;
}
.doc-subtabs a.active {
    color: #4a90e2;
    border-bottom-color: #4a90e2;
}
.doc-tab-pane {
    display: none;
}
.doc-tab-pane.active {
    display: block;
}
.custom-design-form label {
    display: block;
    margin-top: 12px;
}
.custom-design-form textarea {
    min-height: 120px;
    font-family: inherit;
}

/* Tight line spacing for all text boxes (design layout + Quill) */
.design-cell-text,
.design-cell-preview-content,
.design-cell-quill-wrap .ql-editor,
#custom_html_editor.ql-container .ql-editor {
    line-height: 1.2;
}
.design-cell-text p,
.design-cell-preview-content p,
.design-cell-quill-wrap .ql-editor p,
#custom_html_editor.ql-container .ql-editor p {
    margin: 0 0 0.35em;
}
.design-cell-text p:last-child,
.design-cell-preview-content p:last-child,
.design-cell-quill-wrap .ql-editor p:last-child,
#custom_html_editor.ql-container .ql-editor p:last-child {
    margin-bottom: 0;
}

/* Quill rich editor in custom designer */
#custom_html_editor.ql-container {
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}
#custom_html_editor .ql-editor {
    min-height: 200px;
}
#custom_html_editor .ql-toolbar.ql-snow {
    border: none;
    border-bottom: 1px solid #ddd;
    border-radius: 6px 6px 0 0;
    background: #f8f9fa;
}
#custom_html_editor .ql-container.ql-snow {
    border-radius: 0 0 6px 6px;
}

/* Document content Quill (Content Templates): dropdowns stay open (no clipping by ancestors) */
#tab_content_templates {
    overflow: visible;
}
.setting-section.has-document-quill {
    overflow: visible;
}
.setting-section.has-document-quill .setting-section-content {
    overflow: visible;
}
.document-content-quill-wrap,
.document-content-quill-wrap .ql-container,
.document-content-quill-wrap .ql-toolbar.ql-snow {
    overflow: visible;
}
.document-content-quill-wrap .ql-snow .ql-picker.ql-expanded .ql-picker-options {
    z-index: 99999;
    position: absolute;
}
.document-content-quill-wrap .ql-snow .ql-picker {
    position: relative;
}
.document-content-field .document-content-label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    color: #1a1a1a;
}
.document-content-quill-wrap .ql-editor,
.document-content-quill-wrap .ql-editor p {
    font-weight: normal !important;
}
.document-content-quill-wrap .ql-editor strong {
    font-weight: bold !important;
}
.document-content-quill-wrap .ql-container {
    border: 1px solid #ddd;
    border-radius: 0 0 6px 6px;
    font-size: 14px;
}
.document-content-quill-wrap .ql-toolbar.ql-snow {
    border: none;
    border-bottom: 1px solid #ddd;
    border-radius: 6px 6px 0 0;
    background: #f8f9fa;
}
.document-content-quill-wrap .ql-editor {
    line-height: 1.2;
}
.document-content-quill-wrap .ql-editor p {
    margin: 0 0 0.35em;
}
.document-content-quill-wrap .ql-editor p:last-child {
    margin-bottom: 0;
}

/* Block layout row drag/drop */
.design-row-drag-handle {
    cursor: grab;
}
.design-row-drag-handle:active {
    cursor: grabbing;
}
.design-row-card.design-row-dragging {
    opacity: 0.6;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

@media print {
    .site-header,
    .actions,
    .action-bar {
        display: none;
    }
}

