:root {
  --tide-deep: #0B3A3F;
  --tide-mid: #14555C;
  --tide-bright: #1E8A94;
  --catch-amber: #E7A33E;
  --catch-coral: #E0603A;
  --foam: #F5F3EC;
  --foam-card: #FFFFFF;
  --ink: #16282A;
  --ink-soft: #5C7274;
  --line: #DDE3E0;
  --ok: #2E8B57;
  --danger: #C0392B;
  --radius: 10px;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html { overflow-x: hidden; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--foam);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; }

.topbar {
  background: var(--tide-deep);
  color: white;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.topbar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hamburger-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  background: none;
  border: none;
  padding: 6px;
  margin: -6px -2px -6px -6px;
  cursor: pointer;
}
.hamburger-btn span {
  display: block;
  width: 22px;
  height: 2px;
  background: white;
  border-radius: 2px;
}

.topbar-menu {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  flex-wrap: wrap;
  justify-content: space-between;
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.brand .mark {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--tide-bright), var(--catch-amber));
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
}

.topbar nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.topbar nav a, .topbar .userbox {
  color: rgba(255,255,255,0.82);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
}

.topbar nav a:hover { background: rgba(255,255,255,0.1); color: white; }
.topbar nav a.active { background: var(--tide-bright); color: white; font-weight: 600; }

.topbar form.logout { display: inline; margin: 0; }
.topbar form.logout button {
  background: none; border: none; color: rgba(255,255,255,0.7);
  cursor: pointer; font-size: 14px; padding: 8px 10px;
}
.topbar form.logout button:hover { color: white; }

/* Navigasi hamburger — khusus mobile; desktop tetap horizontal seperti di atas */
@media (max-width: 860px) {
  .topbar { flex-direction: column; flex-wrap: nowrap; align-items: stretch; padding: 12px 16px; }
  .hamburger-btn { display: flex; }
  .topbar-menu {
    display: none;
    width: 100%;
    flex: none;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.15);
  }
  .topbar-menu.open { display: flex; }
  .topbar-menu nav { flex-direction: column; gap: 2px; width: 100%; }
  .topbar-menu nav a { width: 100%; padding: 11px 12px; }
  .topbar .userbox {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 10px 12px 4px;
  }
  .topbar form.logout button { padding: 8px 0; }
}


.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px 18px 60px;
}

h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.subtitle { color: var(--ink-soft); font-size: 14px; margin-bottom: 22px; }

