:root {
    --bg: #0b1020;
    --card: #121833;
    --text: #e6e8ef;
    --muted: #9aa3b2;
    --primary: #4f7cf7;
    --primary-hover: #3a66e6;
    --secondary: #22c55e;
    --border: #1e2747;
    --danger: #ef4444;
}

body {
    margin: 0;
    min-height: 100vh;
    background: radial-gradient(1200px 600px at 20% 0%, #0e152d 0%, #0b1020 55%, #070b18 100%);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
    line-height: 1.5;
}

.top-actions {
    position: fixed;
    top: 14px;
    right: 14px;
    display: flex;
    gap: 10px;
    align-items: center;
    z-index: 10000;
}

.top-link {
    display: inline-flex;
    align-items: center;
    height: 44px;
    padding: 0 12px;
    border-radius: 14px;
    border: 1px solid rgba(30,39,71,0.85);
    background: rgba(12,19,40,0.65);
    color: #c9d7ff;
    text-decoration: none;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.3px;
    box-shadow: 0 16px 50px rgba(0,0,0,0.45);
}

.top-link:hover {
    border-color: rgba(79,124,247,0.45);
    background: rgba(79,124,247,0.12);
}

.fab-refresh {
    position: static;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(30,39,71,0.85);
    background: rgba(12,19,40,0.65);
    color: #c9d7ff;
    font-size: 18px;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 16px 50px rgba(0,0,0,0.45);
}

.fab-refresh:hover {
    border-color: rgba(79,124,247,0.45);
    background: rgba(79,124,247,0.12);
}

.fab-refresh:active {
    transform: translateY(1px);
}

.container {
    max-width: 920px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    margin: 10px 0 22px;
    text-align: left;
}

.header h1 {
    margin: 10px 0 6px;
    font-size: 2rem;
    background: linear-gradient(135deg, #4f7cf7 0%, #8b5cf6 60%, #22c55e 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sub {
    color: var(--muted);
    font-size: 0.95rem;
}

.card {
    background: linear-gradient(180deg, rgba(18,24,51,0.9) 0%, rgba(18,24,51,0.65) 100%);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 12px 28px rgba(16,24,48,0.45);
}

.sheet-card {
    position: relative;
    overflow: hidden;
}

.sheet-card.mode-order {
    border-color: rgba(79,124,247,0.35);
    box-shadow: 0 14px 40px rgba(79,124,247,0.10), 0 12px 28px rgba(16,24,48,0.45);
}

.sheet-card.mode-auto {
    border-color: rgba(139,92,246,0.38);
    box-shadow: 0 14px 42px rgba(139,92,246,0.12), 0 12px 28px rgba(16,24,48,0.45);
}

.sheet-card.mode-idcard {
    border-color: rgba(34,197,94,0.30);
    box-shadow: 0 14px 40px rgba(34,197,94,0.09), 0 12px 28px rgba(16,24,48,0.45);
}

.sheet-card::before {
    content: "";
    position: absolute;
    inset: 0;
    opacity: 0.8;
    pointer-events: none;
    background:
        radial-gradient(900px 320px at 0% 0%, rgba(79,124,247,0.18) 0%, rgba(79,124,247,0.00) 58%),
        radial-gradient(900px 320px at 100% 0%, rgba(139,92,246,0.12) 0%, rgba(139,92,246,0.00) 58%);
}

.sheet-card.mode-idcard::before {
    background:
        radial-gradient(900px 320px at 0% 0%, rgba(34,197,94,0.18) 0%, rgba(34,197,94,0.00) 58%),
        radial-gradient(900px 320px at 100% 0%, rgba(79,124,247,0.10) 0%, rgba(79,124,247,0.00) 58%);
}

.sheet-card.mode-auto::before {
    background:
        radial-gradient(900px 320px at 0% 0%, rgba(139,92,246,0.20) 0%, rgba(139,92,246,0.00) 58%),
        radial-gradient(900px 320px at 100% 0%, rgba(79,124,247,0.12) 0%, rgba(79,124,247,0.00) 58%);
}

.sheet-card > * {
    position: relative;
    z-index: 1;
}

.row {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.row .grow {
    flex: 1;
    min-width: 220px;
}

.sheet {
    display: block;
}

.mode-banner {
    border-radius: 18px;
    border: 1px solid rgba(30,39,71,0.85);
    background: rgba(12,19,40,0.35);
    padding: 14px 14px 12px;
    margin: 10px 0 14px;
    position: relative;
    overflow: hidden;
}

.mode-banner::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    background: rgba(79,124,247,0.55);
}

.mode-banner-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 12px;
    color: rgba(201, 215, 255, 0.75);
    letter-spacing: 2px;
}

.mode-select {
    appearance: none;
    border: 1px solid rgba(30,39,71,0.85);
    background: rgba(12,19,40,0.55);
    color: var(--text);
    border-radius: 12px;
    padding: 8px 34px 8px 12px;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0;
    cursor: pointer;
    position: relative;
    background-image: linear-gradient(45deg, transparent 50%, rgba(201,215,255,0.8) 50%),
        linear-gradient(135deg, rgba(201,215,255,0.8) 50%, transparent 50%);
    background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
}

.mode-select:focus {
    outline: none;
    border-color: rgba(79,124,247,0.45);
    box-shadow: 0 0 0 3px rgba(79,124,247,0.18);
}

.sheet-card.mode-auto .mode-select:focus {
    border-color: rgba(139,92,246,0.50);
    box-shadow: 0 0 0 3px rgba(139,92,246,0.18);
}

.sheet-card.mode-idcard .mode-select:focus {
    border-color: rgba(34,197,94,0.45);
    box-shadow: 0 0 0 3px rgba(34,197,94,0.16);
}

.mode-banner-title {
    font-size: 26px;
    font-weight: 900;
    margin-top: 4px;
    letter-spacing: 0.5px;
}

.mode-banner-desc {
    font-size: 13px;
    color: var(--muted);
    margin-top: 6px;
}

.mode-banner.mode-order {
    border-color: rgba(79,124,247,0.45);
    background: linear-gradient(180deg, rgba(79,124,247,0.16) 0%, rgba(12,19,40,0.45) 100%);
    box-shadow: 0 18px 60px rgba(79,124,247,0.12);
}

.mode-banner.mode-auto::before {
    background: rgba(139,92,246,0.60);
}

.mode-banner.mode-auto {
    border-color: rgba(139,92,246,0.48);
    background: linear-gradient(180deg, rgba(139,92,246,0.14) 0%, rgba(12,19,40,0.45) 100%);
    box-shadow: 0 18px 60px rgba(139,92,246,0.12);
}

.mode-banner.mode-auto .mode-banner-top {
    color: rgba(224, 214, 255, 0.78);
}

.mode-banner.mode-auto .mode-banner-title {
    color: #e9d5ff;
}

.mode-banner.mode-order .mode-banner-title {
    color: #c9d7ff;
}

.mode-banner.mode-idcard::before {
    background: rgba(34,197,94,0.55);
}

.mode-banner.mode-idcard {
    border-color: rgba(34,197,94,0.45);
    background: linear-gradient(180deg, rgba(34,197,94,0.14) 0%, rgba(12,19,40,0.45) 100%);
    box-shadow: 0 18px 60px rgba(34,197,94,0.10);
}

.mode-banner.mode-idcard .mode-banner-top {
    color: rgba(187, 247, 208, 0.78);
}

.mode-banner.mode-idcard .mode-banner-title {
    color: #bbf7d0;
}

@media (max-width: 720px) {
    .container {
        padding: 14px;
    }
    .header h1 {
        font-size: 1.7rem;
        margin: 6px 0 6px;
    }
    .sub {
        font-size: 0.9rem;
    }
    .card {
        padding: 14px;
        border-radius: 14px;
    }
    .row .grow {
        min-width: 0;
    }
    .btn {
        width: 100%;
    }
    .mode-banner-title {
        font-size: 22px;
    }
    .mode-banner-desc {
        font-size: 12px;
    }
    .mode-select {
        width: 160px;
    }
}

.input-control {
    width: 100%;
    padding: 12px 12px;
    background: #0c1328;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 1rem;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-control:focus {
    outline: none;
    border-color: #2a5cff;
    box-shadow: 0 0 0 3px rgba(79,124,247,0.18);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    background: var(--primary);
    color: white;
    border: 1px solid #3a5ed9;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgba(58,102,230,.28);
}

.btn.secondary {
    background: #1a2344;
    border-color: var(--border);
    color: var(--text);
}

.btn.secondary:hover {
    background: #222d57;
    box-shadow: 0 10px 22px rgba(16,24,48,.35);
}

.btn.btn-sm {
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
}

.btn.danger {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.35);
    color: #fecaca;
}

