/* ==========================================================================
   Views: dashboard, checklists, users, brands & branches
   ========================================================================== */

/* ---- Dashboard ---- */
.stat-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}
.stat-card {
  position: relative;
  display: grid;
  gap: 4px;
  padding: 22px;
  overflow: hidden;
  background: var(--glass-strong);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  transition:
    transform var(--t-base) var(--ease-out),
    box-shadow var(--t-base) var(--ease-out);
}
.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--sh-2);
}
.stat-ico {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin-bottom: 10px;
  border-radius: 13px;
  color: var(--aqua-700);
  background: var(--aqua-100);
}
.stat-card.tone-mint .stat-ico {
  color: var(--mint-700);
  background: var(--mint-100);
}
.stat-card.tone-coral .stat-ico {
  color: var(--coral-700);
  background: var(--coral-100);
}
.stat-card.tone-glaze .stat-ico {
  color: var(--glaze-700);
  background: var(--glaze-100);
}
.stat-label {
  color: var(--text-soft);
  font: 500 var(--fs-sm) var(--font-display);
}
.stat-number {
  font: 600 clamp(2rem, 1.4rem + 1.6vw, 2.7rem) / 1.1 var(--font-display);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat-desc {
  color: var(--ink-400);
  font-size: var(--fs-xs);
}
/* the one loud element on the dashboard: the headline number */
.stat-card.hero {
  color: #fff;
  border: 0;
  background: var(--grad-brand);
  box-shadow: var(--sh-brand);
}
.stat-card.hero::after {
  content: '';
  position: absolute;
  inset-block-start: -50px;
  inset-inline-end: -40px;
  width: 170px;
  height: 170px;
  border-radius: 50%;
  background: repeating-radial-gradient(circle, transparent 0 14px, rgb(255 255 255 / 0.12) 15px 16px);
}
.stat-card.hero .stat-ico {
  color: #fff;
  background: rgb(255 255 255 / 0.2);
}
.stat-card.hero .stat-label,
.stat-card.hero .stat-desc {
  color: rgb(255 255 255 / 0.8);
}

.branch-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
}
.branch-card {
  position: relative;
  display: grid;
  gap: 18px;
  padding: 20px;
  text-align: start;
  color: inherit;
  background: var(--glass-strong);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  transition:
    transform var(--t-base) var(--ease-out),
    box-shadow var(--t-base) var(--ease-out),
    border-color var(--t-base);
}
.branch-card:hover {
  transform: translateY(-4px);
  border-color: var(--aqua-200);
  box-shadow: var(--sh-2);
}
.branch-card:active {
  transform: translateY(-1px) scale(0.99);
}
.branch-head {
  display: flex;
  align-items: center;
  gap: 13px;
}
.branch-head > div:nth-child(2) {
  flex: 1;
  min-width: 0;
}
.branch-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line), var(--sh-1);
}
.branch-icon img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}
.branch-head h4 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.branch-head small {
  display: block;
  color: var(--text-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.branch-card .ring {
  --size: 58px;
  --stroke: 6px;
}
.branch-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 12px 0;
  border-block: 1px solid var(--line);
}
.branch-metrics > div {
  display: grid;
  gap: 2px;
  padding-inline: 12px;
  text-align: center;
}
.branch-metrics > div + div {
  border-inline-start: 1px solid var(--line);
}
.branch-metrics b {
  font: 600 var(--fs-xl) / 1.2 var(--font-display);
  font-variant-numeric: tabular-nums;
}
.branch-metrics small {
  color: var(--text-soft);
}
.issue-number {
  color: var(--coral-500);
}
.mini-desc {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--ink-400);
  font-size: var(--fs-xs);
}
.branch-arrow {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: var(--aqua-600);
  background: var(--aqua-50);
  transition:
    transform var(--t-base) var(--ease-spring),
    background-color var(--t-base),
    color var(--t-base);
}
.branch-card:hover .branch-arrow {
  color: #fff;
  background: var(--aqua-500);
  transform: translate(-2px, -2px) rotate(-8deg);
}
html[dir='rtl'] .branch-arrow .ico {
  transform: scaleX(-1);
}

