/* ====================================================
   1. DASHBOARD LAYOUTS
   ==================================================== */
.dash-content {
  height: calc(100vh - var(--header-h) - 48px);
}

/* Layout A: 3 columns */
.dl-a {
  display: grid;
  grid-template-columns: 270px 1fr 240px;
  gap: 16px;
  height: 100%;
}
.dl-a .col-left {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow-y: auto;
}
.dl-a .col-left::-webkit-scrollbar { width: 3px; }
.dl-a .col-mid {
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.dl-a .col-right {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}
.dl-a .col-right::-webkit-scrollbar { width: 3px; }

/* Layout B: Top KPI strip + 2 columns */
.dl-b {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 14px;
  height: 100%;
}
.dl-b .kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.dl-b .bottom {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 14px;
  min-height: 0;
}
.dl-b .b-right {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
}
.dl-b .b-right > * { min-height: 0; }

/* Layout C: Center-focused Feed */
.dl-c {
  display: grid;
  grid-template-columns: 230px 1fr 230px;
  gap: 14px;
  height: 100%;
}
.dl-c .c-left {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}
.dl-c .c-left::-webkit-scrollbar { width: 3px; }
.dl-c .c-right {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}
.dl-c .c-right::-webkit-scrollbar { width: 3px; }
.dl-c .c-mid {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Common Feed Scroll Container */
.feed-card-wrap {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--rl);
  padding: 14px;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.feed-scroll {
  overflow-y: auto;
  flex: 1;
}
.feed-scroll::-webkit-scrollbar { width: 3px; }
.feed-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ====================================================
   2. KPI CARDS
   ==================================================== */
.kpi-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--rl);
  padding: 14px;
  position: relative;
}
.kpi-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 5px;
}
.kpi-val {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -1px;
  margin-bottom: 4px;
}
.kpi-chg {
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.kpi-chg.up { color: var(--green); }
.kpi-chg.dn { color: var(--red); }

/* ====================================================
   3. CALENDAR WIDGET
   ==================================================== */
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.cal-month {
  font-size: 13px;
  font-weight: 600;
}
.cal-nav {
  display: flex;
  gap: 3px;
}
.cal-nav button {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-sub);
  transition: background var(--transition);
}
.cal-nav button:hover {
  background: var(--surface-3);
}
.cal-nav [data-lucide] {
  width: 12px;
  height: 12px;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.cal-dh {
  font-size: 10px;
  font-weight: 600;
  text-align: center;
  color: var(--text-muted);
  padding: 4px 0;
  text-transform: uppercase;
}
.cal-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  color: var(--text-sub);
  transition: background var(--transition), color var(--transition);
  position: relative;
}
.cal-day:hover {
  background: var(--surface-3);
  color: var(--text);
}
.cal-day.today {
  background: var(--blue);
  color: #fff;
  font-weight: 700;
}
.cal-day.other {
  color: var(--text-muted);
}
.cal-day.has-dot::after {
  content: '';
  display: block;
  width: 4px;
  height: 4px;
  background: var(--blue);
  border-radius: 50%;
  position: absolute;
  bottom: 3px;
}
.cal-day.today.has-dot::after {
  background: #fff;
}

/* ====================================================
   4. TODO WIDGET
   ==================================================== */
.todo-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}
.todo-row:last-child {
  border-bottom: none;
}
.todo-cb {
  width: 15px;
  height: 15px;
  border-radius: 4px;
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition), border-color var(--transition);
}
.todo-cb.checked {
  background: var(--blue);
  border-color: var(--blue);
}
.todo-cb.checked::after {
  content: '✓';
  font-size: 9px;
  color: #fff;
  line-height: 1;
}
.todo-t {
  flex: 1;
  font-size: 12px;
}
.todo-t.done {
  text-decoration: line-through;
  color: var(--text-muted);
}

/* ====================================================
   5. ACTIVITY FEED WIDGET
   ==================================================== */
