/* KAREET-E — Twenty-like CRM shell · Apple materials */
:root {
  --bg: #f5f5f7;
  --bg-elevated: #ffffff;
  --bg-sidebar: #fbfbfd;
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;
  --blue: #0071e3;
  --blue-hover: #0077ed;
  --blue-soft: rgba(0, 113, 227, 0.1);
  --green: #34c759;
  --orange: #ff9f0a;
  --red: #ff3b30;
  --fill: rgba(0, 0, 0, 0.04);
  --fill-2: rgba(0, 0, 0, 0.06);
  --separator: rgba(0, 0, 0, 0.08);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.04);
  --radius: 12px;
  --radius-lg: 16px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Helvetica, Arial, sans-serif;
  --nav-w: 220px;
  --top-h: 52px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 13px;
  line-height: 1.45;
  letter-spacing: -0.01em;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Twenty-style app shell */
.shell {
  display: grid;
  grid-template-columns: var(--nav-w) 1fr;
  grid-template-rows: var(--top-h) 1fr;
  min-height: 100vh;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 0 12px;
  background: rgba(251, 251, 253, 0.85);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--separator);
  z-index: 20;
  position: sticky;
  top: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.02em;
}
.logo-mark {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: #1d1d1f;
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
}
.search {
  width: min(360px, 40vw);
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--separator);
  background: var(--fill);
  padding: 0 12px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  outline: none;
}
.search:focus {
  background: #fff;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--separator);
  padding: 12px 10px 24px;
  overflow-y: auto;
  height: calc(100vh - var(--top-h));
  position: sticky;
  top: var(--top-h);
}
.nav-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 12px 10px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font: inherit;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.nav-item:hover { background: var(--fill); }
.nav-item.active {
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 600;
}
.nav-item .ico { width: 18px; opacity: 0.75; text-align: center; }

.workspace {
  padding: 20px 28px 64px;
  min-width: 0;
  overflow-x: hidden;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.page-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.page-sub {
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 13px;
}
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  border: none;
  cursor: pointer;
  transition: background 0.12s ease;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-hover); color: #fff; text-decoration: none; }
.btn-secondary { background: var(--fill-2); color: var(--text); }
.btn-secondary:hover { background: rgba(0,0,0,0.1); text-decoration: none; color: var(--text); }
.btn-ghost { background: transparent; color: var(--blue); }
.btn-ghost:hover { background: var(--blue-soft); text-decoration: none; }

.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--separator);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-pad { padding: 18px 20px; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--separator);
  font-weight: 600;
  font-size: 13px;
}

.grid { display: grid; gap: 14px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: 1.35fr 1fr; }
.grid-main { grid-template-columns: 1fr 320px; gap: 16px; }

