/* Feel IT Insight — design system.
 * Mirrors feelit.pro landing palette: white + #f5f5f5 surfaces,
 * #1a5c38 primary green, Inter, green-tinted shadows.
 *
 * Layout breakpoints:
 *   <760px : phone — bottom tab nav, hamburger drawer, KPI 2x2
 *   ≥760px : tablet — sidebar always visible, KPI 4x1
 *   ≥1100px: desktop — comfortable padding, charts side-by-side
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  /* feelit.pro palette */
  --green:        #1a5c38;
  --green-dark:   #144a2c;
  --green-soft:   #e8f3ed;
  --white:        #ffffff;
  --gray:         #f5f5f5;
  --gray-2:       #ececec;
  --gray-border:  #e2e2e2;
  --text:         #1a2a22;
  --muted:        #5a6a62;
  --muted-2:      #8a948f;

  /* Semantic */
  --positive:     #1a5c38;
  --negative:     #c0392b;
  --warning:      #d97706;

  /* Surfaces */
  --shadow-sm: 0 1px 2px rgba(20, 74, 44, .06), 0 1px 3px rgba(20, 74, 44, .04);
  --shadow-md: 0 4px 14px rgba(20, 74, 44, .08), 0 2px 4px rgba(20, 74, 44, .04);
  --shadow-lg: 0 14px 36px rgba(20, 74, 44, .12), 0 4px 10px rgba(20, 74, 44, .06);

  --radius:     14px;
  --radius-sm:   10px;
  --radius-lg:   20px;

  --sidebar-w:   220px;
  --topbar-h:    60px;
  --bottom-nav-h: 60px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px; line-height: 1.5;
  color: var(--text); background: var(--gray);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
a { color: var(--green); text-decoration: none; }
a:hover { color: var(--green-dark); }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; line-height: 1.25; }

/* ---- Splash (initial load) -------------------------------------------- */
.splash {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--gray); color: var(--muted); font-size: 14px;
}

/* ---- Auth screens (login) --------------------------------------------- */
.auth-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: linear-gradient(180deg, var(--green-soft) 0%, var(--white) 100%);
}
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--gray-border);
  padding: 32px 28px;
}
.auth-logo {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 20px;
}
.auth-logo-img {
  height: 36px; width: auto; display: block;
}
.auth-logo .brand-suffix {
  font-weight: 600; font-size: 18px;
  color: var(--muted); letter-spacing: -0.01em;
}
.auth-logo .brand-name {
  font-size: 18px; font-weight: 800; letter-spacing: -0.01em;
}
.auth-card h1 { font-size: 24px; margin-bottom: 4px; }
.auth-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.auth-card .form-row { margin-bottom: 14px; }
.auth-card label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--muted); margin-bottom: 6px; letter-spacing: .02em;
}
.auth-card input[type="email"],
.auth-card input[type="password"],
.auth-card input[type="text"] {
  width: 100%; min-height: 48px;
  padding: 12px 14px;
  font-size: 15px;
  border: 1.5px solid var(--gray-border);
  border-radius: 12px;
  background: var(--white); color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.auth-card input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(26, 92, 56, .12);
}
.auth-card .error {
  margin-top: 10px; padding: 10px 12px;
  background: rgba(192, 57, 43, .08); color: var(--negative);
  border-radius: 10px; font-size: 13px;
  display: none;
}
.auth-card .error.is-shown { display: block; }
.auth-card .hint { font-size: 12px; color: var(--muted-2); margin-top: 14px; text-align: center; }

/* ---- App shell -------------------------------------------------------- */
.app-shell { min-height: 100vh; display: flex; }

/* Sidebar (desktop ≥760px) / Drawer (mobile, slides in) */
.sidebar {
  width: var(--sidebar-w);
  background: var(--white);
  border-right: 1px solid var(--gray-border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  z-index: 30;
  flex-shrink: 0;
}
.sidebar-head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--gray-border);
  display: flex; align-items: center; gap: 10px;
  min-height: var(--topbar-h);
}
.sidebar-logo { display: flex; align-items: center; gap: 8px; min-width: 0; }
.sidebar-logo-img {
  /* Source SVG is 525×200; height-locked keeps it crisp at any sidebar width. */
  height: 26px; width: auto; display: block; flex-shrink: 0;
}
.brand-suffix {
  font-weight: 600; font-size: 14px;
  color: var(--muted);
  letter-spacing: -0.01em;
  white-space: nowrap;
}
/* Legacy classes kept for views that still reference them in fallback text */
.brand-text { font-weight: 800; font-size: 15px; letter-spacing: -0.01em; }
.brand-text .it-mark { color: var(--green); }
.sidebar-close {
  margin-left: auto; background: none; border: 0; padding: 6px;
  color: var(--muted); border-radius: 8px; display: none;
}
.sidebar-close:hover { background: var(--gray); color: var(--text); }