.feed-item {
  display: flex;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.feed-item:last-child {
  border-bottom: none;
}
.feed-body {
  flex: 1;
  min-width: 0;
}
.feed-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 3px;
  flex-wrap: wrap;
}
.feed-name {
  font-size: 12px;
  font-weight: 600;
}
.feed-time {
  font-size: 11px;
  color: var(--text-muted);
}
.feed-desc {
  font-size: 12px;
  color: var(--text-sub);
  line-height: 1.5;
}

/* ====================================================
   6. CUSTOMER & ORDER LIST TABLES
   ==================================================== */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.search-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 6px 12px;
  max-width: 280px;
  flex: 1;
}
.search-bar input {
  width: 100%;
}
.search-bar input::placeholder {
  color: var(--text-muted);
}

.tbl-wrap {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--rl);
  overflow-x: auto;
}
.data-tbl {
  width: 100%;
  border-collapse: collapse;
}
.data-tbl th {
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-tbl td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}
.data-tbl tbody tr:last-child td {
  border-bottom: none;
}
.data-tbl tbody tr {
  transition: background .1s;
}
.data-tbl.clickable tbody tr {
  cursor: pointer;
}
.data-tbl.clickable tbody tr:hover {
  background: var(--surface-3);
}
.cust-cell {
  display: flex;
  align-items: center;
  gap: 9px;
}

/* ====================================================
   7. CUSTOMER DETAIL REDESIGN (SPLIT COLUMNS)
   ==================================================== */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-sub);
  margin-bottom: 16px;
  cursor: pointer;
  transition: color var(--transition);
  font-size: 13px;
}
.back-btn:hover {
  color: var(--blue);
}
.back-btn [data-lucide] {
  width: 13px;
  height: 13px;
}

.cust-split-wrap {
  display: grid;
  grid-template-columns: 310px 1fr;
  gap: 20px;
  height: calc(100vh - var(--header-h) - 130px);
  min-height: 0;
}
.cust-left-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  overflow-y: auto;
}
.cust-left-col::-webkit-scrollbar { width: 3px; }

.cust-profile-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 20px 16px;
}
.cust-profile-card .edit-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition);
}
.cust-profile-card .edit-btn:hover {
  color: var(--text);
}
.cust-profile-name {
  font-size: 16px;
  font-weight: 700;
  margin-top: 10px;
  margin-bottom: 6px;
}

.cust-info-sec {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  width: 100%;
}
.cust-info-sec-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 8px;
}
.cust-info-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 12px;
}
.cust-info-row:last-child {
  margin-bottom: 0;
}
.cust-info-row .lbl {
  color: var(--text-muted);
}
.cust-info-row .val {
  color: var(--text-sub);
  text-align: right;
  max-width: 180px;
  word-break: break-all;
}

/* Contacts grid on left panel */
.contacts-sec {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.contact-card {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 10px 12px;
  position: relative;
}
.contact-actions {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 6px;
  opacity: 0.5;
  transition: opacity var(--transition);
}
.contact-card:hover .contact-actions {
  opacity: 1;
}
.contact-actions button {
  color: var(--text-muted);
  transition: color var(--transition);
}
.contact-actions button.edit:hover { color: var(--blue); }
.contact-actions button.del:hover { color: var(--red); }

.contact-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.contact-name {
  font-size: 12px;
  font-weight: 600;
}
.contact-detail-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-sub);
  margin-bottom: 4px;
}
.contact-detail-row:last-child {
  margin-bottom: 0;
}
.contact-detail-row [data-lucide] {
  width: 12px;
  height: 12px;
  color: var(--text-muted);
}

.cust-right-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
}
.cust-stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.cust-tab-content-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ====================================================
   8. KANBAN (CASES & ORDERS VIEWS)
   ==================================================== */