@media (max-width: 1100px) {
  .grid-4, .grid-3, .grid-2, .grid-main { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .nav { display: none; }
  .grid-4, .grid-3, .grid-2, .grid-main { grid-template-columns: 1fr; }
  .search { display: none; }
}

.stat {
  padding: 16px 18px;
}
.stat-label { color: var(--text-secondary); font-size: 12px; font-weight: 500; margin-bottom: 6px; }
.stat-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.delta {
  display: inline-flex;
  margin-left: 8px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 980px;
  vertical-align: middle;
}
.delta.up { color: #248a3d; background: rgba(52,199,89,.14); }
.delta.down { color: #d70015; background: rgba(255,59,48,.12); }

.chart {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 120px;
  padding: 8px 4px 0;
}
.bar {
  flex: 1;
  background: linear-gradient(180deg, #64b5ff, var(--blue));
  border-radius: 3px 3px 1px 1px;
  min-width: 0;
  opacity: .92;
}

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: .03em;
  padding: 10px 16px;
  border-bottom: 1px solid var(--separator);
  background: #fafafa;
}
td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--separator);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(0,0,0,.015); }

.badge {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
}
.badge-ok { background: rgba(52,199,89,.14); color: #248a3d; }

/* Agent team chips (kchat) */
.agent-chips .chip {
  border: 1px solid var(--separator, rgba(0,0,0,.08));
  background: var(--fill-2, rgba(0,0,0,.04));
  color: var(--text-secondary, #6e6e73);
  border-radius: 980px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  height: auto;
}
.agent-chips .chip:hover { background: rgba(0,0,0,.08); color: var(--text); }
.agent-chips .chip.on {
  background: #1d1d1f;
  color: #fff;
  border-color: #1d1d1f;
}
.badge-warn { background: rgba(255,159,10,.16); color: #b25000; }
.badge-crit { background: rgba(255,59,48,.14); color: #d70015; }
.badge-info { background: var(--blue-soft); color: var(--blue); }
.badge-muted { background: var(--fill-2); color: var(--text-secondary); }

.list-card {
  padding: 12px 14px;
  border-bottom: 1px solid var(--separator);
}
.list-card:last-child { border-bottom: none; }
.list-card h4 { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.list-card p { color: var(--text-secondary); font-size: 12px; }
.list-card.urgent { border-left: 3px solid var(--red); }
.list-card.warn { border-left: 3px solid var(--orange); }
.list-card.info { border-left: 3px solid var(--blue); }

.funnel-row {
  display: grid;
  grid-template-columns: 120px 1fr 64px;
  gap: 10px;
  align-items: center;
  margin: 8px 0;
  font-size: 12px;
}
.funnel-bg { height: 8px; background: var(--fill-2); border-radius: 980px; overflow: hidden; }
.funnel-fg { height: 100%; background: var(--blue); border-radius: 980px; }

/* Course modules — large images */
.mod-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.mod-card {
  background: #fff;
  border: 1px solid var(--separator);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}
.mod-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(0,0,0,.08);
}
.mod-card img, .mod-card .mod-img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  display: block;
  background: #f5f5f7;
}
.mod-body { padding: 14px 16px 16px; }
.mod-body h3 { font-size: 15px; font-weight: 600; letter-spacing: -0.02em; margin-bottom: 4px; }
.mod-body p { color: var(--text-secondary); font-size: 12px; margin-bottom: 8px; }
.mod-meta { font-size: 11px; color: var(--text-tertiary); font-weight: 600; }

/* Media library — big previews */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.media-card {
  border: 1px solid var(--separator);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow);
}
.media-card .preview {
  aspect-ratio: 16/10;
  background: #eee;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.media-card .preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.media-card .meta {
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
}
.media-card .meta span {
  display: block;
  font-weight: 500;
  color: var(--text-tertiary);
  font-size: 11px;
  margin-top: 2px;
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.lightbox.hidden { display: none; }
.lightbox-inner {
  max-width: min(960px, 96vw);
  max-height: 90vh;
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.lightbox-inner img {
  display: block;
  max-width: 100%;
  max-height: 75vh;
  object-fit: contain;
  background: #f5f5f7;
}
.lightbox-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-top: 1px solid var(--separator);
}

/* kchat */
.chat-layout {
  display: grid;
  grid-template-columns: 1fr;
  max-width: 720px;
  gap: 12px;
}
.chat-log {
  background: #fff;
  border: 1px solid var(--separator);
  border-radius: var(--radius-lg);
  min-height: 400px;
  max-height: 520px;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow);
}
.msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.45;
}
.msg.agent {
  align-self: flex-start;
  background: var(--fill-2);
  border-bottom-left-radius: 4px;
}
.msg.user {
  align-self: flex-end;
  background: var(--blue);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg .who { font-size: 11px; font-weight: 600; opacity: .65; margin-bottom: 3px; }
.chat-compose {
  display: flex;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--separator);
  border-radius: 12px;
  padding: 8px;
  box-shadow: var(--shadow);
}
.chat-compose input {
  flex: 1;
  border: none;
  outline: none;
  font: inherit;
  font-size: 14px;
  padding: 0 8px;
  background: transparent;
}

.connect-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.connect-card {
  background: #fff;
  border: 1px solid var(--separator);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.connect-card h3 { font-size: 14px; margin-bottom: 4px; }
.connect-card p { font-size: 11px; color: var(--text-secondary); margin-bottom: 10px; }

.banner {
  background: #fff;
  border: 1px solid var(--separator);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 12px;
  color: var(--text-secondary);
  box-shadow: var(--shadow);
}
.banner strong { color: var(--text); }

.field { display: block; font-size: 11px; font-weight: 600; color: var(--text-secondary); margin-top: 12px; }
.input {
  width: 100%;
  margin-top: 4px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--separator);
  padding: 0 10px;
  font: inherit;
  background: #fff;
}
.input:focus { outline: 2px solid var(--blue-soft); border-color: var(--blue); }

.hidden { display: none !important; }
.mt { margin-top: 16px; }
.scope-list { padding-left: 18px; color: var(--text-secondary); font-size: 12px; line-height: 1.6; }
.scope-list li { margin: 4px 0; }

.checkout-card {
  background: linear-gradient(145deg, #1d1d1f, #3a3a3c);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
}
.checkout-card h3 { font-size: 18px; margin-bottom: 8px; }
.checkout-card p { color: #a1a1a6; font-size: 13px; margin-bottom: 16px; line-height: 1.5; }
.checkout-card .price { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; margin-bottom: 4px; }
.checkout-card .price small { font-size: 14px; font-weight: 500; color: #a1a1a6; }
.btn-wa {
  background: #25d366;
  color: #fff;
}
.btn-wa:hover { background: #1ebe57; color: #fff; text-decoration: none; }
