﻿@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@300;400;500;600;700&display=swap");

/* =====================================================================
   Fluent 2 design tokens (Microsoft Fluent 2 Design System)
   https://fluent2.microsoft.design
   Legacy variable names are remapped to Fluent alias values so the whole
   UI re-skins; new --f* tokens expose the full Fluent ramp.
   ===================================================================== */
:root {
  color-scheme: light;

  /* --- Neutral surfaces / canvas --- */
  --f-canvas: #f5f5f5;            /* colorNeutralBackground3 / app canvas */
  --f-surface: #ffffff;          /* colorNeutralBackground1 (cards)      */
  --f-surface-2: #fafafa;        /* colorNeutralBackground2              */
  --f-surface-3: #f0f0f0;        /* colorNeutralBackground3 subtle       */
  --f-surface-hover: #f5f5f5;    /* subtle hover                         */
  --f-surface-pressed: #ededed;

  /* --- Neutral foreground (text) --- */
  --f-fg-1: #242424;             /* colorNeutralForeground1              */
  --f-fg-2: #424242;             /* colorNeutralForeground2              */
  --f-fg-3: #616161;             /* colorNeutralForeground3 / secondary  */
  --f-fg-disabled: #bdbdbd;      /* colorNeutralForegroundDisabled       */
  --f-fg-on-brand: #ffffff;      /* colorNeutralForegroundOnBrand        */

  /* --- Strokes --- */
  --f-stroke-1: #d1d1d1;         /* colorNeutralStroke1                  */
  --f-stroke-2: #e0e0e0;         /* colorNeutralStroke2                  */
  --f-stroke-accessible: #616161;/* colorNeutralStrokeAccessible         */

  /* --- Brand ramp (workshop logo red) --- */
  --f-brand: #e5352a;            /* primary (from logo)                  */
  --f-brand-hover: #cc2c22;      /* hover                                */
  --f-brand-pressed: #a5231b;    /* pressed                              */
  --f-brand-selected: #cc2c22;
  --f-brand-tint-10: #fdeceb;    /* very light red tint (background)     */
  --f-brand-tint-20: #f9cfcc;
  --f-brand-fg: #c0271d;         /* link / accent text (AA on white)     */

  /* --- Status --- */
  --f-danger: #c50f1f;           /* colorPaletteRedForeground / Background */
  --f-danger-bg: #fdf3f4;
  --f-success: #0e7a0b;          /* colorPaletteGreenForeground          */
  --f-success-bg: #f1faf1;
  --f-warning: #bc4b09;          /* colorPaletteDarkOrangeForeground     */
  --f-warning-bg: #fff9f0;
  --f-info: #0f6cbd;

  /* --- Corner radius --- */
  --f-radius-sm: 2px;            /* borderRadiusSmall                    */
  --f-radius-md: 4px;            /* borderRadiusMedium (controls)        */
  --f-radius-lg: 6px;            /* borderRadiusLarge                    */
  --f-radius-xl: 8px;            /* borderRadiusXLarge (cards/dialogs)   */
  --f-radius-circular: 9999px;

  /* --- Elevation (Fluent shadow ramp, two-layer) --- */
  --f-shadow-2: 0 0 2px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.14);
  --f-shadow-4: 0 0 2px rgba(0,0,0,.12), 0 2px 4px rgba(0,0,0,.14);
  --f-shadow-8: 0 0 2px rgba(0,0,0,.12), 0 4px 8px rgba(0,0,0,.14);
  --f-shadow-16: 0 0 2px rgba(0,0,0,.12), 0 8px 16px rgba(0,0,0,.14);
  --f-shadow-28: 0 0 8px rgba(0,0,0,.12), 0 14px 28px rgba(0,0,0,.14);
  --f-shadow-64: 0 0 8px rgba(0,0,0,.12), 0 32px 64px rgba(0,0,0,.14);

  /* --- Spacing ramp --- */
  --f-space-xs: 4px;
  --f-space-s: 8px;
  --f-space-m: 12px;
  --f-space-l: 16px;
  --f-space-xl: 20px;
  --f-space-xxl: 24px;

  /* ===== Legacy variable names remapped onto Fluent values ===== */
  --bg: var(--f-canvas);
  --paper: var(--f-surface);
  --soft: var(--f-surface-2);
  --line: var(--f-stroke-2);
  --line-strong: var(--f-stroke-1);
  --text: var(--f-fg-1);
  --muted: var(--f-fg-3);
  --muted-2: var(--f-fg-disabled);
  --brand: var(--f-brand);
  --brand-soft: var(--f-brand-tint-10);
  --blue: var(--f-brand);
  --red: var(--f-danger);
  --green: var(--f-success);
  --orange: var(--f-warning);
  --black: var(--f-fg-1);
  --shadow: var(--f-shadow-16);
  --radius: var(--f-radius-md);

  font-family: "Segoe UI", "Segoe UI Variable Text", "IBM Plex Sans Arabic",
    -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
}


* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

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

button {
  cursor: pointer;
}

a {
  color: inherit;
}

svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.hidden {
  display: none !important;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  background: #fbfbfb;
}

.auth-pattern {
  position: absolute;
  inset: 0 0 auto;
  height: 42vh;
  min-height: 210px;
  background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0.1), #fbfbfb 88%), url("/assets/login-pattern.png");
  background-size: cover;
  background-position: center top;
  opacity: 0.9;
}

.auth-card {
  position: relative;
  z-index: 1;
  width: 194px;
  display: grid;
  justify-items: center;
  gap: 12px;
  border: 1px solid #f1f1f1;
  border-radius: 8px;
  padding: 24px 18px 19px;
  background: #fff;
  box-shadow: 0 23px 42px rgba(20, 22, 24, 0.1);
}

.cube-logo,
.cube-mark {
  display: grid;
  place-items: center;
  color: var(--brand);
}

.cube-logo {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #050505;
}

.cube-logo svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
}

.auth-card h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
}

.auth-subtitle {
  max-width: 210px;
  margin: -4px 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.65;
  text-align: center;
}

.phone-field,
.auth-field {
  width: 100%;
  position: relative;
}

.phone-field span,
.auth-field span {
  position: absolute;
  top: -7px;
  right: 10px;
  padding: 0 4px;
  background: #fff;
  color: #b2b2b2;
  font-size: 8px;
}

.phone-field input,
.auth-field input {
  width: 100%;
  height: 29px;
  border: 1px solid var(--brand);
  border-radius: 6px;
  padding: 0 12px;
  direction: ltr;
  text-align: left;
  font-size: 9px;
  outline: 0;
}

.auth-field input {
  direction: ltr;
  text-align: left;
}

.google-action {
  width: 100%;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: #1f1f1f;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 600;
}

.google-action svg {
  width: 15px;
  height: 15px;
  stroke-width: 1.6;
}

.dark-action,
.ghost-action,
.blue-button,
.danger-button,
.soft-button,
.ghost-link {
  min-height: 32px;
  border: 0;
  border-radius: 7px;
  padding: 8px 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
}

.dark-action {
  width: 100%;
  background: var(--black);
  color: #fff;
}

.dark-action.compact {
  width: auto;
  min-width: 126px;
}

