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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;
  background: #f5f5f5;
  color: #333;
}

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

h1 {
  text-align: center;
  margin-bottom: 30px;
  color: #2563eb;
  font-size: 2em;
}

h2 {
  font-size: 1.3em;
  margin-bottom: 16px;
  color: #333;
}

h3 {
  font-size: 1.1em;
  margin: 0;
  color: #333;
}

.card {
  background: white;
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

#login {
  max-width: 400px;
  margin: 0 auto;
}

#login input {
  display: block;
  width: 100%;
  padding: 12px;
  margin-bottom: 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
}

#login input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

#loginMsg {
  margin-top: 12px;
  padding: 8px;
  border-radius: 4px;
  text-align: center;
  min-height: 20px;
}

#loginMsg.error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding: 16px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.topbar span {
  color: #666;
}

/* Topbar center (search removed) */

.topbar-left, .topbar-right { display:flex; align-items:center; gap:12px; }

/* Shops card toolbar */
.card-toolbar {
  display:flex;
  gap:12px;
  align-items:center;
  justify-content:space-between;
  margin-bottom:12px;
}

/* card-toolbar inputs removed (no inline filter input) */

@media (max-width: 480px) {
  /* responsive adjustments */
}

.toolbar-actions { display:flex; gap:8px; align-items:center; }

@media (max-width: 768px) {
  .card-toolbar { flex-direction:column; align-items:stretch; gap:8px; }
  .toolbar-actions { justify-content:flex-end; }
}

button {
  padding: 10px 20px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  background: #f0f0f0;
  color: #333;
  transition: all 0.2s;
}

button:hover {
  background: #e0e0e0;
}

button.primary {
  background: #2563eb;
  color: white;
}

button.primary:hover {
  background: #1d4ed8;
}

button.del {
  background: #ef4444;
  color: white;
}

button.del:hover {
  background: #dc2626;
}

.close-btn {
  background: none;
  border: none;
  font-size: 24px;
  color: #999;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-btn:hover {
  color: #333;
}

table {
  width: 100%;
  border-collapse: collapse;
}

table thead {
  background: #f9fafb;
  border-bottom: 2px solid #e5e7eb;
}

table th {
  padding: 12px;
  text-align: left;
  font-weight: 600;
  color: #374151;
  font-size: 13px;
}

table td {
  padding: 12px;
  border-bottom: 1px solid #e5e7eb;
  font-size: 14px;
}

table tr:hover {
  background: #f9fafb;
}

.action-buttons {
  display: flex;
  gap: 8px;
}

/* Responsive table wrapper to avoid layout overflow on small screens */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Allow table cells to wrap instead of overflowing container */
table th, table td {
  white-space: normal;
  word-break: break-word;
}

/* Mobile stacked shop cards */
.shops-list {
  display: none;
  margin-top: 12px;
  display: grid;
  gap: 12px;
}

.shop-card {
  background: #fff;
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.shop-card .row { display:flex; justify-content:space-between; gap:8px; align-items:center; }
.shop-card .meta { color:#666; font-size:13px }
.shop-card .balance { color:#2563eb; font-weight:700 }
.shop-card .card-actions { display:flex; gap:8px; }


.action-buttons button {
  padding: 6px 12px;
  font-size: 12px;
}

input {
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
}

input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.form-grid > * {
  width: 100%;
}

.input-prefix {
  display: flex;
  align-items: center;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: white;
  grid-column: span 2;
}

.input-prefix input {
  border: none;
  flex: 1;
  padding: 10px;
  border-radius: 0;
}

.input-prefix input:focus {
  box-shadow: none;
}

.prefix {
  padding: 0 10px;
  color: #999;
  font-weight: 500;
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
}

.modal-content {
  position: relative;
  width: calc(100% - 48px);
  max-width: 480px;
  margin: 24px auto;
  max-height: 90vh;
  overflow-y: auto;
  background: white;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

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

.drawer {
  position: fixed;
  top: 0;
  right: -400px;
  width: 400px;
  height: 100vh;
  overflow-y: auto;
  background: white;
  box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
  transition: right 0.3s;
  z-index: 999;
  display: flex;
  flex-direction: column;
}

.drawer.open {
  right: 0;
}

.drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.3);
  z-index: 998;
}

.drawer-content {
  padding: 24px;
  flex: 1;
  background: white;
  border-radius: 0;
  box-shadow: none;
  margin: 0;
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e5e7eb;
}

.muted {
  color: #999;
  font-size: 12px;
}

@media (max-width: 768px) {
  .container {
    padding: 12px;
  }

  h1 {
    font-size: 1.5em;
  }

  .card {
    padding: 16px;
  }

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

  .form-grid .input-prefix {
    grid-column: span 1;
  }

  .topbar {
    flex-direction: column;
    gap: 12px;
  }

  table {
    font-size: 12px;
    min-width: 600px;
  }

  /* show cards and hide table on narrow screens */
  .shops-list { display: grid; }
  .table-responsive { display: none; }

  table th,
  table td {
    padding: 8px;
  }

  .drawer {
    width: 100%;
    right: -100%;
  }

  #summary {
    flex-direction: column !important;
    gap: 16px !important;
  }

  .action-buttons {
    flex-direction: column;
  }
}

/* Smaller devices adjustments */
@media (max-width: 420px) {
  html { font-size: 14px; }

  h1 { font-size: 1.25em; }
  h2 { font-size: 1.05em; }
  h3 { font-size: 1em; }

  button { font-size: 15px; padding: 10px 14px; }
  input { font-size: 15px; padding: 12px; }

  /* Ensure modals fit vertically and horizontally */
  .modal-content { width: calc(100% - 24px); margin: 12px auto; padding: 12px; }
  .modal-header h3 { font-size: 1rem; }

  /* Make form grid and input-prefix stack nicely */
  .form-grid { grid-template-columns: 1fr; gap: 10px; }
  .input-prefix { grid-column: span 1; }

  /* Drawer full-screen on very small devices */
  .drawer { width: 100%; right: -100%; }
  .drawer-content { padding: 16px; }

  /* Reduce table horizontal minimum so it scrolls properly */
  table { min-width: 520px; }
}

/* Bottom sheet style for modal on narrow screens */
@media (max-width: 480px) {
  .modal.bottom-sheet { align-items: flex-end; }
  .modal.bottom-sheet .modal-content {
    width: 100%;
    max-width: none;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    margin: 0;
    padding: 12px;
    max-height: 80vh;
  }
}

/* Highlighted search matches */
mark {
  background: #fffbcc;
  padding: 0 2px;
  border-radius: 2px;
  font-weight: 600;
  color: #4b4b00;
}
