:root {
  --color-bg: #f4f6f5;
  --color-surface: #ffffff;
  --color-text: #1a2e22;
  --color-muted: #5c6f64;
  --color-border: #dde5e0;
  --color-primary: #1f7a4d;
  --color-primary-dark: #185f3c;
  --color-danger: #b3261e;
  --color-warning: #8a5a00;
  --color-warning-bg: #fff4dd;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(20, 40, 30, 0.08), 0 1px 2px rgba(20, 40, 30, 0.06);
  font-size: 18px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  line-height: 1.45;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--color-bg);
  display: flex;
  flex-direction: column;
}

/* Tablet (iPad, dsb.) dan desktop: lebar konten mengikuti layar, kartu bisa
   bersebelahan lewat grid di .app-main, supaya layar lebar tidak sia-sia
   jadi kolom sempit di tengah. Tampilan HP (di bawah 720px) tidak berubah. */
@media (min-width: 720px) {
  .app {
    max-width: 760px;
  }
}

@media (min-width: 1100px) {
  .app {
    max-width: 1080px;
  }
}

.app-header {
  background: var(--color-primary);
  color: #fff;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header h1 {
  font-size: 20px;
  margin: 0;
  font-weight: 700;
}

.app-header .subtitle {
  font-size: 13px;
  opacity: 0.85;
  margin-top: 2px;
}

.app-header .back-link {
  color: #fff;
  text-decoration: none;
  font-size: 24px;
  line-height: 1;
  padding: 4px 8px;
  margin: -4px -8px;
}

.app-main {
  flex: 1;
  padding: 20px 16px 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

@media (min-width: 720px) {
  .app-main {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    align-items: start;
    padding: 24px 24px 40px;
    gap: 18px;
  }

  /* Kartu yang isinya daftar panjang (riwayat, stok, dll) atau kontrol
     halaman (pilih cabang) lebih enak selebar layar, bukan ikut kepotong kolom. */
  .card-full {
    grid-column: 1 / -1;
  }
}

@media (min-width: 1100px) {
  .app-main {
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 20px;
  }
}

.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.card h2 {
  margin: 0 0 12px;
  font-size: 17px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field:last-child {
  margin-bottom: 0;
}

.field label {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-muted);
}

input, select, textarea {
  font-size: 18px;
  padding: 14px;
  border-radius: 10px;
  border: 1.5px solid var(--color-border);
  background: #fff;
  color: var(--color-text);
  font-family: inherit;
  width: 100%;
}

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

.btn {
  display: block;
  width: 100%;
  font-size: 18px;
  font-weight: 700;
  padding: 16px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  color: #fff;
  background: var(--color-primary);
  transition: background 0.15s ease;
}

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

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-primary);
  border: 1.5px solid var(--color-primary);
}

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

.btn-block-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

@media (min-width: 720px) {
  .menu-grid {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1100px) {
  .menu-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.menu-tile {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 14px;
  text-decoration: none;
  color: var(--color-text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  font-weight: 700;
  font-size: 15px;
  min-height: 96px;
  justify-content: center;
}

.menu-tile .icon {
  font-size: 28px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
}

.stat-row:last-child {
  border-bottom: none;
}

.stat-row .label {
  color: var(--color-muted);
  font-size: 15px;
}

.stat-row .value {
  font-size: 18px;
  font-weight: 700;
}

.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
}

.banner.online {
  background: #e4f4ea;
  color: var(--color-primary-dark);
}

.banner.offline {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.status-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  max-width: 480px;
  margin: 0 auto;
}

@media (min-width: 720px) {
  .status-bar {
    max-width: 760px;
  }
}

@media (min-width: 1100px) {
  .status-bar {
    max-width: 1080px;
  }
}

.status-bar.online {
  background: #e4f4ea;
  color: var(--color-primary-dark);
}

.status-bar.offline {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.status-bar.status-bar-quiet {
  padding-top: 4px;
  padding-bottom: 4px;
  font-size: 12px;
  opacity: 0.85;
}

.status-bar button {
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #1a2e22;
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 15px;
  max-width: 90vw;
  text-align: center;
  z-index: 100;
  box-shadow: var(--shadow);
}

.toast.error {
  background: var(--color-danger);
}

.error-text {
  color: var(--color-danger);
  font-size: 14px;
  font-weight: 600;
}

.muted {
  color: var(--color-muted);
  font-size: 14px;
}

.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--color-muted);
}

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
  gap: 12px;
}

.list-item:last-child {
  border-bottom: none;
}

.list-item .name {
  font-weight: 700;
}

.list-item .meta {
  color: var(--color-muted);
  font-size: 13px;
}

.centered-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