.ghost-action,
.ghost-link {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.blue-button {
  background: var(--blue);
  color: #fff;
}

.danger-button {
  background: var(--red);
  color: #fff;
}

.dashboard-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px;
  grid-template-rows: 70px minmax(0, 1fr);
  background: var(--bg);
  direction: ltr;
}

.app-header {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(190px, 260px) minmax(220px, 1fr) 76px;
  align-items: center;
  gap: 16px;
  padding: 0 28px 0 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  direction: ltr;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 11px;
  direction: ltr;
}

.user-trigger > div {
  display: grid;
  gap: 2px;
  direction: rtl;
  text-align: right;
}

.user-chip strong {
  font-size: 13px;
  font-weight: 700;
}

.user-chip span {
  color: var(--muted);
  font-size: 10px;
}

.user-menu,
.round-icon,
.ghost-tool,
.icon-only,
.table-icon {
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: #727272;
}

.user-menu,
.round-icon,
.ghost-tool,
.icon-only {
  width: 32px;
  height: 32px;
}

.global-search {
  width: min(420px, 100%);
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  color: var(--brand);
  background: #fff;
  direction: rtl;
}

.global-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  font-size: 11px;
  color: var(--text);
}

.header-logo {
  display: grid;
  justify-items: center;
}

.cube-mark svg {
  width: 31px;
  height: 31px;
  stroke-width: 2.4;
}

.side-rail {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  justify-content: center;
  padding: 12px 0;
  background: #fff;
  border-left: 1px solid var(--line);
  direction: rtl;
}

.rail-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  width: 56px;
}

.rail-item {
  width: 54px;
  min-height: 54px;
  display: grid;
  place-items: center;
  gap: 3px;
  border: 0;
  border-radius: 8px;
  padding: 5px 3px;
  background: transparent;
  color: #747474;
}

.rail-item span {
  max-width: 48px;
  overflow: hidden;
  font-size: 9px;
  line-height: 1.25;
  white-space: normal;
}

.rail-item.active {
  background: var(--brand-soft);
  color: #222;
}

.rail-item.active svg {
  color: var(--brand);
}

.rail-item.logout-item {
  margin-top: auto;
  color: var(--red);
}

.workspace {
  grid-column: 1;
  grid-row: 2;
  min-width: 0;
  padding: 24px 27px 32px;
  overflow: auto;
  direction: rtl;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(132px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.metric-card {
  min-height: 158px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px 18px 16px;
  background: #fff;
  display: grid;
  align-content: space-between;
  justify-items: end;
}

.metric-card .metric-icon {
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #eaf6ff;
  color: var(--blue);
  margin-bottom: 18px;
}

.metric-card span {
  color: #606060;
  font-size: 14px;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
  line-height: 1.1;
  direction: ltr;
  text-align: right;
}

.metric-card small {
  color: var(--green);
  font-size: 12px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr 1fr;
  gap: 12px;
}

.panel,
.table-panel,
.agent-reference {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.panel {
  min-height: 210px;
  padding: 14px;
}

.panel-title,
.page-head,
.table-tools,
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.panel-title {
  margin-bottom: 14px;
}

.panel-title h2,
.page-head h1,
.modal-head h2,
.agent-reference h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.panel-title span,
.page-head p,
.modal-head p,
.agent-reference p {
  display: block;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.chart-wide {
  grid-column: span 2;
}

.bar-list {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: 40px 1fr 42px;
  align-items: center;
  gap: 8px;
  color: #555;
  font-size: 11px;
}

.bar-track {
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: #f0f0f0;
}

.bar-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffc145, #ff8a00);
}

.mini-feed,
.timeline-list {
  display: grid;
  gap: 9px;
}

.feed-item,
.appointment-item,
.notification-item,
.inbox-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.feed-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.feed-item strong,
.appointment-item strong,
.notification-item strong,
.inbox-item strong {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
}

.feed-item span,
.appointment-item span,
.notification-item span,
.inbox-item span {
  color: var(--muted);
  font-size: 10px;
}

.status-pill,
.soft-pill,
.source-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.soft-pill {
  border: 1px solid var(--line);
  background: #fff;
  color: #555;
}

.status-pill.new_lead,
.status-pill.needs_photos,
.status-pill.quotation_needed {
  background: #fff4e5;
  color: #f08a00;
}

.status-pill.qualified,
.status-pill.inspection_scheduled,
.status-pill.quotation_sent {
  background: #eaf6ff;
  color: #2287d5;
}

.status-pill.deal_won,
.status-pill.in_progress,
.status-pill.completed {
  background: #edfbef;
  color: #279c46;
}

.status-pill.lost_cancelled {
  background: #fff0f1;
  color: var(--red);
}

.donut-layout {
  display: grid;
  grid-template-columns: 130px 1fr;
  align-items: center;
  gap: 8px;
}

.donut-chart {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: conic-gradient(#fb6b2f 0 28%, #11134c 28% 54%, #0c7d58 54% 72%, #f45167 72% 84%, #ffb01f 84% 100%);
  position: relative;
}

.donut-chart::after {
  content: "";
  position: absolute;
  inset: 29px;
  border-radius: 50%;
  background: #fff;
}

.donut-layout ul {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.donut-layout li {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #555;
  font-size: 11px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand);
}

.line-chart {
  width: 100%;
  height: 180px;
}

.line-chart path {
  fill: none;
  stroke: #fb6b2f;
  stroke-width: 4;
}

.line-chart circle {
  fill: #fb6b2f;
}

.page-head {
  margin-bottom: 18px;
}

.page-head h1 {
  font-size: 18px;
}

.head-actions {
  display: flex;
  gap: 8px;
}

.table-panel {
  overflow: hidden;
}

.table-tools {
  padding: 15px;
  border-bottom: 1px solid var(--line);
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.filter-group label,
.form-grid label,
.settings-field {
  display: grid;
  gap: 6px;
}

.filter-group span,
.form-grid span,
.settings-field span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}

.filter-group input,
.filter-group select,
.form-grid input,
.form-grid select,
.form-grid textarea,
.settings-field input,
.settings-field select,
.settings-field textarea {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
  outline: 0;
  font-size: 12px;
}

.filter-group input {
  width: 230px;
}

.table-scroll {
  overflow: auto;
}

.data-table {
  width: 100%;
  min-width: 930px;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  height: 45px;
  border-bottom: 1px solid var(--line);
  padding: 8px 12px;
  text-align: right;
  white-space: nowrap;
  font-size: 11px;
}

.data-table th {
  color: #222;
  background: #fff;
  font-weight: 700;
}

.data-table td {
  color: #555;
}

.data-table tr:hover td {
  background: #fcfcfc;
}

.client-cell {
  display: grid;
  gap: 3px;
}

.table-link {
  border: 0;
  background: transparent;
  padding: 0;
  text-align: right;
  color: inherit;
}

.client-cell strong {
  color: #111;
  font-size: 12px;
}

.client-cell span {
  color: var(--muted);
  font-size: 10px;
}

.source-chip {
  border: 1px solid #dff1ff;
  background: #f3faff;
  color: #2287d5;
}

.table-icon {
  width: 28px;
  height: 28px;
}

.calendar-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 12px;
}

.calendar-panel {
  min-height: 520px;
}

.calendar-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(92px, 1fr));
  gap: 8px;
}

.calendar-day {
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  background: #fff;
}

.calendar-day strong {
  font-size: 12px;
}

.calendar-event {
  margin-top: 8px;
  border-right: 3px solid var(--brand);
  border-radius: 6px;
  padding: 6px;
  background: var(--brand-soft);
  color: #5d4a1e;
  font-size: 10px;
}

.padded {
  padding: 0 14px 14px;
}

.portfolio-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 12px;
}

