:root {
  --brand: #465fff;
  --brand-dark: #3641f5;
  --brand-light: #ecf3ff;
  --bg: #f5f6f8;
  --border: #e5e7eb;
  --text: #111827;
  --text-muted: #6b7280;
  --text-faint: #9ca3af;
  --white: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
}

/* ---------- Header ---------- */

.app-header {
  height: 56px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.app-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  object-fit: contain;
}

.app-title {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.app-title strong {
  font-size: 0.9375rem;
  letter-spacing: 0.02em;
}

.app-title span {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.app-header-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.header-icon-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
}

.header-icon-btn:not(:disabled):hover {
  background: var(--bg);
  color: var(--text);
}

.header-icon-btn:disabled {
  cursor: default;
  opacity: 0.5;
}

.header-icon-btn svg {
  width: 18px;
  height: 18px;
}

.header-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 8px;
}

.header-outlink {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--brand);
  padding: 6px 10px;
  border-radius: 8px;
}

.header-outlink:hover {
  background: var(--brand-light);
}

.header-outlink svg {
  width: 14px;
  height: 14px;
}

/* ---------- Body layout ---------- */

.app-body {
  padding: 20px;
}

.app-container {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.app-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.app-col-left,
.app-col-right {
  width: 348px;
  flex-shrink: 0;
}

.app-col-center {
  flex: 1;
  min-width: 0;
}

.card {
  background: var(--white);
  border-radius: 12px;
  box-shadow: 0 0 2px 0 rgba(0, 0, 0, 0.1), 0 2px 4px 0 rgba(0, 0, 0, 0.06);
  padding: 20px;
}

.card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.card-heading h3 {
  margin: 0;
  font-size: 0.9375rem;
}

/* ---------- Left: app shortcut list ---------- */

.apps-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 20px;
}

.apps-search svg {
  width: 15px;
  height: 15px;
  color: var(--text-faint);
  flex-shrink: 0;
}

.apps-search input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: none;
  font-size: 0.8125rem;
  font-family: inherit;
  color: var(--text);
}

.support-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: 9px;
}

.support-row:hover {
  background: var(--bg);
}

.apps-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.apps-icon svg {
  width: 19px;
  height: 19px;
}

.apps-icon.tone-blue { background: #eaf0ff; color: var(--brand); }
.apps-icon.tone-green { background: #e8f9ee; color: #16a34a; }
.apps-icon.tone-orange { background: #fff2e6; color: #ea8c1c; }
.apps-icon.tone-purple { background: #f2ecff; color: #8151e8; }
.apps-icon.tone-pink { background: #fce7f3; color: #db2777; }
.apps-icon.tone-teal { background: #e0f7f5; color: #0d9488; }
.apps-icon.tone-red { background: #fdeaea; color: #dc2626; }
.apps-icon.tone-gray { background: #f1f5f9; color: #64748b; }
.apps-icon.tone-yellow { background: #fff8db; color: #ca8a04; }

.apps-row-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.apps-row-text .name {
  font-size: 0.8125rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.apps-row-text .desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.apps-hint {
  padding: 1.5rem 0;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: 0;
}

.support-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ---------- Center: quick launch grid ---------- */

.quicklaunch-grid {
  display: flex;
  align-items: flex-start;
  gap: 28px;
  flex-wrap: wrap;
}

.quicklaunch-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 72px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text);
  text-align: center;
}

.quicklaunch-item:hover .apps-icon {
  filter: brightness(0.96);
}

.quicklaunch-item.is-disabled {
  opacity: 0.5;
  cursor: default;
}

/* ---------- Center: welcome banner ---------- */

.welcome-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: linear-gradient(135deg, #2b3ecb 0%, var(--brand) 55%, #6f86ff 100%);
  color: var(--white);
}

.welcome-content {
  min-width: 0;
}

.welcome-eyebrow {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #d7deff;
  margin-bottom: 8px;
}

.welcome-card h2 {
  margin: 0 0 8px;
  font-size: 1.25rem;
}

.welcome-card p {
  margin: 0;
  font-size: 0.8125rem;
  color: #dde3ff;
  max-width: 420px;
  line-height: 1.6;
}

.welcome-banner {
  flex-shrink: 0;
  width: 84px;
  height: 84px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.16);
  display: flex;
  align-items: center;
  justify-content: center;
}

.welcome-banner img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

/* ---------- Empty state ---------- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
}

.empty-state-icon {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  margin-bottom: 12px;
}

.empty-state-icon svg {
  width: 18px;
  height: 18px;
}

.empty-state p {
  margin: 0;
  font-size: 0.8125rem;
}

/* ---------- Right: promo card ---------- */

.promo-card {
  background: linear-gradient(160deg, #10162e 0%, #1c2550 100%);
  color: var(--white);
  min-height: 160px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.promo-eyebrow {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #8fa0ff;
  margin-bottom: 8px;
}

.promo-text {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.6;
  color: #d7deff;
}

/* ---------- Header: "Tất cả ứng dụng" flyout ---------- */

.all-apps-wrap {
  position: relative;
}

.all-apps-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 328px;
  max-height: min(600px, 80vh);
  overflow-y: auto;
  background: var(--white);
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.18), 0 2px 8px rgba(15, 23, 42, 0.08);
  z-index: 60;
  padding-bottom: 8px;
}

.all-apps-panel[hidden] {
  display: none;
}

.all-apps-panel-header {
  position: sticky;
  top: 0;
  background: var(--white);
  padding: 12px 16px;
  font-size: 0.8125rem;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
}

#all-apps-panel-body {
  padding: 0 16px;
}

.all-apps-category {
  padding: 14px 0 6px;
}

.all-apps-category:first-child {
  padding-top: 6px;
}

.all-apps-category-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 12px;
}

.all-apps-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px 2px;
}

.all-apps-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  font-size: 0.6875rem;
  color: var(--text);
  border-radius: 8px;
  padding: 4px 0;
}

.all-apps-item:hover:not(.is-disabled) {
  background: var(--bg);
}

.all-apps-item.is-disabled {
  color: var(--text-faint);
  cursor: default;
}

.all-apps-item .apps-icon {
  width: 36px;
  height: 36px;
}

.all-apps-item .apps-icon svg {
  width: 17px;
  height: 17px;
}

.all-apps-item.is-disabled .apps-icon {
  opacity: 0.55;
}

.all-apps-item-label {
  line-height: 1.25;
  max-width: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

@media (max-width: 480px) {
  .all-apps-panel {
    position: fixed;
    top: 56px;
    right: 8px;
    left: 8px;
    width: auto;
  }
}

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

@media (max-width: 1180px) {
  .app-container {
    flex-direction: column;
  }
  .app-col-left,
  .app-col-right,
  .app-col-center {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .app-header-right .header-outlink span {
    display: none;
  }
  .welcome-card {
    flex-direction: column;
    align-items: flex-start;
  }
}
