/* HNK Service Center - Global Styles */
:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #1e293b;
  --bg-input: #0f172a;
  --border: #334155;
  --accent: #6366f1;
  --accent-light: #818cf8;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --accent-orange: #f59e0b;
  --accent-blue: #3b82f6;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --radius: 12px;
  --radius-sm: 8px;
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Splash Screen */
#splash {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 9999; transition: opacity 0.5s ease;
}
#splash.hide { opacity: 0; pointer-events: none; }
.splash-logo {
  width: 96px; height: 96px; border-radius: 24px;
  background: linear-gradient(135deg, var(--accent), var(--accent-blue));
  display: flex; align-items: center; justify-content: center;
  font-size: 48px; margin-bottom: 24px;
  box-shadow: 0 0 60px rgba(99,102,241,0.5);
  animation: pulse 2s infinite;
}
.splash-title { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; }
.splash-sub { color: var(--text-secondary); margin-top: 8px; font-size: 14px; }
.splash-bar { width: 200px; height: 3px; background: var(--border); border-radius: 2px; margin-top: 48px; overflow: hidden; }
.splash-progress { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-blue)); border-radius: 2px; animation: progress 1.5s ease-out forwards; }
@keyframes progress { from { width: 0 } to { width: 100% } }
@keyframes pulse { 0%,100%{transform:scale(1)}50%{transform:scale(1.05)} }

/* PIN Login */
#login-screen {
  position: fixed; inset: 0;
  background: var(--bg-primary);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 9998; padding: 24px;
}
.pin-display {
  display: flex; gap: 12px; margin: 32px 0 24px;
}
.pin-dot {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--border); transition: all 0.2s;
}
.pin-dot.filled { background: var(--accent); border-color: var(--accent); }
.pin-pad {
  display: grid; grid-template-columns: repeat(3, 80px);
  gap: 12px; margin-top: 8px;
}
.pin-btn {
  width: 80px; height: 80px; border-radius: 50%;
  background: var(--bg-secondary); border: 1px solid var(--border);
  color: var(--text-primary); font-size: 22px; font-weight: 600;
  cursor: pointer; transition: all 0.15s; display: flex;
  align-items: center; justify-content: center;
}
.pin-btn:active { background: var(--accent); transform: scale(0.95); }
.pin-btn.del { font-size: 18px; color: var(--accent-red); }

/* App Layout */
#app { display: none; flex-direction: column; min-height: 100vh; }
#app.show { display: flex; }

/* Header */
.header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
  backdrop-filter: blur(10px);
}
.header-title { font-size: 18px; font-weight: 700; }
.header-sub { font-size: 11px; color: var(--text-secondary); margin-top: 1px; }
.header-actions { display: flex; gap: 8px; }

/* Bottom Navigation */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  display: flex; z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 8px 4px; cursor: pointer;
  color: var(--text-muted); transition: color 0.2s;
  font-size: 9px; font-weight: 500; gap: 3px;
  border: none; background: none;
  -webkit-tap-highlight-color: transparent;
}
.nav-item.active { color: var(--accent); }
.nav-item svg { width: 22px; height: 22px; }