.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
}

.category-tab {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: #fff;
  color: #555;
  font-size: 12px;
}

.category-tab.active {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: #111;
}

.portfolio-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.portfolio-image {
  height: 130px;
  background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.68)), url("/assets/login-pattern.png");
  background-size: cover;
  background-position: center;
}

.portfolio-image.has-upload {
  background-image: var(--portfolio-image);
}

.portfolio-body {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.portfolio-body strong {
  font-size: 13px;
}

.portfolio-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.portfolio-tags span {
  border-radius: 999px;
  padding: 3px 7px;
  background: #f6f6f6;
  color: #666;
  font-size: 9px;
}

.inbox-list {
  display: grid;
  gap: 10px;
}

.inbox-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 14px;
}

.inbox-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.inbox-labels span {
  border-radius: 999px;
  padding: 3px 7px;
  background: var(--brand-soft);
  color: #9a6510;
  font-size: 9px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.settings-field {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: #fff;
}

.settings-field.full {
  grid-column: 1 / -1;
}

.settings-field textarea {
  min-height: 92px;
  resize: vertical;
}

.agent-reference {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 12px;
  padding: 16px;
}

code {
  direction: ltr;
  display: inline-block;
  font-family: Consolas, "Courier New", monospace;
}

.lead-modal,
.detail-modal,
.chat-modal {
  width: min(880px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
}

.lead-modal::backdrop,
.detail-modal::backdrop,
.chat-modal::backdrop {
  background: rgba(0, 0, 0, 0.38);
}

.modal-card,
.detail-card,
.chat-card {
  max-height: calc(100vh - 32px);
  overflow: auto;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.18);
}

.chat-card {
  display: grid;
  grid-template-rows: auto minmax(300px, 1fr) auto;
}

.chat-messages {
  display: grid;
  gap: 10px;
  padding: 18px;
  background: #fafafa;
}

.message-row {
  display: grid;
  gap: 4px;
  max-width: 72%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
}

.message-row.customer {
  justify-self: start;
  border-color: #e6efff;
  background: #f8fbff;
}

.message-row.agent,
.message-row.owner {
  justify-self: end;
  border-color: #ffe5b5;
  background: #fff9ed;
}

.message-row strong {
  font-size: 11px;
}

.message-row p {
  margin: 0;
  color: #333;
  font-size: 12px;
  line-height: 1.7;
}

.message-row span {
  color: var(--muted);
  font-size: 10px;
}

.chat-compose {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.chat-compose input {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  outline: 0;
}

.notification-list,
.backup-list {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.notification-row,
.backup-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.notification-row.unread {
  border-color: #ffd78d;
  background: #fffaf0;
}

.notification-row strong,
.backup-row strong {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
}

.notification-row span,
.backup-row span {
  color: var(--muted);
  font-size: 11px;
}

.backup-panel {
  display: grid;
  gap: 12px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
}

.backup-panel h2 {
  margin: 0 0 4px;
  font-size: 16px;
}

.backup-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.backup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.modal-head {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 18px;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.form-grid textarea {
  resize: vertical;
}

.modal-actions {
  display: flex;
  justify-content: flex-start;
  gap: 9px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
}

.detail-card {
  padding: 0;
}

.detail-hero {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 18px;
  padding: 24px 28px 18px;
}

.avatar-box {
  display: grid;
  place-items: center;
  width: 78px;
  height: 78px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #777;
}

.detail-hero h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-meta span {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 10px;
  color: #555;
  font-size: 11px;
}

.detail-tabs {
  display: flex;
  gap: 20px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
}

.detail-tabs button {
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 12px 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.detail-tabs button.active {
  border-color: #111;
  color: #111;
}

.detail-body {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 14px;
  padding: 18px 28px 24px;
}

.detail-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.detail-box h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.detail-box p {
  margin: 0;
  color: #555;
  font-size: 12px;
  line-height: 1.8;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 28px 24px;
}

.toast {
  position: fixed;
  right: 50%;
  bottom: 22px;
  z-index: 40;
  min-width: 220px;
  max-width: min(420px, calc(100vw - 30px));
  transform: translate(50%, 12px);
  border-radius: 8px;
  padding: 12px 16px;
  background: #111;
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  font-size: 12px;
}

.toast.show {
  transform: translate(50%, 0);
  opacity: 1;
}

.empty-state {
  padding: 26px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

@media (max-width: 1180px) {
  .metric-row {
    grid-template-columns: repeat(3, minmax(132px, 1fr));
  }

  .dashboard-grid,
  .calendar-layout {
    grid-template-columns: 1fr;
  }

  .chart-wide {
    grid-column: auto;
  }

  .portfolio-grid {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }
}

@media (max-width: 760px) {
  .dashboard-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
  }

  .app-header {
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .side-rail {
    grid-column: 1;
    grid-row: 2;
    justify-content: flex-start;
    overflow-x: auto;
    padding: 8px 12px;
    border-left: 0;
    border-bottom: 1px solid var(--line);
  }

  .rail-nav {
    flex-direction: row;
    width: max-content;
  }

  .rail-item.logout-item {
    margin-top: 0;
  }

  .workspace {
    grid-column: 1;
    grid-row: 3;
    padding: 16px;
  }

  .metric-row,
  .portfolio-grid,
  .settings-grid,
  .form-grid,
  .detail-body,
  .detail-hero {
    grid-template-columns: 1fr;
  }

  .detail-hero {
    justify-items: start;
  }

  .page-head,
  .table-tools,
  .inbox-item,
  .agent-reference {
    display: grid;
  }

  .head-actions,
  .head-actions button,
  .blue-button,
  .danger-button {
    width: 100%;
  }

  .filter-group input {
    width: 100%;
  }
}

/* =====================================================================
   FLUENT 2 COMPONENT LAYER
   Restyles the existing components to Microsoft Fluent 2 conventions:
   Segoe UI type ramp, Fluent blue brand, 4px control radius, crisp 1px
   neutral strokes, and the two-layer elevation ramp. Appended last so it
   wins the cascade over the original theme.
   ===================================================================== */

body {
  background: var(--f-canvas);
  color: var(--f-fg-1);
  font-size: 14px;
  line-height: 20px;
  -webkit-font-smoothing: antialiased;
}

/* ---- Typography ramp ---- */
h1 { font-size: 28px; line-height: 36px; font-weight: 600; }
h2 { font-size: 20px; line-height: 26px; font-weight: 600; }
h3 { font-size: 16px; line-height: 22px; font-weight: 600; }
.page-head h1 { font-size: 24px; line-height: 32px; }

/* ---- Buttons: primary (Fluent blue) ---- */
.dark-action,
.blue-button {
  background: var(--f-brand);
  color: var(--f-fg-on-brand);
  border: 1px solid var(--f-brand);
  border-radius: var(--f-radius-md);
  box-shadow: none;
  font-weight: 600;
  padding: 8px 16px;
  transition: background .1s ease, border-color .1s ease;
}
.dark-action:hover,
.blue-button:hover { background: var(--f-brand-hover); border-color: var(--f-brand-hover); }
.dark-action:active,
.blue-button:active { background: var(--f-brand-pressed); border-color: var(--f-brand-pressed); }
.dark-action.compact { padding: 6px 14px; }

/* ---- Buttons: secondary / ghost ---- */
.ghost-action,
.ghost-tool,
.google-action {
  background: var(--f-surface);
  color: var(--f-fg-1);
  border: 1px solid var(--f-stroke-1);
  border-radius: var(--f-radius-md);
  box-shadow: none;
  font-weight: 600;
  padding: 8px 16px;
  transition: background .1s ease;
}
.ghost-action:hover,
.ghost-tool:hover,
.google-action:hover { background: var(--f-surface-hover); }
.ghost-action:active,
.ghost-tool:active,
.google-action:active { background: var(--f-surface-pressed); }

.ghost-link {
  color: var(--f-brand-fg);
  background: transparent;
  border: none;
  font-weight: 600;
}
.ghost-link:hover { color: var(--f-brand-hover); text-decoration: underline; }

/* ---- Buttons: danger ---- */
.danger-button {
  background: var(--f-danger);
  color: #fff;
  border: 1px solid var(--f-danger);
  border-radius: var(--f-radius-md);
  box-shadow: none;
  font-weight: 600;
}
.danger-button:hover { filter: brightness(.94); }

/* ---- Icon buttons ---- */
.icon-only,
.round-icon,
.user-menu {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--f-radius-md);
  color: var(--f-fg-2);
  transition: background .1s ease;
}
.icon-only:hover,
.round-icon:hover,
.user-menu:hover { background: var(--f-surface-hover); color: var(--f-fg-1); }

/* ---- Focus visibility (Fluent focus ring) ---- */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--f-brand);
  outline-offset: 1px;
}

/* ---- Fields (input / select / textarea) : Fluent field look ---- */
input,
select,
textarea {
  background: var(--f-surface);
  color: var(--f-fg-1);
  border: 1px solid var(--f-stroke-1);
  border-bottom-color: var(--f-stroke-accessible);
  border-radius: var(--f-radius-md);
  padding: 7px 10px;
  transition: border-color .1s ease;
}
input::placeholder,
textarea::placeholder { color: var(--f-fg-3); }
input:hover,
select:hover,
textarea:hover { border-color: var(--f-stroke-accessible); }
/* Fluent's signature bottom accent on focus */
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--f-stroke-1);
  border-bottom: 2px solid var(--f-brand);
  padding-bottom: 6px;
}
.form-grid label > span,
.auth-field > span { color: var(--f-fg-2); font-weight: 600; font-size: 12px; }

/* ---- Panels / cards ---- */
.panel,
.chart-card,
.donut-card,
.timeline-card,
.notifications-card,
.backup-panel,
.calendar-panel,
.table-panel,
.chat-card,
.detail-card,
.mini-feed {
  background: var(--f-surface);
  border: 1px solid var(--f-stroke-2);
  border-radius: var(--f-radius-xl);
  box-shadow: var(--f-shadow-2);
}
.panel-title h2 { color: var(--f-fg-1); }
.panel-title span,
.page-head p { color: var(--f-fg-3); }

/* ---- Metric cards ---- */
.metric-row > * {
  background: var(--f-surface);
  border: 1px solid var(--f-stroke-2);
  border-radius: var(--f-radius-xl);
  box-shadow: var(--f-shadow-2);
}

/* ---- Tables ---- */
.data-table { border-color: var(--f-stroke-2); }
.data-table thead th {
  color: var(--f-fg-3);
  font-weight: 600;
  font-size: 12px;
  background: var(--f-surface-2);
  border-bottom: 1px solid var(--f-stroke-2);
}
.data-table tbody td { border-bottom: 1px solid var(--f-stroke-2); color: var(--f-fg-1); }
.data-table tbody tr:hover { background: var(--f-brand-tint-10); }
.table-link { color: var(--f-brand-fg); font-weight: 600; }

/* ---- Sidebar rail (Fluent nav) ---- */
.side-rail {
  background: var(--f-surface);
  border-left: 1px solid var(--f-stroke-2);
}
.rail-item {
  color: var(--f-fg-2);
  border-radius: var(--f-radius-md);
  font-weight: 600;
  transition: background .1s ease, color .1s ease;
}
.rail-item:hover { background: var(--f-surface-hover); color: var(--f-fg-1); }
.rail-item.active {
  background: var(--f-brand-tint-10);
  color: var(--f-brand);
  position: relative;
}
/* Fluent selected-nav indicator bar (RTL: on the right edge) */
.rail-item.active::before {
  content: "";
  position: absolute;
  inset-inline-start: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  border-radius: var(--f-radius-circular);
  background: var(--f-brand);
}
.rail-item.active svg { color: var(--f-brand); }
.logout-item { color: var(--f-danger); }
.logout-item:hover { background: var(--f-danger-bg); color: var(--f-danger); }

/* ---- Header ---- */
.app-header {
  background: var(--f-surface);
  border-bottom: 1px solid var(--f-stroke-2);
}
.global-search input {
  background: var(--f-surface-2);
  border: 1px solid var(--f-stroke-1);
  border-radius: var(--f-radius-md);
}
.global-search input:focus { border-bottom: 2px solid var(--f-brand); }
.user-chip strong { color: var(--f-fg-1); }
.user-chip span { color: var(--f-fg-3); }

/* ---- Pills / status badges ---- */
.soft-pill {
  background: var(--f-brand-tint-10);
  color: var(--f-brand);
  border: 1px solid var(--f-brand-tint-20);
  border-radius: var(--f-radius-circular);
  font-weight: 600;
}

/* ---- Modals / dialogs ---- */
.modal-card,
.chat-card,
.detail-card {
  background: var(--f-surface);
  border: 1px solid var(--f-stroke-2);
  border-radius: var(--f-radius-xl);
  box-shadow: var(--f-shadow-64);
}
.modal-head p { color: var(--f-brand-fg); font-weight: 600; letter-spacing: .02em; }
.modal-head h2 { color: var(--f-fg-1); }
dialog::backdrop { background: rgba(0, 0, 0, .4); }

/* ---- Toast ---- */
.toast {
  background: var(--f-fg-1);
  color: #fff;
  border-radius: var(--f-radius-md);
  box-shadow: var(--f-shadow-16);
}

/* ---- Auth screen ---- */
.auth-card {
  background: var(--f-surface);
  border: 1px solid var(--f-stroke-2);
  border-radius: var(--f-radius-xl);
  box-shadow: var(--f-shadow-28);
}
.auth-card h1 { color: var(--f-fg-1); }

/* =====================================================================
   NEW: user menu popover + change-password modal
   ===================================================================== */
.user-chip { position: relative; }

.user-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--f-radius-md);
  padding: 4px 8px;
  cursor: pointer;
  text-align: start;
  transition: background .1s ease;
}
.user-trigger:hover { background: var(--f-surface-hover); }
.user-trigger strong { display: block; font-size: 14px; font-weight: 600; color: var(--f-fg-1); }
.user-trigger span { display: block; font-size: 12px; color: var(--f-fg-3); }
.user-trigger .chevron { color: var(--f-fg-3); width: 18px; height: 18px; flex: none; transition: transform .12s ease; }
.user-trigger[aria-expanded="true"] .chevron { transform: rotate(180deg); }

