/* ==========================================================================
   Swarelic AI — component system
   Task-management visual language: flat surfaces, hairline borders, dense
   typography, blue accent, no gradients, no shadows, no movement on hover.
   Sections:
     1. Design tokens
     2. Global base
     3. App shell (topbar / sidebar / main)
     4. Layout primitives
     5. Navigation
     6. Forms
     7. Buttons and actions
     8. Feedback
     9. Patterns
    10. App-specific components
    11. Bootstrap bridge
    12. Responsive
   ========================================================================== */

/* --- 1. Design tokens --------------------------------------------------- */
:root {
  --ui-bg: #e4eaf0;
  --ui-surface: #ffffff;
  --ui-surface-soft: #ffffff;
  --ui-surface-muted: #f4f9ff;
  --ui-border: #c9cfd6;
  --ui-border-strong: #b3bbc5;

  --ui-text: #111827;
  --ui-muted: #3f4855;
  --ui-soft: #5a6472;

  --ui-blue: #0269cb;
  --ui-blue-dark: #0257ad;
  --ui-blue-strong: #0269cb;
  --ui-header-bg: var(--ui-surface);
  --ui-blue-stronger: #0257ad;
  --ui-blue-soft: #dff0f5;
  --ui-azure: #05b3fd;

  --ui-green: #16954b;
  --ui-green-strong: #128543;
  --ui-green-light: #93da7b;
  --ui-green-soft: #e6f6df;
  --ui-red: #e54d58;
  --ui-red-strong: #c53742;
  --ui-red-soft: #fdefef;
  --ui-pink: #cf4eb7;
  --ui-pink-soft: #fbecf7;
  --ui-orange: #f18234;
  --ui-orange-strong: #bd560e;
  --ui-orange-soft: #fdeadb;
  --ui-purple: #8068d8;
  --ui-purple-soft: #f1effc;

  --ui-radius-sm: 10px;
  --ui-radius-md: 12px;
  --ui-radius-lg: 16px;

  --ui-sidebar-width: 300px;
  --ui-header-height: 72px;
  --ui-font: Urbanist, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  /* Aliases kept for template inline styles that reference the older names. */
  --ui-primary: var(--ui-blue);
  --ui-primary-dark: var(--ui-blue-dark);
  --ui-primary-deep: var(--ui-blue-dark);
  --ui-primary-soft: var(--ui-blue-soft);
  --ui-secondary: var(--ui-blue-dark);
  --ui-success: var(--ui-green);
  --ui-warning: var(--ui-orange);
  --ui-danger: var(--ui-red);
  --ui-danger-dark: #b8323d;
  --ui-info: var(--ui-blue);
  --ui-page: var(--ui-bg);
  --ui-text-muted: var(--ui-muted);
  --ui-text-soft: var(--ui-soft);
  --ui-hover: #edf6ff;
  --ui-fill-muted: var(--ui-surface-muted);
  --ui-track: #cfd6de;
  --ui-shadow-sm: none;
  --ui-shadow-md: none;
  --ui-sidebar-width-alias: var(--ui-sidebar-width);
}

/* --- 2. Global base ----------------------------------------------------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--ui-font);
  background: var(--ui-bg);
  color: var(--ui-text);
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: -.005em;
}

button, input, select, textarea { font: inherit; }

a { color: var(--ui-blue-dark); text-decoration: none; }
a:hover { color: var(--ui-blue-dark); text-decoration: underline; }

:focus-visible { outline: 2px solid rgba(2,105,203,.55); outline-offset: 2px; }

a, button, input, select, textarea {
  transition: background-color .12s linear, border-color .12s linear, color .12s linear;
}

/* Flat by design: nothing lifts, scales or shifts on hover. */
.ui-card:hover, .ui-btn:hover, .ui-icon-button:hover, .ui-chip:hover,
.ui-list-item:hover, .sidebar-link:hover, .task-card:hover {
  transform: none;
  scale: none;
  translate: none;
}

h1, h2, h3, h4, h5, h6 { letter-spacing: -.02em; font-weight: 800; }

.mini-muted { color: var(--ui-muted); font-size: 15px; }