.btn.danger:hover {
    background: rgba(239, 68, 68, 0.25);
    box-shadow: 0 10px 22px rgba(239, 68, 68, 0.10);
}

.hint {
    margin-top: 12px;
    color: var(--muted);
    font-size: 0.9rem;
    display: none;
}

.table-wrap {
    margin-top: 16px;
    overflow: auto;
    border-radius: 14px;
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(12,19,40,0.55);
}

thead th {
    text-align: left;
    font-size: 0.85rem;
    color: #b5bfd4;
    padding: 12px 14px;
    background: rgba(10,16,36,0.8);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(30,39,71,0.85);
    font-size: 0.95rem;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

tbody tr:hover {
    background: rgba(79,124,247,0.06);
}

.empty {
    padding: 18px 14px;
    color: var(--muted);
    text-align: center;
}

.pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    border: 1px solid rgba(79,124,247,0.35);
    background: rgba(79,124,247,0.10);
    color: #c9d7ff;
}

.pill.success {
    border-color: rgba(34,197,94,0.35);
    background: rgba(34,197,94,0.12);
    color: #22c55e;
}

.pill.error {
    border-color: rgba(239,68,68,0.35);
    background: rgba(239,68,68,0.12);
    color: #fca5a5;
}

.page-status {
    margin-top: 14px;
    text-align: center;
    font-size: clamp(28px, 4.2vw, 54px);
    font-weight: 900;
    letter-spacing: 1px;
    line-height: 1.2;
}

