/* ============================================================
   Tek-Craft — layout.css
   App frame: sidebar navigation, topbar, page headings,
   KPI cards, panels and data tables.
   ============================================================ */

.layout {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar);
  background: var(--surface);
  border-inline-end: 1px solid var(--line);
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  overflow-y: auto;
  scrollbar-width: none;
  z-index: 40;
  padding: 16px 12px;
}

.sidebar::-webkit-scrollbar {
  display: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 8px 4px;
  text-decoration: none;
  color: var(--ink);
}

.brand-symbol {
  display: block;
  border-radius: 7px;
  object-fit: cover;
  flex: none;
}

.brand-name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.brand-sub {
  font-size: 11px;
  color: var(--muted);
}

.sidebar .sub {
  font-size: 11px;
  color: var(--muted);
  margin: 8px 8px 4px;
  line-height: 1.6;
}

.nav-group {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 16px 8px 4px;
  font-weight: 700;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  text-align: start;
  border: none;
  background: transparent;
  border-radius: 8px;
  padding: 8px 10px;
  font-weight: 500;
  min-height: 38px;
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
}

.nav-item:hover {
  background: var(--surface-2);
}

.nav-item.active {
  background: var(--brand-soft);
  color: var(--brand-text);
  font-weight: 600;
}

.nav-item .badge {
  margin-inline-start: auto;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  border-radius: 20px;
  padding: 1px 7px;
  font-weight: 700;
}

/* ---------- Main frame ---------- */
.main {
  flex: 1;
  margin-inline-start: var(--sidebar);
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 16px;
  flex-wrap: wrap;
}

.topbar .grow {
  flex: 1;
  min-width: 140px;
}

.icon-btn {
  width: 36px;
  padding: 0;
  position: relative;
}

.icon-btn .dot {
  position: absolute;
  top: -5px;
  inset-inline-end: -5px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 20px;
  padding: 0 5px;
  line-height: 16px;
}

.icon-btn .dot:empty {
  display: none;
}

.header-notifications {
  position: relative;
  display: flex;
  flex: none;
}

.notification-popup {
  position: absolute;
  z-index: 1;
  inset-block-start: calc(100% + 8px);
  inset-inline-end: 0;
  width: min(360px, calc(100vw - 24px));
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-pop);
}

.notification-popup header,
.notification-popup footer,
.notification-entry {
  padding: 9px 11px;
}

.notification-popup header,
.notification-entry {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 7px;
}

.notification-popup h2,
.notification-entry p {
  margin: 0;
  overflow-wrap: anywhere;
}

.notification-popup header {
  align-items: center;
  border-block-end: 1px solid var(--line);
}

.notification-popup footer {
  border-block-start: 1px solid var(--line);
}

.notification-popup footer button {
  width: 100%;
}

.notification-popup button {
  flex: none;
  padding-inline: 8px;
  font-size: 12px;
}

.notification-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: min(43dvh, 380px);
  overflow-y: auto;
}

.notification-entry + .notification-entry {
  border-block-start: 1px solid var(--line);
}

.notification-entry.unread {
  background: var(--brand-soft);
  box-shadow: inset 0 0 0 1px var(--line);
}

.notification-entry.unread p {
  font-weight: 600;
}

.notification-entry time,
.notification-empty {
  color: var(--muted);
  font-size: 12px;
}

.notification-empty {
  margin: 0;
  padding: 15px 11px;
}

@media (max-width: 900px) {
  .header-notifications {
    position: static;
  }

  .notification-popup {
    inset-block-start: calc(100% + 1px);
    inset-inline: 10px;
    width: auto;
    max-width: 360px;
    margin-inline-start: auto;
  }
}

.content {
  padding: 20px 16px 40px;
  max-width: 1440px;
  margin: 0 auto;
}

body h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}

body h2 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

body h3 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

/* ---------- KPI cards & panels ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
  margin: 14px 0;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-card);
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.kpi .ic-chip {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand-text);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.kpi .v {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.kpi .l {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 14px 0;
  box-shadow: var(--shadow-card);
}

.panel > h3:first-child {
  margin-top: 0;
}

/* ---------- Data tables ---------- */
body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

body th {
  text-align: start;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

body td {
  padding: 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

body tbody tr:hover td {
  background: var(--surface-2);
}

.tablewrap {
  overflow-x: auto;
}

.table-page-hidden {
  display: none;
}

.table-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-block: 8px 14px;
  color: var(--muted);
  font-size: 12px;
}

.table-pager-buttons {
  display: flex;
  gap: 5px;
}

.table-pager button {
  font-size: 12px;
  min-height: 34px;
  padding-inline: 8px;
}

@media (max-width: 540px) {
  .table-page-status {
    order: -1;
    flex: 0 0 100%;
    text-align: center;
  }
}

/* Product / person cell with photo */
.cell-media {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 180px;
}

.thumb {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-2);
  flex: none;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  object-fit: cover;
  background: var(--surface-2);
  flex: none;
}

.init-av {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-text);
  font-weight: 700;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