/* --- 3. App shell ------------------------------------------------------- */
.app-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 1040;
  height: var(--ui-header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 28px;
  background: var(--ui-header-bg);
  color: var(--ui-text);
  border-bottom: 1px solid var(--ui-border-strong);
}

.app-brand {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  color: var(--ui-text);
  text-decoration: none;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -.01em;
}
.app-brand:hover { color: var(--ui-text); text-decoration: none; }

.app-brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid var(--ui-border-strong);
  border-radius: 16px;
  background: var(--ui-surface-soft);
  color: var(--ui-text);
  overflow: hidden;
}

.app-brand-mark img { height: 26px; width: auto; }

.app-header-actions { display: flex; align-items: center; gap: 8px; }

.app-icon-btn {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid var(--ui-border);
  border-radius: 12px;
  background: var(--ui-surface);
  color: var(--ui-muted);
}
.app-icon-btn:hover { background: var(--ui-surface-soft); border-color: var(--ui-border-strong); color: var(--ui-text); }

.app-header-search { position: relative; flex: 0 1 400px; min-width: 0; }
.app-header-search .ui-input { padding-left: 48px; min-height: 48px; }
.app-header-search .ui-input::placeholder { color: var(--ui-soft); }
.app-search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ui-soft);
  pointer-events: none;
}

.app-header-user {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 8px 16px;
  border: 1px solid var(--ui-border);
  border-radius: 12px;
  background: var(--ui-surface);
  color: var(--ui-text);
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
}
.app-header-user:hover { background: var(--ui-surface-soft); border-color: var(--ui-border-strong); text-decoration: none; }

.app-sidebar {
  position: fixed;
  top: var(--ui-header-height);
  bottom: 0;
  left: 0;
  z-index: 1035;
  width: var(--ui-sidebar-width);
  overflow-y: auto;
  padding: 16px 12px 40px;
  background: var(--ui-surface);
  color: var(--ui-muted);
  border-right: 1px solid var(--ui-border-strong);
  transition: transform .2s ease;
}
.app-sidebar.is-collapsed { transform: translateX(calc(-1 * var(--ui-sidebar-width))); }
.app-sidebar { scrollbar-width: none; -ms-overflow-style: none; }
.app-sidebar::-webkit-scrollbar { width: 0; height: 0; display: none; }

.sidebar-intro { padding: 8px 16px 16px; border-bottom: 1px solid var(--ui-border); margin-bottom: 12px; }
.sidebar-intro-title { color: var(--ui-text); font-weight: 800; font-size: 17px; }
.sidebar-intro-text { margin-top: 4px; color: var(--ui-muted); font-size: 13px; }

.sidebar-group { margin: 12px 0 20px; }
.sidebar-group-title {
  padding: 8px 16px 8px;
  color: var(--ui-muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .07em;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 40px;
  margin: 1px 0;
  padding: 6px 16px;
  border-radius: 12px;
  color: var(--ui-muted);
  text-decoration: none;
  font-size: 16px;
}
.sidebar-link:hover, .sidebar-link.active {
  background: var(--ui-blue-soft);
  color: var(--ui-blue-dark);
  text-decoration: none;
}
.sidebar-link i { font-size: 20px; }

.app-main {
  margin-left: var(--ui-sidebar-width);
  padding: calc(var(--ui-header-height) + 24px) 28px 64px;
  background: var(--ui-bg);
  min-height: 100vh;
  transition: margin-left .2s ease;
}
.app-main.is-expanded { margin-left: 0; }

.app-module {
  padding: 24px;
  border: 1px solid var(--ui-border-strong);
  border-radius: 16px;
  background: var(--ui-surface);
}
.app-module > :last-child { margin-bottom: 0; }

/* --- 4. Layout primitives ----------------------------------------------- */
.ui-container { width: min(100%, 1320px); margin-inline: auto; padding-inline: 20px; }

.ui-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.ui-col-4 { grid-column: span 4; }
.ui-col-6 { grid-column: span 6; }
.ui-col-8 { grid-column: span 8; }
.ui-col-12 { grid-column: span 12; }

.ui-stack { display: flex; }
.ui-stack-v { flex-direction: column; }
.ui-stack-h { flex-direction: row; align-items: center; }
.ui-gap-2 { gap: 8px; }
.ui-gap-3 { gap: 16px; }
.ui-gap-4 { gap: 24px; }

.ui-divider { border: 0; border-top: 1px solid var(--ui-border); margin: 16px 0; }
.ui-divider-v { width: 1px; align-self: stretch; background: var(--ui-border); }

.ui-card {
  background: var(--ui-surface);
  border: 1px solid var(--ui-border-strong);
  border-radius: 16px;
  overflow: hidden;
}
.ui-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--ui-border);
  background: var(--ui-surface);
  font-size: 18px;
  font-weight: 800;
}
.ui-card-body { padding: 20px; }
.ui-card-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--ui-border);
  background: var(--ui-surface);
  color: var(--ui-muted);
  font-size: 15px;
}

