:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #111827;
  --primary-2: #1f2937;
  --cash: #111827;
  --cardbtn: #eef2f7;
  --shadow: 0 10px 30px rgba(17, 24, 39, 0.06);
  --shadow-soft: 0 4px 12px rgba(17, 24, 39, 0.05);
  --radius: 20px;
  --radius-sm: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #f8fafc 0%, #eff3f8 100%);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.smp-front-wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

.smp-toolbar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-bottom: 22px;
}

.smp-toolbar h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1;
  letter-spacing: -0.04em;
  font-weight: 800;
}

.smp-muted {
  color: var(--muted);
  font-size: 0.98rem;
  margin-top: 8px;
}

.smp-tabs {
  display: inline-flex;
  gap: 8px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255,255,255,0.8);
  border: 1px solid rgba(17, 24, 39, 0.06);
  box-shadow: var(--shadow-soft);
  width: fit-content;
}

.smp-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  transition: all .18s ease;
}

.smp-tab:hover {
  color: var(--text);
}

.smp-tab.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 8px 18px rgba(17, 24, 39, 0.18);
}

.smp-dashboard {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 0 0 24px;
}

.smp-stat {
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(17,24,39,0.06);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-soft);
}

.smp-stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 10px;
}

.smp-stat-value {
  font-size: clamp(1.5rem, 3vw, 2rem);
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.smp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(235px, 1fr));
  gap: 16px;
  margin-top: 8px;
}

.smp-card {
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(17,24,39,0.06);
  border-radius: 22px;
  padding: 18px;
  box-shadow: var(--shadow);
  transition: transform .18s ease, box-shadow .18s ease;
}

.smp-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgba(17, 24, 39, 0.08);
}

.smp-title {
  margin: 0 0 8px;
  font-size: 1.05rem;
  line-height: 1.2;
  font-weight: 700;
}

.smp-meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 14px;
}

.smp-price {
  font-size: 2rem;
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.04em;
  margin: 0 0 14px;
}

.smp-stock {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.smp-stock.low {
  background: #fff7ed;
  color: #b45309;
}

.smp-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 6px;
}

.smp-actions form {
  margin: 0;
}

.smp-actions button {
  width: 100%;
  min-height: 50px;
  border: 0;
  border-radius: 14px;
  font-size: 0.98rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform .15s ease, opacity .15s ease, box-shadow .15s ease;
  box-shadow: var(--shadow-soft);
}

.smp-actions button:hover {
  transform: translateY(-1px);
}

.smp-actions button:active {
  transform: translateY(0);
}

.smp-actions form:first-child button {
  background: var(--cash);
  color: #fff;
}

.smp-actions form:last-child button {
  background: var(--cardbtn);
  color: var(--text);
}

.smp-front-wrap h2 {
  margin: 34px 0 14px;
  font-size: 2rem;
  line-height: 1;
  letter-spacing: -0.04em;
}

.smp-front-table-wrap {
  overflow-x: auto;
  border-radius: 20px;
  box-shadow: var(--shadow-soft);
}

.smp-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: rgba(255,255,255,0.92);
  border: 1px solid rgba(17,24,39,0.06);
  border-radius: 20px;
  overflow: hidden;
}

.smp-table th {
  background: #f8fafc;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  text-align: left;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.smp-table td {
  padding: 14px 16px;
  border-bottom: 1px solid #edf2f7;
  font-size: 0.96rem;
}

.smp-table tbody tr:last-child td {
  border-bottom: 0;
}

.smp-empty {
  padding: 20px;
  background: rgba(255,255,255,0.92);
  border: 1px solid rgba(17,24,39,0.06);
  border-radius: 20px;
  box-shadow: var(--shadow-soft);
}

input,
select,
button,
textarea {
  font: inherit;
}