.nav {
  flex: 1; padding: 12px 10px; overflow-y: auto;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin-bottom: 2px;
  color: var(--muted); font-weight: 500; font-size: 14px;
  border-radius: var(--radius-sm);
  cursor: pointer; user-select: none;
}
.nav-item:hover { background: var(--gray); color: var(--text); }
.nav-item.is-active {
  background: var(--green-soft); color: var(--green); font-weight: 600;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-foot {
  padding: 12px 14px;
  border-top: 1px solid var(--gray-border);
  font-size: 12px;
}
.user-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  background: var(--gray); margin-bottom: 8px;
  min-width: 0;
}
.user-pill .avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--green); color: var(--white);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; flex-shrink: 0;
}
.user-pill .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-pill .who small { color: var(--muted); display: block; font-size: 11px; }

.lang-switch {
  display: inline-flex; gap: 3px; padding: 3px;
  background: var(--gray); border-radius: 10px;
  margin-bottom: 8px;
}
.lang-switch button {
  font-size: 11px; font-weight: 600;
  padding: 5px 9px; border-radius: 7px; border: 0;
  background: transparent; color: var(--muted);
  letter-spacing: .04em; line-height: 1;
}
.lang-switch button.is-active { background: var(--green); color: var(--white); }
.lang-switch button:not(.is-active):hover { background: var(--white); color: var(--green); }

.logout-link {
  display: block; padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--muted); font-size: 13px; font-weight: 500;
}
.logout-link:hover { background: var(--gray); color: var(--negative); }

/* ---- Body / topbar / content ----------------------------------------- */
.app-body {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  /* Reserve room for bottom tabs on mobile so the last row of content
     isn't hidden behind the fixed nav. */
  padding-bottom: 0;
}
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--gray-border);
  min-height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 8px 18px;
}
.topbar-toggle {
  background: none; border: 0; padding: 6px;
  color: var(--text); border-radius: 8px;
  display: none; /* shown on phone */
}
.topbar-toggle svg { width: 22px; height: 22px; }
.topbar-toggle:hover { background: var(--gray); }
.topbar .biz-name {
  font-weight: 700; font-size: 15px;
  flex-shrink: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 200px;
}
.topbar .spacer { flex: 1; }

/* Date range picker pill */
.daterange {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--gray); padding: 6px 12px; border-radius: 100px;
  font-size: 13px; color: var(--text);
  border: 1px solid transparent;
  cursor: pointer; user-select: none;
}
.daterange:hover { border-color: var(--gray-border); }
.daterange svg { width: 14px; height: 14px; color: var(--muted); }
.daterange .label { font-weight: 500; }

/* Sync status */
.sync-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 100px;
  background: var(--green-soft); color: var(--green);
  font-size: 12px; font-weight: 600;
  border: 0; cursor: pointer; user-select: none;
}
.sync-pill .dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--green);
}
.sync-pill.is-running .dot { animation: pulse 1.4s ease-in-out infinite; }
.sync-pill.is-stale { background: rgba(217, 119, 6, .12); color: var(--warning); }
.sync-pill.is-stale .dot { background: var(--warning); }
.sync-pill.is-error { background: rgba(192, 57, 43, .08); color: var(--negative); }
.sync-pill.is-error .dot { background: var(--negative); }
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .55; transform: scale(1.4); }
}

/* Main content */
.main {
  flex: 1; min-width: 0; padding: 18px;
}
.view-title {
  font-size: 22px; font-weight: 700; margin: 0 0 4px;
}
.view-sub {
  color: var(--muted); font-size: 13px; margin: 0 0 18px;
}

/* ---- Cards ------------------------------------------------------------ */
.card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--gray-border);
  box-shadow: var(--shadow-sm);
  padding: 16px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.card-head h3 { font-size: 14px; color: var(--text); font-weight: 600; }
.card-head .head-action {
  font-size: 12px; color: var(--muted); font-weight: 500;
  display: inline-flex; align-items: center; gap: 4px;
}
.card-head .badge-muted {
  background: var(--gray); color: var(--muted);
  padding: 3px 8px; border-radius: 100px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
}