.page-status.success {
    color: #22c55e;
}

.page-status.error {
    color: #fca5a5;
}

.detail-card {
    margin-top: 14px;
    border-radius: 16px;
    border: 1px solid rgba(30,39,71,0.85);
    background: rgba(12,19,40,0.35);
    padding: 16px 14px 14px;
    box-shadow: 0 18px 60px rgba(0,0,0,0.25);
}

.detail-card.status-success .detail-title {
    color: #22c55e;
}

.detail-card.status-error .detail-title {
    color: #fca5a5;
}

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

.detail-title {
    font-size: 18px;
    font-weight: 900;
    color: var(--text);
    letter-spacing: 0.3px;
}

.detail-msg {
    margin: 0 0 12px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(239,68,68,0.35);
    background: rgba(239,68,68,0.10);
    color: #fca5a5;
    font-weight: 800;
    letter-spacing: 0.2px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.detail-item {
    border: 1px solid rgba(30,39,71,0.85);
    border-radius: 14px;
    padding: 12px 12px;
    background: rgba(12,19,40,0.45);
}

.detail-item .k {
    font-size: 12px;
    color: var(--muted);
    letter-spacing: 2px;
}

.detail-item .v {
    margin-top: 6px;
    font-size: 18px;
    font-weight: 900;
    letter-spacing: 0.2px;
    color: var(--text);
    word-break: break-all;
}

.detail-item .v.mono {
    font-variant-numeric: tabular-nums;
}

.detail-actions {
    display: flex;
    gap: 10px;
    margin-top: 14px;
}

.detail-actions .btn {
    flex: 1;
}

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

.center-message {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    z-index: 9999;
    pointer-events: none;
}

.print-modal {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(3, 6, 18, 0.65);
    backdrop-filter: blur(8px);
    z-index: 10001;
}

.print-modal-card {
    width: min(50vw, 420px);
    border-radius: 18px;
    border: 1px solid rgba(30,39,71,0.85);
    background: linear-gradient(180deg, rgba(18,24,51,0.95) 0%, rgba(18,24,51,0.78) 100%);
    box-shadow: 0 22px 70px rgba(0,0,0,0.55);
    padding: 18px 16px 14px;
    max-height: 82vh;
    overflow: auto;
    position: relative;
    transition: width 0.22s ease, padding 0.22s ease, border-radius 0.22s ease;
}

.print-orientation {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
}

.print-orientation-select {
    height: 32px;
    min-width: 110px;
    padding: 0 10px;
    border-radius: 10px;
    border: 1px solid rgba(30,39,71,0.9);
    background: rgba(12,19,40,0.72);
    color: #c9d7ff;
    font-size: 12px;
    font-weight: 700;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

.print-orientation-select:focus,
.print-orientation-select:hover {
    border-color: rgba(79,124,247,0.6);
    background: rgba(79,124,247,0.14);
    box-shadow: 0 0 0 2px rgba(79,124,247,0.18);
}

.print-orientation-select option {
    color: #0f172a;
    background: #f8fbff;
}

.print-orientation-select option:checked {
    color: #0b1020;
    background: #dbeafe;
}

.print-modal-title {
    font-size: 18px;
    font-weight: 900;
    letter-spacing: 0.6px;
    margin-bottom: 12px;
    color: #c9d7ff;
    transition: font-size 0.2s ease;
}

.print-modal-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    transition: gap 0.2s ease, grid-template-columns 0.2s ease;
}

.print-item {
    border: 1px solid rgba(30,39,71,0.85);
    border-radius: 14px;
    padding: 12px 12px;
    background: rgba(12,19,40,0.35);
    transition: padding 0.2s ease;
}

.print-item .k {
    font-size: 12px;
    color: var(--muted);
    letter-spacing: 2px;
}

.print-item .v {
    margin-top: 6px;
    font-size: 19px;
    font-weight: 900;
    letter-spacing: 0.3px;
    color: var(--text);
    transition: font-size 0.2s ease;
}

.print-modal-card.orientation-landscape {
    width: min(74vw, 620px);
    padding: 16px 14px 12px;
}

.print-modal-card.orientation-landscape .print-modal-title {
    font-size: 20px;
    margin-bottom: 8px;
}

.print-modal-card.orientation-landscape .print-modal-grid {
    grid-template-columns: 1fr;
    gap: 5px;
    margin-top: 6px;
}

.print-modal-card.orientation-landscape .print-item {
    display: flex;
    align-items: baseline;
    gap: 4px;
    min-height: 26px;
    padding: 5px 10px;
}

.print-modal-card.orientation-landscape .print-item .k {
    min-width: 56px;
    letter-spacing: 0.8px;
    font-size: 14px;
    line-height: 1.2;
    color: #b9c5df;
}

.print-modal-card.orientation-landscape .print-item .k::after {
    content: "： ";
}

.print-modal-card.orientation-landscape .print-item .v {
    margin-top: 0;
    font-size: 20px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.print-modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.print-modal-actions .btn {
    flex: 1;
}

.btn.print {
    background: rgba(79,124,247,0.14);
    border-color: rgba(79,124,247,0.35);
    color: #c9d7ff;
}

.btn.print:hover {
    background: rgba(79,124,247,0.22);
    box-shadow: 0 10px 22px rgba(79,124,247,0.12);
}

body.printing * {
    visibility: hidden;
}

body.printing #print-area,
body.printing #print-area * {
    visibility: visible;
}

body.printing #print-area {
    position: fixed;
    inset: 0;
    margin: auto;
    width: 100%;
    max-width: 420px;
    height: fit-content;
    transform: scale(0.5);
    transform-origin: top center;
}