.user-popover {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline-start: 0;
  min-width: 220px;
  background: var(--f-surface);
  border: 1px solid var(--f-stroke-2);
  border-radius: var(--f-radius-lg);
  box-shadow: var(--f-shadow-16);
  padding: 4px;
  z-index: 60;
  display: none;
}
.user-chip .user-popover { display: none; }
.user-chip .user-popover.open { display: block; }
.user-popover .pop-name { padding: 8px 12px 6px; border-bottom: 1px solid var(--f-stroke-2); margin-bottom: 4px; }
.user-popover .pop-name strong { display: block; color: var(--f-fg-1); }
.user-popover .pop-name span { display: block; font-size: 12px; color: var(--f-fg-3); }
.user-popover button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: transparent;
  border: none;
  border-radius: var(--f-radius-md);
  padding: 9px 12px;
  color: var(--f-fg-1);
  font-weight: 600;
  cursor: pointer;
  text-align: start;
}
.user-popover button:hover { background: var(--f-surface-hover); }
.user-popover button svg { width: 18px; height: 18px; color: var(--f-fg-2); }
.user-popover button.danger { color: var(--f-danger); }
.user-popover button.danger:hover { background: var(--f-danger-bg); }
.user-popover button.danger svg { color: var(--f-danger); }

/* change-password modal specifics */
.password-modal .modal-card { width: min(440px, 92vw); }
.password-modal .form-grid { grid-template-columns: 1fr; }
.field-error {
  color: var(--f-danger);
  font-size: 12px;
  margin-top: 4px;
  min-height: 16px;
}
.form-note {
  background: var(--f-brand-tint-10);
  border: 1px solid var(--f-brand-tint-20);
  color: var(--f-fg-2);
  border-radius: var(--f-radius-md);
  padding: 8px 12px;
  font-size: 12px;
  line-height: 18px;
}
.password-hints { font-size: 12px; color: var(--f-fg-3); margin: 2px 0 0; padding-inline-start: 18px; }
.password-hints li.ok { color: var(--f-success); }

