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

body {
    font-family: system-ui, sans-serif;
    background: #f5f5f5;
    color: #111;
}

.app {
    max-width: 960px;
    margin: 0 auto;
    padding: 1.25rem;
}

.row {
    display: flex;
    gap: 10px;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.drop-zone {
    flex: 1;
    min-width: 180px;
    border: 1px dashed #bbb;
    border-radius: 8px;
    padding: 12px 14px;
    text-align: center;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 13px;
    color: #666;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    min-height: 64px;
    justify-content: center;
    background: #fff;
}

.drop-zone:hover,
.drop-zone.over {
    background: #f0f0f0;
}

.drop-zone.loaded {
    border-style: solid;
    border-color: #888;
    color: #111;
}

.drop-zone .icon {
    font-size: 18px;
}

.drop-zone .label {
    font-weight: 500;
    font-size: 13px;
}

.drop-zone .sub {
    font-size: 11px;
    color: #999;
}

input[type=file] {
    display: none;
}

.panels {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.sidebar {
    width: 280px;
    flex-shrink: 0;
    background: #fff;
    border: 0.5px solid #ddd;
    border-radius: 8px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sidebar h3 {
    font-size: 13px;
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 2px;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.field-group label {
    font-size: 11px;
    color: #888;
    font-weight: 500;
}

.field-group input,
.field-group select,
.field-group input[type=datetime-local] {
    font-size: 13px;
    padding: 5px 8px;
    border: 0.5px solid #ccc;
    border-radius: 6px;
    background: #fff;
    color: #111;
    width: 100%;
}

.field-group input:disabled {
    background: #f8f8f8;
    color: #aaa;
}

.field-group.hidden {
    display: none;
}

.template-select select {
    font-size: 13px;
    padding: 5px 8px;
    border: 0.5px solid #ccc;
    border-radius: 6px;
    width: 100%;
    background: #fff;
}

.btn-gen {
    padding: 7px 0;
    font-size: 13px;
    font-weight: 600;
    border: none;
    border-radius: 7px;
    cursor: pointer;
    background: #111;
    color: #fff;
    width: 100%;
    transition: opacity 0.15s;
}

.btn-gen:hover {
    opacity: 0.82;
}

.divider {
    border: none;
    border-top: 0.5px solid #eee;
    margin: 2px 0;
}

.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sig-preview {
    background: #fff;
    border: 0.5px solid #ddd;
    border-radius: 8px;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 90px;
}

.sig-preview img {
    max-width: 100%;
    max-height: 120px;
    border-radius: 4px;
}

.sig-preview .empty {
    font-size: 12px;
    color: #bbb;
}

.controls-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.page-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #666;
}

.page-nav button {
    padding: 2px 9px;
    font-size: 12px;
    border: 0.5px solid #ccc;
    border-radius: 6px;
    background: #fff;
    color: #111;
    cursor: pointer;
}

.page-nav button:disabled {
    opacity: 0.3;
    cursor: default;
}

label.size-label {
    font-size: 12px;
    color: #666;
}

input[type=range] {
    width: 90px;
}

.download-btn {
    margin-left: auto;
    padding: 5px 14px;
    font-size: 13px;
    font-weight: 500;
    border: 0.5px solid #ccc;
    border-radius: 7px;
    background: #fff;
    color: #111;
    cursor: pointer;
    transition: background 0.12s;
}

.download-btn:hover {
    background: #f0f0f0;
}

.download-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.canvas-wrap {
    position: relative;
    display: inline-block;
    border: 0.5px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    cursor: crosshair;
    user-select: none;
    max-width: 100%;
}

#pdf-canvas {
    display: block;
    max-width: 100%;
}

#sig-overlay {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
}

.sig-handle {
    position: absolute;
    pointer-events: none;
}

.sig-handle img {
    display: block;
    pointer-events: all;
    width: 100%;
}

.resize-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #fff;
    border: 2px solid #333;
    border-radius: 50%;
    pointer-events: all;
    z-index: 10;
    cursor: nwse-resize;
}

.resize-handle.ne {
    cursor: nesw-resize;
}

#no-pdf {
    border: 1px dashed #ddd;
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    color: #bbb;
    font-size: 13px;
    background: #fff;
}