:root {
  --bg: #eef2f7;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #0f4c81;
  --primary-hover: #0b3a63;
  --accent: #1d9bb8;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --sidebar-w: 270px;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.07);
  --radius: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "DM Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; }
.hidden { display: none !important; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.btn {
  border: 0;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s ease;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-soft { background: var(--danger-soft); color: var(--danger); border: 1px solid #fecaca; }
.btn-block { width: 100%; }
.btn-icon {
  width: 42px; height: 42px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn-sm { padding: 7px 11px; font-size: 13px; }

.muted { color: var(--muted); }
.eyebrow {
  margin: 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
}
.error-text { color: var(--danger); font-size: 14px; margin: 8px 0 0; }

/* ========== LOGIN ========== */
.view-login {
  display: none;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 4vw, 40px);
  background:
    linear-gradient(160deg, #0f4c81 0%, #136a9e 45%, #1d9bb8 100%);
}
.view-login.active { display: flex; }

.login-shell {
  width: 100%;
  max-width: 420px;
  display: grid;
  gap: 20px;
}

.login-brand { text-align: center; color: #fff; }
.logo-mark {
  width: 58px; height: 58px; margin: 0 auto 12px;
  border-radius: 16px;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.28);
  color: #fff; font-weight: 700; font-size: 20px;
  display: grid; place-items: center;
  backdrop-filter: blur(6px);
}
.logo-mark.sm {
  width: 42px; height: 42px; margin: 0;
  font-size: 14px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border: 0;
}
.login-brand h1 { margin: 0 0 6px; font-size: clamp(24px, 5vw, 30px); }
.company-name {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: #bfe8f3;
}
.login-brand > p:last-child { margin: 0; opacity: 0.9; }

.login-card { padding: clamp(18px, 4vw, 28px); }
.login-card h2 { margin: 0 0 16px; font-size: 20px; }
.login-card label,
.modal label,
.upload-drawer label {
  display: block; font-size: 13px; font-weight: 600; margin: 0 0 6px; color: var(--muted);
}
.login-card input,
.modal input,
.modal textarea,
.modal select,
.upload-drawer input,
.upload-drawer textarea,
.filter-group input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  appearance: none;
  -webkit-appearance: none;
}
.modal select {
  padding-right: 40px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 3px),
    calc(100% - 12px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  cursor: pointer;
}
.login-card input:focus,
.modal input:focus,
.modal textarea:focus,
.modal select:focus,
.filter-group input:focus,
.search-wrap:focus-within {
  outline: 2px solid rgba(15, 76, 129, 0.18);
  border-color: var(--primary);
}
.login-card .btn { margin-top: 16px; }

/* ========== APP SHELL ========== */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: #0b2f4d;
  color: #e8f1f8;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  z-index: 40;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-brand .company-name { color: #8ec8de; }
.sidebar-brand strong { display: block; font-size: 14px; }

.sidebar-nav, .sidebar-admin { display: grid; gap: 6px; margin-top: 16px; }
.sidebar-section {
  margin: 8px 8px 4px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #7fb5cb;
  font-weight: 700;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #c9dde9;
  text-align: left;
  cursor: pointer;
  font-weight: 600;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: rgba(29, 155, 184, 0.25); color: #fff; }

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
  display: grid;
  gap: 10px;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
}
.user-avatar {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 700;
}
.user-chip strong { display: block; font-size: 14px; }
.user-chip small { color: #9ec3d5; }
.sidebar-footer .btn-ghost {
  color: #d7e8f1;
  border-color: rgba(255,255,255,0.18);
}
.sidebar-footer .btn-ghost:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}

.main-area {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.mobile-bar {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 25;
}
.mobile-bar-title strong { display: block; font-size: 15px; }

.content {
  padding: clamp(16px, 2.5vw, 28px);
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
}

.page { display: none; }
.page.active { display: block; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.page-header h1 {
  margin: 4px 0 0;
  font-size: clamp(22px, 3.5vw, 30px);
  line-height: 1.2;
}
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.toolbar { padding: 14px; margin-bottom: 18px; }
.search-wrap {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; background: #fff;
}
.search-wrap input {
  border: 0; outline: none; width: 100%; background: transparent;
}
#outletCount { margin: 10px 0 0; font-size: 14px; }

.outlet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr));
  gap: 14px;
}
.outlet-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 130px;
}
.outlet-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: #9fd0e3;
}
.outlet-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.outlet-code {
  display: inline-block;
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em;
  color: var(--primary); background: #e8f3fa;
  padding: 4px 8px; border-radius: 999px;
}
.outlet-card h3 { margin: 0; font-size: 16px; line-height: 1.35; }
.outlet-meta { margin: 0; font-size: 13px; color: var(--muted); margin-top: auto; }
.outlet-delete {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
  line-height: 0;
}
.outlet-delete:hover { background: var(--danger-soft); color: var(--danger); }

.filter-bar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
  gap: 12px;
  align-items: end;
}
.filter-group label {
  display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px;
}
.filter-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.media-stats { margin-bottom: 14px; font-size: 14px; }

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  gap: 16px;
}
.media-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.05);
}
.media-preview {
  aspect-ratio: 4 / 3;
  background: #0f172a;
  display: grid; place-items: center;
  overflow: hidden;
  position: relative;
  cursor: pointer;
}
.media-preview img,
.media-preview video {
  width: 100%; height: 100%; object-fit: cover;
  pointer-events: none;
}
/* Video / thumbnail video: tampil utuh, tidak di-crop / stretch */
.media-preview.is-video {
  aspect-ratio: auto;
  min-height: 180px;
  max-height: 320px;
}
.media-preview.is-video img,
.media-preview.is-video video {
  width: 100%;
  height: auto;
  max-height: 320px;
  object-fit: contain;
  background: #0f172a;
}
.media-preview .placeholder {
  color: #94a3b8; font-size: 13px; padding: 16px; text-align: center;
}
.media-preview-overlay {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: linear-gradient(to top, rgba(15, 23, 42, 0.55), transparent 45%);
  opacity: 0;
  transition: opacity 0.18s ease;
  pointer-events: none;
}
.media-card:hover .media-preview-overlay,
.media-preview:focus-visible .media-preview-overlay {
  opacity: 1;
}
.media-preview-play {
  width: 52px; height: 52px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: var(--primary);
  display: grid; place-items: center;
  font-size: 22px; line-height: 1;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}