/* ---- KPI tiles ------------------------------------------------------- */
.kpi-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(2, 1fr);
  margin-bottom: 18px;
}
.kpi {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--gray-border);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 4px;
  min-width: 0;
}
.kpi .label {
  font-size: 11px; font-weight: 600; color: var(--muted);
  letter-spacing: .04em; text-transform: uppercase;
  display: flex; align-items: center; gap: 4px;
}
.kpi .label svg { width: 14px; height: 14px; color: var(--muted-2); }
.kpi .value {
  font-size: 24px; font-weight: 800; color: var(--text);
  letter-spacing: -0.02em; line-height: 1.1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kpi .delta {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600;
  color: var(--muted);
}
.kpi .delta.positive { color: var(--positive); }
.kpi .delta.negative { color: var(--negative); }
.kpi .delta svg { width: 12px; height: 12px; }
.kpi .sub { font-size: 11px; color: var(--muted-2); margin-top: 2px; }

/* ---- Charts row ------------------------------------------------------ */
.row {
  display: grid; gap: 12px;
  grid-template-columns: 1fr;
  margin-bottom: 18px;
}
.row-2 { grid-template-columns: 1fr; }
.chart-card { min-height: 280px; }
.chart-wrap {
  position: relative; height: 220px; width: 100%;
}

/* ---- Tables ---------------------------------------------------------- */
.table-wrap {
  overflow-x: auto;
  margin: -6px;
  padding: 6px;
}
.table {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}
.table th, .table td {
  text-align: left; padding: 10px 8px;
  border-bottom: 1px solid var(--gray-border);
}
.table th {
  font-weight: 600; color: var(--muted);
  font-size: 11px; letter-spacing: .04em; text-transform: uppercase;
  background: transparent;
}
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .truncate { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table .muted { color: var(--muted); font-size: 12px; }

/* Recent / list rows on mobile become card-like */
.list-rows .list-row {
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-border);
  display: grid; grid-template-columns: 1fr auto; gap: 4px;
  align-items: baseline;
}
.list-rows .list-row:last-child { border-bottom: 0; }
.list-rows .list-row .primary { font-weight: 600; font-size: 13px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.list-rows .list-row .secondary { color: var(--muted); font-size: 12px; }
.list-rows .list-row .amount { font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; }

/* ---- Top-products horizontal bars ----------------------------------- */
.hbar-list { display: flex; flex-direction: column; gap: 10px; }
.hbar {
  display: grid; grid-template-columns: 1fr auto; gap: 4px;
  align-items: baseline; font-size: 13px;
}
.hbar .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.hbar .val { font-variant-numeric: tabular-nums; font-weight: 600; }
.hbar .track {
  grid-column: 1 / -1;
  height: 6px; background: var(--gray); border-radius: 100px; overflow: hidden;
}
.hbar .track .fill {
  height: 100%; background: var(--green); border-radius: 100px;
  transition: width .5s cubic-bezier(.2,.8,.2,1);
}

/* ---- Badges --------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700;
  padding: 4px 9px; border-radius: 100px;
  letter-spacing: .04em; text-transform: uppercase;
  line-height: 1;
}
.badge-positive { background: var(--green-soft); color: var(--green); }
.badge-warning  { background: rgba(217, 119, 6, .12); color: var(--warning); }
.badge-danger   { background: rgba(192, 57, 43, .1); color: var(--negative); }
.badge-muted    { background: var(--gray); color: var(--muted); }

/* ---- Buttons -------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; min-height: 44px;
  font-size: 14px; font-weight: 600;
  border-radius: 12px; border: 0; cursor: pointer;
  line-height: 1.2;
  transition: transform .08s ease, box-shadow .15s ease, background .15s ease, color .15s ease;
}
.btn-primary { background: var(--green); color: var(--white); }
.btn-primary:hover { background: var(--green-dark); box-shadow: var(--shadow-md); }
.btn-primary:active { transform: translateY(0); }
.btn-ghost { background: transparent; color: var(--green); border: 1.5px solid var(--green); }
.btn-ghost:hover { background: var(--green-soft); }
.btn-subtle { background: var(--gray); color: var(--text); }
.btn-subtle:hover { background: var(--gray-2); }
.btn-danger { background: var(--negative); color: var(--white); }
.btn-sm { padding: 7px 12px; min-height: 32px; font-size: 12px; border-radius: 9px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }

/* ---- Forms --------------------------------------------------------- */
.form-row { margin-bottom: 12px; }
.form-row label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--muted); margin-bottom: 5px; letter-spacing: .02em;
}
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], select, textarea {
  width: 100%; min-height: 40px;
  padding: 9px 12px;
  font-size: 14px;
  border: 1.5px solid var(--gray-border);
  border-radius: 10px;
  background: var(--white); color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(26, 92, 56, .12);
}

