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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.5;
}

nav {
    background: #1a1a2e;
    color: #fff;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 56px;
}
nav a { color: #ccc; text-decoration: none; padding: 8px 12px; font-size: 14px; }
nav a:hover { color: #fff; }
.nav-left, .nav-right { display: flex; align-items: center; gap: 4px; }
.nav-logo { font-weight: bold; font-size: 18px; color: #fff !important; margin-right: 16px; }
.balance { background: #16213e; border-radius: 4px; font-weight: 500; color: #4ecca3 !important; }
.user-name { font-size: 13px; color: #888; padding: 0 8px; }
.btn-logout { color: #e74c3c !important; font-size: 13px; }

main { margin: 24px; padding: 0; }

h1 { margin-bottom: 20px; font-size: 24px; }
h2 { margin: 24px 0 12px; font-size: 18px; }
h3 { margin-bottom: 8px; font-size: 16px; }

/* Auth */
.auth-container { max-width: 400px; margin: 60px auto; background: #fff; padding: 32px; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.auth-container h1 { text-align: center; }
.auth-link { text-align: center; margin-top: 16px; font-size: 14px; }
.auth-link a { color: #2563eb; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 500; margin-bottom: 4px; font-size: 14px; }
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="tel"],
.form-group input[type="number"],
.form-group input[type="file"],
.form-group select {
    width: 100%; padding: 8px 12px; border: 1px solid #ddd; border-radius: 4px; font-size: 14px;
}
.form-group small { color: #888; font-size: 12px; }
.radio-group { display: flex; flex-direction: column; gap: 6px; }
.radio-group label { font-weight: normal; display: flex; align-items: center; gap: 6px; }

/* Buttons */
.btn { display: inline-block; padding: 10px 20px; border: none; border-radius: 4px; font-size: 14px; cursor: pointer; text-decoration: none; }
.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-small { padding: 6px 12px; font-size: 13px; }
.btn-action { background: #fff; border: 1px solid #ddd; padding: 16px 24px; border-radius: 8px; font-size: 14px; color: #333; }
.btn-action:hover { border-color: #2563eb; color: #2563eb; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: 4px; margin-bottom: 16px; font-size: 14px; }
.alert-error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 24px; }
.card { background: #fff; padding: 16px; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.card h3 { font-size: 13px; color: #666; font-weight: 500; }
.card-value { font-size: 28px; font-weight: 700; margin: 4px 0; }
.card-price { font-size: 12px; color: #888; }

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

/* Tables */
table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
th, td { padding: 10px 14px; text-align: left; font-size: 14px; }
th { background: #f8f9fa; font-weight: 600; color: #555; border-bottom: 2px solid #eee; }
td { border-bottom: 1px solid #f0f0f0; }
tr:last-child td { border-bottom: none; }

/* Status */
.status-ok { color: #16a34a; font-weight: 500; }
.status-err { color: #dc2626; font-weight: 500; }
.status-wait { color: #ca8a04; font-weight: 500; }

/* Balance */
.balance-block { background: #fff; padding: 24px; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); margin-bottom: 20px; text-align: center; }
.balance-amount { font-size: 42px; font-weight: 700; color: #16a34a; margin-bottom: 16px; }
.topup-form { display: flex; gap: 8px; justify-content: center; align-items: center; }
.topup-form input { width: 160px; }

/* Money colors */
.amount-plus { color: #16a34a; font-weight: 500; }
.amount-minus { color: #dc2626; font-weight: 500; }

/* Upload */
.upload-section { background: #fff; padding: 24px; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); margin-bottom: 20px; display: flex; flex-direction: column; }

/* Results */
.result-card { background: #fff; padding: 16px; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); margin-bottom: 12px; }
.result-table { margin-top: 8px; }
.result-table td:first-child { color: #666; width: 160px; font-size: 13px; }

/* Pricing */
.pricing-table { background: #fff; padding: 16px; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); margin-bottom: 20px; }

/* Info */
.info-block { background: #fff; padding: 16px; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); margin-top: 16px; }
.info-block ul { padding-left: 20px; }
.info-block li { margin-bottom: 4px; font-size: 14px; }
.info-block p { font-size: 14px; margin-top: 8px; color: #666; }

/* Dropzone with result (compare inside) */
.dropzone.has-result { border-color: #16a34a; background: #f8faf8; padding: 8px; }
.dropzone-compare { display: flex; gap: 8px; width: 100%; }
.dropzone-compare-img { flex: 1; text-align: center; min-width: 0; }
.dropzone-compare-img img { max-width: 100%; max-height: 160px; object-fit: contain; border-radius: 4px; }
.dropzone-compare-img span {
    display: block; font-size: 11px; color: #888; margin-top: 4px;
    text-transform: uppercase; letter-spacing: 0.5px;
}
.dropzone-compare-img .label-ok { color: #16a34a; font-weight: 600; }
.dropzone-compare-img a {
    display: block; position: relative; border-radius: 4px; overflow: hidden;
    text-decoration: none;
}
.dropzone-dl {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,0); transition: background 0.2s; opacity: 0;
}
.dropzone-dl span {
    background: #16a34a; color: #fff; padding: 8px 20px; border-radius: 6px;
    font-size: 13px; font-weight: 600; box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.dropzone-compare-img a:hover .dropzone-dl { background: rgba(0,0,0,0.4); opacity: 1; }
.dropzone-compare { position: relative; }
.dropzone-close {
    position: absolute; top: -8px; right: -8px; width: 22px; height: 22px; z-index: 2;
    border: 2px solid #fff; border-radius: 50%; background: rgba(0,0,0,0.5); color: #fff;
    font-size: 14px; line-height: 1; cursor: pointer; display: flex;
    align-items: center; justify-content: center; padding: 0;
}
.dropzone-close:hover { background: rgba(0,0,0,0.8); }

/* Dropzone */
.dropzone {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    border: 2px dashed #ccc; border-radius: 8px; padding: 32px 16px; margin-bottom: 16px;
    cursor: pointer; text-align: center; transition: border-color 0.2s, background 0.2s;
    min-height: 180px; flex: 1;
}
.dropzone:hover { border-color: #2563eb; background: #f8faff; }
.dropzone.drag-over { border-color: #2563eb; background: #eff6ff; }
.dropzone.has-file { border-color: #16a34a; background: #f0fdf4; }
.dropzone input[type="file"] { display: none; }
.dropzone-preview { max-width: 100%; max-height: 160px; object-fit: contain; border-radius: 4px; }
.dropzone-icon { font-size: 40px; margin-bottom: 8px; line-height: 1; }
.dropzone-text { font-size: 15px; font-weight: 500; color: #333; }
.dropzone-hint { font-size: 13px; color: #999; margin-top: 4px; }
.dropzone-filename { font-size: 13px; color: #2563eb; font-weight: 500; margin-top: 8px; word-break: break-all; }
.dropzone-details { font-size: 12px; color: #aaa; margin-top: 10px; line-height: 1.6; }
.btn-full { width: 100%; text-align: center; }

/* Recognition processing overlay */
.dropzone-overlay {
    position: absolute; inset: 0; background: rgba(0,0,0,0.6); border-radius: 6px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    z-index: 5;
}
.dropzone-overlay-text { color: #fff; font-size: 15px; font-weight: 500; margin-bottom: 12px; }
.dropzone-spinner {
    width: 36px; height: 36px; border: 3px solid rgba(255,255,255,0.3);
    border-top-color: #fff; border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Recognition result inside dropzone */
.dropzone-result {
    display: flex; gap: 12px; width: 100%; height: 100%; align-items: stretch;
}
.dropzone-result-left {
    flex: 1; display: flex; align-items: center; justify-content: center;
    border-right: 1px solid #e0e0e0; padding-right: 12px;
}
.dropzone-result-left img { max-width: 100%; max-height: 200px; object-fit: contain; border-radius: 4px; }
.dropzone-result-right {
    flex: 1; display: flex; flex-direction: column; gap: 4px; overflow-y: auto;
    font-size: 13px; justify-content: center;
}
.dropzone-result-file {
    display: flex; align-items: center; gap: 6px; padding: 3px 0;
    color: #333; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dropzone-result-file-icon { font-size: 16px; flex-shrink: 0; }
.dropzone-result-fio { font-weight: 600; font-size: 14px; margin-bottom: 4px; color: #1a1a2e; }
.dropzone-result-download {
    display: inline-block; margin-top: 8px; padding: 8px 16px; background: #16a34a;
    color: #fff; border-radius: 6px; text-decoration: none; font-size: 13px; font-weight: 600;
    text-align: center;
}
.dropzone-result-download:hover { background: #15803d; }
.dropzone.has-recognition { border-color: #16a34a; background: #f8faf8; padding: 12px; position: relative; }

/* Stamp settings */
.stamps-grid { min-height: auto !important; }
.stamp-preview {
    position: relative; border: 1px solid #e0e0e0; border-radius: 8px;
    padding: 12px; margin-bottom: 12px; background: #fafafa; text-align: center;
}
.stamp-preview img { max-width: 100%; max-height: 150px; object-fit: contain; }
.stamp-delete-form { position: absolute; top: 4px; right: 4px; }
.stamp-delete {
    width: 24px; height: 24px; border: none; border-radius: 50%;
    background: rgba(220,38,38,0.8); color: #fff; font-size: 16px;
    cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0;
}
.stamp-delete:hover { background: rgba(220,38,38,1); }
.stamp-filename { text-align: center; font-size: 12px; color: #888; margin-bottom: 8px; }

/* Columns */
.two-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.three-columns { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 24px; min-height: calc(100vh - 140px); }
.results-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.two-columns .upload-section,
.three-columns .upload-section { height: 100%; display: flex; flex-direction: column; }
.two-columns .upload-section p,
.three-columns .upload-section p { color: #666; font-size: 14px; margin-bottom: 16px; }
.two-columns .upload-section h2,
.three-columns .upload-section h2 { font-size: 18px; margin-bottom: 4px; }
.two-columns .upload-section form,
.three-columns .upload-section form { flex: 1; display: flex; flex-direction: column; }
.three-columns .column { display: flex; min-width: 0; }
.three-columns .upload-section { width: 100%; margin-bottom: 0; }
.hint-list { margin-top: 12px; padding-left: 18px; }
.hint-list li { font-size: 13px; color: #888; margin-bottom: 2px; }

.section { margin-bottom: 24px; }

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

@media (max-width: 640px) {
    nav { flex-direction: column; height: auto; padding: 8px; }
    .nav-left, .nav-right { flex-wrap: wrap; justify-content: center; }
    .cards { grid-template-columns: repeat(2, 1fr); }
    .actions { flex-direction: column; }
    .two-columns { grid-template-columns: 1fr; }
    .three-columns { grid-template-columns: 1fr; }
}