.media-preview-hint {
  position: absolute; left: 12px; bottom: 10px; right: 12px;
  color: #fff; font-size: 12px; font-weight: 600;
  text-align: center;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

/* Media lightbox viewer */
.media-viewer {
  position: fixed; inset: 0; z-index: 80;
  display: grid; place-items: center;
  padding: 16px;
}
.media-viewer-backdrop {
  position: absolute; inset: 0;
  background: rgba(8, 15, 28, 0.88);
  backdrop-filter: blur(4px);
}
.media-viewer-shell {
  position: relative;
  width: min(960px, 100%);
  max-height: min(92vh, 900px);
  display: flex;
  flex-direction: column;
  background: #0b1220;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
  animation: uploadDrawerIn 0.2s ease;
}
.media-viewer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(15, 23, 42, 0.9);
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
}
.media-viewer-top-info {
  display: flex; align-items: center; gap: 10px; min-width: 0;
}
.media-viewer-counter { font-size: 13px; }
.media-viewer-top-actions {
  display: flex; align-items: center; gap: 8px;
}
.media-viewer-top-actions .btn-ghost {
  color: #e2e8f0;
  border-color: rgba(148, 163, 184, 0.3);
}
.media-viewer-top-actions .btn-ghost:hover:not(:disabled) {
  background: rgba(148, 163, 184, 0.15);
  color: #fff;
}
.media-viewer-close { font-size: 26px; line-height: 1; color: #e2e8f0; }
.media-viewer-stage {
  position: relative;
  flex: 1;
  min-height: 280px;
  display: grid;
  place-items: center;
  background: #020617;
}
.media-viewer-content {
  width: 100%;
  height: min(62vh, 620px);
  display: grid;
  place-items: center;
  padding: 12px;
}
.media-viewer-content img,
.media-viewer-content video {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  background: #000;
}
.media-viewer-content video {
  /* Ikuti rasio asli video — jangan force full width */
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
}
.media-viewer-loading {
  text-align: center;
  color: #94a3b8;
}
.media-viewer-loading .spinner { border-color: #334155; border-top-color: var(--accent); }
.media-viewer-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px; height: 44px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.75);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
  transition: background 0.15s ease, opacity 0.15s ease;
}
.media-viewer-nav:hover:not(:disabled) { background: rgba(29, 155, 184, 0.85); }
.media-viewer-nav:disabled { opacity: 0.35; cursor: not-allowed; }
.media-viewer-prev { left: 10px; }
.media-viewer-next { right: 10px; }
.media-viewer-meta {
  padding: 14px 16px 16px;
  background: rgba(15, 23, 42, 0.95);
  border-top: 1px solid rgba(148, 163, 184, 0.15);
}
.media-viewer-comment {
  margin: 0 0 6px;
  color: #f8fafc;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.45;
  word-break: break-word;
}
.media-viewer-details {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
}

