/* ============================================================
   KamaiKart — App UI layer
   Layout shell, grids, page headers, menus and polish for the
   authenticated panels. Loaded AFTER kamaikart.css; only adds.
   ============================================================ */

[x-cloak] { display: none !important; }

body { background: var(--surface-page); }

/* ---------- Shell ---------- */
.kk-shell { display: flex; min-height: 100vh; }

.kk-side {
  width: var(--sidebar-w); flex: 0 0 auto;
  background: linear-gradient(180deg, #073066 0%, var(--surface-navy) 100%);
  color: #fff; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.kk-side__brand { padding: 20px 18px 14px; }
.kk-side__nav { flex: 1; overflow-y: auto; padding: 6px 12px 12px; }
.kk-side__nav::-webkit-scrollbar { width: 6px; }
.kk-side__nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.16); border-radius: 99px; }
.kk-side__foot { padding: 12px; border-top: 1px solid rgba(255,255,255,.10); }

.kk-snav__section {
  font-size: 10.5px; font-weight: var(--fw-bold); letter-spacing: var(--ls-caps);
  text-transform: uppercase; color: rgba(255,255,255,.42);
  padding: 14px 14px 6px;
}
.kk-snav__item { position: relative; }
.kk-snav__item[aria-current="page"]::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--orange-500);
}
.kk-snav__ico { width: 20px; height: 20px; }
.kk-snav__ico svg { width: 19px; height: 19px; display: block; }

/* user mini-card in sidebar footer */
.kk-usermini { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-md); }
.kk-usermini__meta { min-width: 0; }
.kk-usermini__name { font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kk-usermini__sub { font-size: var(--fs-xs); color: rgba(255,255,255,.55); }

/* ---------- Main / topbar ---------- */
.kk-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.kk-topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: rgba(255,255,255,.86); backdrop-filter: saturate(150%) blur(8px);
  border-bottom: 1px solid var(--border-subtle); padding: 12px 28px;
}
.kk-topbar__title { font-size: var(--fs-h4); font-weight: var(--fw-bold); color: var(--ink-900); line-height: 1.1; }
.kk-topbar__sub { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 2px; }

.kk-iconbtn {
  position: relative; width: 40px; height: 40px; border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle); background: #fff; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; color: var(--ink-700);
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.kk-iconbtn:hover { background: var(--blue-50); border-color: var(--blue-200); color: var(--blue-700); }
.kk-iconbtn__dot {
  position: absolute; top: 7px; right: 8px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 99px; background: var(--orange-500); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 16px; text-align: center; box-shadow: 0 0 0 2px #fff;
}

.kk-userchip {
  display: inline-flex; align-items: center; gap: 9px; padding: 5px 10px 5px 5px;
  border-radius: var(--radius-pill); border: 1px solid var(--border-subtle); background: #fff; cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.kk-userchip:hover { background: var(--blue-50); border-color: var(--blue-200); }
.kk-userchip__name { font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--ink-900); }

.kk-menu-btn { display: none; width: 40px; height: 40px; border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle); background: #fff; cursor: pointer; color: var(--ink-700); align-items: center; justify-content: center; }

/* ---------- Dropdowns ---------- */
.kk-pop { position: relative; }
.kk-pop__panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 50; width: 280px;
  background: #fff; border: 1px solid var(--border-subtle); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); overflow: hidden;
}
.kk-pop__head { padding: 12px 14px; border-bottom: 1px solid var(--border-subtle); display: flex; align-items: center; justify-content: space-between; }
.kk-pop__title { font-weight: var(--fw-bold); font-size: var(--fs-sm); color: var(--ink-900); }
.kk-menu__item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 10px 14px; font-size: var(--fs-sm); color: var(--ink-700);
  background: none; border: none; cursor: pointer; text-decoration: none;
}
.kk-menu__item:hover { background: var(--blue-50); color: var(--blue-700); text-decoration: none; }
.kk-menu__item--danger:hover { background: var(--red-100); color: var(--red-600); }
.kk-menu__sep { height: 1px; background: var(--border-subtle); }
.kk-noterow { display: block; padding: 11px 14px; border-bottom: 1px solid var(--border-subtle); text-decoration: none; }
.kk-noterow:hover { background: var(--surface-sunken); text-decoration: none; }
.kk-noterow--unread { background: var(--blue-50); }
.kk-noterow__title { font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--ink-900); }
.kk-noterow__time { font-size: var(--fs-xs); color: var(--ink-400); margin-top: 2px; }

/* ---------- Content ---------- */
.kk-content { padding: 26px 28px 40px; max-width: var(--container-max); width: 100%; margin: 0 auto;
  display: flex; flex-direction: column; gap: 20px; }