.ui-section {
  padding: 24px;
  border: 1px solid var(--ui-border-strong);
  border-radius: 16px;
  background: var(--ui-surface);
}
.ui-section h3 { margin: 0 0 8px; font-size: 20px; font-weight: 800; }
.ui-section p { margin: 0; color: var(--ui-muted); font-size: 16px; }

.ui-page { padding: 20px; border: 1px solid var(--ui-border-strong); border-radius: 16px; background: var(--ui-surface); }
.ui-page-title { margin: 0 0 8px; font-size: 27px; font-weight: 800; }
.ui-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.ui-header {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 16px;
  border: 1px solid var(--ui-border-strong);
  border-radius: 16px;
  background: var(--ui-surface);
}
.ui-header-nav, .ui-navbar-links { display: flex; align-items: center; gap: 20px; }
.ui-header-nav a, .ui-navbar-links a { color: var(--ui-muted); text-decoration: none; font-size: 16px; }
.ui-header-nav a:hover, .ui-navbar-links a:hover { color: var(--ui-blue-dark); }

.ui-sidebar {
  width: 330px;
  background: var(--ui-surface);
  border: 1px solid var(--ui-border-strong);
  border-radius: 16px;
  overflow: hidden;
}
.ui-sidebar.collapsed { width: 90px; }
.ui-sidebar.collapsed .sidebar-text { display: none; }
.ui-sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 16px; border-bottom: 1px solid var(--ui-border); background: var(--ui-surface); font-weight: 800; }
.ui-sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 4px 8px;
  padding: 12px 16px;
  border-radius: 10px;
  color: var(--ui-muted);
  text-decoration: none;
  font-size: 16px;
}
.ui-sidebar-nav a:hover, .ui-sidebar-nav a.active { background: var(--ui-blue-soft); color: var(--ui-blue-dark); }

/* --- 5. Navigation ------------------------------------------------------ */
.ui-navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 16px;
  border: 1px solid var(--ui-border-strong);
  border-radius: 16px;
  background: var(--ui-surface);
}
.ui-navbar-brand { color: var(--ui-text); text-decoration: none; font-weight: 800; }

.ui-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--ui-muted);
  font-size: 16px;
}
.ui-breadcrumb li + li::before { content: "/"; margin-right: 8px; color: var(--ui-soft); }
.ui-breadcrumb a { color: var(--ui-blue-dark); text-decoration: none; }

.ui-tabs { display: flex; gap: 8px; padding: 0 4px; border-bottom: 1px solid var(--ui-border); }
.ui-tab {
  padding: 12px 16px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 10px 10px 0 0;
  background: transparent;
  color: var(--ui-muted);
  font-weight: 700;
  font-size: 16px;
}
.ui-tab:hover { background: var(--ui-blue-soft); color: var(--ui-text); }
.ui-tab.active { background: var(--ui-surface); color: var(--ui-text); border-bottom-color: var(--ui-blue); }

.ui-dropdown-menu { padding: 8px; border: 1px solid var(--ui-border-strong); border-radius: 12px; background: var(--ui-surface); }
.ui-dropdown-menu .dropdown-item { padding: 8px 16px; border-radius: 10px; font-size: 16px; }
.ui-dropdown-menu .dropdown-item:hover { background: var(--ui-blue-soft); color: var(--ui-blue-dark); }

