/* ==========================================================================
   Partywalas Sales Intelligence — design system
   Brand: hot pink + charcoal, taken from the Partywalas mark.
   ========================================================================== */

:root {
  --brand: #d6248c;
  --brand-bright: #ff63c4;
  --brand-soft: #fdf0f8;
  --brand-border: #f6cee6;

  --ink: #1c1f26;
  --ink-2: #2b303b;
  --text: #1f2430;
  --muted: #6b7280;
  --muted-2: #9aa1ad;

  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #fbfbfc;
  --border: #e5e7eb;
  --border-strong: #d5d8de;

  --good: #0e9f6e;
  --good-soft: #e8f7f1;
  --warn: #b45309;
  --warn-soft: #fdf3e4;
  --bad: #c92a3d;
  --bad-soft: #fdeef0;
  --info: #2563eb;
  --info-soft: #eef3fe;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(16, 20, 30, .06);
  --shadow: 0 1px 3px rgba(16, 20, 30, .08), 0 6px 18px -8px rgba(16, 20, 30, .12);
  --shadow-lg: 0 12px 40px -12px rgba(16, 20, 30, .28);

  --sidebar-w: 236px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.012em; color: var(--ink); }
h1 { font-size: 21px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0 0 10px; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- Layout */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--ink);
  color: #cfd4dd;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.sidebar__brand img { width: 34px; height: 34px; object-fit: contain; background: #fff; border-radius: 7px; padding: 3px; }
.sidebar__brand-name { color: #fff; font-weight: 680; font-size: 14px; letter-spacing: -.01em; line-height: 1.2; }
.sidebar__brand-sub { font-size: 11px; color: #8d95a3; letter-spacing: .02em; }

.nav { padding: 12px 10px; flex: 1; }
.nav__group { margin-bottom: 16px; }
.nav__label {
  font-size: 10px; text-transform: uppercase; letter-spacing: .09em;
  color: #6f7787; padding: 0 10px 6px; font-weight: 640;
}
.nav__item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; border-radius: var(--radius-sm);
  color: #c3c9d4; font-size: 13.5px; cursor: pointer;
  text-decoration: none; margin-bottom: 1px;
  transition: background .12s, color .12s;
}
.nav__item:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav__item.is-active { background: var(--brand); color: #fff; font-weight: 560; }
.nav__item svg { width: 15px; height: 15px; flex: none; opacity: .9; }
.nav__badge {
  margin-left: auto; font-size: 10.5px; background: rgba(255, 255, 255, .12);
  padding: 1px 6px; border-radius: 20px; font-variant-numeric: tabular-nums;
}
.nav__item.is-active .nav__badge { background: rgba(0, 0, 0, .2); }

.sidebar__foot { padding: 12px 18px 16px; border-top: 1px solid rgba(255,255,255,.07); font-size: 11.5px; color: #79808e; }

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

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 40;
}
.topbar__title { flex: 1; min-width: 200px; }
.topbar__sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.topbar__actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.content { padding: 20px 24px 56px; flex: 1; }
.page { max-width: 1500px; margin: 0 auto; }

/* --------------------------------------------------------------- Buttons */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); font-size: 13px; font-weight: 520; font-family: inherit;
  cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted-2); text-decoration: none; }