/* ---- Checklists ---- */
.check-layout {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}
.section-sidebar {
  position: sticky;
  inset-block-start: calc(var(--topbar-h) + 16px);
  padding: 12px;
  max-height: calc(100dvh - var(--topbar-h) - 32px);
  overflow-y: auto;
}
.section-sidebar-title {
  padding: 8px 10px 10px;
  color: var(--ink-400);
  font: 500 var(--fs-xs) var(--font-display);
}
.section-list {
  display: grid;
  gap: 3px;
}
.section-link {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  text-align: start;
  color: var(--ink-700);
  transition:
    background-color var(--t-base) var(--ease-out),
    color var(--t-base),
    transform var(--t-base) var(--ease-out);
}
.section-link b {
  display: block;
  font: 500 var(--fs-sm) / 1.4 var(--font-display);
}
.section-link small {
  display: block;
  color: var(--ink-400);
}
.section-count {
  display: grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  color: var(--ink-500);
  background: var(--ink-100);
  font: 600 var(--fs-xs) var(--font-display);
  transition:
    background-color var(--t-base),
    color var(--t-base),
    transform var(--t-base) var(--ease-spring);
}
.section-link:hover {
  background: var(--aqua-50);
}
.section-link:hover .section-count {
  transform: scale(1.1);
}
.section-link.selected {
  color: var(--aqua-700);
  background: var(--aqua-100);
}
.section-link.selected .section-count {
  color: #fff;
  background: var(--grad-brand);
  box-shadow: var(--sh-brand);
}
.check-main {
  display: grid;
  gap: 18px;
  min-width: 0;
}
.check-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.check-top small {
  color: var(--aqua-600);
  font: 500 var(--fs-xs) var(--font-display);
}
.period-btns {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: var(--r-md);
  background: var(--ink-100);
}
.period-btns .ghost-btn {
  min-height: 38px;
  border: 0;
  background: transparent;
  box-shadow: none;
}
.period-btns .ghost-btn.active {
  color: var(--ink-900);
  background: #fff;
  box-shadow: var(--sh-1);
}
.month-days {
  display: flex;
  gap: 8px;
  padding: 4px 2px 10px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
}
.day-button {
  display: grid;
  gap: 1px;
  flex: none;
  min-width: 52px;
  padding: 9px 6px;
  border-radius: var(--r-md);
  text-align: center;
  color: var(--ink-600);
  background: var(--glass-strong);
  border: 1px solid var(--line);
  scroll-snap-align: center;
  transition:
    transform var(--t-fast) var(--ease-out),
    background-color var(--t-base),
    border-color var(--t-base),
    box-shadow var(--t-base);
}
.day-button b {
  font: 600 var(--fs-lg) / 1.2 var(--font-display);
}
.day-button small {
  color: var(--ink-400);
  font-size: 0.68rem;
}
.day-button:hover {
  border-color: var(--aqua-400);
  transform: translateY(-2px);
}
.day-button.selected {
  color: #fff;
  background: var(--grad-brand);
  border-color: transparent;
  box-shadow: var(--sh-brand);
  transform: translateY(-2px);
}
.day-button.selected small {
  color: rgb(255 255 255 / 0.8);
}