@media (max-width: 560px) {
  .media-viewer { padding: 0; }
  .media-viewer-shell {
    width: 100%;
    max-height: 100vh;
    height: 100%;
    border-radius: 0;
  }
  .media-viewer-content { height: min(58vh, 520px); }
  .media-viewer-nav { width: 38px; height: 38px; font-size: 24px; }
  .media-preview-overlay { opacity: 1; background: linear-gradient(to top, rgba(15, 23, 42, 0.45), transparent 40%); }
}
.media-body { padding: 14px 16px 16px; }
.media-date {
  font-size: 12px; color: var(--muted); margin-bottom: 8px;
  display: flex; justify-content: space-between; gap: 8px;
}
.media-comment {
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
  font-weight: 500;
  word-break: break-word;
}
.media-actions {
  display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap;
}

.empty-state, .loading-state {
  text-align: center; padding: 48px 20px; color: var(--muted);
}
.empty-state h3 { margin: 0 0 6px; color: var(--text); }
.spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid #dbeafe; border-top-color: var(--primary);
  animation: spin 0.8s linear infinite; margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.upload-panel { position: fixed; right: 20px; bottom: 20px; z-index: 30; }
.fab {
  width: 56px; height: 56px; border-radius: 50%; border: 0;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff; font-size: 28px; line-height: 1; cursor: pointer;
  box-shadow: 0 12px 24px rgba(15, 76, 129, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: grid; place-items: center;
}
.fab:hover { transform: scale(1.04); box-shadow: 0 14px 28px rgba(15, 76, 129, 0.4); }
.fab-icon { display: block; line-height: 1; }
.fab-icon-close { font-size: 32px; font-weight: 300; }
.upload-drawer {
  position: absolute; right: 0; bottom: 68px; width: min(380px, calc(100vw - 40px));
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  animation: uploadDrawerIn 0.22s ease;
}
@keyframes uploadDrawerIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.upload-drawer-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.upload-drawer-header h3 { margin: 0 0 4px; font-size: 18px; }
.upload-drawer-header .field-hint { margin: 0; }
.upload-close { flex-shrink: 0; font-size: 22px; line-height: 1; }

.upload-file-input {
  position: absolute; width: 0; height: 0; opacity: 0; pointer-events: none;
}
.upload-dropzone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: 22px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  margin-bottom: 14px;
}
.upload-dropzone:hover,
.upload-dropzone:focus-visible {
  border-color: var(--accent);
  background: #f0f9ff;
  outline: none;
  box-shadow: 0 0 0 3px rgba(29, 155, 184, 0.12);
}
.upload-dropzone.dragover {
  border-color: var(--primary);
  background: #eff6ff;
  box-shadow: 0 0 0 3px rgba(15, 76, 129, 0.15);
}
.upload-dropzone-icon {
  color: var(--accent);
  margin-bottom: 10px;
  display: flex; justify-content: center;
}
.upload-dropzone-title {
  margin: 0 0 4px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}