@media (max-width: 720px) {
    .print-modal-card {
        width: min(84vw, 360px);
        border-radius: 16px;
    }
}

@media print {
    @page {
        size: 40mm 60mm;
        margin: 0;
    }
    html, body {
        width: 40mm !important;
        height: 60mm !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
    }
    body.printing * {
        visibility: visible !important;
    }
    body.printing .container,
    body.printing .top-actions,
    body.printing #center-message {
        display: none !important;
    }
    body.printing .print-orientation {
        display: none !important;
    }
    body.printing #print-modal {
        position: static !important;
        inset: auto !important;
        padding: 0 !important;
        background: #fff !important;
        backdrop-filter: none !important;
        display: block !important;
    }
    body.printing #print-area {
        position: static !important;
        inset: auto !important;
        margin: 0 !important;
        width: 40mm !important;
        height: 60mm !important;
        transform: none !important;
        transform-origin: initial !important;
        padding-left: 5mm !important;
        box-sizing: border-box !important;
    }
    .fab-refresh {
        display: none !important;
    }
    .print-modal-actions {
        display: none !important;
    }
    body {
        background: #fff !important;
        color: #000 !important;
    }
    .print-modal-card {
        width: 40mm !important;
        max-height: none !important;
        overflow: hidden !important;
        padding: 2mm 2mm 2mm !important;
        border-radius: 0 !important;
        background: #fff !important;
        border: none !important;
        box-shadow: none !important;
    }
    body.print-landscape #print-area {
        width: 60mm !important;
        height: 40mm !important;
    }
    body.print-landscape .print-modal-card {
        width: 60mm !important;
        padding: 2mm 2mm 2mm !important;
    }
    body.print-landscape .print-modal-grid {
        grid-template-columns: 1fr !important;
        gap: 2px !important;
        margin-top: 1.5mm !important;
    }
    body.print-landscape .print-item {
        display: flex !important;
        align-items: baseline !important;
        gap: 2px !important;
        min-height: 7mm !important;
        padding: 2px 4px !important;
    }
    body.print-landscape .print-item .k {
        min-width: 12mm !important;
        font-size: 11px !important;
        line-height: 1.2 !important;
        letter-spacing: 0.6px !important;
    }
    body.print-landscape .print-item .k::after {
        content: "： " !important;
    }
    body.print-landscape .print-item .v {
        font-size: 13px !important;
        margin-top: 0 !important;
        line-height: 1.2 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    body.print-landscape .print-modal-title {
        font-size: 13px !important;
        margin-bottom: 3px !important;
    }
    .print-modal-title {
        font-size: 14px !important;
        margin-bottom: 6px !important;
        color: #111827 !important;
        text-align: center !important;
    }
    .print-modal-grid {
        gap: 6px !important;
    }
    .print-item {
        background: #fff !important;
        border: 1px solid #ddd !important;
        border-radius: 8px !important;
        padding: 6px 6px !important;
    }
    .print-item .k {
        color: #333 !important;
        font-size: 10px !important;
        letter-spacing: 1px !important;
    }
    .print-item .v {
        color: #000 !important;
        font-size: 14px !important;
    }
}

.center-message-text {
    font-size: clamp(24px, 4.2vw, 54px);
    font-weight: 900;
    letter-spacing: 1px;
    text-align: center;
    padding: 8px 14px;
    border-radius: 16px;
    background: rgba(12,19,40,0.35);
    border: 1px solid rgba(30,39,71,0.85);
    box-shadow: 0 18px 60px rgba(0,0,0,0.45);
}

.center-message.success .center-message-text {
    color: #22c55e;
    border-color: rgba(34, 197, 94, 0.35);
    box-shadow: 0 18px 60px rgba(34, 197, 94, 0.12), 0 18px 60px rgba(0,0,0,0.45);
}

.center-message.error .center-message-text {
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.35);
    box-shadow: 0 18px 60px rgba(239, 68, 68, 0.10), 0 18px 60px rgba(0,0,0,0.45);
}

.center-message.info .center-message-text {
    color: #c9d7ff;
    border-color: rgba(79,124,247,0.35);
    box-shadow: 0 18px 60px rgba(79,124,247,0.10), 0 18px 60px rgba(0,0,0,0.45);
}
