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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: #1a1a1a;
  color: #e0e0e0;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  background: #2d2d2d;
  padding: 15px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  flex-wrap: wrap;
  gap: 10px;
}

h1 {
  font-size: 20px;
  color: #fff;
}

h2 {
  margin-bottom: 15px;
  font-size: 18px;
  color: #fff;
}

h3 {
  margin: 15px 0 10px;
  font-size: 16px;
  color: #fff;
}

@media (max-width: 768px) {
  h1 {
    font-size: 18px;
  }
  h2 {
    font-size: 16px;
  }
}

.btn-primary {
  background: #007bff;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
}

.btn-primary:hover {
  background: #0056b3;
}

.btn-secondary {
  background: #6c757d;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  margin: 10px 0;
}

.btn-delete {
  background: #dc3545;
  color: white;
  border: none;
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

@media (max-width: 768px) {
  .btn-primary {
    padding: 8px 12px;
    font-size: 12px;
  }
}

.tabs {
  display: flex;
  gap: 5px;
  margin-bottom: 15px;
  background: #2d2d2d;
  padding: 10px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab {
  background: transparent;
  border: none;
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 13px;
  white-space: nowrap;
  flex-shrink: 0;
  color: #b0b0b0;
}

.tab.active {
  background: #007bff;
  color: white;
}

.tab-content {
  display: none;
  background: #2d2d2d;
  padding: 15px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  overflow-x: auto;
}

.tab-content.active {
  display: block;
}

@media (max-width: 768px) {
  .tabs {
    gap: 3px;
    padding: 8px;
  }
  
  .tab {
    padding: 6px 10px;
    font-size: 12px;
  }
  
  .tab-content {
    padding: 10px;
  }
}

form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 15px;
  padding-bottom: 15px;
  border-bottom: 1px solid #eee;
}

input, select {
  padding: 10px;
  border: 1px solid #444;
  border-radius: 4px;
  font-size: 14px;
  flex: 1;
  min-width: 120px;
  background: #1a1a1a;
  color: #e0e0e0;
}

input:focus, select:focus {
  outline: none;
  border-color: #007bff;
}

@media (max-width: 768px) {
  input, select {
    min-width: 100%;
    font-size: 16px;
  }
  
  form {
    gap: 8px;
  }
}

.radio-group {
  display: flex;
  gap: 20px;
  align-items: center;
  flex-wrap: wrap;
}

.radio-group label {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  white-space: nowrap;
}

@media (max-width: 768px) {
  .radio-group {
    gap: 15px;
    width: 100%;
  }
}

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

th, td {
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px solid #444;
}

th {
  background: #1a1a1a;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 10;
  color: #fff;
}

tr:hover {
  background: #3a3a3a;
}

@media (max-width: 768px) {
  table {
    font-size: 12px;
  }
  
  th, td {
    padding: 8px 4px;
  }
  
  th {
    font-size: 11px;
  }
}

.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.8);
}

.modal-content {
  background: #2d2d2d;
  margin: 5% auto;
  padding: 20px;
  border-radius: 8px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
}

@media (max-width: 768px) {
  .modal-content {
    margin: 10px;
    padding: 15px;
    width: calc(100% - 20px);
    max-height: 90vh;
  }
}

.close {
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  color: #888;
}

.close:hover {
  color: #fff;
}

.overview-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  margin-top: 20px;
}

.overview-card {
  background: #1a1a1a;
  padding: 20px;
  border-radius: 8px;
  text-align: center;
  border: 1px solid #444;
}

.overview-card h3 {
  font-size: 14px;
  color: #b0b0b0;
  margin-bottom: 10px;
}

.overview-value {
  font-size: 28px;
  font-weight: bold;
  color: #fff;
  margin: 10px 0;
}

.overview-card small {
  color: #888;
  font-size: 12px;
}

@media (max-width: 768px) {
  .overview-cards {
    grid-template-columns: 1fr;
  }
  
  .overview-value {
    font-size: 24px;
  }
}
.item-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #2d2d2d;
  border: 1px solid #555;
  border-radius: 4px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 1000;
}

.item-dropdown-item {
  padding: 10px;
  cursor: pointer;
  border-bottom: 1px solid #444;
}

.item-dropdown-item:hover {
  background: #3d3d3d;
}