.upload-dropzone-sub {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--muted);
}
.upload-dropzone-link {
  color: var(--primary);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.upload-dropzone-formats {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}

.upload-preview {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 14px;
  background: var(--surface-2);
}
.upload-preview-media {
  aspect-ratio: 16 / 9;
  background: #0f172a;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.upload-preview-media img,
.upload-preview-media video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.upload-preview-info {
  padding: 12px 14px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.upload-preview-name {
  margin: 4px 0 0;
  font-size: 14px;
  font-weight: 600;
  word-break: break-all;
  line-height: 1.35;
}
.upload-preview-meta { margin: 0; font-size: 12px; }
.upload-type-badge {
  align-self: flex-start;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 999px;
}
.upload-type-badge.image { background: #dbeafe; color: #1d4ed8; }
.upload-type-badge.video { background: #fce7f3; color: #be185d; }
.upload-clear-btn { margin: 10px 14px 12px; width: calc(100% - 28px); }

.upload-drawer label { margin-top: 2px; }
.upload-drawer textarea { resize: vertical; min-height: 72px; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45);
  display: grid; place-items: center; z-index: 60; padding: 16px;
}
.modal {
  width: min(480px, 100%);
  padding: 22px;
  max-height: min(90vh, 720px);
  overflow: auto;
}
.modal h3 { margin: 0 0 16px; font-size: 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.field-hint { margin: 6px 0 0; font-size: 12px; color: var(--muted); line-height: 1.4; }

.form-grid {
  display: grid;
  gap: 14px;
}
.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.field-group {
  display: grid;
  gap: 6px;
}
.field-group.full { grid-column: 1 / -1; }

.role-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.role-card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 10px;
  text-align: center;
  cursor: pointer;
  background: #fff;
  transition: 0.15s ease;
}
.role-card:hover { border-color: #9fd0e3; }
.role-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.role-card strong {
  display: block;
  font-size: 13px;
  margin-bottom: 2px;
}
.role-card small {
  display: block;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.3;
}
.role-card:has(input:checked) {
  border-color: var(--primary);
  background: #eaf4fb;
  box-shadow: inset 0 0 0 1px var(--primary);
}

.outlet-picker {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}
.outlet-picker-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.outlet-picker-search input {
  border: 0 !important;
  outline: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  background: transparent !important;
}
.outlet-picker select {
  border: 0 !important;
  border-radius: 0 !important;
  min-height: 180px;
  padding: 8px !important;
  background-image: none !important;
}
.outlet-picker select option {
  padding: 10px 12px;
  border-radius: 8px;
  margin: 2px 0;
}
.outlet-picker select option:checked {
  background: linear-gradient(#eaf4fb, #eaf4fb);
  color: var(--text);
}
.outlet-picker-meta {
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  background: var(--surface-2);
}

@media (max-width: 560px) {
  .form-row-2,
  .role-cards {
    grid-template-columns: 1fr;
  }
  .outlet-picker select {
    min-height: 140px;
  }
}

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 35;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .mobile-bar { display: flex; }

  .sidebar {
    position: fixed;
    left: 0; top: 0;
    width: min(var(--sidebar-w), 86vw);
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: 8px 0 30px rgba(0,0,0,0.2);
  }
  .app-shell.sidebar-open .sidebar {
    transform: translateX(0);
  }
  .app-shell.sidebar-open .sidebar-overlay {
    display: block;
  }

  .filter-bar {
    grid-template-columns: 1fr;
  }
  .filter-actions .btn { flex: 1; }
}

@media (max-width: 560px) {
  .content { padding: 14px; }
  .page-header { flex-direction: column; align-items: stretch; }
  .page-actions .btn, #addOutletBtn { width: 100%; }
  .media-actions .btn { flex: 1; }
  .outlet-grid { grid-template-columns: 1fr; }
  .upload-panel { right: 14px; bottom: 14px; }
  .upload-drawer {
    width: calc(100vw - 28px);
    max-height: calc(100vh - 100px);
    overflow-y: auto;
  }
}

@media (min-width: 1400px) {
  .content { max-width: 1400px; }
}

/* Toast */
.toast-host {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100;
  display: grid;
  gap: 8px;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: #0f172a;
  color: #fff;
  padding: 12px 14px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  font-size: 14px;
  animation: toast-in 0.2s ease;
}
.toast.success { background: #065f46; }
.toast.error { background: #991b1b; }
.toast.info { background: #0f4c81; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Stats / panels */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.stat-card strong { display: block; font-size: 28px; margin-top: 4px; }
.stat-card span { color: var(--muted); font-size: 13px; font-weight: 600; }
.stat-card .stat-sub {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}
.panel { padding: 16px; margin-bottom: 16px; }
.panel h3 { margin: 0 0 4px; font-size: 16px; }
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.panel-head .field-hint { margin: 0; }
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: #e8f3fa;
  color: var(--primary);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
}
.chip.chip-click {
  border: 0;
  cursor: pointer;
  font: inherit;
}
.chip.chip-click:hover { background: #d5ebf7; }

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 16px;
  margin-bottom: 0;
}
.dashboard-grid > .panel { margin-bottom: 16px; }

.trend-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}
.lg-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
.lg-dot.total { background: var(--primary); }
.lg-dot.image { background: #38bdf8; }
.lg-dot.video { background: #ec4899; }

.trend-chart {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
  min-height: 220px;
  padding: 8px 0 0;
}
.trend-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.trend-bars {
  width: 100%;
  height: 160px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  padding: 0 2px;
}
.trend-bar {
  width: 28%;
  max-width: 14px;
  min-height: 2px;
  border-radius: 6px 6px 2px 2px;
  transition: height 0.25s ease;
}
.trend-bar.total { background: linear-gradient(180deg, var(--accent), var(--primary)); }
.trend-bar.image { background: #38bdf8; }
.trend-bar.video { background: #ec4899; }
.trend-count {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.trend-col.is-today .trend-count { color: var(--primary); }
.trend-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  text-align: center;
  line-height: 1.25;
}
.trend-col.is-today .trend-label { color: var(--primary); }
.trend-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  padding: 40px 12px;
}

.rank-list { display: grid; gap: 10px; }
.rank-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}
.rank-num {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  display: grid; place-items: center;
}
.rank-row.top-1 .rank-num { background: #fef3c7; color: #b45309; }
.rank-row.top-2 .rank-num { background: #e2e8f0; color: #475569; }
.rank-row.top-3 .rank-num { background: #ffedd5; color: #c2410c; }
.rank-info { min-width: 0; }
.rank-name {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rank-code { margin: 2px 0 0; font-size: 11px; color: var(--muted); }
.rank-bar-wrap {
  height: 6px;
  background: #e2e8f0;
  border-radius: 999px;
  margin-top: 6px;
  overflow: hidden;
}
.rank-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}
.rank-count {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}
.rank-count small {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-align: right;
}

@media (max-width: 980px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}

.log-list { display: grid; gap: 10px; }
.log-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.log-item:last-child { border-bottom: 0; }
.log-meta { color: var(--muted); font-size: 12px; margin-top: 4px; }

.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}
.seg {
  border: 0;
  background: transparent;
  padding: 9px 12px;
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
}
.seg.active { background: var(--primary); color: #fff; }

.progress-wrap { margin-top: 14px; }
.progress-bar {
  height: 10px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.15s ease;
  border-radius: 999px;
}
.upload-drawer .progress-wrap p { margin: 6px 0 0; font-size: 13px; }
.upload-drawer #uploadSubmit { margin-top: 12px; }
.load-more-wrap { display: flex; justify-content: center; margin: 16px 0 8px; }

.table-wrap { overflow: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.table th, .table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.file-nav { cursor: pointer; }
.badge-soft {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: #ecfdf5;
  color: #047857;
}
.badge-soft.off { background: #fef2f2; color: #b91c1c; }

@media (max-width: 980px) {
  .filter-bar { grid-template-columns: 1fr; }
}