/* Content */
.content {
  flex: 1;
  padding: 16px;
  padding-bottom: calc(80px + env(safe-area-inset-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.card-title { font-size: 15px; font-weight: 700; }
.card-sub { font-size: 12px; color: var(--text-secondary); }

/* Dashboard Stats */
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
  display: flex; flex-direction: column; gap: 4px;
}
.stat-value { font-size: 26px; font-weight: 800; }
.stat-label { font-size: 11px; color: var(--text-secondary); font-weight: 500; }
.stat-change { font-size: 11px; color: var(--accent-green); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 10px 16px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; cursor: pointer;
  border: none; transition: all 0.15s; text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:active { background: var(--accent-light); transform: scale(0.98); }
.btn-secondary { background: var(--bg-secondary); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:active { background: var(--border); }
.btn-success { background: var(--accent-green); color: white; }
.btn-danger { background: var(--accent-red); color: white; }
.btn-warning { background: var(--accent-orange); color: white; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); background: var(--bg-secondary); border: 1px solid var(--border); cursor: pointer; color: var(--text-primary); }
.btn-block { width: 100%; }
.btn-fab {
  position: fixed; bottom: calc(80px + 16px + env(safe-area-inset-bottom));
  right: 16px; width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: white; font-size: 24px;
  box-shadow: var(--shadow); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  z-index: 50; transition: transform 0.2s;
}
.btn-fab:active { transform: scale(0.92); }

/* Forms */
.form-group { margin-bottom: 14px; }
.form-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; display: block; text-transform: uppercase; letter-spacing: 0.5px; }
.form-control {
  width: 100%; padding: 12px 14px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-size: 15px; transition: border-color 0.2s;
  -webkit-appearance: none;
}
.form-control:focus { outline: none; border-color: var(--accent); }
.form-control.error { border-color: var(--accent-red); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* Autocomplete */
.autocomplete-wrapper { position: relative; }
.autocomplete-list {
  position: absolute; top: 100%; left: 0; right: 0;
  background: var(--bg-secondary); border: 1px solid var(--accent);
  border-radius: var(--radius-sm); margin-top: 2px;
  max-height: 200px; overflow-y: auto; z-index: 200;
  box-shadow: var(--shadow);
}
.autocomplete-item {
  padding: 10px 14px; cursor: pointer; font-size: 14px;
  border-bottom: 1px solid var(--border);
}
.autocomplete-item:hover, .autocomplete-item:active { background: var(--bg-primary); }
.autocomplete-item small { color: var(--text-secondary); font-size: 11px; display: block; }

/* Tables */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { background: var(--bg-primary); color: var(--text-secondary); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; padding: 10px 12px; text-align: left; white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tr:active td { background: var(--bg-primary); }

/* Badges */
.badge {
  display: inline-block; padding: 3px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 700;
}
.badge-success { background: rgba(16,185,129,0.15); color: var(--accent-green); }
.badge-danger { background: rgba(239,68,68,0.15); color: var(--accent-red); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--accent-orange); }
.badge-info { background: rgba(59,130,246,0.15); color: var(--accent-blue); }
.badge-purple { background: rgba(99,102,241,0.15); color: var(--accent); }

/* Modals */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 500; opacity: 0; visibility: hidden; transition: all 0.3s;
}
.modal-overlay.show { opacity: 1; visibility: visible; }
.modal {
  background: var(--bg-secondary); border-radius: var(--radius) var(--radius) 0 0;
  width: 100%; max-height: 92vh; overflow-y: auto;
  transform: translateY(100%); transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  padding: 0 0 env(safe-area-inset-bottom);
}
.modal-overlay.show .modal { transform: translateY(0); }
.modal-handle { width: 36px; height: 4px; background: var(--border); border-radius: 2px; margin: 12px auto 0; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg-secondary); z-index: 1;
}
.modal-title { font-size: 17px; font-weight: 700; }
.modal-body { padding: 16px; }
.modal-footer { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 10px; }

/* Toast */
#toast-container {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  z-index: 9999; display: flex; flex-direction: column; gap: 8px;
  width: calc(100vw - 32px); max-width: 400px;
}
.toast {
  background: var(--bg-secondary); border-radius: var(--radius-sm);
  padding: 12px 16px; font-size: 14px; font-weight: 500;
  display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow); border: 1px solid var(--border);
  animation: slideDown 0.3s ease;
}
.toast.success { border-color: var(--accent-green); }
.toast.error { border-color: var(--accent-red); }
.toast.warning { border-color: var(--accent-orange); }
@keyframes slideDown { from { opacity:0; transform:translateY(-20px) } to { opacity:1; transform:translateY(0) } }

