/* === RESET & BASE === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; font-size: 16px; }
body {
  font-family: -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: #f0f2f5;
  color: #1a1a2e;
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; font-size: 14px; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

/* === SPLASH === */
.splash {
  position: fixed; inset: 0; background: #0d47a1;
  display: flex; align-items: center; justify-content: center;
  z-index: 9999; transition: opacity 0.4s ease;
}
.splash.fade-out { opacity: 0; pointer-events: none; }
.splash-inner { text-align: center; }
.splash-logo { margin-bottom: 16px; animation: splashPop 0.5s ease; }
@keyframes splashPop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.splash-name { font-size: 28px; font-weight: 700; color: #fff; letter-spacing: 1px; margin-bottom: 6px; }
.splash-tagline { font-size: 14px; color: rgba(255,255,255,0.65); margin-bottom: 32px; }
.splash-loader { width: 120px; height: 3px; background: rgba(255,255,255,0.2); border-radius: 2px; overflow: hidden; margin: 0 auto; }
.loader-bar { height: 100%; background: #69f0ae; border-radius: 2px; animation: loadBar 1.2s ease forwards; }
@keyframes loadBar { from { width: 0; } to { width: 100%; } }

/* === APP LAYOUT === */
.app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* === HEADER === */
.header {
  background: #0d47a1;
  color: #fff;
  padding: 0 16px;
  height: 58px;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(13,71,161,0.3);
  z-index: 100;
  position: relative;
}
.header-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.icon-btn { color: rgba(255,255,255,0.9); padding: 8px; border-radius: 8px; display: flex; align-items: center; justify-content: center; transition: background 0.15s; flex-shrink: 0; }
.icon-btn:active { background: rgba(255,255,255,0.15); }
.header-title-block { min-width: 0; }
.header-title { font-size: 16px; font-weight: 600; color: #fff; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-sub { font-size: 11px; color: rgba(255,255,255,0.6); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.sync-indicator { display: flex; align-items: center; gap: 4px; font-size: 11px; color: rgba(255,255,255,0.7); }
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: #69f0ae; }
.sync-dot.syncing { animation: pulse 1s infinite; background: #ffa726; }
.sync-dot.error { background: #ef5350; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.3} }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255,255,255,0.2);
  color: #fff; font-size: 13px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid rgba(255,255,255,0.3);
}

/* === DRAWER === */
.drawer-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 200;
}
.drawer-overlay.open { display: block; }
.drawer {
  position: fixed; top: 0; left: -280px; width: 280px; height: 100%;
  background: #fff; z-index: 201; display: flex; flex-direction: column;
  transition: left 0.28s cubic-bezier(0.4,0,0.2,1);
  box-shadow: 4px 0 20px rgba(0,0,0,0.15);
}
.drawer.open { left: 0; }
.drawer-header { background: #0d47a1; padding: 20px 16px; }
.drawer-logo { display: flex; align-items: center; gap: 12px; }
.drawer-app-name { color: #fff; font-size: 18px; font-weight: 700; }
.drawer-site { color: rgba(255,255,255,0.6); font-size: 12px; margin-top: 2px; }
.drawer-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 14px;
  width: 100%; padding: 13px 20px;
  font-size: 14px; color: #374151; text-align: left;
  transition: background 0.15s, color 0.15s;
  border-left: 3px solid transparent;
}
.nav-item svg { flex-shrink: 0; opacity: 0.7; }
.nav-item:hover { background: #e8f0fe; color: #1a73e8; }
.nav-item.active { background: #e8f0fe; color: #1a73e8; border-left-color: #1a73e8; font-weight: 600; }
.nav-item.active svg { opacity: 1; }
.nav-divider { height: 1px; background: #f0f2f5; margin: 8px 0; }
.drawer-footer { padding: 16px 20px; border-top: 1px solid #f0f2f5; }
.drawer-credit { font-size: 11px; color: #6b7280; }
.drawer-version { font-size: 11px; color: #9ca3af; margin-top: 2px; }

/* === MAIN CONTENT === */
.main-content { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.page { display: none; padding: 16px 16px 100px; }
.page.active { display: block; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:none} }

/* === WEEK CARD === */
.week-card {
  background: linear-gradient(135deg, #1565c0 0%, #0d47a1 100%);
  border-radius: 14px; padding: 16px 18px; color: #fff;
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 16px;
}
.week-label { font-size: 11px; opacity: 0.7; text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 4px; }
.week-dates { font-size: 15px; font-weight: 600; }
.week-card-right { text-align: right; }
.week-today { font-size: 11px; opacity: 0.7; text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 4px; }
.week-today-date { font-size: 14px; font-weight: 500; }

/* === METRICS GRID === */
.metrics-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 20px; }
.metric-card { background: #fff; border-radius: 12px; padding: 14px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.metric-card-val { font-size: 26px; font-weight: 700; color: #1a1a2e; line-height: 1; margin-bottom: 5px; }
.metric-card-lbl { font-size: 11px; color: #6b7280; text-transform: uppercase; letter-spacing: 0.5px; }
.metric-card.warn .metric-card-val { color: #f59e0b; }
.metric-card.danger .metric-card-val { color: #ef4444; }
.metric-card.good .metric-card-val { color: #10b981; }

/* === SECTION HEADER === */
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.section-title { font-size: 13px; font-weight: 600; color: #6b7280; text-transform: uppercase; letter-spacing: 0.7px; }
.text-btn { font-size: 13px; color: #1a73e8; font-weight: 500; padding: 4px 8px; border-radius: 6px; }
.text-btn:active { background: #e8f0fe; }

/* === STOCK CARDS === */
.stock-cards { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.stock-item-card {
  background: #fff; border-radius: 12px; padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.stock-item-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; flex-shrink: 0;
  background: #e8f0fe; color: #1a73e8;
}
.stock-item-icon.low { background: #fff8e1; color: #f59e0b; }
.stock-item-icon.critical { background: #fee2e2; color: #ef4444; }
.stock-item-info { flex: 1; min-width: 0; }
.stock-item-name { font-size: 14px; font-weight: 500; color: #1a1a2e; margin-bottom: 4px; }
.stock-item-details { font-size: 12px; color: #6b7280; }
.stock-item-right { text-align: right; flex-shrink: 0; }
.stock-item-qty { font-size: 20px; font-weight: 700; color: #1a1a2e; }
.stock-item-qty.low { color: #f59e0b; }
.stock-item-qty.critical { color: #ef4444; }
.stock-badge { font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 10px; margin-top: 3px; display: inline-block; }
.badge-ok { background: #d1fae5; color: #065f46; }
.badge-low { background: #fef3c7; color: #92400e; }
.badge-critical { background: #fee2e2; color: #991b1b; }
.stock-bar { width: 100%; height: 3px; background: #e5e7eb; border-radius: 2px; margin-top: 5px; }
.stock-bar-fill { height: 100%; border-radius: 2px; background: #1a73e8; transition: width 0.4s; }
.stock-bar-fill.low { background: #f59e0b; }
.stock-bar-fill.critical { background: #ef4444; }

/* === ACTIVITY === */
.activity-list { display: flex; flex-direction: column; gap: 0; }
.activity-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid #f0f2f5; }
.activity-item:last-child { border-bottom: none; }
.activity-icon-wrap { width: 34px; height: 34px; border-radius: 50%; background: #e8f0fe; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.activity-icon-wrap svg { width: 15px; height: 15px; color: #1a73e8; }
.activity-text { font-size: 13px; color: #374151; line-height: 1.5; }
.activity-meta { font-size: 11px; color: #9ca3af; margin-top: 2px; }
.no-data { text-align: center; padding: 40px 20px; color: #9ca3af; font-size: 14px; }

/* === ALERT BANNER === */
.alert-banner {
  background: #fff8e1; border-left: 4px solid #f59e0b;
  border-radius: 0 10px 10px 0; padding: 12px 14px;
  margin-bottom: 14px; font-size: 13px; color: #78350f; line-height: 1.5;
}
.alert-banner.critical { background: #fee2e2; border-left-color: #ef4444; color: #7f1d1d; }

/* === LOG PAGE === */
.log-header-card {
  background: linear-gradient(135deg, #1565c0, #0d47a1);
  border-radius: 14px; padding: 16px 18px; color: #fff; margin-bottom: 16px;
}
.log-date-label { font-size: 11px; opacity: 0.7; text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 4px; }
.log-date-value { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.log-hint { font-size: 12px; opacity: 0.65; }
.log-item-card {
  background: #fff; border-radius: 12px; margin-bottom: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06); overflow: hidden;
}
.log-item-top { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 10px; }
.log-item-name { font-size: 14px; font-weight: 500; color: #1a1a2e; }
.log-item-balance { font-size: 12px; color: #6b7280; margin-top: 2px; }
.log-item-balance .bal-num { font-weight: 600; color: #1a1a2e; }
.log-item-balance .bal-num.low { color: #f59e0b; }
.log-item-balance .bal-num.critical { color: #ef4444; }
.log-qty-row { display: flex; align-items: center; gap: 0; padding: 0 16px 14px; }
.qty-btn {
  width: 38px; height: 38px; border-radius: 10px;
  background: #e8f0fe; color: #1a73e8; font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 300; transition: background 0.1s; flex-shrink: 0;
}
.qty-btn:active { background: #c5d8fb; }
.qty-field {
  flex: 1; text-align: center; font-size: 20px; font-weight: 700; color: #1a1a2e;
  border: none; outline: none; background: none; padding: 0 8px;
  -moz-appearance: textfield;
}
.qty-field::-webkit-outer-spin-button, .qty-field::-webkit-inner-spin-button { -webkit-appearance: none; }
.log-notes-card { background: #fff; border-radius: 12px; padding: 14px 16px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); margin-top: 8px; }
.log-notes-card textarea { width: 100%; border: 1px solid #e5e7eb; border-radius: 8px; padding: 10px; resize: none; color: #374151; outline: none; }
.log-notes-card textarea:focus { border-color: #1a73e8; }

/* === STOCK COUNT PAGE === */
.stock-count-card {
  background: #fff; border-radius: 12px; margin-bottom: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06); padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
}
.stock-count-info { flex: 1; }
.stock-count-name { font-size: 14px; font-weight: 500; color: #1a1a2e; margin-bottom: 3px; }
.stock-count-prev { font-size: 12px; color: #6b7280; }
.stock-count-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.stock-count-input { width: 80px; text-align: center; border: 1.5px solid #e5e7eb; border-radius: 8px; padding: 7px 8px; font-size: 15px; font-weight: 600; color: #1a1a2e; outline: none; }
.stock-count-input:focus { border-color: #1a73e8; }
.variance-tag { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 8px; }
.var-pos { background: #d1fae5; color: #065f46; }
.var-neg { background: #fee2e2; color: #991b1b; }
.var-zero { background: #f3f4f6; color: #6b7280; }

/* === REPORTS === */
.report-type-row { display: flex; gap: 8px; margin-bottom: 14px; }
.rtype-btn { flex: 1; padding: 10px 6px; border-radius: 10px; font-size: 13px; font-weight: 500; color: #6b7280; background: #fff; border: 1.5px solid #e5e7eb; transition: all 0.15s; }
.rtype-btn.active { background: #0d47a1; color: #fff; border-color: #0d47a1; }
.custom-range-card { background: #fff; border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.btn-full-primary { width: 100%; padding: 14px; background: #0d47a1; color: #fff; border-radius: 12px; font-size: 15px; font-weight: 600; margin-bottom: 16px; transition: background 0.15s; }
.btn-full-primary:active { background: #0a3380; }
.report-card { background: #fff; border-radius: 12px; padding: 16px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); margin-bottom: 12px; }
.report-title { font-size: 15px; font-weight: 700; color: #1a1a2e; margin-bottom: 4px; }
.report-meta { font-size: 12px; color: #6b7280; margin-bottom: 14px; }
.report-section-title { font-size: 11px; font-weight: 600; color: #9ca3af; text-transform: uppercase; letter-spacing: 0.7px; margin: 14px 0 8px; }
.report-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.report-table th { color: #6b7280; font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; padding: 6px 0; border-bottom: 1px solid #f0f2f5; text-align: left; }
.report-table td { padding: 8px 0; border-bottom: 1px solid #f9fafb; color: #374151; }
.report-table tr:last-child td { border-bottom: none; }
.report-summary-row { display: flex; gap: 10px; margin-bottom: 14px; }
.rpt-metric { flex: 1; background: #f8faff; border-radius: 10px; padding: 10px; text-align: center; }
.rpt-metric-val { font-size: 22px; font-weight: 700; color: #0d47a1; }
.rpt-metric-lbl { font-size: 10px; color: #6b7280; text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }
.print-btn { width: 100%; padding: 12px; background: #fff; color: #0d47a1; border: 1.5px solid #0d47a1; border-radius: 10px; font-size: 14px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 12px; }

/* === SETTINGS === */
.settings-card { background: #fff; border-radius: 14px; padding: 16px; margin-bottom: 12px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.settings-card-title { font-size: 13px; font-weight: 700; color: #6b7280; text-transform: uppercase; letter-spacing: 0.7px; margin-bottom: 14px; }
.settings-hint { font-size: 13px; color: #6b7280; margin-bottom: 12px; line-height: 1.5; }
.danger-card { border: 1px solid #fee2e2; }
.settings-item-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid #f0f2f5; }
.settings-item-row:last-child { border-bottom: none; }
.settings-item-name { font-size: 14px; color: #1a1a2e; font-weight: 500; }
.settings-item-detail { font-size: 12px; color: #6b7280; margin-top: 2px; }
.add-item-form { margin-top: 14px; padding-top: 14px; border-top: 1px solid #f0f2f5; }
.holiday-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #f0f2f5; }
.holiday-row:last-child { border-bottom: none; }
.about-card { text-align: center; padding: 24px 16px; background: #fff; border-radius: 14px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); margin-bottom: 12px; }
.about-logo { margin-bottom: 10px; }
.about-name { font-size: 20px; font-weight: 800; color: #0d47a1; margin-bottom: 4px; }
.about-version { font-size: 13px; color: #9ca3af; margin-bottom: 12px; }
.about-credit { font-size: 14px; font-weight: 600; color: #374151; margin-bottom: 4px; }
.about-copy { font-size: 12px; color: #9ca3af; }

/* === FORMS === */
.form-group { margin-bottom: 12px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-label { display: block; font-size: 12px; font-weight: 600; color: #6b7280; margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.4px; }
.field-input {
  width: 100%; border: 1.5px solid #e5e7eb; border-radius: 10px;
  padding: 10px 12px; font-size: 14px; color: #1a1a2e; background: #fff;
  outline: none; transition: border-color 0.15s;
}
.field-input:focus { border-color: #1a73e8; }

/* === BUTTONS === */
.btn-primary {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 20px; background: #0d47a1; color: #fff;
  border-radius: 10px; font-size: 14px; font-weight: 600;
  transition: background 0.15s;
}
.btn-primary:active { background: #0a3380; }
.btn-success { display: inline-flex; align-items: center; gap: 8px; padding: 11px 20px; background: #059669; color: #fff; border-radius: 10px; font-size: 14px; font-weight: 600; }
.btn-success:active { background: #047857; }
.btn-ghost { padding: 11px 20px; color: #6b7280; border-radius: 10px; font-size: 14px; font-weight: 500; background: #f0f2f5; }
.btn-ghost:active { background: #e5e7eb; }
.btn-danger { padding: 9px 16px; background: #ef4444; color: #fff; border-radius: 8px; font-size: 13px; font-weight: 600; }
.btn-danger:active { background: #dc2626; }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-icon-sm { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 8px; background: #fee2e2; color: #ef4444; }

/* === BOTTOM BAR === */
.bottom-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: #fff; border-top: 1px solid #e5e7eb;
  padding: 12px 16px 24px; display: flex; gap: 10px;
  z-index: 50; box-shadow: 0 -4px 16px rgba(0,0,0,0.06);
}
.bottom-bar .btn-primary { flex: 1; justify-content: center; padding: 13px; font-size: 15px; }
.bottom-bar .btn-success { flex: 1; justify-content: center; padding: 13px; font-size: 15px; }
.fab-spacer { height: 80px; }

/* === TOAST === */
.toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%) translateY(10px);
  background: #1a1a2e; color: #fff; padding: 10px 20px;
  border-radius: 24px; font-size: 13px; font-weight: 500;
  opacity: 0; transition: all 0.25s; pointer-events: none;
  white-space: nowrap; z-index: 9999; max-width: 90vw; white-space: normal; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* === MODAL === */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 500; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.open { display: flex; }
.modal { background: #fff; border-radius: 16px; padding: 20px; width: 100%; max-width: 340px; }
.modal-title { font-size: 16px; font-weight: 700; color: #1a1a2e; margin-bottom: 10px; }
.modal-body { font-size: 14px; color: #374151; line-height: 1.6; margin-bottom: 18px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* === PRINT === */
@media print {
  .header, .drawer, .drawer-overlay, .bottom-bar, .nav-item, .fab-spacer { display: none !important; }
  .page { display: block !important; padding: 0 !important; }
  body { overflow: visible !important; background: #fff; }
  .main-content { overflow: visible !important; }
  .app { height: auto !important; overflow: visible !important; }
  .report-card { box-shadow: none !important; border: 1px solid #e5e7eb; page-break-inside: avoid; }
  .print-btn { display: none !important; }
}

/* === STOCK DAY BANNER === */
.stock-day-banner {
  background: linear-gradient(135deg, #059669, #047857);
  border-radius: 12px; padding: 14px 16px; margin-bottom: 14px;
  display: flex; align-items: center; gap: 12px; color: #fff;
}
.stock-day-icon { font-size: 22px; }
.stock-day-text { font-size: 13px; font-weight: 600; }
.stock-day-sub { font-size: 11px; opacity: 0.75; margin-top: 2px; }