.item-dropdown-item:last-child {
  border-bottom: none;
}
/* Swipe delete feature */
.swipe-row {
  position: relative;
  transition: transform 0.2s ease;
}

.swipe-actions {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  display: flex;
  align-items: center;
  background: #ff4757;
  padding: 0 15px;
  transform: translateX(100%);
  transition: transform 0.2s ease;
  cursor: pointer;
}

.swipe-row.swiped {
  transform: translateX(-80px);
}

.swipe-row.swiped .swipe-actions {
  transform: translateX(0);
}
/* Mobile layout for Udhari Balance page */
@media (max-width: 768px) {
  /* Stack filter controls vertically on mobile */
  #udhari-balance > div:first-of-type {
    flex-direction: column !important;
    gap: 10px !important;
  }
  
  #udhari-balance input[type="text"], 
  #udhari-balance input[type="date"] {
    width: 100% !important;
    max-width: none !important;
  }
  
  /* Mobile-friendly summary cards */
  #udhariDateSummary > div:last-child {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }
  
  #udhariDateSummary > div:last-child > div {
    padding: 10px;
    background: #3d3d3d;
    border-radius: 8px;
  }
  
  /* Card-style layout for mobile instead of table */
  #udhariBalanceTable {
    display: none;
  }
  
  .mobile-balance-cards {
    display: block;
  }
  
  .balance-card {
    background: #2d2d2d;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    border-left: 4px solid #555;
    cursor: pointer;
    transition: all 0.2s ease;
  }
  
  .balance-card:active {
    transform: scale(0.98);
  }
  
  .balance-card.positive {
    border-left-color: #ff4757;
  }
  
  .balance-card.negative {
    border-left-color: #2ed573;
  }
  
  .balance-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
  }
  
  .balance-card-name {
    font-size: 16px;
    font-weight: bold;
    color: #fff;
  }
  
  .balance-card-phone {
    font-size: 12px;
    color: #ccc;
  }
  
  .balance-card-amount {
    font-size: 18px;
    font-weight: bold;
  }
  
  .balance-card-details {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #ccc;
    margin-top: 8px;
  }
}

/* Desktop: hide mobile cards */
@media (min-width: 769px) {
  .mobile-balance-cards {
    display: none;
  }
}
/* Mobile layout for Purchases page */
@media (max-width: 768px) {
  /* Stack purchase controls vertically on mobile */
  #purchases > div:first-of-type {
    flex-direction: column !important;
    gap: 10px !important;
  }
  
  #purchases > div:first-of-type > div {
    width: 100% !important;
  }
  
  #purchases input[type="date"] {
    width: 100% !important;
  }
  
  /* Mobile-friendly purchase summary */
  #purchaseDateSummary > div:nth-child(2) {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }
  
  #purchaseDateSummary > div:nth-child(2) > div {
    padding: 10px;
    background: #3d3d3d;
    border-radius: 8px;
  }
  
  /* Card-style layout for mobile instead of table */
  #purchasesTable {
    display: none;
  }
  
  .mobile-purchase-cards {
    display: block;
  }
  
  .purchase-card {
    background: #2d2d2d;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 8px;
    border-left: 3px solid #555;
    transition: all 0.2s ease;
  }
  
  .purchase-card:active {
    transform: scale(0.98);
  }
  
  .purchase-card.cash {
    border-left-color: #2ed573;
  }
  
  .purchase-card.online {
    border-left-color: #3742fa;
  }
  
  .purchase-card.pending {
    border-left-color: #ffa502;
  }
  
  .purchase-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
  }
  
  .purchase-card-item {
    font-size: 14px;
    font-weight: bold;
    color: #fff;
  }
  
  .purchase-card-date {
    font-size: 11px;
    color: #ccc;
  }
  
  .purchase-card-amount {
    font-size: 16px;
    font-weight: bold;
    color: #ff6b6b;
  }
  
  .purchase-card-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
  }
  
  .purchase-card-mode {
    font-size: 10px;
    padding: 3px 6px;
    border-radius: 10px;
    font-weight: bold;
  }
  
  .purchase-card-mode.cash {
    background: #2ed573;
    color: white;
  }
  
  .purchase-card-mode.online {
    background: #3742fa;
    color: white;
  }
  
  .purchase-card-mode.pending {
    background: #ffa502;
    color: white;
  }
  
  .purchase-card-actions {
    display: flex;
    gap: 4px;
  }
  
  .purchase-card-actions button {
    padding: 4px 8px;
    font-size: 10px;
    border-radius: 3px;
  }
  
  .purchase-card-actions select {
    padding: 3px;
    font-size: 10px;
    border-radius: 3px;
  }
}

