/* ==========================================================================
   Timegem application UI — faithful static replica.
   Mirrors the production design tokens so the demo reads as the real product.
   All data rendered through these classes is fictional.
   ========================================================================== */

@import url('../fonts/fonts.css');

:root {
  /* Foundation — neutral palette */
  --ink: #0a0a0a;
  --slate-fg: #737373;
  --mist: #a0a0a0;
  --hairline: #e8e5e1;
  --page: #ffffff;
  --linen: #f5f2ed;

  /* Productivity — functional colours used in charts and reports */
  --prod-productive: #10b981;
  --prod-neutral: #0ea5e9;
  --prod-unproductive: #f97316;
  --prod-flagged: #dc2626;
  --prod-idle: #cbd5e1;

  /* Greys */
  --s50: #f8fafc;
  --s100: #f1f5f9;
  --s200: #e2e8f0;
  --s300: #cbd5e1;
  --s400: #94a3b8;
  --s500: #64748b;
  --s600: #475569;
  --s700: #334155;
  --s900: #0f172a;

  --font-ui: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', monospace;
}

.tg,
.tg *,
.tg *::before,
.tg *::after { box-sizing: border-box; }

.tg {
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--page);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.tg button { font: inherit; color: inherit; cursor: pointer; }
.tg .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---------- Shell ------------------------------------------------------ */

.tg-shell { display: flex; min-height: 100%; background: var(--page); }

.tg-sidebar {
  width: 240px;
  flex: 0 0 240px;
  border-right: 1px solid var(--hairline);
  background: #fff;
  display: flex;
  flex-direction: column;
}

.tg-brand {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px;
  border-bottom: 1px solid var(--hairline);
  font-weight: 600;
  letter-spacing: .12em;
  font-size: 12.5px;
  text-transform: uppercase;
}
.tg-brand svg { flex: 0 0 auto; }

.tg-nav { flex: 1; overflow-y: auto; padding: 12px; }
.tg-nav-group + .tg-nav-group { margin-top: 12px; }
.tg-nav-label {
  padding: 8px 12px 2px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--slate-fg);
}
.tg-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: 0;
  background: none;
  text-align: left;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13.5px;
  color: var(--slate-fg);
  transition: background .12s, color .12s;
  text-decoration: none;
}
.tg-nav-item + .tg-nav-item { margin-top: 2px; }
.tg-nav-item:hover { background: var(--linen); color: var(--ink); }
.tg-nav-item.is-active { background: var(--ink); color: #fff; }
.tg-nav-item .ico { flex: 0 0 16px; opacity: .85; }

.tg-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.tg-topbar {
  height: 56px;
  flex: 0 0 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--s200);
  background: #fff;
  padding: 0 24px;
}
.tg-topbar-right { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.tg-bell {
  position: relative; border: 0; background: none; padding: 6px;
  border-radius: 6px; color: var(--s400);
}
.tg-bell:hover { background: var(--s50); }
.tg-bell .dot-badge {
  position: absolute; top: 3px; right: 3px;
  width: 15px; height: 15px; border-radius: 999px;
  background: #dc2626; color: #fff;
  font-size: 9px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.tg-user { display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 4px; border-radius: 6px; }
.tg-user:hover { background: var(--s50); }
.tg-user .meta { text-align: right; line-height: 1.25; }
.tg-user .meta b { display: block; font-size: 13px; font-weight: 500; color: var(--s900); }
.tg-user .meta span { font-size: 11.5px; color: var(--s500); text-transform: capitalize; }
.tg-avatar {
  width: 36px; height: 36px; border-radius: 999px;
  background: var(--ink); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
}

.tg-page { flex: 1; overflow-y: auto; background: var(--page); }
.tg-page-inner { max-width: 1280px; margin: 0 auto; padding: 32px; }

.tg-h1 { font-size: 23px; font-weight: 600; color: var(--s900); margin: 0; letter-spacing: -.01em; }
.tg-sub { font-size: 13px; color: var(--s500); margin: 4px 0 0; }
.tg-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }
.tg-h2 { font-size: 13px; font-weight: 600; color: var(--s700); margin: 0; }

/* ---------- Cards, KPIs ------------------------------------------------ */

.tg-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .05);
  outline: 1px solid var(--s200);
  outline-offset: -1px;
}
.tg-card-pad { padding: 24px; }