.check-info {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  background: var(--glass-strong);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
}
.check-logo {
  width: 46px;
  height: 46px;
  padding: 3px;
  object-fit: contain;
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line);
}
.check-info > div:not(.ring) {
  flex: 1;
  min-width: 0;
}
.check-info strong {
  display: block;
  font-size: var(--fs-md);
  font-weight: 600;
}
.check-info small {
  color: var(--text-soft);
}
.check-info .ring {
  --size: 52px;
  --stroke: 6px;
}
.done-badge {
  padding: 6px 13px;
  border-radius: var(--r-pill);
  color: var(--mint-700);
  background: var(--mint-100);
  font: 600 var(--fs-xs) var(--font-display);
  white-space: nowrap;
}
.checklist-table {
  overflow: hidden;
}
.group-title {
  padding: 11px 20px;
  color: var(--aqua-700);
  background: rgb(238 249 252 / 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  font: 600 var(--fs-sm) var(--font-display);
}
.group-title small {
  color: var(--ink-400);
  font-weight: 400;
  margin-inline-start: 6px;
}
.task-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  transition: background-color var(--t-base);
}
.task-row:last-child {
  border-bottom: 0;
}
.task-row:hover {
  background: rgb(238 249 252 / 0.6);
}
.task-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.task-text strong {
  font: 500 var(--fs-md) / 1.55 var(--font-body);
}
.task-text small {
  color: var(--ink-400);
}
.task-text em {
  color: var(--ink-300);
  font-size: var(--fs-xs);
  font-style: normal;
}
.note-preview {
  margin-top: 4px;
  padding: 6px 10px;
  width: fit-content;
  max-width: 100%;
  border-radius: var(--r-xs);
  color: var(--glaze-700);
  background: var(--glaze-100);
  font-size: var(--fs-xs);
}
.task-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}
.choice {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 42px;
  padding: 0 14px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink-600);
  font: 500 var(--fs-sm) var(--font-display);
  transition:
    transform var(--t-fast) var(--ease-out),
    background-color var(--t-base),
    border-color var(--t-base),
    color var(--t-base),
    box-shadow var(--t-base);
}
.choice .ico {
  width: 16px;
  height: 16px;
  stroke-width: 2.4;
}
.choice[data-choice='done']:hover {
  border-color: var(--mint-500);
  color: var(--mint-700);
  background: var(--mint-100);
}
.choice[data-choice='issue']:hover {
  border-color: var(--coral-500);
  color: var(--coral-700);
  background: var(--coral-100);
}
.choice[data-choice='na']:hover {
  border-color: var(--ink-300);
  background: var(--ink-100);
}
.choice.chosen {
  color: #fff;
  border-color: transparent;
}
.choice.chosen[data-choice='done'] {
  background: linear-gradient(135deg, #17a07a, var(--mint-500));
  box-shadow: 0 6px 16px rgb(31 179 132 / 0.35);
}
.choice.chosen[data-choice='issue'] {
  background: linear-gradient(135deg, #dc4a3c, var(--coral-500));
  box-shadow: 0 6px 16px rgb(234 93 79 / 0.35);
}
.choice.chosen[data-choice='na'] {
  background: linear-gradient(135deg, var(--ink-500), var(--ink-400));
}
.choice.chosen .ico {
  animation: popIn 0.4s var(--ease-spring);
}
.note-btn {
  min-height: 42px;
  width: 42px;
  padding: 0;
  border-radius: 50%;
}
.saved-flash {
  animation: flashRow 1.4s ease-out;
}

.hourly-head,
.hourly-row {
  display: grid;
  grid-template-columns: 92px minmax(220px, 1.1fr) minmax(160px, 1fr) 110px;
  align-items: center;
  gap: 14px;
  padding: 11px 20px;
}
.hourly-head {
  color: var(--ink-500);
  background: rgb(243 247 250 / 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  font: 500 var(--fs-xs) var(--font-display);
}
.hourly-row {
  border-bottom: 1px solid var(--line);
  transition: background-color var(--t-base);
}
.hourly-row:hover {
  background: rgb(238 249 252 / 0.6);
}
.hourly-row:last-of-type {
  border-bottom: 0;
}
.slot-time {
  justify-self: start;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  color: var(--ink-700);
  background: var(--ink-100);
  font: 600 var(--fs-sm) var(--font-display);
  font-variant-numeric: tabular-nums;
}
.slot-main {
  display: flex !important;
  gap: 8px !important;
}
.slot-main input {
  max-width: 120px !important;
}
.slot-note {
  min-height: 42px;
}
.hourly-row .save-mini {
  width: 100%;
}
.instructions {
  margin: 8px 20px 20px;
  padding: 16px 18px;
  border-radius: var(--r-md);
  background: var(--aqua-50);
  border: 1px solid var(--aqua-100);
}
.instructions h4 {
  margin-bottom: 8px;
  color: var(--aqua-700);
  font-size: var(--fs-md);
}
.instruction-item {
  display: grid;
  padding: 8px 0;
  font-size: var(--fs-sm);
  border-top: 1px dashed var(--aqua-200);
}
.instruction-item:first-of-type {
  border-top: 0;
}
.instruction-item span {
  color: var(--ink-400);
  font-size: var(--fs-xs);
}

/* ---- Users + Brands & branches ---- */
.users-card {
  display: grid;
  gap: 18px;
  padding: clamp(18px, 2.4vw, 26px);
}
.users-header h3 {
  font-size: var(--fs-lg);
}
.users-header p {
  color: var(--text-soft);
  font-size: var(--fs-sm);
}
.user-form {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  align-items: end;
}
.user-form .primary {
  min-height: 46px;
}
.user-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.user-actions .ghost-btn {
  min-height: 34px;
  padding: 0 11px;
  font-size: var(--fs-xs);
}
#view-brands .section-heading,
#view-users .section-heading {
  margin-top: 6px;
}

/* ---- Responsive ---- */
@media (max-width: 1100px) {
  .check-layout {
    grid-template-columns: 1fr;
  }
  .section-sidebar {
    position: static;
    max-height: none;
    padding: 8px;
  }
  .section-list {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 4px;
  }
  .section-link {
    flex: none;
    width: auto;
    white-space: nowrap;
    background: var(--ink-50);
  }
  .section-link small {
    display: none;
  }
  .section-sidebar-title {
    display: none;
  }
}
@media (max-width: 720px) {
  .group-title,
  .hourly-head {
    inset-block-start: var(--topbar-h);
  }
  .task-row {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .task-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 44px;
  }
  .choice {
    justify-content: center;
    padding: 0 6px;
  }
  .hourly-head {
    display: none;
  }
  .hourly-row {
    grid-template-columns: auto 1fr;
    grid-template-areas: 'time main' 'note note' 'save save';
    gap: 10px 12px;
    padding: 14px 16px;
  }
  .slot-time {
    grid-area: time;
  }
  .slot-main {
    grid-area: main;
  }
  .slot-note {
    grid-area: note;
  }
  .hourly-row .save-mini {
    grid-area: save;
  }
  .slot-main input {
    max-width: 96px !important;
  }
  .check-info {
    flex-wrap: wrap;
  }
  .check-info > div:not(.ring) {
    flex: 1 1 calc(100% - 80px);
  }
  .check-info .done-badge {
    margin-inline-start: auto;
  }
  .branch-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .stat-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
  .stat-card {
    padding: 16px;
  }
}
@media (max-width: 420px) {
  .stat-grid {
    grid-template-columns: 1fr;
  }
}