.ui-pagination .page-link { min-width: 51px; text-align: center; color: var(--ui-muted); border-color: var(--ui-border); font-size: 16px; }
.ui-pagination .page-item.active .page-link { background: var(--ui-blue-strong); border-color: var(--ui-blue-strong); color: #fff; }

.ui-stepper { display: flex; align-items: flex-start; justify-content: space-between; }
.ui-step { position: relative; flex: 1; text-align: center; color: var(--ui-muted); font-size: 15px; }
.ui-step:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 22px;
  left: 55%;
  right: -45%;
  height: 1px;
  background: var(--ui-border-strong);
}
.ui-step-circle {
  position: relative;
  z-index: 1;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  margin: 0 auto 8px;
  border: 1px solid var(--ui-border-strong);
  border-radius: 50%;
  background: var(--ui-surface);
  font-weight: 800;
}
.ui-step-label { display: block; }
.ui-step.active { color: var(--ui-blue-dark); }
.ui-step.active .ui-step-circle { border-color: var(--ui-blue-strong); background: var(--ui-blue-strong); color: #fff; }
.ui-step.complete::after, .ui-step.done::after { background: var(--ui-blue); }
.ui-step.complete .ui-step-circle, .ui-step.done .ui-step-circle { border-color: var(--ui-blue-strong); background: var(--ui-blue-strong); color: #fff; }

.ui-link { color: var(--ui-blue-dark); text-decoration: none; font-weight: 700; }
.ui-link:hover { text-decoration: underline; }

.ui-anchor-nav { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px; border: 1px solid var(--ui-border); border-radius: 12px; background: var(--ui-surface-soft); }
.ui-anchor-nav a { padding: 8px 12px; border-radius: 10px; color: var(--ui-muted); text-decoration: none; font-size: 15px; }
.ui-anchor-nav a:hover { background: var(--ui-surface); color: var(--ui-blue-dark); }

.ui-mega-menu { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px; padding: 20px; border: 1px solid var(--ui-border-strong); border-radius: 16px; background: var(--ui-surface); }
.ui-mega-menu h6 { margin-bottom: 8px; color: var(--ui-soft); font-size: 15px; font-weight: 800; text-transform: uppercase; }
.ui-mega-menu a { display: block; padding: 8px 0; color: var(--ui-text); text-decoration: none; font-size: 16px; }
.ui-mega-menu a:hover { color: var(--ui-blue-dark); }

.ui-back-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  color: var(--ui-muted);
  font-weight: 700;
  font-size: 16px;
  padding: 0;
}
.ui-back-button:hover { color: var(--ui-blue-dark); }

/* --- 6. Forms ----------------------------------------------------------- */
.ui-form { display: grid; gap: 16px; }
.ui-form-group { display: grid; gap: 8px; }
.ui-label { display: block; margin-bottom: 8px; font-size: 16px; font-weight: 800; }
.ui-form-group > .ui-label { margin-bottom: 0; }
.ui-help { color: var(--ui-muted); font-size: 15px; }
.ui-error { color: #b8323d; font-size: 15px; font-weight: 700; }

.ui-input, .ui-textarea, .ui-select {
  width: 100%;
  min-height: 54px;
  padding: 12px 16px;
  border: 1px solid #cbd1d8;
  border-radius: 12px;
  background: var(--ui-surface);
  color: var(--ui-text);
  outline: 0;
  font-size: 16px;
}
.ui-input:hover, .ui-textarea:hover, .ui-select:hover { border-color: #b7c0c9; }
.ui-input:focus, .ui-textarea:focus, .ui-select:focus {
  border-color: #05b3fd;
  outline: 2px solid #dff0f5;
  outline-offset: 0;
}
.ui-textarea { min-height: 132px; resize: vertical; }

/* Search field with the icon inside the control, matching the header search. */
.ui-search { position: relative; }
.ui-search .ui-input { padding-left: 44px; }
.ui-search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ui-soft);
  pointer-events: none;
}

/* Tom Select controls sit beside kit fields, so they share their metrics. */
.ts-wrapper .ts-control {
  min-height: 54px;
  padding: 11px 14px;
  border: 1px solid #cbd1d8;
  border-radius: 12px;
  background: var(--ui-surface);
  color: var(--ui-text);
  font-size: 16px;
}
.ts-wrapper.focus .ts-control { border-color: #05b3fd; box-shadow: 0 0 0 2px #dff0f5; }
.ts-wrapper .ts-control > .item {
  border-radius: 8px;
  background: var(--ui-blue-soft);
  color: var(--ui-blue-dark);
  font-weight: 700;
}
.ts-dropdown { border: 1px solid var(--ui-border-strong); border-radius: 12px; }
.ts-dropdown .active { background: var(--ui-blue-soft); color: var(--ui-blue-dark); }

/* Native select arrows sit hard against the edge and differ per browser.
   One chevron, same offset as the Bootstrap select below it. */
.ui-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 42px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%235a6472' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px 16px;
}
.ui-select[multiple], .ui-select[size]:not([size="1"]) {
  padding-right: 16px;
  background-image: none;
}
.ui-input.is-invalid, .ui-select.is-invalid, .ui-textarea.is-invalid { border-color: var(--ui-red); }

.ui-check { display: inline-flex; align-items: flex-start; gap: 10px; font-size: 16px; }
.ui-check input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--ui-blue); }
.ui-radio-group { display: grid; gap: 12px; }
.ui-input + .mini-muted,
.ui-select + .mini-muted,
.ui-textarea + .mini-muted,
.ui-radio-group + .mini-muted,
.action-card small.mini-muted { display: block; margin-top: 6px; }
.ui-radio { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.ui-radio input { width: 18px; height: 18px; accent-color: var(--ui-blue); }

.ui-switch { position: relative; width: 60px; height: 32px; display: inline-block; }
.ui-switch input { opacity: 0; width: 0; height: 0; }
.ui-switch-track { position: absolute; inset: 0; border-radius: 999px; background: #cfd6de; cursor: pointer; }
.ui-switch-track::after { content: ""; position: absolute; width: 24px; height: 24px; left: 4px; top: 4px; border-radius: 50%; background: #fff; transition: left .12s linear; }
.ui-switch input:checked + .ui-switch-track { background: var(--ui-blue); }
.ui-switch input:checked + .ui-switch-track::after { left: 32px; }

.ui-slider { width: 100%; accent-color: var(--ui-blue); }
.ui-slider-value { color: var(--ui-blue-dark); font-weight: 800; font-size: 16px; }

.ui-upload {
  padding: 32px 24px;
  border: 1px dashed var(--ui-border-strong);
  border-radius: 12px;
  background: var(--ui-surface-soft);
  text-align: center;
  cursor: pointer;
}
.ui-upload:hover, .ui-upload.dragging { border-color: var(--ui-blue); background: var(--ui-blue-soft); }
.ui-upload input { display: none; }
.ui-upload-icon { margin-bottom: 8px; color: var(--ui-blue-dark); font-size: 36px; }

/* --- 7. Buttons and actions --------------------------------------------- */
.ui-btn {
  min-height: 54px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--ui-surface);
  color: var(--ui-text);
  font-size: 16px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}
.ui-btn:hover { text-decoration: none; }
.ui-btn-primary { background: var(--ui-blue-strong); border-color: var(--ui-blue-strong); color: #fff; }
.ui-btn-primary:hover { background: var(--ui-blue-stronger); border-color: var(--ui-blue-stronger); color: #fff; }
.ui-btn-secondary { background: var(--ui-surface); border-color: #c9d0d7; color: #2b3441; }
.ui-btn-secondary:hover { background: var(--ui-blue-soft); border-color: #bac3cc; color: #2b3441; }
.ui-btn-danger { background: var(--ui-red-strong); border-color: var(--ui-red-strong); color: #fff; }
.ui-btn-danger:hover { background: #b8323d; border-color: #b8323d; color: #fff; }
.ui-btn-link { min-height: auto; padding: 0; border: 0; background: transparent; color: var(--ui-blue-dark); }
.ui-btn:disabled, .ui-btn.disabled { opacity: .6; cursor: not-allowed; pointer-events: none; }

.ui-icon-button {
  width: 54px;
  height: 54px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #d3d8dd;
  border-radius: 12px;
  background: var(--ui-surface);
  color: var(--ui-muted);
  cursor: pointer;
}
.ui-icon-button:hover { background: var(--ui-blue-soft); border-color: #bfc7cf; color: #1f2937; }
.ui-card-header .ui-icon-button { width: 36px; height: 36px; border-radius: 10px; }

.ui-fab {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border: 1px solid var(--ui-blue-strong);
  border-radius: 20px;
  background: var(--ui-blue-strong);
  color: #fff;
  font-size: 24px;
}
.ui-fab:hover { background: var(--ui-blue-stronger); border-color: var(--ui-blue-stronger); }

.ui-button-group { display: inline-flex; }
.ui-button-group .ui-btn { margin-left: -1px; border-radius: 0; }
.ui-button-group .ui-btn:first-child { margin-left: 0; border-radius: 12px 0 0 12px; }
.ui-button-group .ui-btn:last-child { border-radius: 0 12px 12px 0; }

.ui-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--ui-surface);
  border-color: var(--ui-border-strong);
  color: #4b5563;
  font-size: 14px;
  line-height: 1.2;
  font-weight: 700;
  cursor: pointer;
}
.ui-chip:hover { background: var(--ui-blue-soft); color: #2b3441; }
.ui-chip.active { background: var(--ui-blue-soft); border-color: #b9dfeb; color: #0269cb; }
.ui-chip-green { background: var(--ui-green-soft); color: #107c3f; }
.ui-chip-pink { background: #faedf7; color: #9c3286; }
.ui-chip-orange { background: var(--ui-orange-soft); color: #9f4a0e; }
.ui-chip-purple { background: #f0eefb; color: #705bc1; }

/* Status pills. .ui-badge-count is the small red counter from the reference. */
.ui-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 28px;
  padding: 5px 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--ui-surface);
  border-color: var(--ui-border-strong);
  color: #4b5563;
  font-size: 13px;
  line-height: 1.2;
  font-weight: 800;
}
.ui-badge-primary { background: var(--ui-blue); border-color: var(--ui-blue); color: #fff; }
.ui-badge-info { background: var(--ui-blue); border-color: var(--ui-blue); color: #fff; }
.ui-badge-success { background: var(--ui-green-strong); border-color: var(--ui-green-strong); color: #fff; }
.ui-badge-warning { background: var(--ui-orange-strong); border-color: var(--ui-orange-strong); color: #fff; }
.ui-badge-danger { background: var(--ui-red-strong); border-color: var(--ui-red-strong); color: #fff; }
.ui-badge-neutral { background: var(--ui-muted); border-color: var(--ui-muted); color: #fff; }
.ui-badge-dark { background: var(--ui-text); border-color: var(--ui-text); color: #fff; }
.ui-badge-count {
  min-width: 28px;
  padding: 5px 8px;
  border-color: var(--ui-red-strong);
  background: var(--ui-red-strong);
  color: #fff;
}

/* --- 8. Feedback -------------------------------------------------------- */
.ui-alert {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 16px;
  border: 1px solid var(--ui-border);
  border-radius: 12px;
  background: var(--ui-surface);
  font-size: 16px;
}
.ui-alert-info { border: 1px solid var(--ui-blue); }
.ui-alert-success { border: 1px solid var(--ui-green); }
.ui-alert-warning { border: 1px solid var(--ui-orange); }
.ui-alert-danger { border: 1px solid var(--ui-red); }

.ui-toast { width: 400px; border: 1px solid var(--ui-border-strong); border-radius: 16px; background: var(--ui-surface); overflow: hidden; }
.ui-toast-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px; border-bottom: 1px solid var(--ui-border); font-size: 16px; }
.ui-toast-body { padding: 16px; color: var(--ui-muted); font-size: 15px; }

.ui-snackbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 16px;
  border: 1px solid #222;
  border-radius: 12px;
  background: #202630;
  color: #fff;
  font-size: 16px;
}

.ui-progress { height: 12px; overflow: hidden; border-radius: 999px; background: #d5dce4; }
.ui-progress-bar { height: 100%; border-radius: inherit; background: var(--ui-blue); }

.ui-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid #cfd6dc;
  border-top-color: var(--ui-blue);
  border-radius: 50%;
  animation: ui-spin .8s linear infinite;
}
@keyframes ui-spin { to { transform: rotate(360deg); } }

.ui-skeleton { background: #dde3e9; border-radius: 10px; }
.ui-skeleton-line { height: 16px; margin-bottom: 12px; }
.ui-skeleton-avatar { width: 44px; height: 44px; border-radius: 50%; }

.ui-tooltip-demo { display: inline-flex; align-items: center; gap: 8px; color: var(--ui-muted); border-bottom: 1px dashed var(--ui-soft); cursor: help; font-size: 16px; }

.ui-modal-content { border: 1px solid var(--ui-border-strong); border-radius: 16px; background: var(--ui-surface); }
.ui-drawer.offcanvas { width: min(600px, 92vw); }

.ui-empty-state {
  padding: 40px 28px;
  text-align: center;
  border: 1px solid #d3d8dd;
  border-radius: 12px;
  background: var(--ui-surface-soft);
}
.ui-empty-icon { color: var(--ui-soft); font-size: 44px; }
.ui-empty-state h4 { margin: 12px 0 8px; font-size: 22px; }
.ui-empty-state p { margin: 0 0 16px; color: var(--ui-muted); font-size: 15px; }

/* --- 9. Patterns -------------------------------------------------------- */
.ui-accordion .accordion-item { border-color: var(--ui-border); }
.ui-accordion .accordion-button { font-size: 16px; }
.ui-accordion .accordion-button:not(.collapsed) { background: var(--ui-blue-soft); color: var(--ui-blue-dark); }

.ui-avatar {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--ui-blue-soft);
  color: var(--ui-text);
  font-size: 15px;
  font-weight: 800;
}
.ui-avatar img { width: 100%; height: 100%; object-fit: cover; }
.ui-avatar-group { display: flex; }
.ui-avatar-group .ui-avatar + .ui-avatar { margin-left: -12px; }

.ui-list { margin: 0; padding: 0; list-style: none; border: 1px solid var(--ui-border-strong); border-radius: 16px; background: var(--ui-surface); overflow: hidden; }
.ui-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 16px;
  border-bottom: 1px solid var(--ui-border);
  background: var(--ui-surface);
  font-size: 16px;
}
.ui-list-item:last-child { border-bottom: 0; }

.ui-table-wrap { overflow-x: auto; border: 1px solid var(--ui-border-strong); border-radius: 16px; background: var(--ui-surface); }
.ui-table { width: 100%; min-width: 860px; border-collapse: collapse; background: var(--ui-surface); font-size: 15px; }
.ui-table th { padding: 12px 16px; background: var(--ui-surface); border-bottom: 1px solid var(--ui-border-strong); color: #414b59; font-size: 12px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; text-align: left; }
.ui-table td { padding: 16px 16px; border-top: 1px solid var(--ui-border); }
.ui-table tbody tr:hover { background: #f7fbff; }

.ui-tree { margin: 0; padding: 0; list-style: none; font-size: 16px; }
.ui-tree ul { margin: 8px 0 0 28px; padding-left: 20px; list-style: none; }
.ui-tree-row { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.ui-tree-toggle { width: 32px; height: 32px; border: 0; background: transparent; color: var(--ui-muted); }

/* --- 10. App-specific components ---------------------------------------- */
.ui-stat {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 100%;
  padding: 20px;
  border: 1px solid var(--ui-border-strong);
  border-radius: 16px;
  background: var(--ui-surface);
}
.ui-stat-icon {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: var(--ui-blue-soft);
  color: var(--ui-blue-dark);
  font-size: 26px;
}
.ui-stat-value { font-size: 32px; font-weight: 800; line-height: 1.1; letter-spacing: -.02em; }
.ui-stat-label { color: var(--ui-muted); font-size: 15px; }

.task-card { padding: 16px; margin-bottom: 12px; border: 1px solid var(--ui-border); border-radius: 12px; background: var(--ui-surface); }
.task-card:hover { background: #f7fbff; border-color: #bec8d2; }
.task-card-title { margin: 12px 0 8px; font-size: 17px; font-weight: 800; line-height: 1.35; }
.task-card-desc { color: #566070; font-size: 14px; line-height: 1.45; }
.task-card-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; padding-top: 16px; border-top: 1px solid #dadee2; }

.action-sheet .modal-dialog { display: flex; align-items: flex-end; min-height: calc(100% - 1rem); margin: .5rem; max-width: none; }
.action-sheet .modal-content { border-radius: 16px 16px 0 0; }

/* --- 11. Bootstrap bridge ----------------------------------------------- */
:root {
  --bs-primary: var(--ui-blue);
  --bs-primary-rgb: 2, 105, 203;
  --bs-body-font-family: var(--ui-font);
  --bs-body-color: var(--ui-text);
  --bs-body-bg: var(--ui-surface);
  --bs-border-color: var(--ui-border);
}
.modal-content, .offcanvas, .dropdown-menu, .toast { border-color: var(--ui-border-strong); }
.dropdown-menu { padding: 8px; border-radius: 12px; }
.dropdown-item { padding: 8px 16px; border-radius: 10px; font-size: 16px; }
.dropdown-item:hover, .dropdown-item:focus { background: var(--ui-blue-soft); color: var(--ui-blue-dark); }
.modal-header, .offcanvas-header { border-bottom-color: var(--ui-border); }
.modal-footer { border-top-color: var(--ui-border); }
.modal-title, .offcanvas-title { font-size: 22px; font-weight: 800; }
.form-check-input:checked { background-color: var(--ui-blue); border-color: var(--ui-blue); }
.accordion-button:not(.collapsed) { background: var(--ui-blue-soft); color: var(--ui-blue-dark); }
.table > :not(caption) > * > * { padding: 16px 16px; }
.table { --bs-table-bg: var(--ui-surface); font-size: 15px; }

/* Bootstrap's .alert-dismissible reserves padding-right for the absolutely
   positioned close button; .ui-alert's shorthand padding overrides it. */
.ui-alert.alert-dismissible { padding-right: 48px; }

/* Bootstrap controls sit beside kit controls, so they share its metrics. */
.btn:not(.btn-close) {
  --bs-btn-padding-y: 10px;
  --bs-btn-padding-x: 20px;
  --bs-btn-font-size: 16px;
  --bs-btn-font-weight: 800;
  --bs-btn-border-radius: 12px;
  min-height: 54px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-sm:not(.btn-close) {
  --bs-btn-padding-y: 6px;
  --bs-btn-padding-x: 14px;
  --bs-btn-font-size: 14px;
  min-height: 38px;
}
.btn-primary {
  --bs-btn-bg: var(--ui-blue-strong);
  --bs-btn-border-color: var(--ui-blue-strong);
  --bs-btn-hover-bg: var(--ui-blue-stronger);
  --bs-btn-hover-border-color: var(--ui-blue-stronger);
  --bs-btn-active-bg: var(--ui-blue-stronger);
  --bs-btn-active-border-color: var(--ui-blue-stronger);
}
.btn-outline-secondary {
  --bs-btn-color: #2b3441;
  --bs-btn-border-color: #c9d0d7;
  --bs-btn-hover-bg: #f6f8fa;
  --bs-btn-hover-border-color: #bac3cc;
  --bs-btn-hover-color: #2b3441;
}
.form-control, .form-select {
  min-height: 54px;
  padding: 12px 16px;
}
.form-select {
  padding-right: 42px;
  background-position: right 14px center;
  background-size: 16px 16px;
}
.form-control, .form-select {
  border-color: #cbd1d8;
  border-radius: 12px;
  font-size: 16px;
}
.form-control:focus, .form-select:focus {
  border-color: #05b3fd;
  box-shadow: 0 0 0 2px #dff0f5;
}
.card { border-color: var(--ui-border-strong); border-radius: 16px; }

/* --- 12. Responsive ----------------------------------------------------- */
@media (max-width: 850px) {
  .app-sidebar { transform: translateX(calc(-1 * var(--ui-sidebar-width))); }
  .app-sidebar.mobile-open { transform: translateX(0); }
  .app-main { margin-left: 0; padding-inline: 16px; }
  .app-header-search { display: none; }
  .ui-header-nav, .ui-navbar-links { display: none; }
  .ui-mega-menu { grid-template-columns: 1fr; }
  .ui-col-4, .ui-col-6, .ui-col-8 { grid-column: span 12; }
}