/* ---- Profile page (Fluent 2) ---- */
.profile-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 16px;
  align-items: start;
}
.profile-card { padding: 24px; }
.profile-side { padding: 20px; }
.profile-side h3 { margin: 0 0 12px; }
.profile-avatar-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--f-stroke-2);
}
.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: var(--f-radius-circular);
  background: var(--f-brand-tint-10);
  background-size: cover;
  background-position: center;
  border: 1px solid var(--f-stroke-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--f-brand);
  font-weight: 600;
  font-size: 22px;
  flex: none;
}
.profile-avatar.has-image span { display: none; }
.profile-avatar-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.profile-avatar-actions .ghost-action { cursor: pointer; display: inline-block; }
.profile-avatar-hint { margin: 2px 0 0; font-size: 12px; color: var(--f-fg-3); }
.profile-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--f-stroke-2);
  font-size: 13px;
}
.profile-meta span { color: var(--f-fg-3); }
.profile-meta strong { color: var(--f-fg-1); }
.profile-side .ghost-action { margin-top: 14px; width: 100%; justify-content: center; }
@media (max-width: 860px) {
  .profile-layout { grid-template-columns: 1fr; }
}

/* Figma KPI refresh: orange/black system palette and compact home layout. */
:root {
  --f-brand: #ef2f2a;
  --f-brand-hover: #d92621;
  --f-brand-pressed: #a91d19;
  --f-brand-selected: #ef2f2a;
  --f-brand-tint-10: #fff0f0;
  --f-brand-tint-20: #ffd5d3;
  --f-brand-fg: #d92621;
  --f-info: #ef2f2a;
  --f-warning: #d92621;
  --bg: #fafafa;
  --paper: #ffffff;
  --soft: #f7f7f7;
  --line: #f1f1f1;
  --line-strong: #e8e8e8;
  --text: #1f1f1e;
  --muted: rgba(31, 31, 30, .58);
  --brand: var(--f-brand);
  --brand-soft: var(--f-brand-tint-10);
  --blue: var(--f-brand);
  --orange: var(--f-brand);
  --green: #6bbc61;
  --radius: 16px;
  --shadow: 0 8px 24px rgba(31, 31, 30, .04);
  font-family: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, Arial, sans-serif;
}

body {
  background: #fafafa;
}

.dashboard-shell {
  grid-template-columns: minmax(0, 1fr) 76px;
  grid-template-rows: 70px minmax(0, 1fr);
  background: #fafafa;
}

.app-header {
  min-height: 70px;
  background: #ffffff;
  border-bottom: 1px solid #f1f1f1;
  box-shadow: none;
}

.global-search {
  width: min(340px, 100%);
  height: 36px;
  border-color: #f1f1f1;
  border-radius: 8px;
  color: #ef2f2a;
}

.global-search input {
  background: #fff;
  border: 0;
  color: rgba(31, 31, 30, .72);
}

.global-search input:focus {
  border: 0;
  outline: 0;
}

.cube-logo,
.cube-mark,
.header-logo {
  color: #ef2f2a;
}

.round-icon,
.user-trigger {
  border-color: #f1f1f1;
  border-radius: 8px;
  background: #fff;
  color: rgba(31, 31, 30, .62);
}

.side-rail {
  padding: 10px 8px;
  background: #ffffff;
  border-left: 1px solid #f1f1f1;
}

.rail-nav {
  width: 58px;
  gap: 6px;
}

.rail-item {
  width: 56px;
  min-height: 56px;
  border-radius: 10px;
  color: rgba(31, 31, 30, .45);
}

.rail-item svg {
  width: 19px;
  height: 19px;
  stroke-width: 1.9;
}

.rail-item span {
  color: currentColor;
  font-size: 9px;
  font-weight: 600;
}

.rail-item.active {
  background: #fff0f0;
  color: #1f1f1e;
}

.rail-item.active svg {
  color: #ef2f2a;
}

.rail-item:hover {
  background: #fafafa;
  color: #1f1f1e;
}

.workspace {
  padding: 24px 28px 32px;
}

