*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Microsoft JhengHei", Roboto, sans-serif;
    background: #f3f4f6;
    color: #111827;
    -webkit-text-size-adjust: 100%;
}

a { color: inherit; text-decoration: none; }

.app-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    padding: 12px 16px 0;
}

.app-title {
    margin: 0 0 8px;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-title .total {
    font-size: 12px;
    color: #6b7280;
    font-weight: 400;
}

.tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 10px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
    flex: 0 0 auto;
    padding: 8px 14px;
    border-radius: 999px;
    background: #f3f4f6;
    color: #374151;
    font-size: 14px;
    border: 1px solid transparent;
    white-space: nowrap;
}
.tab.active {
    background: #111827;
    color: #fff;
}
.tab .count {
    margin-left: 6px;
    font-size: 12px;
    opacity: 0.85;
}

.container {
    padding: 14px;
    padding-bottom: 32px;
    max-width: 720px;
    margin: 0 auto;
}

.list {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.row-card {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.row-card:active { background: #f9fafb; }

.bc-thumb {
    width: 100%;
    height: auto;
    display: block;
}

.row-value {
    font-size: 15px;
    color: #111827;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.4px;
    text-align: center;
    word-break: break-all;
}

.row-status {
    display: flex;
    align-items: center;
    gap: 10px;
}

.row-note {
    font-size: 12px;
    color: #6b7280;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    color: #fff;
    line-height: 1.6;
}
.cat-badge {
    background: #fef3c7 !important;
    color: #92400e !important;
    border: 1px solid #fde68a;
}

.cats {
    margin-bottom: 4px;
}
.cats .tab {
    background: #fff7ed;
    color: #9a3412;
    border: 1px solid #fed7aa;
}
.cats .tab.active {
    background: #ea580c !important;
    color: #fff !important;
    border-color: transparent;
}

textarea.note-input,
input.cat-input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid #d1d5db;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.5;
    background: #fff;
    box-sizing: border-box;
}
input.cat-input:focus,
textarea.note-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* ====== detail page ====== */
.detail-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.back {
    padding: 6px 10px;
    border-radius: 8px;
    background: #f3f4f6;
    font-size: 14px;
}
.detail-title {
    font-size: 16px;
    font-weight: 600;
    flex: 1;
    font-variant-numeric: tabular-nums;
}

.image-wrap {
    background: #fff;
    margin: 14px;
    border-radius: 14px;
    padding: 18px 14px 14px;
    border: 1px solid #e5e7eb;
    overflow: hidden;
    text-align: center;
}
.image-wrap svg {
    width: 100%;
    height: auto;
    display: block;
    max-width: 100%;
}
.image-wrap img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
}
.image-wrap:fullscreen {
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    margin: 0;
    border-radius: 0;
}
.image-wrap:fullscreen svg {
    height: 60vh;
    width: auto;
    max-width: 95vw;
}
.bc-value {
    margin-top: 10px;
    font-size: 14px;
    color: #111827;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.5px;
    word-break: break-all;
    font-weight: 500;
}
.bc-hint {
    margin-top: 6px;
    font-size: 11px;
    color: #9ca3af;
}
.image-wrap:fullscreen .bc-hint { display: none; }

.section {
    background: #fff;
    margin: 14px;
    border-radius: 14px;
    padding: 14px;
    border: 1px solid #e5e7eb;
}
.section h3 {
    margin: 0 0 10px;
    font-size: 14px;
    color: #374151;
    font-weight: 600;
}
.section .updated {
    margin-top: 8px;
    font-size: 12px;
    color: #6b7280;
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}
@media (min-width: 480px) {
    .status-grid { grid-template-columns: repeat(5, 1fr); }
}
.status-btn {
    appearance: none;
    border: 1.5px solid #e5e7eb;
    background: #fff;
    border-radius: 12px;
    padding: 12px 8px;
    font-size: 15px;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    transition: transform 0.05s ease;
}
.status-btn:active { transform: scale(0.97); }
.status-btn.selected {
    color: #fff;
    border-color: transparent;
}

textarea.note-input {
    min-height: 90px;
    resize: vertical;
}

.actions {
    position: sticky;
    bottom: 0;
    background: linear-gradient(to top, #f3f4f6 60%, rgba(243,244,246,0));
    padding: 14px;
    padding-top: 28px;
}
.btn {
    display: block;
    width: 100%;
    padding: 14px;
    border-radius: 12px;
    border: none;
    background: #111827;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}
.btn:active { background: #000; }

.flash {
    margin: 12px 14px 0;
    padding: 10px 14px;
    background: #ecfdf5;
    color: #047857;
    border-radius: 10px;
    font-size: 14px;
    border: 1px solid #a7f3d0;
}

.empty {
    text-align: center;
    color: #6b7280;
    padding: 60px 20px;
    font-size: 14px;
}