@media (max-width: 768px) {
  .smp-front-wrap {
    padding: 14px 12px 28px;
  }

  .smp-dashboard {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .smp-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .smp-price {
    font-size: 1.7rem;
  }

  .smp-front-wrap h2 {
    font-size: 1.8rem;
  }

  .smp-table th,
  .smp-table td {
    padding: 12px 10px;
    font-size: 0.9rem;
  }
}

@media (max-width: 560px) {
  .smp-tabs {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .smp-tab {
    min-width: 0;
    padding: 0 8px;
    font-size: 0.92rem;
  }

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

  .smp-card {
    padding: 16px;
    border-radius: 18px;
  }

  .smp-actions button {
    min-height: 54px;
    font-size: 1rem;
  }

  .smp-front-wrap h2 {
    margin-top: 26px;
  }
}

/* =========================
   PRODUCTS / SALES VISUAL POLISH ONLY
   ========================= */

.smp-panel .smp-card {
  border-radius: 24px;
  padding: 22px;
}

.smp-panel .smp-card h2 {
  margin: 0 0 18px;
  font-size: 2rem;
  line-height: 1;
  letter-spacing: -0.04em;
}

/* Add Product form */
.smp-form-stack input,
.smp-form-stack select,
.smp-inline-form input,
.smp-inline-form select {
  height: 42px;
  border: 1px solid #d8dee8;
  background: #fff;
  border-radius: 12px;
  padding: 0 12px;
  font-size: 14px;
  color: #111827;
  outline: none;
  box-shadow: none;
}

.smp-form-stack input:focus,
.smp-form-stack select:focus,
.smp-inline-form input:focus,
.smp-inline-form select:focus {
  border-color: #111827;
  box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.08);
}

.smp-form-stack button,
.smp-inline-form button,
.smp-panel form button {
  height: 42px;
  border: 0;
  border-radius: 12px;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all .18s ease;
}

.smp-form-stack button:hover,
.smp-inline-form button:hover,
.smp-panel form button:hover {
  transform: translateY(-1px);
}

/* Primary buttons */
.smp-form-stack button,
.smp-inline-form button[type="submit"] {
  background: #111827;
  color: #fff;
  box-shadow: 0 6px 16px rgba(17, 24, 39, 0.12);
}

/* Delete buttons */
.smp-panel form button.smp-danger,
.smp-panel form .smp-danger {
  background: #fff1f2;
  color: #be123c;
  box-shadow: none;
  border: 1px solid #fecdd3;
}

/* Tables */
.smp-panel .smp-table,
.smp-front-table-wrap .smp-table {
  border-radius: 24px;
  overflow: hidden;
}

.smp-panel .smp-table th,
.smp-panel .smp-table td {
  vertical-align: middle;
}

.smp-panel .smp-table td {
  padding-top: 18px;
  padding-bottom: 18px;
}

/* Better badge look */
.smp-badge {
  background: #f3f4f6;
  color: #374151;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
}

.smp-panel .smp-table td .smp-badge {
  white-space: nowrap;
}

/* Inline action forms */
.smp-inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.smp-inline-form input,
.smp-inline-form select {
  width: auto;
  min-width: 100px;
}

.smp-inline-form input[name="sku"] {
  min-width: 110px;
}

.smp-inline-form input[name="name"] {
  min-width: 140px;
}

.smp-inline-form input[name="price"],
.smp-inline-form input[name="qty"],
.smp-inline-form input[name="unit_price"],
.smp-inline-form input[name="stock"] {
  min-width: 80px;
}

.smp-inline-form select[name="is_active"],
.smp-inline-form select[name="payment_method"] {
  min-width: 95px;
}

.smp-inline-form select[name="product_id"] {
  min-width: 180px;
  max-width: 220px;
}

/* Separate delete button nicely */
.smp-panel form[style] {
  margin-top: 10px !important;
}

/* Sales/Product action cells breathe more */
.smp-panel .smp-table td:last-child {
  min-width: 320px;
}

/* Make forms feel aligned inside cells */
.smp-panel .smp-table td form {
  margin-bottom: 0;
}

/* Add Product section spacing */
.smp-form-grid {
  gap: 14px;
}

.smp-form-grid > div {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Mobile */
@media (max-width: 768px) {
  .smp-panel .smp-card {
    padding: 18px;
    border-radius: 20px;
  }

  .smp-panel .smp-card h2 {
    font-size: 1.7rem;
  }

  .smp-panel .smp-table td:last-child {
    min-width: 260px;
  }

  .smp-inline-form {
    gap: 6px;
  }

  .smp-inline-form input,
  .smp-inline-form select,
  .smp-inline-form button {
    min-width: 100%;
    width: 100%;
  }
}


html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body.smp-app,
body.smp-app-page {
  min-height: 100vh;
  min-height: 100dvh;
  background: linear-gradient(180deg, #f8fafc 0%, #eff3f8 100%);
}

body.smp-app-page {
  overflow-x: hidden;
}

body.smp-app-page .smp-front-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* safe area support for iPhone */
body.smp-app-page .smp-front-wrap {
  padding-top: max(14px, env(safe-area-inset-top));
  padding-right: max(12px, env(safe-area-inset-right));
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  padding-left: max(12px, env(safe-area-inset-left));
}


/* =========================
   LOGIN PAGE
   ========================= */

.smp-login-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.smp-login-card {
  width: 100%;
  max-width: 440px;
  text-align: center;
}

.smp-login-brand {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.45em;
  text-transform: uppercase;
  margin-bottom: 28px;
  color: #111;
}

.smp-login-title {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin: 0 0 34px;
  color: #111;
}

.smp-login-form {
  display: grid;
  gap: 22px;
}

.smp-login-field input {
  width: 100%;
  height: 54px;
  border: 0;
  border-bottom: 1px solid #cfcfcf;
  border-radius: 0;
  background: transparent;
  padding: 0 8px;
  font-size: 1rem;
  color: #111;
  outline: none;
  box-shadow: none;
}

.smp-login-field input::placeholder {
  color: #9ca3af;
}

.smp-login-field input:focus {
  border-bottom-color: #111;
}

.smp-login-button {
  width: 160px;
  height: 50px;
  margin: 8px auto 0;
  border: 0;
  background: #111;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: all .18s ease;
}

.smp-login-button:hover {
  transform: translateY(-1px);
  opacity: .96;
}

@media (max-width: 640px) {
  .smp-login-wrap {
    padding: 20px;
  }

  .smp-login-brand {
    font-size: 1.8rem;
    letter-spacing: 0.35em;
  }

  .smp-login-title {
    font-size: 1.5rem;
    margin-bottom: 28px;
  }

  .smp-login-button {
    width: 100%;
  }
}