/* Search */
.search-bar {
  position: relative; margin-bottom: 12px;
}
.search-bar input {
  width: 100%; padding: 10px 16px 10px 40px;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary); font-size: 15px;
}
.search-bar input:focus { outline: none; border-color: var(--accent); }
.search-bar svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); width: 18px; height: 18px; }

/* List items */
.list-item {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; margin-bottom: 8px;
  cursor: pointer; transition: border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.list-item:active { border-color: var(--accent); }
.list-item-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 6px; }
.list-item-title { font-weight: 700; font-size: 15px; }
.list-item-meta { font-size: 12px; color: var(--text-secondary); }

/* Part rows in forms */
.part-row {
  background: var(--bg-primary); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px; margin-bottom: 8px;
}
.part-row-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }

/* Tabs */
.tabs { display: flex; gap: 4px; background: var(--bg-primary); border-radius: var(--radius-sm); padding: 4px; margin-bottom: 16px; }
.tab-btn { flex: 1; padding: 8px; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; border: none; background: none; color: var(--text-muted); transition: all 0.2s; }
.tab-btn.active { background: var(--accent); color: white; }

/* Section titles */
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-secondary); margin-bottom: 10px; margin-top: 4px; }

/* Chips */
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--bg-primary); border: 1px solid var(--border); border-radius: 20px; padding: 4px 10px; font-size: 12px; font-weight: 500; }

/* Divider */
.divider { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

/* No data */
.no-data { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.no-data svg { width: 48px; height: 48px; margin: 0 auto 12px; opacity: 0.3; }
.no-data p { font-size: 15px; font-weight: 600; }
.no-data span { font-size: 13px; }

/* Alert */
.alert { padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 12px; }
.alert-warning { background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.3); color: var(--accent-orange); }
.alert-danger { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: var(--accent-red); }
.alert-success { background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.3); color: var(--accent-green); }
.alert-info { background: rgba(99,102,241,0.1); border: 1px solid rgba(99,102,241,0.3); color: var(--accent); }

/* Loader */
.loader { display: flex; justify-content: center; padding: 24px; }
.spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg) } }

/* Grid layouts */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

/* Amount displays */
.amount { font-weight: 700; }
.amount-lg { font-size: 24px; font-weight: 800; }
.text-green { color: var(--accent-green); }
.text-red { color: var(--accent-red); }
.text-orange { color: var(--accent-orange); }
.text-blue { color: var(--accent-blue); }
.text-purple { color: var(--accent); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }

/* Print styles */
@media print {
  .bottom-nav, .header, .btn-fab, #toast-container, .no-print { display: none !important; }
  body { background: white; color: black; }
  .content { padding: 0; }
  .card, .list-item { break-inside: avoid; border: 1px solid #ccc; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Transitions */
.page { display: none; animation: fadeIn 0.2s ease; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: translateY(0) } }

/* Install banner */
#install-banner {
  background: linear-gradient(135deg, var(--accent), var(--accent-blue));
  padding: 12px 16px; display: none; align-items: center; gap: 12px;
}
#install-banner.show { display: flex; }
#install-banner p { flex: 1; font-size: 13px; font-weight: 600; }

/* Low stock indicator */
.stock-critical { color: var(--accent-red); }
.stock-low { color: var(--accent-orange); }
.stock-ok { color: var(--accent-green); }

/* Qty badge */
.qty-badge {
  display: inline-block; min-width: 32px; text-align: center;
  padding: 2px 8px; border-radius: 4px; font-weight: 700; font-size: 14px;
}

/* Report table */
.report-table th { position: sticky; top: 0; z-index: 1; }

/* Swipe actions */
.swipe-container { overflow: hidden; position: relative; border-radius: var(--radius); margin-bottom: 8px; }

/* Info rows */
.info-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.info-row:last-child { border-bottom: none; }
.info-row-label { color: var(--text-secondary); }
.info-row-value { font-weight: 600; text-align: right; max-width: 60%; }

/* Misc */
.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mt-2 { margin-top: 8px; }
.w-full { width: 100%; }
.text-right { text-align: right; }
.font-bold { font-weight: 700; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