/* Auto-fit rather than a fixed column count: the row then responds to the
   width of its CONTAINER, not the viewport. That keeps a phone from
   overflowing and keeps the portfolio page's scaled 1320px previews at their
   full desktop column count regardless of the visitor's screen size. */
.tg-kpis { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(126px, 1fr)); }
.tg-kpi { background: #fff; border-radius: 12px; padding: 16px 14px; box-shadow: 0 1px 2px rgba(15,23,42,.05); outline: 1px solid var(--s200); outline-offset: -1px; }
.tg-kpi .k { font-size: 10.5px; font-weight: 500; text-transform: uppercase; letter-spacing: .05em; color: var(--s500); }
.tg-kpi .v { margin-top: 8px; font-size: 22px; font-weight: 600; color: var(--s900); letter-spacing: -.02em; line-height: 1.1; }
.tg-kpi .avg { margin-top: 4px; font-size: 11px; font-weight: 500; color: var(--s500); }
.tg-kpi.t-unproductive .v { color: #ea580c; }
.tg-kpi.t-flagged .v { color: #dc2626; }
.tg-kpi.t-productive .v { color: var(--ink); }

/* ---------- Pills / badges --------------------------------------------- */

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: 999px; padding: 2px 9px;
  font-size: 11px; font-weight: 500; white-space: nowrap;
}
.pill .d { width: 6px; height: 6px; border-radius: 999px; background: currentColor; opacity: .85; }
.pill-emerald { background: #d1fae5; color: #065f46; }
.pill-amber   { background: #fef3c7; color: #92400e; }
.pill-red     { background: #fee2e2; color: #991b1b; }
.pill-slate   { background: var(--s200); color: var(--s700); }
.pill-mute    { background: var(--s100); color: var(--s500); }
.pill-violet  { background: #ede9fe; color: #5b21b6; }
.pill-sky     { background: #e0f2fe; color: #075985; }
.pill-orange  { background: #ffedd5; color: #9a3412; }

.dot { width: 8px; height: 8px; border-radius: 999px; display: inline-block; flex: 0 0 8px; }
.dot-present { background: #10b981; }
.dot-late { background: #f59e0b; }
.dot-absent { background: #ef4444; }
.dot-notyet { background: var(--s400); }
.dot-off { background: var(--s300); }
.dot-holiday { background: #a78bfa; }
.dot-online { background: #10b981; box-shadow: 0 0 0 3px rgba(16,185,129,.18); }
.dot-offline { background: var(--s300); }

/* ---------- Tables ----------------------------------------------------- */

.tg-tablewrap { overflow-x: auto; border-radius: 12px; }
.tg-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tg-table thead th {
  background: var(--s50);
  text-align: left;
  font-size: 10.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--s500);
  padding: 11px 16px;
  white-space: nowrap;
}
.tg-table thead th.r, .tg-table td.r { text-align: right; }
.tg-table thead th.c, .tg-table td.c { text-align: center; }
.tg-table tbody td { padding: 11px 16px; border-top: 1px solid var(--s100); vertical-align: middle; }
.tg-table tbody tr:hover { background: var(--s50); }
.tg-table .name { font-weight: 500; color: var(--s900); }
.tg-table .muted { color: var(--s500); font-size: 11.5px; }

/* Several screens reuse .name / .muted outside a table (list rows, calendar
   entries, card sub-lines). Define them at the .tg root too so they style
   consistently wherever they appear; the table rules above still win inside
   a table by specificity. */
.tg .name { font-weight: 500; color: var(--s900); }
.tg .muted { color: var(--s500); font-size: 11.5px; }

/* ---------- Controls --------------------------------------------------- */

.tg-btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 36px; padding: 0 15px; border-radius: 6px;
  border: 1px solid var(--s300); background: #fff; color: var(--s700);
  font-size: 13px; font-weight: 500; white-space: nowrap;
}
.tg-btn:hover { background: var(--s50); }
.tg-btn-dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.tg-btn-dark:hover { opacity: .9; background: var(--ink); }
.tg-btn-sm { height: 30px; padding: 0 11px; font-size: 12px; }
.tg-btn-ghost { border-color: transparent; background: transparent; color: var(--s500); }
.tg-btn-ghost:hover { background: var(--s100); color: var(--s900); }
.tg-btn:disabled { opacity: .5; cursor: default; }

.tg-input, .tg-select {
  height: 34px; border: 1px solid var(--s300); border-radius: 6px;
  background: #fff; padding: 0 10px; font-size: 13px; color: var(--s900);
  font-family: inherit;
}
.tg-field > span { display: block; font-size: 10.5px; font-weight: 500; text-transform: uppercase; letter-spacing: .05em; color: var(--s500); margin-bottom: 5px; }
.tg-textarea { border: 1px solid var(--s300); border-radius: 6px; padding: 8px 10px; font-size: 13px; font-family: inherit; width: 100%; resize: vertical; }

.tg-seg { display: inline-flex; border: 1px solid var(--s200); border-radius: 8px; overflow: hidden; background: #fff; }
.tg-seg button { border: 0; background: #fff; padding: 7px 13px; font-size: 12.5px; color: var(--s600); }
.tg-seg button + button { border-left: 1px solid var(--s200); }
.tg-seg button:hover { background: var(--s50); }
.tg-seg button.is-active { background: var(--ink); color: #fff; }

.tg-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--s200); }
.tg-tabs button {
  border: 0; background: none; padding: 9px 14px; font-size: 13px; color: var(--s500);
  border-bottom: 2px solid transparent; margin-bottom: -1px; display: inline-flex; align-items: center; gap: 7px;
}
.tg-tabs button:hover { color: var(--s900); }
.tg-tabs button.is-active { color: var(--s900); font-weight: 500; border-bottom-color: var(--ink); }
.tg-tabs .count { background: var(--s100); color: var(--s600); border-radius: 999px; padding: 1px 7px; font-size: 10.5px; font-weight: 600; }

.tg-toggle { width: 34px; height: 20px; border-radius: 999px; background: var(--s300); position: relative; border: 0; padding: 0; display: inline-block; transition: background .15s; }
.tg-toggle::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 999px; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.tg-toggle.is-on { background: var(--prod-productive); }
.tg-toggle.is-on::after { transform: translateX(14px); }

/* ---------- Productivity bar ------------------------------------------- */

.prodbar { display: flex; align-items: flex-end; gap: 2px; height: 132px; }
.prodbar .col { flex: 1 1 0; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; border-radius: 2px 2px 0 0; overflow: hidden; background: var(--s100); }
.prodbar .seg { width: 100%; }
.seg-productive { background: var(--prod-productive); }
.seg-neutral { background: var(--prod-neutral); }
.seg-unproductive { background: var(--prod-unproductive); }
.seg-flagged { background: var(--prod-flagged); }
.seg-idle { background: var(--prod-idle); }
.prodbar-axis { display: flex; justify-content: space-between; margin-top: 8px; font-size: 10.5px; color: var(--s500); font-family: var(--font-mono); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 11.5px; color: var(--s600); }
.legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; margin-right: 6px; vertical-align: -1px; }

/* ---------- Donut ------------------------------------------------------ */

.donut { display: block; }
.donut-wrap { display: flex; align-items: center; gap: 20px; }

/* ---------- Presence strip --------------------------------------------- */

.presence { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--s100); }
.presence i { display: block; height: 100%; }
.pres-office { background: #0ea5e9; }
.pres-home { background: #8b5cf6; }
.pres-unknown { background: var(--s300); }

/* ---------- AI summary card -------------------------------------------- */

.ai-card { border-radius: 12px; padding: 20px 22px; background: linear-gradient(135deg, #f5f2ed 0%, #eef6f2 100%); outline: 1px solid var(--hairline); outline-offset: -1px; }
.ai-card .hd { display: flex; align-items: center; gap: 9px; }
.ai-card h3 { margin: 0; font-size: 13px; font-weight: 600; color: var(--s900); }
.ai-card .headline { margin: 12px 0 0; font-size: 15px; font-weight: 600; color: var(--ink); letter-spacing: -.01em; }
.ai-card .bodytext { margin: 7px 0 0; font-size: 13px; color: var(--s600); line-height: 1.6; max-width: 80ch; }
.ai-insights { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.ai-insights span { background: rgba(255,255,255,.75); border: 1px solid var(--hairline); border-radius: 999px; padding: 4px 11px; font-size: 11.5px; color: var(--s700); }
.ai-insights span b { font-weight: 600; color: var(--ink); }

/* ---------- Screenshot grid -------------------------------------------- */

.shot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(208px, 1fr)); gap: 14px; }
.shot-tile { border-radius: 10px; overflow: hidden; outline: 1px solid var(--s200); outline-offset: -1px; background: #fff; }
.shot-tile .thumb { aspect-ratio: 16/10; position: relative; overflow: hidden; background: var(--s100); display: block; }
.shot-tile .cap { padding: 8px 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.shot-tile .cap .t { font-family: var(--font-mono); font-size: 11px; color: var(--s700); }
.shot-tile .cap .a { font-size: 10.5px; color: var(--s600); max-width: 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Miniature faux desktop rendered inside a screenshot thumbnail. */
.faux { position: absolute; inset: 0; display: flex; flex-direction: column; }
.faux .bar { height: 13%; display: flex; align-items: center; gap: 3px; padding: 0 5px; }
.faux .bar i { width: 4px; height: 4px; border-radius: 999px; display: block; }
.faux .content { flex: 1; padding: 5px; display: flex; gap: 4px; }
.faux .lines { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.faux .lines u { display: block; height: 3px; border-radius: 2px; text-decoration: none; }

/* ---------- Remote control --------------------------------------------- */

.rc-stage { background: #0b0f14; border-radius: 12px; overflow: hidden; position: relative; aspect-ratio: 16/9; }
.rc-stage .hud { position: absolute; left: 12px; top: 12px; display: flex; gap: 8px; align-items: center; z-index: 2; }
.rc-chip { background: rgba(10,10,10,.72); color: #e2e8f0; border-radius: 999px; padding: 4px 11px; font-size: 11px; font-family: var(--font-mono); display: inline-flex; align-items: center; gap: 6px; }
.rc-chip .live { width: 7px; height: 7px; border-radius: 999px; background: #10b981; animation: rcpulse 1.6s ease-in-out infinite; }
@keyframes rcpulse { 0%,100% { opacity: 1 } 50% { opacity: .35 } }
.rc-toolbar { position: absolute; right: 12px; top: 12px; display: flex; gap: 6px; z-index: 2; }
.rc-toolbar button { background: rgba(10,10,10,.72); border: 0; color: #e2e8f0; border-radius: 6px; padding: 5px 10px; font-size: 11.5px; }
.rc-toolbar button.is-active { background: #fff; color: #0a0a0a; }
.rc-target { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-top: 1px solid var(--s100); flex-wrap: wrap; }
.rc-target:first-child { border-top: 0; }

/* Faux remote desktop rendered on the stage. */
.rd { position: absolute; inset: 0; background: linear-gradient(160deg, #1e293b, #0f172a 60%); }
.rd-win { position: absolute; border-radius: 6px; overflow: hidden; box-shadow: 0 18px 40px rgba(0,0,0,.45); }
.rd-win .tt { height: 20px; background: #e2e8f0; display: flex; align-items: center; gap: 4px; padding: 0 7px; }
.rd-win .tt i { width: 6px; height: 6px; border-radius: 999px; display: block; }
.rd-win .bd { background: #fff; height: calc(100% - 20px); padding: 8px; }
.rd-task { position: absolute; left: 0; right: 0; bottom: 0; height: 26px; background: rgba(15,23,42,.85); display: flex; align-items: center; gap: 6px; padding: 0 10px; }
.rd-task i { width: 12px; height: 12px; border-radius: 3px; display: block; }

/* ---------- Misc ------------------------------------------------------- */

.tg-empty { padding: 40px; text-align: center; color: var(--s500); font-size: 13px; }
.tg-note { border-radius: 10px; background: var(--linen); border: 1px solid var(--hairline); padding: 13px 15px; font-size: 12.5px; color: var(--s700); line-height: 1.6; }
.tg-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tg-stack > * + * { margin-top: 16px; }
.tg-grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.tg-grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.tg-bar-mini { height: 6px; border-radius: 999px; background: var(--s100); overflow: hidden; display: flex; min-width: 90px; }
.tg-bar-mini i { display: block; height: 100%; }
.tg-avatar-sm { width: 30px; height: 30px; border-radius: 999px; display: flex; align-items: center; justify-content: center; font-size: 11.5px; font-weight: 600; color: #fff; flex: 0 0 30px; }

.tg-modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 60; }
.tg-modal { background: #fff; border-radius: 12px; width: 100%; max-width: 560px; box-shadow: 0 24px 60px rgba(15,23,42,.25); overflow: hidden; max-height: 88vh; overflow-y: auto; }
.tg-modal header { padding: 18px 22px; border-bottom: 1px solid var(--s100); display: flex; align-items: center; justify-content: space-between; }
.tg-modal header h3 { margin: 0; font-size: 15px; font-weight: 600; }
.tg-modal .bd { padding: 22px; }
.tg-modal footer { padding: 15px 22px; border-top: 1px solid var(--s100); display: flex; justify-content: flex-end; gap: 8px; background: var(--s50); }

/* ---------- Narrow-viewport containment --------------------------------
   Wide content must scroll inside its own container — the page body itself
   must never scroll horizontally. */

.tg-input, .tg-select, .tg-textarea { max-width: 100%; }
.tg-row, .tg-head > *, .tg-row > *, .tg-card, .tg-kpi { min-width: 0; }
/* Long unbreakable tokens (a mono process name, a 5-digit count) must not
   push a KPI tile wider than its grid track. */
.tg-kpi .k, .tg-kpi .v, .tg-kpi .avg { overflow-wrap: anywhere; }
.tg-seg, .tg-tabs { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.tg-seg::-webkit-scrollbar, .tg-tabs::-webkit-scrollbar { display: none; }
.tg-seg button, .tg-tabs button { flex: 0 0 auto; }

/* Below the sidebar breakpoint the nav collapses into a select in the
   topbar, so every screen stays reachable on a phone or a narrow window. */
.tg-mobilenav { display: none; }

/* ---------- Breakpoints -------------------------------------------------
   Only genuinely viewport-dependent chrome lives here. Every content grid
   above uses auto-fit and therefore needs no breakpoint of its own. */

@media (max-width: 860px) {
  .tg-sidebar { display: none; }
  .tg-mobilenav { display: block; max-width: 180px; }
  .tg-topbar { padding: 0 14px; }
  .tg-topbar .tg-row span:not(.pill) { display: none; }
  .tg-user .meta { display: none; }
  .tg-page-inner { padding: 20px; }
  .tg-head { gap: 14px; }
}

/* ---------- Fixed-width preview override -------------------------------
   The portfolio page renders this UI at a fixed 1320px design width inside a
   frame and then scales it down. CSS media queries resolve against the
   viewport, not the element, so on a narrow screen the previews would
   otherwise collapse into the phone layout inside a wide frame. Re-assert
   the desktop layout for anything marked .tg-preview, at every breakpoint. */

.tg-preview .tg-sidebar { display: flex; }
.tg-preview .tg-mobilenav { display: none; }
.tg-preview .tg-topbar { padding: 0 24px; }
.tg-preview .tg-topbar .tg-row span:not(.pill) { display: inline; }
.tg-preview .tg-user .meta { display: block; }
.tg-preview .tg-page-inner { padding: 32px; }