.kanban {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 6px;
  height: 100%;
}
.kanban::-webkit-scrollbar {
  height: 4px;
}
.kanban::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
.k-col {
  width: 236px;
  min-width: 236px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100%;
}
.k-col-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 11px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-size: 12px;
  font-weight: 600;
}
.k-count {
  background: var(--surface-3);
  padding: 1px 7px;
  border-radius: 100px;
  font-size: 10px;
  color: var(--text-sub);
}
.k-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  overflow-y: auto;
}
.k-cards::-webkit-scrollbar { width: 3px; }
.k-cards::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.k-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px;
  transition: border-color .15s, transform .15s;
}
.k-card:hover {
  border-color: var(--blue);
  transform: translateY(-1px);
}
.k-id {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 3px;
}
.k-title {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 8px;
  line-height: 1.4;
}
.k-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
}
.k-amount {
  font-size: 11px;
  color: var(--text-sub);
}
.k-adv {
  font-size: 11px;
  padding: 3px 8px;
  background: var(--blue-bg);
  color: var(--blue);
  border-radius: 5px;
  border: 1px solid rgba(79,158,255,.2);
  display: flex;
  align-items: center;
  gap: 3px;
  transition: background .12s;
}
.k-adv:hover {
  background: rgba(79,158,255,.2);
}
.k-adv [data-lucide] {
  width: 11px;
  height: 11px;
}
.k-empty {
  padding: 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 11px;
}

/* Nested expanded Case list */
.case-nested-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.case-nest-row {
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface-2);
  overflow: hidden;
  transition: border-color var(--transition);
}
.case-nest-row.expanded {
  border-color: var(--blue);
}
.case-nest-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  cursor: pointer;
  user-select: none;
}
.case-nest-hd:hover {
  background: var(--surface-3);
}
.case-nest-bd {
  display: none;
  border-top: 1px solid var(--border);
  padding: 14px;
  background: #111116;
}
.case-nest-row.expanded .case-nest-bd {
  display: block;
}

/* ====================================================
   9. STEPPER (ORDER FLOW - 9 STAGES)
   ==================================================== */
.stepper {
  display: flex;
  align-items: flex-start;
  margin-bottom: 24px;
  overflow-x: auto;
  padding: 10px 4px;
}
.stepper::-webkit-scrollbar {
  height: 3px;
}
.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  flex: 1;
  min-width: 80px;
}
.step::before {
  content: '';
  position: absolute;
  top: 14px;
  left: -50%;
  right: 50%;
  height: 2px;
  background: var(--border);
  z-index: 0;
}
.step:first-child::before {
  display: none;
}
.step.done::before {
  background: var(--green);
}
.step.active::before {
  background: var(--blue);
}
.step-circ {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  background: var(--surface-2);
  z-index: 1;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: all .3s;
}
.step.done .step-circ {
  border-color: var(--green);
  background: var(--green-bg);
  color: var(--green);
}
.step.active .step-circ {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
  box-shadow: 0 0 0 5px rgba(79,158,255,.15);
  animation: pulse-ring 2s infinite;
}
.step-lbl {
  font-size: 10px;
  font-weight: 500;
  text-align: center;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.3;
}
.step.done .step-lbl { color: var(--green); }
.step.active .step-lbl { color: var(--blue); font-weight: 600; }

.stage-records {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}
.rec-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px;
}
.rec-stage {
  font-size: 11px;
  font-weight: 600;
  color: var(--blue);
  margin-bottom: 7px;
}
.rec-person {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
}
.rec-name {
  font-size: 12px;
  font-weight: 600;
}
.rec-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.rec-note {
  font-size: 12px;
  color: var(--text-sub);
  margin-top: 6px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.order-action {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.row-prog {
  display: flex;
  gap: 3px;
  align-items: center;
}
.prog-seg {
  flex: 1;
  height: 3px;
  border-radius: 2px;
}

/* ====================================================
   10. MISC UTILITY ELEMENTS
   ==================================================== */
.info-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-sub);
}
.info-pill [data-lucide] {
  width: 11px;
  height: 11px;
  color: var(--text-muted);
}
.meta-summary {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 12px;
  color: var(--text-sub);
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: 12px;
}