/* ---- Mixed currency banner ------------------------------------------ */
.banner {
  padding: 12px 14px; border-radius: var(--radius);
  background: rgba(217, 119, 6, .08); color: var(--warning);
  border: 1px solid rgba(217, 119, 6, .25);
  font-size: 13px; margin-bottom: 14px;
  display: flex; align-items: flex-start; gap: 10px;
}
.banner svg { flex-shrink: 0; margin-top: 2px; }
.banner select {
  margin-left: 8px; padding: 4px 8px; min-height: 28px;
  background: var(--white); border-color: rgba(217, 119, 6, .35);
}

/* ---- Empty states --------------------------------------------------- */
.empty {
  padding: 30px 18px; text-align: center;
  color: var(--muted); font-size: 13px;
}
.empty .empty-title { font-weight: 600; color: var(--text); margin-bottom: 4px; }

/* ---- Toast --------------------------------------------------------- */
#toast-root {
  position: fixed; bottom: calc(var(--bottom-nav-h) + 20px); left: 50%;
  transform: translateX(-50%); z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
  max-width: calc(100vw - 32px);
}
.toast {
  background: var(--text); color: var(--white);
  padding: 10px 16px; border-radius: 100px;
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in .25s ease;
}
.toast.is-error { background: var(--negative); }
.toast.is-success { background: var(--green); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ---- Modal --------------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 150;
  background: rgba(20, 30, 24, .55);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  animation: fade-in .2s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--white); border-radius: var(--radius-lg);
  width: 100%; max-width: 460px;
  max-height: calc(100vh - 32px); overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-head {
  padding: 18px 22px 8px;
  display: flex; align-items: center; justify-content: space-between;
}
.modal-head h2 { font-size: 18px; }
.modal-close {
  background: none; border: 0; padding: 4px; color: var(--muted);
  border-radius: 8px;
}
.modal-close:hover { background: var(--gray); color: var(--text); }
.modal-body { padding: 8px 22px 18px; }
.modal-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--gray-border);
  display: flex; gap: 10px; justify-content: flex-end;
}

/* ---- Bottom nav (phone only) --------------------------------------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-h);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--white);
  border-top: 1px solid var(--gray-border);
  display: none; /* shown on phone */
  z-index: 25;
}
.bottom-nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
  padding: 6px 4px;
  color: var(--muted); font-size: 10px; font-weight: 600;
  cursor: pointer; user-select: none;
}
.bottom-nav-item svg { width: 20px; height: 20px; }
.bottom-nav-item.is-active { color: var(--green); }
.bottom-nav-item.is-active svg { color: var(--green); }

/* Backdrop for sidebar drawer on mobile */
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0; z-index: 28;
  background: rgba(20, 30, 24, .4);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
  animation: fade-in .15s ease;
}

/* ============================================================
   Mobile-first → larger screens
   ============================================================ */

/* ---- Phone (default <760) ---- */
@media (max-width: 759px) {
  .sidebar {
    position: fixed; top: 0; left: 0;
    height: 100vh; width: 270px;
    transform: translateX(-100%);
    transition: transform .22s cubic-bezier(.2,.8,.2,1);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-backdrop.is-open { display: block; }
  .sidebar-close { display: inline-flex; }
  .topbar-toggle { display: inline-flex; }
  .bottom-nav { display: flex; }
  .app-body { padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom)); }
  .main { padding: 14px; }
  .topbar { padding: 8px 12px; gap: 8px; }
  .topbar .biz-name { font-size: 14px; max-width: 130px; }
  .daterange .label { display: none; }
  .sync-pill { padding: 6px 10px; }
  .sync-pill .label { display: none; }
}

/* ---- Tablet+ (≥760) ---- */
@media (min-width: 760px) {
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  .row-2 { grid-template-columns: 1fr 1fr; }
  .main { padding: 22px 26px; }
  .kpi .value { font-size: 26px; }
}

/* ---- Desktop (≥1100) ---- */
@media (min-width: 1100px) {
  .main { padding: 26px 32px; max-width: 1400px; }
}

/* ============================================================
   Reduce motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