.kk-page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.kk-page-head__title { font-size: var(--fs-h2); }
.kk-page-head__sub { color: var(--text-muted); margin-top: 4px; }
.kk-page-head__actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* welcome banner */
.kk-welcome {
  position: relative; overflow: hidden; border-radius: var(--radius-xl); color: #fff;
  padding: 24px 26px; background: linear-gradient(120deg, #0B3470 0%, #06285A 60%, #0A2A5E 100%);
  box-shadow: var(--shadow-navy); display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap;
}
.kk-welcome::after { content: ""; position: absolute; right: -50px; top: -70px; width: 220px; height: 220px;
  border-radius: 50%; background: radial-gradient(circle, rgba(244,122,31,.35), transparent 65%); pointer-events: none; }
.kk-welcome__title { font-size: var(--fs-h2); color: #fff; position: relative; z-index: 1; }
.kk-welcome__sub { color: rgba(255,255,255,.78); margin-top: 4px; position: relative; z-index: 1; }
.kk-welcome__actions { position: relative; z-index: 1; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- Grids ---------- */
.kk-grid { display: grid; gap: 16px; }
.kk-grid--2 { grid-template-columns: repeat(2, 1fr); }
.kk-grid--3 { grid-template-columns: repeat(3, 1fr); }
.kk-grid--4 { grid-template-columns: repeat(4, 1fr); }
.kk-grid--sidebar { grid-template-columns: 340px 1fr; align-items: start; }
.kk-grid--main-aside { grid-template-columns: 1fr 360px; align-items: start; }

@media (max-width: 1100px) {
  .kk-grid--4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .kk-side { position: fixed; z-index: 60; left: 0; top: 0; transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  .kk-side.is-open { transform: translateX(0); }
  .kk-menu-btn { display: inline-flex; }
  .kk-backdrop { position: fixed; inset: 0; background: rgba(6,40,90,.45); z-index: 55; }
  .kk-grid--sidebar, .kk-grid--main-aside, .kk-grid--3 { grid-template-columns: 1fr; }
  .kk-content { padding: 18px; }
  .kk-topbar { padding: 12px 16px; }
}
@media (max-width: 560px) {
  .kk-grid--2, .kk-grid--4 { grid-template-columns: 1fr; }
  .kk-userchip__name { display: none; }
}

/* ---------- Stat card polish ---------- */
.kk-stat { transition: box-shadow .18s ease, transform .18s ease; }
.kk-stat--hover:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

/* ---------- Empty state ---------- */
.kk-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 34px 20px; text-align: center; color: var(--text-muted); }
.kk-empty__ico { width: 52px; height: 52px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--surface-sunken); color: var(--ink-400); }
.kk-empty__title { font-weight: var(--fw-semibold); color: var(--ink-700); }

/* small helpers */
.kk-muted { color: var(--text-muted); }
.kk-divider { height: 1px; background: var(--border-subtle); margin: 4px 0; }

/* ============================================================
   Auth (guest) — branded two-column experience
   ============================================================ */
.kk-authwrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }

.kk-authside {
  position: relative; overflow: hidden; color: #fff;
  padding: 48px 52px; display: flex; flex-direction: column; justify-content: space-between;
  background: linear-gradient(150deg, #0B3470 0%, #06285A 55%, #08234F 100%);
}
.kk-authside::after {
  content: ""; position: absolute; right: -120px; bottom: -120px; width: 380px; height: 380px;
  border-radius: 50%; background: radial-gradient(circle, rgba(244,122,31,.30), transparent 65%); pointer-events: none;
}
.kk-authside::before {
  content: ""; position: absolute; left: -90px; top: -90px; width: 260px; height: 260px;
  border-radius: 50%; background: radial-gradient(circle, rgba(46,111,224,.30), transparent 65%); pointer-events: none;
}
.kk-authside__inner { position: relative; z-index: 1; }
.kk-authside__tagline { font-family: var(--font-heading); font-size: 30px; font-weight: var(--fw-extrabold); line-height: 1.2; margin-top: 28px; }
.kk-authside__tagline span { color: var(--orange-500); }
.kk-authside__lead { color: rgba(255,255,255,.78); margin-top: 12px; max-width: 420px; }
.kk-authside__feat { display: flex; align-items: center; gap: 12px; margin-top: 18px; color: rgba(255,255,255,.92); }
.kk-authside__feat .kk-authside__fico {
  width: 38px; height: 38px; border-radius: 11px; display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.12); color: #fff; flex: 0 0 auto;
}
.kk-authside__foot { position: relative; z-index: 1; color: rgba(255,255,255,.55); font-size: var(--fs-xs); }

.kk-authmain { display: flex; align-items: center; justify-content: center; padding: 28px; background: var(--surface-page); }
.kk-authcard { width: 100%; max-width: 430px; }
.kk-authcard__brand { text-align: center; margin-bottom: 18px; display: none; }
.kk-auth__alt { text-align: center; margin-top: 18px; font-size: var(--fs-sm); color: var(--text-muted); }

@media (max-width: 920px) {
  .kk-authwrap { grid-template-columns: 1fr; }
  .kk-authside { display: none; }
  .kk-authcard__brand { display: block; }
}

/* ============================================================
   Bar chart (dependency-free) — merchant reports
   ============================================================ */
.kk-bars { display: flex; align-items: flex-end; gap: 10px; height: 180px; padding-top: 8px; }
.kk-bars__col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; }
.kk-bars__track { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.kk-bars__bar {
  width: 60%; max-width: 46px; min-height: 4px; border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, var(--blue-500), var(--blue-600));
  position: relative; transition: filter .15s ease;
}
.kk-bars__bar:hover { filter: brightness(1.08); }
.kk-bars__bar[data-strong="1"] { background: linear-gradient(180deg, var(--orange-500), var(--orange-600)); }
.kk-bars__val { position: absolute; top: -20px; left: 50%; transform: translateX(-50%); font-size: 10px; font-weight: 700; color: var(--ink-700); white-space: nowrap; }
.kk-bars__lbl { font-size: var(--fs-xs); color: var(--text-muted); white-space: nowrap; }

/* ============================================================
   Table refinements
   ============================================================ */
.kk-table thead th { position: sticky; top: 0; }
.kk-table tbody tr { transition: background .12s ease; }
.kk-table-wrap { border-radius: var(--radius-md); }
/* right-aligned numeric columns keep tabular rhythm even on hover */
.kk-table__num { white-space: nowrap; }