.metric-row {
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.metric-card,
.metric-row > * {
  min-height: 118px;
  padding: 16px 18px 14px;
  border: 1px solid #f1f1f1;
  border-radius: 16px;
  background: #fff;
  box-shadow: none;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto auto;
  column-gap: 10px;
  align-content: center;
  justify-items: end;
}

.metric-card .metric-icon {
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
  width: 32px;
  height: 36px;
  margin: 0 0 12px;
  border-radius: 0;
  background: transparent;
  color: #46a1e7;
}

.metric-card .metric-icon svg {
  width: 32px;
  height: 36px;
  stroke: rgba(255, 255, 255, .92);
  stroke-width: 1.35;
  fill: none;
}

.metric-card .metric-icon .filled {
  fill: currentColor;
  stroke: currentColor;
}

.metric-card small {
  grid-column: 1;
  grid-row: 2;
  justify-self: start;
  color: #6bbc61;
  font-size: 11px;
  font-weight: 700;
  direction: ltr;
}

.metric-card span {
  grid-column: 2;
  grid-row: 2;
  color: rgba(31, 31, 30, .58);
  font-size: 12px;
  font-weight: 700;
}

.metric-card strong {
  grid-column: 1 / -1;
  grid-row: 3;
  justify-self: end;
  margin-top: 4px;
  color: #1f1f1e;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0;
}

.dashboard-grid {
  grid-template-columns: 1.05fr 1fr 1fr;
  gap: 14px;
}

.panel,
.chart-card,
.donut-card,
.timeline-card,
.notifications-card,
.backup-panel,
.calendar-panel,
.table-panel,
.chat-card,
.detail-card,
.mini-feed {
  border: 1px solid #f1f1f1;
  border-radius: 16px;
  background: #fff;
  box-shadow: none;
}

.panel {
  min-height: 220px;
  padding: 16px;
}

.panel-title {
  margin-bottom: 16px;
}

.panel-title h2 {
  color: #1f1f1e;
  font-size: 14px;
  font-weight: 800;
}

.panel-title span {
  color: #d92621;
  font-size: 11px;
  font-weight: 700;
}

.bar-track {
  height: 6px;
  background: #f1f1f1;
}

.bar-track span {
  background: linear-gradient(90deg, #ffaaa6, #ef2f2a);
}

.feed-item,
.appointment-item,
.notification-item,
.inbox-item {
  border-color: #f1f1f1;
  border-radius: 12px;
  background: #fff;
}

.donut-chart {
  background:
    conic-gradient(#d92621 0 30%, #ef2f2a 30% 55%, #291564 55% 75%, #043120 75% 90%, #f25661 90% 100%);
}

.line-chart path {
  stroke: #ef2f2a;
}

.dark-action,
.blue-button {
  background: #ef2f2a;
  border-color: #ef2f2a;
  color: #fff;
}

.blue-button:hover,
.dark-action:hover {
  background: #d92621;
  border-color: #d92621;
}

.form-note,
.profile-avatar {
  background: #fff0f0;
  border-color: #ffd5d3;
  color: #d92621;
}

/* ---- Brand logo + login tabs / panels + OTP (rebrand) ---- */
.brand-logo {
  width: 96px; height: 96px; margin: 0 auto 8px;
  border-radius: var(--f-radius-circular);
  background: #fff; border: 1px solid var(--f-stroke-2);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.brand-logo img { width: 100%; height: 100%; object-fit: contain; padding: 8px; }
.header-logo .cube-mark {
  width: 44px; height: 44px; border-radius: var(--f-radius-lg);
  background: #fff; border: 1px solid var(--f-stroke-2);
  display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 0;
}
.header-logo .cube-mark img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }

.auth-tabs {
  display: flex; gap: 4px; background: var(--f-surface-3);
  border-radius: var(--f-radius-lg); padding: 4px; margin: 8px 0 16px;
}
.auth-tab {
  flex: 1; border: none; background: transparent; cursor: pointer;
  padding: 8px 10px; border-radius: var(--f-radius-md);
  font-weight: 600; font-size: 13px; color: var(--f-fg-3);
}
.auth-tab.active { background: #fff; color: var(--f-brand); box-shadow: var(--f-shadow-2); }

.auth-panel { display: none; flex-direction: column; gap: 12px; }
.auth-panel.active { display: flex; }
.auth-hint {
  background: var(--f-brand-tint-10); border: 1px solid var(--f-brand-tint-20);
  color: var(--f-fg-2); border-radius: var(--f-radius-md);
  padding: 8px 12px; font-size: 12px; line-height: 18px; margin: 0;
}
.auth-forgot { align-self: center; font-size: 13px; margin-top: 2px; }
.hidden { display: none !important; }

/* Final red brand pass + Landing admin UI */
:root {
  --f-brand: #ef2f2a;
  --f-brand-hover: #d92621;
  --f-brand-pressed: #a91d19;
  --f-brand-selected: #d92621;
  --f-brand-tint-10: #fff0f0;
  --f-brand-tint-20: #ffd5d3;
  --f-brand-fg: #c91f1a;
  --f-warning: #ef2f2a;
  --f-warning-bg: #fff0f0;
  --f-info: #ef2f2a;
  --brand: var(--f-brand);
  --brand-soft: var(--f-brand-tint-10);
  --blue: var(--f-brand);
  --orange: var(--f-brand);
}

.global-search,
.cube-logo,
.cube-mark,
.header-logo,
.rail-item.active svg,
.metric-card .metric-icon,
.panel-title span,
.modal-head p,
.ghost-link,
.table-link {
  color: var(--f-brand) !important;
}

.rail-item.active,
.form-note,
.profile-avatar,
.auth-hint {
  background: var(--f-brand-tint-10) !important;
  border-color: var(--f-brand-tint-20) !important;
}

.dark-action,
.blue-button,
.bar-track span {
  background: var(--f-brand) !important;
  border-color: var(--f-brand) !important;
}

.dark-action:hover,
.blue-button:hover {
  background: var(--f-brand-hover) !important;
  border-color: var(--f-brand-hover) !important;
}

.line-chart path {
  stroke: var(--f-brand) !important;
}

.donut-chart {
  background: conic-gradient(#ef2f2a 0 32%, #ff6b64 32% 56%, #291564 56% 76%, #043120 76% 90%, #f25661 90% 100%) !important;
}

.landing-admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.landing-admin-card.full,
.landing-analytics {
  grid-column: 1 / -1;
}

.landing-analytics {
  min-height: auto;
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
}

.landing-stat {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: #fff;
}

.landing-stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.landing-stat strong {
  font-size: 26px;
  color: var(--text);
}

.landing-json-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.landing-json-grid label,
.landing-json-grid .full {
  display: grid;
  gap: 6px;
}

.landing-json-grid textarea {
  min-height: 180px;
  direction: ltr;
  text-align: left;
  font-family: Consolas, monospace;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
}

.landing-media-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.landing-media-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
}

.landing-media-row span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 860px) {
  .landing-admin-grid,
  .landing-json-grid,
  .landing-analytics {
    grid-template-columns: 1fr;
  }
}

/* Keep the dashboard home KPIs visible above the charts. */
[data-view="home"].active {
  display: block;
}

[data-view="home"] .metric-row {
  display: grid !important;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 14px;
  margin: 0 0 14px;
  min-height: 118px;
}

[data-view="home"] .metric-card {
  min-height: 118px;
}

[data-view="home"] .dashboard-grid {
  display: grid !important;
  grid-template-columns: 1.05fr 1fr 1fr;
  gap: 14px;
}

@media (max-width: 1180px) {
  [data-view="home"] .metric-row {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }
}

@media (max-width: 760px) {
  [data-view="home"] .metric-row,
  [data-view="home"] .dashboard-grid {
    grid-template-columns: 1fr;
  }
}


/* ===== Landing admin — Polaris-inspired (our red/RTL theme) ===== */
.landing-analytics{display:grid;grid-template-columns:repeat(5,1fr);gap:12px;margin-bottom:16px}
.pol-stat{background:var(--f-surface);border:1px solid var(--f-stroke-2);border-radius:var(--f-radius-lg);
  padding:14px 16px;box-shadow:var(--f-shadow-2)}
.pol-stat span{display:block;color:var(--f-fg-3);font-size:12px;font-weight:600;margin-bottom:4px}
.pol-stat strong{font-size:24px;color:var(--f-brand)}
.pol-stat.big strong{font-size:30px}
@media(max-width:900px){.landing-analytics{grid-template-columns:repeat(2,1fr)}}

.polaris-shell{display:grid;grid-template-columns:220px 1fr;gap:16px;align-items:start}
.polaris-nav{position:sticky;top:16px;display:flex;flex-direction:column;gap:2px;
  background:var(--f-surface);border:1px solid var(--f-stroke-2);border-radius:var(--f-radius-lg);padding:8px;box-shadow:var(--f-shadow-2)}
.pol-navitem{text-align:start;background:none;border:none;border-radius:var(--f-radius-md);padding:10px 12px;
  font-weight:600;color:var(--f-fg-2);cursor:pointer;font-family:inherit;font-size:14px}
.pol-navitem:hover{background:var(--f-surface-hover)}
.pol-navitem.active{background:var(--f-brand-tint-10);color:var(--f-brand)}
.polaris-content{display:flex;flex-direction:column;gap:16px;min-width:0}
.pol-card{background:var(--f-surface);border:1px solid var(--f-stroke-2);border-radius:var(--f-radius-xl);
  box-shadow:var(--f-shadow-2);padding:20px}
.pol-card-head{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:16px;
  padding-bottom:12px;border-bottom:1px solid var(--f-stroke-2)}
.pol-card-head h2{font-size:18px;margin:0}
.pol-form{display:grid;grid-template-columns:1fr 1fr;gap:14px}
.pol-form label{display:flex;flex-direction:column;gap:6px}
.pol-form label.full{grid-column:1/-1}
.pol-form label > span{font-size:12px;font-weight:600;color:var(--f-fg-2)}
.pol-form input,.pol-form select,.pol-form textarea{width:100%}
.pol-inline{flex-direction:row !important;align-items:center;justify-content:space-between;
  background:var(--f-surface-2);border:1px solid var(--f-stroke-2);border-radius:var(--f-radius-md);padding:8px 12px}
@media(max-width:820px){.polaris-shell{grid-template-columns:1fr}.polaris-nav{flex-direction:row;overflow:auto}.pol-form{grid-template-columns:1fr}}

/* switch */
.pol-switch{position:relative;display:inline-block;width:42px;height:24px;flex:none}
.pol-switch input{opacity:0;width:0;height:0}
.pol-switch span{position:absolute;inset:0;background:var(--f-stroke-1);border-radius:999px;transition:.2s;cursor:pointer}
.pol-switch span::before{content:"";position:absolute;width:18px;height:18px;inset-inline-start:3px;top:3px;background:#fff;border-radius:50%;transition:.2s}
.pol-switch input:checked + span{background:var(--f-brand)}
.pol-switch input:checked + span::before{transform:translateX(-18px)}

/* list items */
.pol-items{display:flex;flex-direction:column;gap:12px}
.pol-item{border:1px solid var(--f-stroke-2);border-radius:var(--f-radius-lg);padding:14px;background:var(--f-surface-2);
  display:flex;gap:12px;align-items:flex-start;justify-content:space-between}
.pol-item-body{display:grid;grid-template-columns:1fr 1fr;gap:12px;flex:1}
.pol-item-body label{display:flex;flex-direction:column;gap:5px}
.pol-item-body label.full{grid-column:1/-1}
.pol-item-body label > span{font-size:12px;font-weight:600;color:var(--f-fg-3)}
.ghost-link.danger{color:var(--f-danger)}

/* media manager */
.pol-preview{grid-column:1/-1}
.pol-preview img,.pol-preview video{max-height:180px;border-radius:var(--f-radius-md);border:1px solid var(--f-stroke-2)}
.pol-media-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(200px,1fr));gap:14px}
.pol-media{border:1px solid var(--f-stroke-2);border-radius:var(--f-radius-lg);overflow:hidden;background:var(--f-surface)}
.pol-media-thumb{aspect-ratio:4/3;background:var(--f-surface-3)}
.pol-media-thumb img,.pol-media-thumb video{width:100%;height:100%;object-fit:cover}
.pol-media-body{padding:12px;display:flex;flex-direction:column;gap:8px}
.pol-media-body strong{font-size:14px}
.pol-media-tags{display:flex;gap:6px;flex-wrap:wrap}
.pol-tag{border:1px solid var(--f-stroke-1);background:var(--f-surface-2);border-radius:999px;padding:4px 10px;
  font-size:12px;font-weight:600;cursor:pointer;color:var(--f-fg-3)}
.pol-tag.on{background:var(--f-brand-tint-10);color:var(--f-brand);border-color:var(--f-brand-tint-20)}
.pol-analytics{display:grid;grid-template-columns:repeat(3,1fr);gap:12px}
@media(max-width:700px){.pol-analytics{grid-template-columns:1fr 1fr}.pol-item-body{grid-template-columns:1fr}}

/* Landing media upload controls */
.landing-media-field {
  display: grid;
  gap: 12px;
}

.landing-media-preview,
.pol-preview {
  min-height: 180px;
  border: 1px dashed var(--f-stroke-2);
  border-radius: 16px;
  background: #fff7f7;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.landing-media-preview img,
.landing-media-preview video,
.pol-preview img,
.pol-preview video {
  width: 100%;
  max-height: 260px;
  object-fit: cover;
}

.pol-media-empty {
  color: var(--f-fg-3);
  font-weight: 700;
  padding: 22px;
}

.landing-media-actions,
.advanced-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.upload-btn {
  cursor: pointer;
  margin: 0;
}

.landing-advanced {
  border: 1px solid var(--f-stroke-1);
  border-radius: 14px;
  padding: 10px 12px;
  background: #fff;
}

.landing-advanced summary {
  cursor: pointer;
  color: var(--f-fg-3);
  font-size: 12px;
  font-weight: 800;
}

.advanced-row {
  margin-top: 10px;
}

.advanced-row input {
  flex: 1 1 260px;
}

/* review image uploader (testimonials admin) */
.review-upload{display:flex;flex-direction:column;gap:8px}
.pol-flabel{display:block;font-size:12px;font-weight:600;color:var(--f-fg-3);margin-bottom:4px}
.review-upload-preview{width:100%;max-width:220px;min-height:90px;border:1px dashed var(--f-stroke-1);border-radius:var(--f-radius-md);
  background:var(--f-surface-2);display:flex;align-items:center;justify-content:center;overflow:hidden}
.review-upload-preview img{width:100%;height:auto;display:block}
.review-upload-preview span{color:var(--f-fg-3);font-size:12px}
.review-upload-actions{display:flex;gap:8px;align-items:center}
.upload-btn{cursor:pointer}

/* Readability pass: inputs and secondary text +2px. */
input,
select,
textarea,
.filter-group input,
.filter-group select,
.form-grid input,
.form-grid select,
.form-grid textarea,
.settings-field input,
.settings-field select,
.settings-field textarea,
.global-search input,
.chat-compose input,
.auth-field input,
.phone-field input,
.pol-form input,
.pol-form select,
.pol-form textarea,
.advanced-row input {
  font-size: calc(1em + 2px) !important;
}

.panel-title span,
.metric-card span,
.metric-card small,
.feed-item span,
.appointment-item span,
.notification-item span,
.inbox-item span,
.backup-row span,
.portfolio-body span,
.auth-hint,
.form-note,
.empty-state,
.table-panel th,
.category-tab,
.status-pill,
.source-chip,
.pol-stat span,
.pol-navitem,
.pol-card-head span,
.landing-advanced summary,
.user-chip span,
.page-head p,
.field-error {
  font-size: calc(1em + 2px) !important;
}

/* Production responsive hardening: dashboard + admin pages on phones. */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

* {
  min-width: 0;
}

img,
video,
canvas,
svg {
  max-width: 100%;
}

.data-table-wrap,
.table-scroll,
.table-panel,
.settings-grid,
.polaris-shell,
.pol-card,
.modal-card,
.workspace,
.view {
  min-width: 0;
}

@media (max-width: 860px) {
  body {
    font-size: 15px;
  }

  .dashboard-shell {
    min-height: 100dvh;
    display: grid !important;
    grid-template-columns: 1fr !important;
    grid-template-rows: auto auto minmax(0, 1fr) !important;
    direction: rtl;
    overflow-x: hidden;
  }

  .app-header {
    grid-column: 1 !important;
    grid-row: 1 !important;
    display: grid !important;
    grid-template-columns: 1fr auto !important;
    grid-template-areas:
      "user bell"
      "search search" !important;
    gap: 10px !important;
    min-height: auto !important;
    padding: 10px 14px !important;
    direction: rtl;
    position: sticky;
    top: 0;
    z-index: 30;
  }

  .user-chip {
    grid-area: user;
    justify-self: start;
    max-width: 100%;
  }

  .user-trigger {
    max-width: min(260px, calc(100vw - 82px));
    min-height: 46px;
    padding: 7px 10px !important;
  }

  .user-trigger strong,
  .user-chip strong {
    font-size: 14px !important;
  }

  .user-trigger span,
  .user-chip span {
    font-size: 12px !important;
  }

  .round-icon {
    grid-area: bell;
    justify-self: end;
    width: 44px !important;
    height: 44px !important;
  }

  .global-search {
    grid-area: search;
    width: 100% !important;
    max-width: none !important;
    height: 44px !important;
    justify-self: stretch !important;
  }

  .global-search input {
    font-size: 14px !important;
  }

  .header-logo {
    display: none !important;
  }

  .side-rail {
    grid-column: 1 !important;
    grid-row: 2 !important;
    width: 100% !important;
    max-width: 100vw;
    justify-content: flex-start !important;
    padding: 8px 10px !important;
    border-left: 0 !important;
    border-bottom: 1px solid var(--line) !important;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    position: sticky;
    top: 118px;
    z-index: 29;
  }

  .rail-nav {
    display: flex !important;
    flex-direction: row !important;
    align-items: stretch !important;
    gap: 6px !important;
    width: max-content !important;
    min-width: max-content !important;
  }

  .rail-item {
    width: 62px !important;
    min-width: 62px !important;
    min-height: 58px !important;
    padding: 6px 4px !important;
    border-radius: 12px !important;
  }

  .rail-item svg {
    width: 20px !important;
    height: 20px !important;
  }

  .rail-item span {
    max-width: 56px !important;
    font-size: 10px !important;
    line-height: 1.25 !important;
    white-space: normal !important;
  }

  .rail-item.logout-item {
    margin-top: 0 !important;
  }

  .workspace {
    grid-column: 1 !important;
    grid-row: 3 !important;
    width: 100% !important;
    max-width: 100vw;
    padding: 16px 14px 88px !important;
    overflow-x: hidden;
  }

  .page-head,
  .table-tools,
  .panel-title,
  .pol-card-head {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
    align-items: start !important;
  }

  .page-head h1,
  .hero-title,
  .view h1 {
    font-size: 24px !important;
    line-height: 1.3 !important;
  }

  .metric-row,
  .dashboard-grid,
  .settings-grid,
  .calendar-layout,
  .portfolio-grid,
  .detail-body,
  .detail-hero,
  .form-grid,
  .polaris-shell,
  .pol-form,
  .pol-item-body,
  .landing-json-grid {
    grid-template-columns: 1fr !important;
  }

  [data-view="home"] .metric-row {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
  }

  .metric-card,
  .metric-row > * {
    min-height: 112px !important;
    padding: 14px !important;
    border-radius: 14px !important;
  }

  .metric-card strong {
    font-size: 19px !important;
  }

  .metric-card span,
  .metric-card small {
    font-size: 12px !important;
  }

  .panel,
  .chart-card,
  .donut-card,
  .timeline-card,
  .notifications-card,
  .backup-panel,
  .calendar-panel,
  .table-panel,
  .chat-card,
  .detail-card,
  .mini-feed,
  .pol-card {
    border-radius: 14px !important;
    padding: 14px !important;
    min-height: auto !important;
  }

  .data-table-wrap,
  .table-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .data-table {
    min-width: 680px;
  }

  .filter-group,
  .head-actions,
  .landing-media-actions,
  .advanced-row,
  .review-upload-actions {
    width: 100%;
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  .filter-group input,
  .filter-group select,
  .head-actions button,
  .blue-button,
  .danger-button,
  .dark-action,
  .ghost-action,
  .pol-form input,
  .pol-form select,
  .pol-form textarea,
  .form-grid input,
  .form-grid select,
  .form-grid textarea,
  .settings-field input,
  .settings-field select,
  .settings-field textarea {
    width: 100% !important;
    min-height: 44px;
  }

  textarea {
    min-height: 112px;
  }

  .polaris-nav {
    position: static !important;
    display: flex !important;
    flex-direction: row !important;
    overflow-x: auto !important;
    gap: 6px !important;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }

  .pol-navitem {
    flex: 0 0 auto;
    white-space: nowrap;
    min-height: 42px;
  }

  .pol-media-grid {
    grid-template-columns: 1fr !important;
  }

  .modal {
    align-items: end !important;
    padding: 10px !important;
  }

  .modal-card {
    width: 100% !important;
    max-height: calc(100dvh - 24px);
    overflow: auto;
    border-radius: 18px 18px 0 0 !important;
  }

  .chat-drawer {
    width: min(100vw, 430px) !important;
  }
}

@media (max-width: 430px) {
  .app-header {
    padding: 9px 10px !important;
  }

  .workspace {
    padding-inline: 10px !important;
  }

  [data-view="home"] .metric-row {
    grid-template-columns: 1fr !important;
  }

  .rail-item {
    width: 58px !important;
    min-width: 58px !important;
  }

  .rail-item span {
    font-size: 9px !important;
  }
}
