:root {
    --color-primary: #6366f1;
    --color-secondary: #8b5cf6;
    --color-success: #10b981;
    --color-info: #3b82f6;
    --color-danger: #ef4444;
    --color-warning: #f59e0b;
    --color-dark: #1e1b4b;
    --color-darker: #0f172a;
    --color-border: #334155;
    --color-text: #e2e8f0;
    --color-text-muted: #94a3b8;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--color-darker) 0%, var(--color-dark) 100%);
    color: var(--color-text);
    min-height: 100vh;
    padding: 20px;
}

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

.header {
    text-align: center;
    margin-bottom: 40px;
    padding: 30px 20px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 16px;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
}

.logo-icon {
    font-size: 48px;
    animation: spin 3s linear infinite;
    display: inline-block;
    transform-origin: center;
}

.logo-icon img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    display: block;
    margin: 0 auto;
    transform-origin: center;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.header h1 {
    font-size: 48px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header h1 .suite-text {
    background: none;
    -webkit-background-clip: unset;
    -webkit-text-fill-color: #e6eaf2;
    background-clip: unset;
    color: #e6eaf2;
}

.subtitle {
    font-size: 18px;
    color: var(--color-text-muted);
    margin-top: 10px;
}

.btn-back {
    display: inline-block;
    margin-top: 15px;
    padding: 10px 20px;
    background: rgba(168, 85, 247, 0.2);
    color: var(--color-text);
    text-decoration: none;
    border-radius: 8px;
    border: 1px solid rgba(168, 85, 247, 0.3);
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 600;
}

.btn-back:hover {
    background: rgba(168, 85, 247, 0.3);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.content {
    margin-bottom: 30px;
}

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

.card {
    background: rgba(30, 27, 75, 0.5);
    border-radius: 16px;
    padding: 26px;
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-lg);
}

.card h2 {
    font-size: 22px;
    margin-bottom: 18px;
}

.field {
    margin-bottom: 18px;
}

.field label {
    display: block;
    margin-bottom: 10px;
    font-weight: 700;
}

.file {
    width: 100%;
    padding: 12px 12px;
    border-radius: 12px;
    border: 2px solid var(--color-border);
    background: var(--color-darker);
    color: var(--color-text);
}

.file-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}

.dropzone {
    display: flex;
    gap: 16px;
    align-items: center;
    padding: 18px 18px;
    border-radius: 14px;
    border: 2px dashed rgba(99, 102, 241, 0.65);
    background: rgba(15, 23, 42, 0.5);
    cursor: pointer;
    transition: all 0.25s ease;
    user-select: none;
}

.dropzone:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.dropzone:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
}

.dropzone.dragover {
    background: rgba(99, 102, 241, 0.12);
    border-color: rgba(99, 102, 241, 0.95);
}

.drop-icon {
    width: 54px;
    height: 54px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(99, 102, 241, 0.14);
    border: 1px solid rgba(99, 102, 241, 0.28);
    flex: 0 0 auto;
    font-size: 22px;
}

.drop-title {
    font-weight: 900;
    color: var(--color-text);
    line-height: 1.2;
}

.drop-subtitle {
    margin-top: 4px;
    font-size: 13px;
    color: var(--color-text-muted);
}

.drop-filename {
    margin-top: 8px;
    font-size: 12px;
    color: rgba(226, 232, 240, 0.78);
    font-weight: 700;
    word-break: break-word;
}

.hint {
    margin-top: 8px;
    font-size: 13px;
    color: var(--color-text-muted);
}

.viewer {
    margin-top: 12px;
}

.viewer-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 10px;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-indicator {
    padding: 8px 10px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    color: var(--color-text-muted);
    font-weight: 700;
    font-size: 13px;
    min-width: 120px;
    text-align: center;
}

.canvas-wrap {
    position: relative;
    width: 100%;
    border-radius: 14px;
    border: 2px solid rgba(51, 65, 85, 0.8);
    overflow: hidden;
    background: rgba(15, 23, 42, 0.65);
    min-height: 320px;
}

.pdf-canvas {
    width: 100%;
    height: auto;
    display: block;
}