.card {
  background: var(--foam-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
}

.grid-2 { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 18px; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); }
th { color: var(--ink-soft); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.4px; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--font-mono); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: 8px; padding: 10px 16px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  background: var(--tide-mid); color: white; text-decoration: none;
}
.btn:hover { background: var(--tide-deep); }
.btn.amber { background: var(--catch-amber); color: var(--tide-deep); }
.btn.amber:hover { background: #cf8f30; }
.btn.ghost { background: transparent; color: var(--tide-mid); border: 1px solid var(--line); }
.btn.small { padding: 6px 10px; font-size: 12.5px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.form-row { margin-bottom: 12px; }
.form-row label { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 4px; font-weight: 600; }
input, select {
  width: 100%; padding: 9px 10px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 14px; font-family: var(--font-body); background: white;
}
input:focus, select:focus { outline: 2px solid var(--tide-bright); outline-offset: 1px; }

.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .form-row { margin-bottom: 0; flex: 1; min-width: 140px; }

.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
}
.badge.ok { background: #E4F3EA; color: var(--ok); }
.badge.warn { background: #FCEFE0; color: #B5651D; }
.badge.off { background: #F1E9E9; color: var(--ink-soft); }

.flash {
  background: #FCEFE0; border: 1px solid var(--catch-amber);
  color: #7A4A0E; padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px;
}
.flash.error { background: #FBECE8; border-color: var(--danger); color: #8B2E22; }

/* ---------- LOGIN ---------- */
.login-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(circle at 15% 20%, rgba(30,138,148,0.25), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(231,163,62,0.18), transparent 45%),
    var(--tide-deep);
  padding: 20px;
}
.login-card {
  background: var(--foam-card);
  border-radius: 14px;
  padding: 34px 30px;
  width: 100%; max-width: 360px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.login-card .mark {
  width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, var(--tide-bright), var(--catch-amber));
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; margin-bottom: 14px;
}
.login-card h1 { font-size: 20px; margin-bottom: 2px; }
.login-card .subtitle { margin-bottom: 22px; }
.login-card .btn { width: 100%; margin-top: 6px; }

/* ---------- POS (kasir) ---------- */
.pos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.ikan-card {
  background: white; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; cursor: pointer; text-align: left;
  transition: border-color .12s, transform .12s;
}
.ikan-card:hover { border-color: var(--tide-bright); transform: translateY(-1px); }
.ikan-card:disabled, .ikan-card.habis { opacity: 0.45; cursor: not-allowed; }
.ikan-card .nama { font-weight: 700; margin-bottom: 6px; display: block; }
.ikan-card .harga { color: var(--tide-mid); font-family: var(--font-mono); font-size: 13.5px; }
.ikan-card .stok { color: var(--ink-soft); font-size: 12.5px; margin-top: 4px; }

.cart-item { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.cart-item .nama { flex: 1; min-width: 0; font-weight: 600; font-size: 13.5px; }
.cart-item input.qty { width: 68px; text-align: right; padding: 6px; }
.cart-item .subtotal { width: 90px; text-align: right; font-family: var(--font-mono); font-size: 13px; }
.cart-item .remove { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 16px; padding: 0 4px; }

.cart-total { display: flex; justify-content: space-between; padding: 12px 0; font-weight: 700; font-size: 17px; border-top: 2px solid var(--tide-deep); margin-top: 8px; }
.cart-empty { color: var(--ink-soft); text-align: center; padding: 30px 0; font-size: 13.5px; }

/* ---------- STRUK / PRINT ---------- */
.receipt-wrap { display: flex; justify-content: center; padding: 20px; background: var(--foam); min-height: 100vh; }
.receipt {
  width: 302px;
  background: white; padding: 16px;
  font-family: var(--font-mono);
  font-size: 12.5px; color: #111;
}
.receipt .center { text-align: center; }
.receipt .toko { font-weight: 700; font-size: 14px; }
.receipt hr { border: none; border-top: 1px dashed #999; margin: 8px 0; }
.receipt .row { display: flex; justify-content: space-between; }
.receipt table { font-size: 12px; }
.receipt th, .receipt td { border: none; padding: 2px 0; }
.receipt-actions { text-align: center; margin-top: 16px; }

/* ---------- Tabel di layar sempit ---------- */
/* Untuk tabel yang barisnya ada form edit inline (Ikan/Gudang/Akun) — aman digeser ke samping */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Untuk tabel baca-saja — di mobile diubah jadi kartu bertumpuk, jauh lebih enak dibaca daripada geser-geser */
@media (max-width: 700px) {
  .table-responsive thead { display: none; }
  .table-responsive table, .table-responsive tbody, .table-responsive tr, .table-responsive td {
    display: block; width: 100%;
  }
  .table-responsive tr {
    border: 1px solid var(--line); border-radius: 8px;
    margin-bottom: 10px; padding: 4px 12px; background: white;
  }
  .table-responsive tr:last-child { margin-bottom: 0; }
  .table-responsive td {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 8px 0; border-bottom: 1px dashed var(--line); text-align: right;
  }
  .table-responsive td:last-child { border-bottom: none; }
  .table-responsive td::before {
    content: attr(data-label);
    font-weight: 600; color: var(--ink-soft); font-size: 12px;
    text-align: left; text-transform: uppercase; letter-spacing: 0.3px; flex-shrink: 0;
  }
  .table-responsive td.num { font-family: var(--font-mono); }
}

@media (max-width: 640px) {
  .wrap { padding: 16px 12px 50px; }
  .card { padding: 14px; }
  h1 { font-size: 20px; }
  .grid-2 { gap: 12px; }

  /* Input & select minimal 16px supaya Safari/Chrome di HP tidak auto-zoom saat difokus */
  input, select { font-size: 16px; }
  td input, td select { padding: 7px 5px !important; font-size: 15px !important; }

  /* Form jadi satu kolom penuh, lebih gampang diisi jari daripada berdesakan */
  .inline-form { flex-direction: column; align-items: stretch; gap: 12px; }
  .inline-form .form-row { min-width: 100%; }
  .inline-form > .btn { width: 100%; }

  /* Tombol lebih besar untuk disentuh */
  .btn { padding: 12px 16px; font-size: 15px; }
  .btn.small { padding: 8px 12px; font-size: 13px; }

  .pos-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
  .cart-item .qty { width: 56px; }
  .cart-item .subtotal { width: 72px; font-size: 12px; }

  .login-card { padding: 28px 22px; }
}

@media (max-width: 400px) {
  .brand { font-size: 14px; gap: 6px; }
  .brand .mark { width: 26px; height: 26px; font-size: 13px; }
}

@media print {
  .no-print { display: none !important; }
  .receipt-wrap { padding: 0; background: white; }
  .receipt { width: 100%; box-shadow: none; }
  body { background: white; }
}
