/* ==========================================================================
   ERP Syalis - Mobile-first Design System (Red/Black brand)
   ========================================================================== */

/* Atribut hidden harus menang atas display:flex/grid milik komponen -
   dipakai js/auth-guard.js untuk menyembunyikan menu yang tidak dibolehkan
   akun, dan tombol yang disembunyikan per hak akses di halaman lain. */
[hidden] { display: none !important; }

/* Dialog cadangan tautan bagikan (js/bagikan-tautan.js) */
.bagikan-tautan-ket { font-size: 0.78rem; color: var(--muted); margin: -4px 0 10px; }
.bagikan-tautan-url {
  width: 100%; box-sizing: border-box; padding: 10px 12px; margin-bottom: 12px;
  border: 1.5px solid #CBD0D8; border-radius: var(--radius-sm); background: var(--bg);
  font-family: inherit; font-size: 0.82rem; font-weight: 600; color: var(--ink); outline: none;
}

/* Tombol × kosongkan tanggal (dipasang js/pwa.js di sebelah input[type=date]) */
.tgl-hapus {
  flex: 0 0 auto; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(15, 23, 42, .08); color: var(--ink-soft); font-size: 1rem; line-height: 1; cursor: pointer;
}
.tgl-hapus:hover { background: var(--red); color: #fff; }

/* ---- Tombol tutup/hapus bundar yang isinya cuma tanda × ------------------
   Huruf × ikut garis dasar font, jadi di dalam lingkaran kecil selalu
   terlihat agak turun/miring - tidak pas di tengah. Di sini hurufnya
   disembunyikan (font-size 0) dan tandanya digambar sebagai ikon SVG
   (mask) seukuran tetap yang mengikuti warna tombol (currentColor), jadi
   persis di tengah lingkaran, apa pun font & ukurannya. Daftar kelas ini =
   semua tombol di ERP yang isinya hanya × (lihat js/*.js). */
.tgl-hapus, .impor-attach-remove, .stok-lightbox-tutup, .restock-img-hapus, .kalk-dim-x,
.free-settings-del, .aj-row-remove, .stok-riwayat-hapus, .skill-riwayat-x, .skill-berkas-tutup,
.restock-riwayat-del, .full-preview-x, .full-manual-hapus, .full-kotak-hapus, .free-list-btn--danger,
.dok-unggah-tutup {
  font-size: 0 !important;
  line-height: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-sizing: border-box;
}
.tgl-hapus::before, .impor-attach-remove::before, .stok-lightbox-tutup::before, .restock-img-hapus::before, .kalk-dim-x::before,
.free-settings-del::before, .aj-row-remove::before, .stok-riwayat-hapus::before, .skill-riwayat-x::before, .skill-berkas-tutup::before,
.restock-riwayat-del::before, .full-preview-x::before, .full-manual-hapus::before, .full-kotak-hapus::before, .free-list-btn--danger::before,
.dok-unggah-tutup::before {
  content: '';
  display: block;
  width: 45%;
  height: 45%;
  min-width: 8px; min-height: 8px;
  max-width: 14px; max-height: 14px;
  background-color: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round'%3E%3Cline x1='5' y1='5' x2='19' y2='19'/%3E%3Cline x1='19' y1='5' x2='5' y2='19'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round'%3E%3Cline x1='5' y1='5' x2='19' y2='19'/%3E%3Cline x1='19' y1='5' x2='5' y2='19'/%3E%3C/svg%3E") center / contain no-repeat;
}
/* display:inline-flex !important di atas tidak boleh mengalahkan [hidden]. */
.tgl-hapus[hidden], .impor-attach-remove[hidden], .stok-lightbox-tutup[hidden], .restock-img-hapus[hidden], .kalk-dim-x[hidden],
.free-settings-del[hidden], .aj-row-remove[hidden], .stok-riwayat-hapus[hidden], .skill-riwayat-x[hidden], .skill-berkas-tutup[hidden],
.restock-riwayat-del[hidden], .full-preview-x[hidden], .full-manual-hapus[hidden], .full-kotak-hapus[hidden], .free-list-btn--danger[hidden],
.dok-unggah-tutup[hidden] { display: none !important; }

:root {
  --red: #E4212B;
  --red-dark: #B8151D;
  --surface-dark: #1B2033;
  --ink: #16161B;
  --ink-soft: #55555F;
  --muted: #8C8C96;
  --bg: #FAFAFB;
  --card: #FFFFFF;
  --border: #ECECEF;

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 999px;

  --shadow-card: 0 1px 2px rgba(20,20,26,.05), 0 8px 20px -14px rgba(20,20,26,.18);
  --shadow-pop: 0 10px 24px -8px rgba(228,33,43,.28);

  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

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

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

/* On screens wider than the app card, dress up the side margins instead of
   leaving flat empty gray — a soft brand-colored glow, not a layout change. */
@media (min-width: 481px) {
  body {
    background:
      radial-gradient(760px 760px at -12% -8%, rgba(228,33,43,0.10), transparent 60%),
      radial-gradient(760px 760px at 112% 108%, rgba(17,17,17,0.06), transparent 60%),
      linear-gradient(180deg, #FFFBFB 0%, #F5F3F4 100%);
    background-attachment: fixed;
  }
}

a { text-decoration: none; color: inherit; }
input, textarea, select { font-family: inherit; }
button { font: inherit; border: none; background: none; }
svg { display: block; }

/* ==========================================================================
   App shell — mobile-first, centers as a phone-width column on larger screens
   ========================================================================== */
.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
}

@media (min-width: 481px) {
  .app {
    min-height: 100vh;
    box-shadow: 0 0 0 1px var(--border), 0 30px 80px -30px rgba(20,20,26,0.16);
  }
}

/* ==========================================================================
   Top App Bar
   ========================================================================== */
.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(14px + var(--safe-top)) 18px 14px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

/* Tata letak HP: kop atas hanya ada di Beranda.

   Di halaman dalam, isi kop itu tinggal logo, tombol Instal Aplikasi, dan
   avatar - tidak satu pun berhubungan dengan pekerjaan yang sedang dibuka,
   sementara ia memakan sekitar 67px tinggi layar di SETIAP halaman. Beranda
   tetap memakainya: di sanalah tempatnya memperkenalkan aplikasi.

   Ditandai lewat kelas di <body>, bukan lewat ada-tidaknya .appbar-back:
   menyembunyikan induk dari anaknya perlu :has(), dan menandainya lewat
   JavaScript berarti kopnya sempat berkedip dulu sebelum hilang.

   --safe-top ikut dipindahkan ke .app. Kop inilah SATU-SATUNYA yang menahan
   isi halaman supaya tidak masuk ke bawah poni layar (lihat padding
   .appbar di atas), jadi begitu ia disembunyikan penahannya harus ada yang
   menggantikan - kalau tidak, di HP berponi judul halaman tertimpa jam dan
   ikon sinyal. */
.halaman-dalam .appbar { display: none; }
.halaman-dalam .app { padding-top: var(--safe-top); }

/* Sits first in the app bar, filling the gap the brand block leaves behind
   once it's hidden on desktop. Only sub-pages carry one — Beranda has
   nowhere to go back to. */
.appbar-back {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--ink-soft);
  cursor: pointer;
}

.appbar-back svg {
  width: 18px;
  height: 18px;
}

.appbar-back:hover {
  border-color: var(--red);
  color: var(--red);
  background: #FDEBEC;
}

.appbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 44px;
  height: auto;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-name {
  font-size: 1.02rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.appbar-search {
  display: none;
}

.appbar-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.appbar-date,
.appbar-bell {
  display: none;
}

/* Install button — visible at every width (unlike .appbar-date/.appbar-bell),
   kept deliberately small so it doesn't crowd the mobile header. */
.appbar-install {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: var(--radius-full);
  background: #17803D;
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.appbar-user {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.appbar-avatar {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface-dark);
  color: #fff;
  font-size: 0.74rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.appbar-user-text {
  display: none;
  flex-direction: column;
  text-align: left;
}

.appbar-user-text strong {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--ink);
}

.appbar-user-text small {
  font-size: 0.68rem;
  color: var(--muted);
  font-weight: 600;
}

/* ==========================================================================
   Sidebar Navigation (desktop/web)
   ========================================================================== */
.sidebar {
  display: none;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 20px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}

.sidebar-brand-mark {
  flex-shrink: 0;
  width: 42px;
  height: 32px;
  background: #fff;
  border-radius: 8px;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-brand-mark img {
  width: 100%;
  height: auto;
}

.sidebar .brand-name {
  color: #fff;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-nav-label {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255,255,255,.38);
  padding: 16px 10px 6px;
}

.sidebar-nav-label:first-child {
  padding-top: 4px;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: rgba(255,255,255,.68);
  font-size: 0.85rem;
  font-weight: 600;
  transition: background-color .15s ease, color .15s ease;
}

.sidebar-nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-nav-item:hover {
  background: rgba(255,255,255,.06);
  color: #fff;
}

.sidebar-nav-item.active {
  background: var(--red);
  color: #fff;
  font-weight: 700;
}

/* Sub-links for a nav item's own section (currently just Laporan
   Keuangan) — hidden unless that item is the active one, so the sidebar
   reveals Omset Bulanan/Laba Rugi/etc. once you're inside that section,
   instead of listing every page's sub-tree all the time. */
.sidebar-nav-sub {
  display: none;
  flex-direction: column;
  gap: 1px;
  padding: 2px 0 6px 34px;
}

.sidebar-nav-sub.open {
  display: flex;
}

.sidebar-nav-subitem {
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.5);
  font-size: 0.78rem;
  font-weight: 600;
}

.sidebar-nav-subitem:hover {
  background: rgba(255,255,255,.06);
  color: #fff;
}

.sidebar-nav-subitem.active {
  color: #fff;
  font-weight: 800;
}

.app-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

/* ==========================================================================
   Main Content
   ========================================================================== */
.content {
  flex: 1;
  width: 100%;
  padding: 20px 18px calc(96px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* Greeting */
.greeting {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #17803D;
  background: #E8F8EE;
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22B356;
  display: inline-block;
}

.greeting h1 {
  font-size: 1.36rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.greeting p {
  font-size: 0.86rem;
  color: var(--ink-soft);
  max-width: 46ch;
}

/* Section heading */
.section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.section-head h2 {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink);
}

/* ==========================================================================
   Priority cards (Laporan Impor / Restock / Barang PO)
   ========================================================================== */
.priority-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.priority-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  box-shadow: var(--shadow-card);
  transition: transform .15s ease, box-shadow .15s ease;
}

.priority-card:active {
  transform: scale(0.98);
}

.priority-icon {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 14px -6px rgba(20,20,26,.35);
}

.priority-icon svg {
  width: 26px;
  height: 26px;
}

/* Module accent colors — each module gets its own hue so the icon set reads
   varied and eye-catching instead of one flat monotone chip. */
.priority-icon svg,
.menu-icon svg {
  stroke-width: 2.3;
}

.icon-red { background: #E4212B; }
.icon-amber { background: #D97706; }
.icon-violet { background: #7C3AED; }
.icon-indigo { background: #4F46E5; }
.icon-emerald { background: #059669; }
.icon-teal { background: #0D9488; }
.icon-sky { background: #0284C7; }
.icon-terracotta { background: #B45309; }
.icon-rose { background: #DB2777; }

.priority-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.priority-title {
  font-size: 0.96rem;
  font-weight: 800;
  color: var(--ink);
}

.priority-desc {
  font-size: 0.76rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.priority-count {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--red);
  line-height: 1.1;
}

.priority-count em {
  font-style: normal;
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* First priority card gets a little extra emphasis */
.priority-stack .priority-card:first-child {
  border-color: rgba(228,33,43,.18);
  box-shadow: var(--shadow-pop);
}

/* ==========================================================================
   Secondary module grid
   ========================================================================== */
.menu-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.menu-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 6px;
  box-shadow: var(--shadow-card);
  transition: transform .15s ease;
}

.menu-tile:active {
  transform: scale(0.96);
}

.menu-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 14px -6px rgba(20,20,26,.3);
}

.menu-icon svg {
  width: 20px;
  height: 20px;
}

.menu-tile > span:not(.menu-icon):not(.erp-menu-badge) {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--ink-soft);
  line-height: 1.25;
}

/* ==========================================================================
   Mode aplikasi satu menu (js/aplikasi-menu.js): halaman dipasang sebagai
   aplikasi tersendiri, cakupannya cuma halaman ini. Bilah bawah - isinya
   tautan ke halaman lain - disembunyikan, dan ruang kosong yang tadinya
   disisakan untuknya di bawah isi dikembalikan.
   ========================================================================== */
html.aplikasi-menu .bottom-nav { display: none; }
html.aplikasi-menu .content { padding-bottom: calc(24px + var(--safe-bottom)); }

/* ==========================================================================
   Bottom navigation
   ========================================================================== */
.bottom-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 480px;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 8px 6px calc(8px + var(--safe-bottom));
  z-index: 30;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 0;
  color: var(--muted);
  border-radius: var(--radius-sm);
}

.nav-item svg {
  width: 21px;
  height: 21px;
}

.nav-item span {
  font-size: 0.62rem;
  font-weight: 700;
}

.nav-item.active {
  color: var(--red);
}

/* ==========================================================================
   Small-phone tightening
   ========================================================================== */
@media (max-width: 360px) {
  .content { padding-left: 14px; padding-right: 14px; }
  .menu-grid { gap: 8px; }
}

/* ==========================================================================
   Wider viewports: give the priority cards a little breathing room
   ========================================================================== */
@media (min-width: 481px) {
  .content { padding-top: 26px; }
}

/* ==========================================================================
   Desktop / tablet-landscape — a real proportional layout, not a stretched
   phone. Content reflows into rows/columns and the phone-frame cap is
   dropped; navigation moves into the header instead of a thumb-reach bar.
   ========================================================================== */
@media (min-width: 860px) {
  .app {
    max-width: none;
    box-shadow: none;
    flex-direction: row;
    align-items: stretch;
  }

  .sidebar {
    display: flex;
    flex-direction: column;
    width: 264px;
    flex-shrink: 0;
    background: var(--surface-dark);
    padding: 20px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
  }

  .appbar {
    padding: 14px 32px;
    gap: 20px;
  }

  /* Di sini kopnya berisi kolom cari, tanggal, lonceng, dan avatar - dan
     ruang vertikal bukan barang langka - jadi ia dikembalikan. */
  .halaman-dalam .appbar {
    display: flex;
  }

  .halaman-dalam .app {
    padding-top: 0;
  }

  .appbar-brand {
    display: none;
  }

  .appbar-search {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    max-width: 360px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: 9px 16px;
    color: var(--muted);
  }

  .appbar-search svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
  }

  .appbar-search input {
    border: none;
    background: none;
    outline: none;
    width: 100%;
    font: inherit;
    color: var(--ink);
  }

  .appbar-install {
    padding: 7px 14px;
    font-size: 0.72rem;
  }

  .appbar-date {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--ink-soft);
    white-space: nowrap;
  }

  .appbar-date svg {
    width: 15px;
    height: 15px;
  }

  .appbar-bell {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid var(--border);
    color: var(--ink-soft);
  }

  .appbar-bell svg {
    width: 18px;
    height: 18px;
  }

  .bell-dot {
    position: absolute;
    top: 8px;
    right: 9px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--red);
    border: 2px solid var(--card);
  }

  .appbar-user-text {
    display: flex;
  }

  .content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px 32px 56px;
    gap: 36px;
  }

  .greeting h1 {
    font-size: 1.7rem;
  }

  .priority-stack {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }

  .priority-card {
    align-items: flex-start;
    flex-direction: column;
    gap: 16px;
    padding: 20px;
  }

  .priority-icon {
    width: 56px;
    height: 56px;
  }

  .priority-count {
    align-items: flex-start;
    flex-direction: row;
    gap: 5px;
    align-self: stretch;
    justify-content: space-between;
  }

  .priority-count em {
    align-self: flex-end;
  }

  .menu-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
  }

  .menu-tile {
    padding: 22px 10px;
  }

  .menu-icon {
    width: 46px;
    height: 46px;
  }

  .bottom-nav {
    display: none;
  }
}