.overlay-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.overlay-item {
    position: absolute;
    pointer-events: auto;
    cursor: default;
    user-select: none;
    border: 2px solid rgba(59, 130, 246, 0.35);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.78);
    padding: 0;
    backdrop-filter: blur(2px);
    z-index: 10;
}

.overlay-item.selected {
    border-color: rgba(59, 130, 246, 0.95);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

.overlay-item .overlay-controls,
.overlay-item .resize-handle {
    display: none;
}

.overlay-item.selected .overlay-controls,
.overlay-item.selected .resize-handle {
    display: flex;
}

.overlay-item.selected .resize-handle {
    display: block;
}

.overlay-controls {
    position: absolute;
    top: -12px;
    right: -12px;
    display: flex;
    gap: 6px;
    z-index: 50;
}

.overlay-control {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: 1px solid rgba(148, 163, 184, 0.55);
    background: rgba(15, 23, 42, 0.9);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.overlay-control:hover {
    background: rgba(15, 23, 42, 0.98);
}

.overlay-drag {
    cursor: grab;
}

.overlay-drag:active {
    cursor: grabbing;
}

.overlay-remove {
    border-color: rgba(239, 68, 68, 0.65);
}

.overlay-remove:hover {
    background: rgba(239, 68, 68, 0.95);
    border-color: rgba(239, 68, 68, 0.95);
}

.overlay-item img {
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
    object-fit: contain;
}

.overlay-text {
    color: var(--color-text);
    font-weight: 400;
    white-space: pre-wrap;
    line-height: 1.15;
    pointer-events: auto;
    user-select: text;
    outline: none;
    width: 100%;
    height: 100%;
    padding: 10px 10px;
}

.resize-handle {
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 999px;
    border: 2px solid rgba(59, 130, 246, 0.95);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    z-index: 40;
}

.resize-nw { top: -7px; left: -7px; cursor: nwse-resize; }
.resize-ne { top: -7px; right: -7px; cursor: nesw-resize; }
.resize-se { bottom: -7px; right: -7px; cursor: nwse-resize; }
.resize-sw { bottom: -7px; left: -7px; cursor: nesw-resize; }

.text-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.text-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.text-actions .btn {
    box-shadow: none;
}

.viewer-hint {
    margin-top: 10px;
    color: var(--color-text-muted);
    font-size: 13px;
}

.details-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 12px;
}

.details-row .input {
    min-width: 0;
}

.field-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.signature-options {
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: rgba(15, 23, 42, 0.22);
    padding: 12px 12px;
    margin-top: -6px;
}

.signature-options .field {
    margin-top: 0;
}

.signature-options .field + .field {
    margin-top: 14px;
}

.signature-preview {
    margin-top: 10px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: #ffffff;
    min-height: 54px;
    display: flex;
    align-items: center;
    padding: 10px 12px;
    color: #0f172a;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.field-item {
    display: grid;
    grid-template-columns: 34px 34px 1fr;
    gap: 12px;
    align-items: center;
    padding: 12px 12px;
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: rgba(15, 23, 42, 0.35);
}

.field-handle {
    width: 34px;
    height: 34px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(148, 163, 184, 0.12);
    color: var(--color-text);
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
}

.field-handle:active {
    cursor: grabbing;
}

.field-badge {
    width: 34px;
    height: 34px;
    border-radius: 12px;
    border: 1px solid rgba(99, 102, 241, 0.25);
    background: rgba(99, 102, 241, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
}

.field-title {
    font-weight: 900;
    line-height: 1.2;
}

.field-subtitle {
    margin-top: 2px;
    font-size: 12px;
    color: var(--color-text-muted);
}

.color-palette {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.color-dot {
    width: 18px;
    height: 18px;
    border-radius: 999px;
    border: 2px solid rgba(148, 163, 184, 0.35);
    background: rgba(148, 163, 184, 0.22);
    cursor: pointer;
}

.color-dot.active {
    border-color: rgba(99, 102, 241, 0.95);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
}

.color-dot[data-color="#0f172a"] { background: #0f172a; }
.color-dot[data-color="#3b82f6"] { background: #3b82f6; }
.color-dot[data-color="#ef4444"] { background: #ef4444; }

.mode-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.mode-tab {
    border: 1px solid rgba(148, 163, 184, 0.3);
    background: rgba(148, 163, 184, 0.12);
    color: var(--color-text);
    padding: 10px 12px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 900;
    transition: all 0.25s ease;
}

.mode-tab:hover {
    transform: translateY(-1px);
    background: rgba(148, 163, 184, 0.18);
}

.mode-tab.active {
    border-color: rgba(99, 102, 241, 0.7);
    background: rgba(99, 102, 241, 0.18);
}

.sig-wrap {
    border-radius: 14px;
    border: 2px solid rgba(51, 65, 85, 0.8);
    background: rgba(255, 255, 255, 0.92);
    overflow: hidden;
}

.type-wrap {
    border-radius: 14px;
    border: 2px solid rgba(51, 65, 85, 0.8);
    background: rgba(15, 23, 42, 0.65);
    padding: 14px;
}

.input,
.select {
    width: 100%;
    padding: 12px 12px;
    border-radius: 12px;
    border: 2px solid var(--color-border);
    background: var(--color-darker);
    color: var(--color-text);
    font-weight: 700;
}

.type-controls {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 12px;
    flex-wrap: wrap;
}

.type-controls .select {
    flex: 1 1 180px;
}

.range-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1 1 220px;
}

.range-value {
    min-width: 48px;
    text-align: right;
    color: var(--color-text-muted);
    font-weight: 900;
    font-size: 12px;
}

.type-preview {
    margin-top: 12px;
    padding: 14px 14px;
    border-radius: 12px;
    border: 1px dashed rgba(99, 102, 241, 0.6);
    background: rgba(255, 255, 255, 0.04);
    font-size: 34px;
    line-height: 1.2;
    min-height: 70px;
    display: flex;
    align-items: center;
}

.image-wrap {
    border-radius: 14px;
    border: 2px solid rgba(51, 65, 85, 0.8);
    background: rgba(15, 23, 42, 0.65);
    padding: 14px;
}

.sig-canvas {
    width: 100%;
    height: 160px;
    display: block;
    touch-action: none;
    background: transparent;
}

.sig-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 14px;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
    color: #fff;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.btn:disabled {
    opacity: 0.88;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    filter: saturate(0.9);
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
}

.btn-danger {
    background: linear-gradient(135deg, var(--color-danger), #dc2626);
}

.btn-info {
    background: linear-gradient(135deg, var(--color-info), #2563eb);
}

.btn-warning {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.btn-ghost {
    background: rgba(148, 163, 184, 0.12);
    color: var(--color-text);
    border: 1px solid rgba(148, 163, 184, 0.3);
    box-shadow: none;
}

.btn-ghost:hover:not(:disabled) {
    background: rgba(148, 163, 184, 0.18);
}

.range {
    width: 100%;
}

.signature-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 160px;
    height: auto;
    cursor: grab;
    user-select: none;
    background: rgba(255, 255, 255, 0.06);
    border: 2px dashed rgba(99, 102, 241, 0.65);
    border-radius: 10px;
    padding: 6px;
    backdrop-filter: blur(2px);
}

.signature-overlay:active {
    cursor: grabbing;
}

.signature-overlay img {
    width: 100%;
    height: auto;
    display: block;
}

.note {
    margin-top: 14px;
    color: var(--color-text-muted);
    font-size: 13px;
    line-height: 1.6;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: rgba(15, 23, 42, 0.35);
}

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

@media (max-width: 640px) {
    body {
        padding: 12px;
        overflow-x: hidden;
    }

    .header {
        padding: 18px 14px;
        margin-bottom: 22px;
    }

    .logo-icon img {
        width: 36px;
        height: 36px;
    }

    .header h1 {
        font-size: 34px;
    }

    .subtitle {
        font-size: 15px;
    }

    .grid {
        gap: 14px;
    }

    .card {
        padding: 16px;
    }

    .dropzone {
        flex-wrap: wrap;
        gap: 12px;
    }

    .drop-text {
        min-width: 0;
        flex: 1 1 240px;
    }

    .viewer-toolbar {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }

    .toolbar-left,
    .toolbar-right {
        flex: 1 1 100%;
        justify-content: center;
        flex-wrap: wrap;
    }

    .page-indicator {
        min-width: 0;
    }

    .details-row {
        grid-template-columns: 1fr;
    }

    .type-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .range-wrap {
        flex: 1 1 auto;
    }
}
