:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-card: #0f3460;
  --text-primary: #eaeaea;
  --text-secondary: #a0a0a0;
  --accent: #e94560;
  --accent-hover: #ff6b6b;
  --success: #4ecca3;
  --warning: #ffc107;
  --danger: #e94560;
  --border-radius: 12px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}

.app-container {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 100px;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 16px;
}

.app-header h1 { font-size: 1.5rem; font-weight: 600; }
.version { font-size: 0.75rem; color: var(--text-secondary); background: var(--bg-secondary); padding: 4px 8px; border-radius: 4px; }

.tab-nav { display: flex; gap: 8px; margin-bottom: 20px; background: var(--bg-secondary); padding: 6px; border-radius: var(--border-radius); }
.tab-btn { flex: 1; padding: 12px 16px; border: none; background: transparent; color: var(--text-secondary); font-size: 0.95rem; font-weight: 500; border-radius: 8px; cursor: pointer; transition: all 0.2s ease; }
.tab-btn.active { background: var(--accent); color: white; }
.tab-btn:hover:not(.active) { background: rgba(255, 255, 255, 0.1); }

.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.card { background: var(--bg-card); border-radius: var(--border-radius); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card h2 { font-size: 1.1rem; margin-bottom: 16px; padding-bottom: 8px; border-bottom: 1px solid rgba(255, 255, 255, 0.1); }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 6px; }

input[type="text"], input[type="tel"], input[type="number"], select {
  width: 100%; padding: 12px 14px; border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 8px;
  background: var(--bg-secondary); color: var(--text-primary); font-size: 1rem; transition: border-color 0.2s ease;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
input::placeholder { color: var(--text-secondary); opacity: 0.6; }

.item-input-row { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr auto; gap: 8px; margin-bottom: 16px; }
.item-input-row input, .item-input-row select { padding: 10px; font-size: 0.9rem; }

.item-list { list-style: none; max-height: 300px; overflow-y: auto; }
.item-list li { display: flex; justify-content: space-between; align-items: center; padding: 12px; background: var(--bg-secondary); border-radius: 8px; margin-bottom: 8px; }
.item-list li .item-info { flex: 1; }
.item-list li .item-name { font-weight: 500; }
.item-list li .item-detail { font-size: 0.8rem; color: var(--text-secondary); }
.item-list li .item-price { font-weight: 600; margin-right: 12px; }
.item-list li .item-delete { background: var(--danger); color: white; border: none; width: 28px; height: 28px; border-radius: 50%; cursor: pointer; font-size: 1rem; }

.totals { margin-top: 16px; padding-top: 16px; border-top: 1px solid rgba(255, 255, 255, 0.1); }
.total-row { display: flex; justify-content: space-between; padding: 8px 0; font-size: 0.95rem; }
.total-grand { font-size: 1.2rem; font-weight: 700; color: var(--success); border-top: 2px solid var(--success); margin-top: 8px; padding-top: 12px; }

.change-display { margin-top: 12px; padding: 12px; background: var(--bg-secondary); border-radius: 8px; font-size: 1.1rem; text-align: center; }
.change-display span { font-weight: 700; color: var(--success); }

button { cursor: pointer; transition: all 0.2s ease; }
.btn-primary { background: var(--accent); color: white; border: none; padding: 12px 24px; border-radius: 8px; font-size: 1rem; font-weight: 500; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-2px); }
.btn-secondary { background: var(--bg-secondary); color: var(--text-primary); border: 1px solid rgba(255, 255, 255, 0.2); padding: 12px 24px; border-radius: 8px; font-size: 1rem; }
.btn-secondary:hover { background: rgba(255, 255, 255, 0.1); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); padding: 12px 24px; border-radius: 8px; font-size: 1rem; }
.btn-danger:hover { background: var(--danger); color: white; }

.action-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 20px; }
.logo-preview { margin-top: 12px; text-align: center; }
.logo-preview img { max-width: 150px; max-height: 80px; border-radius: 8px; }
.search-box { margin-bottom: 16px; }

.receipt-list { list-style: none; }
.receipt-list li { display: flex; justify-content: space-between; align-items: center; padding: 16px; background: var(--bg-secondary); border-radius: 8px; margin-bottom: 8px; cursor: pointer; transition: transform 0.2s ease; }
.receipt-list li:hover { transform: translateX(4px); }
.receipt-list .receipt-info { flex: 1; }
.receipt-list .receipt-date { font-size: 0.8rem; color: var(--text-secondary); }
.receipt-list .receipt-total { font-weight: 600; color: var(--success); }

.info-list { display: grid; grid-template-columns: auto 1fr; gap: 12px; }
.info-list dt { color: var(--text-secondary); }
.info-list dd { text-align: right; }

.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.8); z-index: 1000; justify-content: center; align-items: center; }
.modal.active { display: flex; }
.modal-content { background: var(--bg-card); border-radius: var(--border-radius); max-width: 420px; width: 90%; max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid rgba(255, 255, 255, 0.1); }
.modal-header h2 { font-size: 1.1rem; margin: 0; padding: 0; border: none; }
.modal-close { background: none; border: none; color: var(--text-secondary); font-size: 1.5rem; cursor: pointer; }
.modal-body { padding: 20px; text-align: center; }
.modal-body canvas { background: white; border-radius: 4px; max-width: 100%; }
.modal-footer { display: flex; gap: 12px; padding: 16px 20px; border-top: 1px solid rgba(255, 255, 255, 0.1); }
.modal-footer button { flex: 1; }

@media (max-width: 480px) {
  .item-input-row { grid-template-columns: 1fr 1fr; }
  .item-input-row input:first-child { grid-column: 1 / -1; }
  .action-buttons { grid-template-columns: 1fr; }
}

input[type="file"] { padding: 10px; background: var(--bg-secondary); border: 1px dashed rgba(255, 255, 255, 0.3); border-radius: 8px; color: var(--text-secondary); }
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 3px; }
