:root {
  --primary: #0d9488;
  --primary-dark: #0f766e;
  --primary-light: #ccfbf1;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --dark: #1e293b;
  --gray: #64748b;
  --light: #f1f5f9;
  --white: #ffffff;
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--light);
  color: var(--dark);
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

/* Layout */
#app {
  display: flex;
  min-height: 100vh;
}

/* Navbar */
.navbar {
  width: 260px;
  background: var(--white);
  border-right: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 100;
}

.nav-brand {
  padding: 20px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo {
  font-size: 24px;
}

.brand-text {
  font-weight: 700;
  font-size: 18px;
  color: var(--primary-dark);
}

.nav-menu {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow-y: auto;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray);
  transition: all 0.2s;
  text-align: left;
  width: 100%;
}

.nav-btn:hover {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.nav-btn.active {
  background: var(--primary);
  color: var(--white);
}

.nav-btn .icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: 260px;
  padding: 24px;
  max-width: 900px;
}

.page {
  display: none;
  animation: fadeIn 0.3s ease;
}

.page.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-header {
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--dark);
}

.page-header p {
  color: var(--gray);
  font-size: 14px;
  margin-top: 4px;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
}

.stat-card.success { border-left-color: var(--success); }
.stat-card.warning { border-left-color: var(--warning); }
.stat-card.info { border-left-color: var(--info); }

.stat-icon {
  font-size: 28px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  border-radius: var(--radius-sm);
}

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 12px;
  color: var(--gray);
  font-weight: 500;
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--dark);
}

/* Quick Actions */
.quick-actions {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.quick-actions h3 {
  font-size: 16px;
  margin-bottom: 16px;
  color: var(--dark);
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 8px;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  background: var(--white);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 12px;
  font-weight: 500;
  color: var(--dark);
}

.action-btn:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: translateY(-2px);
}

.action-icon {
  font-size: 28px;
}

/* Forms */
.form-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.form-group {
  margin-bottom: 16px;
  flex: 1;
}

.form-row {
  display: flex;
  gap: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  background: var(--white);
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.product-detail {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  padding: 10px 14px;
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.product-detail.hidden { display: none; }

.price-tag strong { color: var(--primary-dark); }
.profit-tag strong { color: var(--success); }

.form-actions {
  margin-top: 24px;
}

/* Buttons */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

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

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--light);
  color: var(--dark);
}

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

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

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

.btn-large {
  width: 100%;
  justify-content: center;
  padding: 14px;
  font-size: 15px;
}

/* Transaction List */
.filter-bar {
  display: flex;
  gap: 12px;
  margin-top: 12px;
}

.filter-bar input,
.filter-bar select {
  padding: 8px 12px;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  font-size: 14px;
}

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

.transaction-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--gray);
  cursor: pointer;
  transition: transform 0.2s;
}

.transaction-card:hover {
  transform: translateX(4px);
}

.transaction-card.pending { border-left-color: var(--warning); }
.transaction-card.success { border-left-color: var(--success); }
.transaction-card.failed { border-left-color: var(--danger); }

.trx-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 8px;
}

.trx-title {
  font-weight: 600;
  font-size: 15px;
}

.trx-target {
  font-size: 13px;
  color: var(--gray);
  margin-top: 2px;
}

.trx-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #f1f5f9;
}

.trx-price {
  font-weight: 700;
  font-size: 16px;
  color: var(--primary-dark);
}

.trx-profit {
  font-size: 12px;
  color: var(--success);
  font-weight: 500;
}

.trx-status {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.status-pending { background: #fef3c7; color: #92400e; }
.status-success { background: #d1fae5; color: #065f46; }
.status-failed { background: #fee2e2; color: #991b1b; }

.trx-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.trx-actions button {
  padding: 6px 12px;
  font-size: 12px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
}

/* Product List */
.product-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.product-item {
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
}

.product-info h4 {
  font-size: 14px;
  font-weight: 600;
}

.product-info span {
  font-size: 12px;
  color: var(--gray);
}

.product-prices {
  text-align: right;
}

.product-prices .sell {
  font-weight: 700;
  color: var(--primary-dark);
}

.product-prices .base {
  font-size: 12px;
  color: var(--gray);
  text-decoration: line-through;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--white);
  border-radius: var(--radius);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalSlide 0.3s ease;
}

.modal-content.struk-modal {
  max-width: 400px;
}

@keyframes modalSlide {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.btn-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--gray);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.btn-close:hover {
  background: var(--light);
}

.modal form {
  padding: 20px;
}

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* Struk Thermal */
.struk-content {
  padding: 20px;
  background: #fff;
}

.struk-thermal {
  font-family: 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.4;
  color: #000;
  max-width: 320px;
  margin: 0 auto;
}

.struk-header {
  text-align: center;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px dashed #000;
}

.struk-header h2 {
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 4px;
}

.struk-header p {
  font-size: 11px;
  margin: 2px 0;
}

.struk-body {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px dashed #000;
}

.struk-row {
  display: flex;
  justify-content: space-between;
  margin: 4px 0;
}

.struk-row.label {
  font-weight: bold;
  margin-top: 8px;
}

.struk-total {
  font-size: 14px;
  font-weight: bold;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #000;
}

.struk-footer {
  text-align: center;
  font-size: 11px;
  margin-top: 12px;
}

/* Report Table */
.report-table {
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-top: 20px;
}

.report-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.report-table th,
.report-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
}

.report-table th {
  background: var(--light);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--gray);
}

.report-table tr:hover {
  background: #f8fafc;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--dark);
  color: var(--white);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 2000;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .navbar {
    width: 100%;
    height: auto;
    position: fixed;
    bottom: 0;
    top: auto;
    border-right: none;
    border-top: 1px solid #e2e8f0;
    flex-direction: row;
    padding: 0;
  }

  .nav-brand {
    display: none;
  }

  .nav-menu {
    flex-direction: row;
    justify-content: space-around;
    padding: 6px 0;
    width: 100%;
    overflow-x: auto;
  }

  .nav-btn {
    flex-direction: column;
    padding: 6px 8px;
    font-size: 10px;
    gap: 4px;
    flex: 1;
    min-width: 60px;
    align-items: center;
  }

  .nav-btn .icon {
    font-size: 20px;
  }

  .main-content {
    margin-left: 0;
    margin-bottom: 70px;
    padding: 16px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .action-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .filter-bar {
    flex-direction: column;
  }

  .trx-header {
    flex-direction: column;
  }

  .trx-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}

/* Print Styles for Thermal Printer */
@media print {
  body * {
    visibility: hidden;
  }
  .struk-thermal,
  .struk-thermal * {
    visibility: visible;
  }
  .struk-thermal {
    position: absolute;
    left: 0;
    top: 0;
    width: 58mm;
    max-width: 58mm;
    margin: 0;
    padding: 0;
  }
  @page {
    size: 58mm auto;
    margin: 0;
  }
}
