:root {
    --bg: #eef2f7;
    --panel: #ffffff;
    --text: #14213d;
    --muted: #6b7280;
    --line: #d8dee9;
    --primary: #0f62fe;
    --danger: #dc2626;
    --shadow: 0 16px 40px rgba(15, 23, 42, .12);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
}

.app-shell {
    display: grid;
    grid-template-columns: 390px minmax(0, 1fr);
    min-height: 100vh;
}

.panel {
    background: var(--panel);
    border-right: 1px solid var(--line);
    padding: 18px;
    overflow-y: auto;
    max-height: 100vh;
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 18px;
}

.brand-icon {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    background: #eff6ff;
    display: grid;
    place-items: center;
    font-size: 25px;
}

h1, h2, p { margin: 0; }

h1 { font-size: 24px; }
h2 { font-size: 15px; margin-bottom: 12px; }
p, small, .muted { color: var(--muted); }

.card {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 14px;
    margin-bottom: 14px;
    background: #fff;
}

.upload-box {
    border: 2px dashed #b6c2d6;
    border-radius: 14px;
    padding: 24px 16px;
    display: grid;
    gap: 6px;
    text-align: center;
    cursor: pointer;
    background: #f8fafc;
}

.upload-box input { display: none; }
.upload-box span { font-weight: 700; }

label {
    display: grid;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
}

input, select {
    width: 100%;
    padding: 10px 11px;
    border: 1px solid #cbd5e1;
    border-radius: 11px;
    background: #fff;
    font-size: 14px;
}

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


.print-note {
    margin: -2px 0 12px;
    padding: 10px 11px;
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    background: #eff6ff;
    color: #1e3a8a;
    font-size: 12px;
    line-height: 1.45;
}

.print-note strong { display: block; margin-bottom: 3px; }

.checkbox-row {
    display: grid;
    gap: 8px;
    font-weight: 400;
}

.checkbox-row label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.checkbox-row input { width: auto; }

.button-row, .action-sticky {
    display: flex;
    gap: 10px;
}

.btn {
    border: 0;
    border-radius: 12px;
    padding: 11px 14px;
    background: #e5e7eb;
    color: #111827;
    font-weight: 800;
    cursor: pointer;
    transition: transform .12s ease, opacity .12s ease;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.primary { background: var(--primary); color: white; }
.btn.print { background: #16a34a; color: white; flex: 1; }
.btn.danger { background: var(--danger); color: white; }
.btn.small { padding: 8px 12px; border-radius: 10px; }

.action-sticky {
    position: sticky;
    bottom: 0;
    background: linear-gradient(to top, #fff 70%, rgba(255,255,255,0));
    padding-top: 16px;
}

.is-hidden { display: none !important; }

.photo-list {
    display: grid;
    gap: 10px;
}

.photo-list.empty {
    color: var(--muted);
    font-size: 13px;
}

.photo-item {
    display: grid;
    grid-template-columns: 54px 1fr auto;
    gap: 10px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 8px;
    cursor: pointer;
}

.photo-item.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 98, 254, .12);
}

.photo-item img {
    width: 54px;
    height: 54px;
    object-fit: cover;
    border-radius: 10px;
}

.photo-item strong {
    display: block;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.photo-item span {
    color: var(--muted);
    font-size: 12px;
}

.photo-item button {
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 9px;
    background: #fee2e2;
    color: var(--danger);
    cursor: pointer;
    font-weight: 900;
}

.preview-area {
    padding: 20px;
    overflow: auto;
}

.toolbar {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    box-shadow: var(--shadow);
}

.toolbar span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin-top: 3px;
}

.paper-wrapper {
    display: grid;
    place-items: start center;
    min-width: max-content;
}

.paper {
    background: #fff;
    box-shadow: var(--shadow);
    overflow: hidden;
    position: relative;
}

.print-area {
    width: 100%;
    height: 100%;
    display: flex;
    align-content: flex-start;
    align-items: flex-start;
    flex-wrap: wrap;
}

.photo-print {
    position: relative;
    overflow: hidden;
    background: white;
    flex: 0 0 auto;
}

.photo-print.cutline {
    border: .2mm dashed #888;
}

.photo-print img {
    width: 100%;
    height: 100%;
    display: block;
}

.photo-print.cover img { object-fit: cover; }
.photo-print.contain img { object-fit: contain; background: #fff; }

.photo-label {
    position: absolute;
    left: 1mm;
    bottom: 1mm;
    font-size: 7pt;
    background: rgba(255,255,255,.82);
    color: #111827;
    padding: .5mm 1mm;
    border-radius: 1mm;
}

@media (max-width: 900px) {
    .app-shell { grid-template-columns: 1fr; }
    .panel { max-height: none; border-right: 0; border-bottom: 1px solid var(--line); }
    .grid-2 { grid-template-columns: 1fr; }
}

@page {
    size: A4 portrait;
    margin: 0;
}

@media print {
    body { background: #fff; }
    .no-print, .panel, .toolbar { display: none !important; }
    .app-shell { display: block; min-height: auto; }
    .preview-area { padding: 0; overflow: visible; }
    .paper-wrapper { display: block; min-width: 0; }
    .paper {
        box-shadow: none;
        margin: 0;
        page-break-after: always;
    }
}
