:root {
    --primary: #2d6a4f;
    --bg: #f4f9f4;
    --text: #1b4332;
    --danger: #d00000;
    --accent: #95d5b2;
    --scan: #0077b6;
    --write: #e07a5f;
}

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

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    padding-bottom: 80px;
}

.hidden { display: none !important; }

input, textarea, button {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border-radius: 8px;
    border: 1px solid #ccc;
    box-sizing: border-box;
    font-size: 16px;
}

button {
    background: var(--primary);
    color: white;
    border: none;
    font-weight: bold;
    cursor: pointer;
    transition: opacity 0.2s;
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

button.secondary {
    background: transparent;
    color: #666;
    border: 1px solid #ccc;
}

button.danger {
    background: var(--danger);
    color: white;
}

button.text-only {
    background: transparent;
    color: #666;
    border: none;
    width: auto;
    display: inline-block;
}

button.scan-btn {
    background: var(--scan);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 15px;
    width: auto;
    min-width: 60px;
    margin-bottom: 0;
}

button.write-btn {
    background: var(--write);
    color: white;
}

.scanning {
    animation: pulse 1.5s infinite;
    background: #0096c7 !important;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

button.clear-btn {
    background: #eee;
    color: #666;
    width: 45px;
    margin-bottom: 0;
    padding: 0;
    font-size: 1.2em;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #ddd;
}

.card {
    background: white;
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    margin-bottom: 15px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    transition: transform 0.1s;
}

.card:active { transform: scale(0.98); }

.card-meta {
    font-size: 0.85em;
    color: #666;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
}

.card-note {
    white-space: pre-wrap;
    line-height: 1.5;
    margin-bottom: 10px;
    max-height: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.badge-row {
    display: flex;
    gap: 10px;
    margin-bottom: 5px;
    flex-wrap: wrap;
}

.badge {
    font-size: 0.75em;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: opacity 0.2s;
}

.badge:hover { opacity: 0.8; }
.badge-loc { background: #e0f7fa; color: #006064; }
.badge-batch { background: #fff3e0; color: #e65100; }
.badge-nfc { background: #e1bee7; color: #4a148c; }

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 5px;
    margin-bottom: 10px;
    pointer-events: none;
}

.image-grid img {
    width: 100%;
    height: 80px;
    object-fit: cover;
    border-radius: 4px;
    background: #eee;
}

.detail-meta {
    color: #666;
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.detail-text {
    font-size: 1.1em;
    line-height: 1.6;
    margin-bottom: 30px;
    white-space: pre-wrap;
}

.detail-images img {
    width: 100%;
    margin-bottom: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    cursor: zoom-in;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}

.modal img {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
}

.write-modal {
    background: white;
    width: 90%;
    max-width: 400px;
    padding: 20px;
    border-radius: 12px;
    z-index: 2001;
    cursor: default;
}

.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 5px;
}

.tag {
    background: var(--accent);
    color: var(--text);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8em;
    cursor: pointer;
    transition: opacity 0.2s;
}

.tag:hover { opacity: 0.8; }

header {
    background: white;
    padding: 15px 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.logo-svg {
    width: 32px;
    height: 32px;
    fill: var(--primary);
}

h1 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--primary);
}

.header-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 5px;
}

.fab {
    position: fixed;
    bottom: 25px;
    right: 25px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-size: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    cursor: pointer;
    z-index: 99;
    transition: transform 0.2s;
}

.fab:active { transform: scale(0.95); }

.camera-box {
    display: block;
    margin-bottom: 15px;
    text-align: center;
    padding: 20px;
    border: 2px dashed #ccc;
    border-radius: 10px;
    background: white;
    cursor: pointer;
    color: #666;
}

.preview-list {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.preview-item {
    position: relative;
    flex: 0 0 100px;
    height: 100px;
}

.preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

.preview-item .remove-btn {
    position: absolute;
    top: -5px;
    right: -5px;
    background: red;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.tag-input-container {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 10px;
    background: white;
    border: 1px solid #ccc;
    border-radius: 8px;
    margin-bottom: 15px;
}

.tag-input-container input {
    border: none;
    margin: 0;
    padding: 5px;
    width: auto;
    flex-grow: 1;
    outline: none;
}

.input-group {
    display: flex;
    gap: 8px;
    align-items: stretch;
    margin-bottom: 15px;
    height: 46px;
}

.input-group input {
    margin-bottom: 0;
    flex: 1;
    min-width: 0;
}

.label-small {
    font-size: 0.85em;
    color: #666;
    margin-bottom: 4px;
    display: block;
}

.date-info-box {
    background: #e3f2fd;
    color: #0d47a1;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 0.9em;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.date-info-box button {
    background: #1976d2;
    margin: 0;
    padding: 5px 10px;
    width: auto;
    font-size: 0.9em;
}

.chart-container {
    margin-bottom: 20px;
    background: white;
    padding: 10px;
    border-radius: 12px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.chart-container img {
    width: 100%;
    height: auto;
    border-radius: 4px;
}

.chart-title {
    font-weight: bold;
    color: #666;
    margin-bottom: 5px;
}

.device-code-display {
    font-size: 2em;
    letter-spacing: 5px;
    font-weight: bold;
    text-align: center;
    margin: 20px 0;
    color: var(--primary);
}

.task-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 12px 15px;
    cursor: default;
}

.task-item:active { transform: none; }

.task-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    flex: 1;
    margin-top: 5px;
}

.task-checkbox {
    width: 22px;
    height: 22px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--primary);
    flex-shrink: 0;
    margin-top: 2px;
}

.task-text {
    font-size: 1.05em;
    transition: color 0.3s, text-decoration 0.3s;
    word-break: break-word;
}

.task-text.completed {
    text-decoration: line-through;
    color: #999;
}

.task-action-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: transparent;
    border: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    cursor: pointer;
    transition: background 0.2s;
}

.task-action-btn.delete-btn { font-size: 1.5em; color: #999; }
.task-action-btn.delete-btn:hover { background: #ffeeee; color: var(--danger); border-color: var(--danger); }
.task-action-btn.edit-btn { font-size: 1em; color: #666; }
.task-action-btn.edit-btn:hover { background: #e3f2fd; border-color: #0d47a1; }

.text-primary { color: var(--primary); }
.text-secondary { color: #666; }
.text-muted { color: #999; }
.align-center { align-items: center; }
.task-checkbox-lg { width: auto; margin: 0; transform: scale(1.5); }
.task-label-lg { margin: 0; font-weight: bold; color: var(--text); }
.task-actions { display: flex; flex-direction: column; gap: 5px; }
.pb-10 { padding-bottom: 10px; }
.mt-20 { margin-top: 20px; }
.col-span-2 { grid-column: span 2; }
.scrollable-modal { max-height: 90vh; overflow-y: auto; }
.fw-bold { font-weight: bold; }
.pointer { cursor: pointer; }

.spectrum-img {
    width: 100%;
    border-radius: 4px;
    background: #eee;
    min-height: 100px;
    max-height: 200px;
    object-fit: cover;
}

.spectrum-canvas {
    width: 100%;
    height: auto;
    min-height: 100px;
    border-radius: 4px;
    background: #fafafa;
    border: 1px solid #eee;
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
    border-radius: 8px;
    overflow: hidden;
}

.stats-table th, .stats-table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.stats-table th {
    background: var(--primary);
    color: white;
    font-weight: normal;
}

.stats-table tr:last-child td { border-bottom: none; }

.text-center { text-align: center; }
.margin-top-60 { margin-top: 60px; }
.margin-bottom-30 { margin-bottom: 30px; }
.margin-top-15 { margin-top: 15px; }
.margin-top-10 { margin-top: 10px; }
.margin-bottom-0 { margin-bottom: 0; }
.margin-bottom-10 { margin-bottom: 10px; }
.margin-bottom-15 { margin-bottom: 15px; }
.margin-bottom-20 { margin-bottom: 20px; }
.margin-top-0 { margin-top: 0; }
.margin-top-30 { margin-top: 30px; }
.login-logo { width: 80px; height: 80px; fill: #2d6a4f; margin-bottom: 15px; }
.login-title { color: var(--primary); margin: 0; }
.login-subtitle { color: #666; }
.error-msg { color: var(--danger); text-align: center; margin-top: 15px; }
.success-msg { color: var(--primary); text-align: center; margin-top: 15px; font-weight: bold; }
.width-auto { width: auto !important; }
.padding-0 { padding: 0 !important; }
.break-all { word-break: break-all; }
.fw-normal { font-weight: normal; }
.margin-top-5 { margin-top: 5px; }
.flex-gap-5 { display: flex; gap: 5px; }
.flex-gap-10 { display: flex; gap: 10px; }
.flex-justify-between { display: flex; justify-content: space-between; align-items: center; }
.w-100 { width: 100%; }
.bg-light { background: #f8f9fa; border-color: #ddd; }
.flex-1 { flex: 1; }
.padding-15 { padding: 15px; }
.padding-header-btn { padding: 6px 10px; margin: 0; font-size: 14px; }
.padding-btn-sm { padding: 5px 10px; font-size: 0.8em; margin: 0; }
.font-1-1 { font-size: 1.1em; }
.font-0-9 { font-size: 0.9em; }
.contents { display: contents; }

.detail-badge-container {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.detail-badge {
    width: fit-content;
    font-size: 0.9em;
    cursor: pointer;
}

.border-top {
    border-top: 1px solid #eee;
    margin-top: 40px;
    padding-top: 20px;
}

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

.modal-overlay { background: rgba(0,0,0,0.5); }
.btn-primary { background: var(--primary); color: white; }
.btn-secondary { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn-accent { background: var(--accent); color: var(--text); }
.btn-info { background: #0288d1; color: white; }
.btn-danger { background: var(--danger); color: white; }
.hidden-input { display: none; }
.approve-code-input { text-align: center; font-size: 1.1em; letter-spacing: 5px; }
.loading-text { text-align: center; color: #999; margin-top: 40px; }
.empty-text { text-align: center; color: #999; margin-top: 40px; }
.error-text { text-align: center; color: var(--danger); margin-top: 40px; }
.tag-close { cursor: pointer; margin-left: 4px; }

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

.spec-box {
    background: white;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #eee;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.spec-label {
    font-size: 0.75em;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.spec-value {
    font-size: 1.05em;
    font-weight: bold;
    color: var(--text);
}

.yield-history-list {
    margin-top: 10px;
    max-height: 200px;
    overflow-y: auto;
    border-top: 1px solid #eee;
    padding-top: 10px;
}

.yield-item {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px dashed #eee;
    font-size: 0.9em;
}