/* Desktop: hide mobile cards */
@media (min-width: 769px) {
  .mobile-purchase-cards {
    display: none;
  }
}
/* Complete Mobile-Friendly Design for All Tabs */
@media (max-width: 768px) {
  /* Header and Navigation */
  .container {
    padding: 5px;
  }
  
  header {
    flex-direction: column;
    gap: 10px;
    padding: 10px;
  }
  
  h1 {
    font-size: 18px;
  }
  
  /* Tabs - Horizontal scrollable */
  .tabs {
    display: flex;
    overflow-x: auto;
    gap: 5px;
    padding: 5px 0;
    margin-bottom: 10px;
    -webkit-overflow-scrolling: touch;
  }
  
  .tab {
    white-space: nowrap;
    min-width: 80px;
    padding: 8px 12px;
    font-size: 12px;
    border-radius: 15px;
  }
  
  /* Dashboard - Keep original table layout */
  #summaryTable {
    display: table;
  }
  
  .mobile-dashboard-cards {
    display: none;
  }
  
  /* Daily Cash - Stack form elements */
  #daily-cash form {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  
  #daily-cash input, #daily-cash button {
    width: 100%;
    padding: 12px;
    font-size: 16px;
  }
  
  /* Online Sales - Stack form elements */
  #online-sales form {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  
  #online-sales input, #online-sales button {
    width: 100%;
    padding: 12px;
    font-size: 16px;
  }
  
  /* Customers - Mobile cards */
  #customersTable {
    display: none;
  }
  
  .mobile-customer-cards {
    display: block;
  }
  
  .customer-card {
    background: #2d2d2d;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    border-left: 3px solid #2ed573;
  }
  
  .customer-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
  }
  
  .customer-card-name {
    font-size: 14px;
    font-weight: bold;
    color: #fff;
  }
  
  .customer-card-phone {
    font-size: 12px;
    color: #ccc;
  }
  
  .customer-card-actions {
    display: flex;
    gap: 5px;
  }
  
  .customer-card-actions button {
    padding: 6px 10px;
    font-size: 11px;
  }
  
  /* Items - Mobile cards */
  #itemsTable {
    display: none;
  }
  
  .mobile-item-cards {
    display: block;
  }
  
  .item-card {
    background: #2d2d2d;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    border-left: 3px solid #46d204;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  
  .item-card-name {
    font-size: 14px;
    font-weight: bold;
    color: #fff;
  }
  
  .item-card-action button {
    padding: 6px 10px;
    font-size: 11px;
  }
  
  /* Overview - Stack buttons vertically */
  #overview > div:first-of-type {
    flex-direction: column !important;
    gap: 10px !important;
  }
  
  #overview button {
    width: 100%;
    padding: 12px;
    font-size: 14px;
  }
  
  .overview-cards {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  
  .overview-card {
    padding: 15px !important;
  }
  
  /* Forms - Better mobile styling */
  form {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  
  input, select, button {
    padding: 12px;
    font-size: 16px;
    border-radius: 6px;
  }
  
  /* Tables - Hide on mobile (replaced with cards) */
  table:not(.keep-mobile) {
    font-size: 12px;
  }
  
  table:not(.keep-mobile) th,
  table:not(.keep-mobile) td {
    padding: 8px 4px;
  }
  
  /* Modals - Full screen on mobile */
  .modal-content {
    width: 95% !important;
    max-width: none !important;
    margin: 10px !important;
    max-height: 90vh;
    overflow-y: auto;
  }
  
  /* Quick Udhari Modal */
  #udhariForm {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  
  #udhariForm input,
  #udhariForm select,
  #udhariForm button {
    width: 100%;
    padding: 12px;
    font-size: 16px;
  }
  
  /* Payment Date Modal */
  #paymentDateModal .modal-content {
    width: 90% !important;
  }
  
  #paymentDateInput {
    padding: 12px !important;
    font-size: 16px !important;
  }
}

/* Desktop: hide mobile cards */
@media (min-width: 769px) {
  .mobile-customer-cards,
  .mobile-item-cards {
    display: none;
  }
}
