* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #f5f5f5; color: #111; }

/* ── LAYOUT ── */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px; background: #fff; border-right: 1px solid #e5e5e5;
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; height: 100vh;
  z-index: 200; transition: transform .25s ease;
}
.sidebar.collapsed { transform: translateX(-220px); }

.main {
  margin-left: 220px; padding: 1.5rem; flex: 1;
  transition: margin-left .25s ease; min-width: 0;
}
.main.full { margin-left: 0; }

/* Overlay for mobile */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.35); z-index: 150;
}
.sidebar-overlay.show { display: block; }

/* ── TOPBAR ── */
.topbar {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 1.25rem;
}
.toggle-btn {
  background: #fff; border: 1px solid #e5e5e5; border-radius: 8px;
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 18px; flex-shrink: 0; color: #555;
  transition: background .1s;
}
.toggle-btn:hover { background: #f5f5f5; }
.topbar-title { font-size: 18px; font-weight: 600; }

/* ── SIDEBAR BRAND ── */
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 1.1rem 1.25rem; border-bottom: 1px solid #e5e5e5;
  flex-shrink: 0;
}
.brand-icon { font-size: 22px; }
.brand-name { font-size: 15px; font-weight: 600; }
.brand-sub  { font-size: 11px; color: #888; }

.nav-section {
  font-size: 10px; font-weight: 600; color: #bbb;
  text-transform: uppercase; letter-spacing: .06em;
  padding: .65rem 1.25rem .2rem;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 1.25rem; font-size: 13px; color: #555;
  text-decoration: none; border-left: 2px solid transparent;
  transition: all .15s;
}
.nav-item:hover { background: #f5f5f5; color: #111; }
.nav-item.active { background: #EFF6FF; color: #1D4ED8; border-left-color: #1D4ED8; font-weight: 500; }
.nav-item .icon { font-size: 16px; }

.sidebar-footer {
  margin-top: auto; padding: 1rem 1.25rem;
  border-top: 1px solid #e5e5e5;
}
.logout-btn {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: #888; cursor: pointer;
  background: none; border: none; font-family: inherit;
  padding: 6px 0; width: 100%; transition: color .15s;
}
.logout-btn:hover { color: #dc2626; }

/* ── CARDS ── */
.card { background: #fff; border: 1px solid #e5e5e5; border-radius: 10px; padding: 1.25rem; margin-bottom: 1rem; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; gap: 8px; }
.card-title { font-size: 14px; font-weight: 600; }

/* ── METRICS ── */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 1.25rem; }
.metric { background: #fff; border: 1px solid #e5e5e5; border-radius: 10px; padding: .875rem 1rem; }
.metric-label { font-size: 11px; color: #888; margin-bottom: 4px; }
.metric-value { font-size: 26px; font-weight: 700; }
.metric-value.ok     { color: #16a34a; }
.metric-value.warn   { color: #d97706; }
.metric-value.danger { color: #dc2626; }

/* ── TABLE ── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 480px; }
th { text-align: left; font-size: 11px; font-weight: 600; color: #888; text-transform: uppercase; letter-spacing: .04em; padding: 0 10px 10px 0; border-bottom: 1px solid #e5e5e5; white-space: nowrap; }
td { padding: 10px 10px 10px 0; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
tr:last-child td { border-bottom: none; }

/* ── BADGES ── */
.badge { display: inline-block; padding: 3px 9px; border-radius: 100px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge-ok     { background: #dcfce7; color: #15803d; }
.badge-warn   { background: #fef9c3; color: #a16207; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-in     { background: #dcfce7; color: #15803d; }
.badge-out    { background: #fee2e2; color: #b91c1c; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; font-size: 13px;
  font-weight: 500; cursor: pointer; border: 1px solid #d1d5db;
  background: #fff; color: #374151; transition: all .1s;
  font-family: inherit; text-decoration: none; white-space: nowrap;
}
.btn:hover    { background: #f9fafb; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary  { background: #1D4ED8; color: #fff; border-color: #1D4ED8; }
.btn-primary:hover { background: #1e40af; }
.btn-green    { background: #16a34a; color: #fff; border-color: #16a34a; }
.btn-green:hover { background: #15803d; }
.btn-danger   { background: #fee2e2; color: #b91c1c; border-color: #fca5a5; }
.btn-danger:hover { background: #fecaca; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ── FORMS ── */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.form-group label { font-size: 12px; font-weight: 500; color: #555; }
.form-group input, .form-group select, .form-group textarea {
  padding: 9px 11px; border: 1px solid #d1d5db; border-radius: 8px;
  font-size: 14px; font-family: inherit; background: #fff; color: #111;
  outline: none; transition: border .15s; -webkit-appearance: none;
}
.form-group input:focus, .form-group select:focus { border-color: #1D4ED8; box-shadow: 0 0 0 3px #dbeafe; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── ALERT ── */
.alert { border-radius: 10px; padding: 1rem 1.25rem; margin-bottom: 1.25rem; }
.alert-danger  { background: #fff1f2; border: 1px solid #fca5a5; }
.alert-success { background: #f0fdf4; border: 1px solid #86efac; }
.alert-title   { font-size: 13px; font-weight: 600; color: #991b1b; margin-bottom: 8px; }
.alert-item    { font-size: 12px; color: #7f1d1d; padding: 3px 0; display: flex; justify-content: space-between; gap: 8px; }

/* ── TOAST ── */
#toast {
  position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%);
  background: #111; color: #fff; padding: 10px 20px; border-radius: 8px;
  font-size: 13px; font-weight: 500; opacity: 0; transition: opacity .3s;
  pointer-events: none; z-index: 999; white-space: nowrap;
}
#toast.show { opacity: 1; }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center; z-index: 300;
  padding: 1rem;
}
.modal { background: #fff; border-radius: 12px; padding: 1.5rem; width: 480px; max-width: 100%; max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; }
.modal-title  { font-size: 15px; font-weight: 600; }
.modal-close  { background: none; border: none; font-size: 22px; cursor: pointer; color: #888; line-height: 1; }

/* ── BAR CHART ── */
.bar-wrap { display: flex; align-items: center; gap: 8px; }
.bar-bg   { flex: 1; height: 6px; background: #f0f0f0; border-radius: 3px; overflow: hidden; min-width: 60px; }
.bar-fill { height: 100%; background: #1D4ED8; border-radius: 3px; }

/* ── LOADING / EMPTY ── */
.loading, .empty { text-align: center; padding: 2.5rem; color: #aaa; font-size: 14px; }

/* ── LOGIN PAGE ── */
.login-page {
  min-height: 100vh; display: flex; align-items: center;
  justify-content: center; background: #f5f5f5; padding: 1rem;
}
.login-card {
  background: #fff; border: 1px solid #e5e5e5; border-radius: 14px;
  padding: 2rem; width: 100%; max-width: 380px;
}
.login-brand { text-align: center; margin-bottom: 1.75rem; }
.login-brand .icon { font-size: 36px; }
.login-brand h1 { font-size: 20px; font-weight: 700; margin-top: 8px; }
.login-brand p  { font-size: 13px; color: #888; margin-top: 4px; }
.login-error { background: #fff1f2; border: 1px solid #fca5a5; color: #b91c1c; font-size: 13px; padding: 9px 12px; border-radius: 8px; margin-bottom: 14px; display: none; }

/* ── STOK FORM GRID ── */
.stok-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ── MOBILE ── */
@media (max-width: 640px) {
  .main { margin-left: 0; padding: 1rem; }
  .sidebar { transform: translateX(-220px); }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,.15); }
  .form-row { grid-template-columns: 1fr; }
  .stok-grid { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .topbar-title { font-size: 16px; }
}
@media (min-width: 641px) {
  .sidebar-overlay { display: none !important; }
  .main.full { margin-left: 0; }
  .sidebar.collapsed { transform: translateX(-220px); }
  .main:not(.full) { margin-left: 220px; }
}