.btn:active { transform: translateY(.5px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn--primary:hover { background: #bf1f7d; border-color: #bf1f7d; }
.btn--ghost { border-color: transparent; background: transparent; }
.btn--ghost:hover { background: rgba(0,0,0,.045); }
.btn--danger { border-color: #f0c2c8; color: var(--bad); background: #fff; }
.btn--danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn--sm { padding: 4px 9px; font-size: 12px; }
.btn svg { width: 14px; height: 14px; }

.btn-group { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.btn-group button {
  border: 0; background: var(--surface); padding: 6px 12px; font-size: 12.5px;
  cursor: pointer; font-family: inherit; color: var(--muted); border-right: 1px solid var(--border);
}
.btn-group button:last-child { border-right: 0; }
.btn-group button.is-active { background: var(--ink); color: #fff; font-weight: 560; }
.btn-group button:hover:not(.is-active) { background: var(--surface-2); color: var(--text); }

/* ----------------------------------------------------------------- Cards */

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  margin-bottom: 16px; overflow: hidden;
}
.card__head {
  padding: 13px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.card__head h2 { flex: 1; min-width: 140px; }
.card__sub { font-size: 12.5px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.card__body { padding: 16px; }
.card__body--flush { padding: 0; }

.grid { display: grid; gap: 16px; }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--sidebar { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }

/* ------------------------------------------------------------------- KPI */

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 13px 15px; box-shadow: var(--shadow-sm);
}
.kpi__label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.kpi__value { font-size: 25px; font-weight: 680; letter-spacing: -.022em; color: var(--ink); margin-top: 5px; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi__meta { font-size: 12px; color: var(--muted); margin-top: 4px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.kpi--muted .kpi__value { color: var(--muted-2); font-weight: 560; }

.delta { font-weight: 620; font-variant-numeric: tabular-nums; display: inline-flex; align-items: center; gap: 2px; }
.delta--up { color: var(--good); }
.delta--down { color: var(--bad); }
.delta--flat { color: var(--muted); }

/* ---------------------------------------------------------------- Tables */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  font-weight: 640; background: var(--surface-2); position: sticky; top: 0; z-index: 1;
  border-bottom: 1px solid var(--border-strong);
}
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--text); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tbody tr:hover { background: var(--brand-soft); }
table.data tbody tr.is-clickable { cursor: pointer; }
table.data tfoot td { font-weight: 660; background: var(--surface-2); border-top: 2px solid var(--border-strong); }
table.data .dim { color: var(--muted-2); }
.table-empty { padding: 34px 16px; text-align: center; color: var(--muted); font-size: 13px; }

.bar-cell { position: relative; }
.bar-cell__fill { position: absolute; inset: 3px auto 3px 0; background: var(--brand-soft); border-radius: 3px; z-index: 0; }
.bar-cell__text { position: relative; z-index: 1; }

/* ---------------------------------------------------------------- Charts */

.chart { position: relative; width: 100%; }
.chart canvas { max-width: 100%; }
.chart--sm { height: 190px; }
.chart--md { height: 260px; }
.chart--lg { height: 330px; }

/* --------------------------------------------------------------- Filters */

.filters {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 16px; box-shadow: var(--shadow-sm);
}
.filters__row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field__label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 620; }
.field input, .field select, .field textarea {
  font-family: inherit; font-size: 13px; padding: 6px 9px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); min-width: 120px;
}
.field input:focus, .field select:focus { outline: 2px solid var(--brand-border); outline-offset: -1px; border-color: var(--brand); }
.field--grow { flex: 1; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--brand-soft); border: 1px solid var(--brand-border); color: #9c1466;
  padding: 2px 8px; border-radius: 20px; font-size: 12px;
}
.chip button { border: 0; background: none; cursor: pointer; color: inherit; padding: 0; font-size: 14px; line-height: 1; opacity: .6; }
.chip button:hover { opacity: 1; }

.multiselect { position: relative; }
.multiselect__toggle {
  display: flex; align-items: center; gap: 6px; justify-content: space-between;
  padding: 6px 9px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); cursor: pointer; font-size: 13px; min-width: 148px; font-family: inherit;
}
.multiselect__panel {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 60;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); min-width: 230px; max-height: 300px; overflow-y: auto; padding: 6px;
}
.multiselect__panel label {
  display: flex; align-items: center; gap: 7px; padding: 5px 8px;
  border-radius: var(--radius-sm); cursor: pointer; font-size: 13px;
}
.multiselect__panel label:hover { background: var(--surface-2); }
.multiselect__search { width: 100%; margin-bottom: 4px; }

/* ------------------------------------------------------------- Callouts */

.callout {
  display: flex; gap: 10px; padding: 11px 14px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface-2);
  font-size: 13px; margin-bottom: 14px; align-items: flex-start;
}
.callout__icon { flex: none; width: 16px; height: 16px; margin-top: 1px; }
.callout__body { flex: 1; min-width: 0; }
.callout__title { font-weight: 620; color: var(--ink); margin-bottom: 2px; }
.callout--info { background: var(--info-soft); border-color: #cfdcfb; }
.callout--good { background: var(--good-soft); border-color: #bfe8d8; }
.callout--warn { background: var(--warn-soft); border-color: #f3ddb8; }
.callout--bad { background: var(--bad-soft); border-color: #f5cbd2; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 640; padding: 2px 7px; border-radius: 20px;
  text-transform: uppercase; letter-spacing: .04em;
}
.badge--good { background: var(--good-soft); color: var(--good); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.badge--bad { background: var(--bad-soft); color: var(--bad); }
.badge--info { background: var(--info-soft); color: var(--info); }
.badge--neutral { background: #eef0f3; color: var(--muted); }

/* -------------------------------------------------------------- Insights */

.insight {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 13px 15px;
  background: var(--surface); border-left-width: 3px; margin-bottom: 10px;
}
.insight--positive { border-left-color: var(--good); }
.insight--warning { border-left-color: var(--warn); }
.insight--critical { border-left-color: var(--bad); }
.insight--neutral { border-left-color: var(--muted-2); }
.insight__title { font-weight: 640; color: var(--ink); margin-bottom: 3px; font-size: 14px; }
.insight__detail { color: var(--ink-2); font-size: 13px; }
.insight__action { margin-top: 7px; font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; }
.insight__action strong { color: var(--brand); font-weight: 620; flex: none; }

/* -------------------------------------------------------------- Calendar */

.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.calendar__dow { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 640; text-align: center; padding-bottom: 4px; }
.cal-day {
  aspect-ratio: 1 / .82; border-radius: var(--radius-sm); border: 1px solid var(--border);
  padding: 6px 7px; display: flex; flex-direction: column; cursor: pointer;
  background: var(--surface); transition: transform .1s, box-shadow .1s; position: relative;
  min-height: 62px;
}
.cal-day:hover { transform: translateY(-1px); box-shadow: var(--shadow); z-index: 2; border-color: var(--brand); }
.cal-day--empty { background: transparent; border-color: transparent; cursor: default; }
.cal-day--empty:hover { transform: none; box-shadow: none; border-color: transparent; }
.cal-day__num { font-size: 11.5px; font-weight: 640; color: var(--ink); opacity: .75; }
.cal-day__value { margin-top: auto; font-size: 12.5px; font-weight: 660; font-variant-numeric: tabular-nums; }
.cal-day__sub { font-size: 10.5px; opacity: .72; font-variant-numeric: tabular-nums; }
.cal-day--dark .cal-day__num, .cal-day--dark .cal-day__value, .cal-day--dark .cal-day__sub { color: #fff; }
.cal-day--zero .cal-day__value { color: var(--muted-2); font-weight: 500; }

.legend { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.legend__scale { display: flex; gap: 2px; }
.legend__swatch { width: 26px; height: 12px; border-radius: 2px; border: 1px solid rgba(0,0,0,.06); }

/* ---------------------------------------------------------------- Upload */

.dropzone {
  border: 2px dashed var(--border-strong); border-radius: var(--radius);
  padding: 40px 24px; text-align: center; background: var(--surface-2);
  transition: border-color .15s, background .15s; cursor: pointer;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--brand); background: var(--brand-soft); }
.dropzone__title { font-weight: 640; color: var(--ink); font-size: 15px; margin-bottom: 4px; }
.dropzone__hint { color: var(--muted); font-size: 13px; }

.sheet-card { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; }
.sheet-card__head { padding: 10px 14px; background: var(--surface-2); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.sheet-card__name { font-weight: 640; font-size: 13.5px; }
.sheet-card__body { padding: 12px 14px; }

.mapping { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 7px; }
.mapping__row { display: flex; align-items: center; gap: 7px; font-size: 12.5px; padding: 5px 8px; background: var(--surface-2); border-radius: var(--radius-sm); border: 1px solid var(--border); }
.mapping__field { font-weight: 620; color: var(--ink); }
.mapping__arrow { color: var(--muted-2); }
.mapping__col { color: var(--muted); font-family: var(--mono); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; }

.issues { margin-top: 10px; }
.issue { display: flex; gap: 8px; font-size: 12.5px; padding: 5px 0; border-bottom: 1px solid var(--border); align-items: flex-start; }
.issue:last-child { border-bottom: 0; }
.issue__level { flex: none; }

/* --------------------------------------------------------------- Drawer */

.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(15, 20, 30, .38);
  z-index: 90; opacity: 0; pointer-events: none; transition: opacity .16s;
}
.drawer-backdrop.is-open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(720px, 94vw);
  background: var(--bg); z-index: 91; box-shadow: var(--shadow-lg);
  transform: translateX(100%); transition: transform .2s ease; overflow-y: auto;
  display: flex; flex-direction: column;
}
.drawer.is-open { transform: none; }
.drawer__head {
  padding: 15px 20px; border-bottom: 1px solid var(--border); background: var(--surface);
  display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 2;
}
.drawer__head h2 { flex: 1; }
.drawer__body { padding: 18px 20px 40px; }

/* ---------------------------------------------------------------- Misc */

.skeleton { background: linear-gradient(90deg, #eef0f3 25%, #f6f7f9 50%, #eef0f3 75%); background-size: 400% 100%; animation: shimmer 1.3s infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.skeleton--kpi { height: 88px; }
.skeleton--chart { height: 260px; }

.empty-state { text-align: center; padding: 56px 24px; }
.empty-state__title { font-size: 17px; font-weight: 650; color: var(--ink); margin-bottom: 6px; }
.empty-state__body { color: var(--muted); max-width: 480px; margin: 0 auto 18px; font-size: 13.5px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.stack > * + * { margin-top: 10px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.hidden { display: none !important; }
.tnum { font-variant-numeric: tabular-nums; }

.toast-host { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--ink); color: #fff; padding: 10px 15px; border-radius: var(--radius);
  box-shadow: var(--shadow-lg); font-size: 13px; max-width: 400px;
  animation: toast-in .2s ease; display: flex; gap: 9px; align-items: flex-start;
}
.toast--bad { background: var(--bad); }
.toast--good { background: var(--good); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

.progress { height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress__bar { height: 100%; background: var(--brand); transition: width .25s; }

/* --------------------------------------------------------------- Login */

.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--ink); padding: 20px; }
.login-card { background: var(--surface); border-radius: 14px; padding: 30px; width: 100%; max-width: 380px; box-shadow: var(--shadow-lg); }
.login-card img { width: 130px; display: block; margin: 0 auto 18px; }

/* --------------------------------------------------------- Responsive */

@media (max-width: 1180px) {
  .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--sidebar { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 100;
    transform: translateX(-100%); transition: transform .2s ease; height: 100vh;
  }
  .sidebar.is-open { transform: none; }
  .content { padding: 16px 14px 48px; }
  .topbar { padding: 12px 14px; }
  .grid--2, .grid--3, .grid--4 { grid-template-columns: minmax(0, 1fr); }
  .menu-toggle { display: inline-flex !important; }
  .kpis { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .kpi__value { font-size: 21px; }
}

.menu-toggle { display: none; }

@media (max-width: 620px) {
  .cal-day { min-height: 52px; padding: 4px; }
  .cal-day__value { font-size: 11px; }
  .cal-day__sub { display: none; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ----------------------------------------------------------------- Print */

@media print {
  @page { margin: 12mm; size: A4 landscape; }
  .sidebar, .topbar__actions, .filters, .menu-toggle, .drawer, .drawer-backdrop, .toast-host, .no-print { display: none !important; }
  .app { grid-template-columns: 1fr; }
  .topbar { position: static; border-bottom: 2px solid var(--ink); padding: 0 0 10px; }
  body { background: #fff; font-size: 11px; }
  .content { padding: 0; }
  .card { break-inside: avoid; box-shadow: none; border-color: #ccc; margin-bottom: 10px; }
  .kpi { box-shadow: none; }
  .chart--lg { height: 240px; }
  .chart--md { height: 190px; }
  table.data { font-size: 10px; }
  table.data th, table.data td { padding: 4px 6px; }
  .print-only { display: block !important; }
  a { color: inherit; text-decoration: none; }
}
.print-only { display: none; }
