/* Onfinity design theme — extracted from the Onfinity dashboard/right-panel UI.
   Shared tokens + components for the Time Tracker web app. */

:root {
  /* Brand */
  --blue: #0083DA;
  --blue-action: #1F83FF;
  --blue-deep: #002640;
  --blue-link: #106AB0;
  --pale-border: #BFE4FF;

  /* Surfaces */
  --app-bg-start: #C7E8FF;
  --app-bg-end: #FFFFC4;
  --glass-start: rgba(255, 255, 255, 0.82);
  --glass-end: rgba(255, 255, 255, 0.58);
  --solid: #FFFFFF;
  --secondary: #FBFDFF;
  --faint-blue: #EEF6FF;
  --divider: #EDF2F6;
  --border-light: #E4EDF4;

  /* Text */
  --ink: #102C3F;
  --ink-2: #5F7283;
  --ink-3: #748494;

  /* Semantic */
  --green-bright: #20A464;
  --red: #ED1C24;
  --amber: #D78B10;

  /* Shape */
  --radius-lg: 14px;
  --radius-md: 12px;
  --radius-pill: 999px;
  --shadow-widget: 0 10px 24px rgba(15, 61, 97, 0.06);
  --shadow-btn: 0 4px 10px rgba(31, 131, 255, 0.28);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  color: var(--ink);
  background: linear-gradient(129deg, var(--app-bg-start) 0%, var(--app-bg-end) 100%);
  background-attachment: fixed;
}

a { color: var(--blue-link); text-decoration: none; }
a:hover { color: var(--blue); }

/* Glass surface */
.glass {
  background: linear-gradient(180deg, var(--glass-start), var(--glass-end));
  border: 2px solid #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-widget);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

/* Brand wordmark */
.brand { display: flex; align-items: center; gap: 10px; }
.brand .mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--blue), var(--blue-action));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 17px;
  box-shadow: 0 4px 12px rgba(31, 131, 255, 0.35);
}
.brand .name { font-size: 18px; font-weight: 700; color: var(--ink); letter-spacing: .2px; line-height: 1.05; }
.brand .name small {
  display: block; font-size: 10.5px; font-weight: 500; color: var(--ink-3);
  letter-spacing: .4px; text-transform: uppercase;
}
.brand-logo { height: 26px; width: auto; display: block; }
.brand-sub {
  font-size: 11px; font-weight: 600; color: var(--ink-3); text-transform: uppercase;
  letter-spacing: .4px; padding-left: 10px; margin-left: 2px; border-left: 1px solid var(--border-light);
}
.auth-card .brand { margin-bottom: 18px; }
.auth-card .brand-logo { height: 30px; }

/* Login */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 360px; padding: 34px 32px; }
.auth-card h1 { margin: 18px 0 4px; font-size: 20px; font-weight: 700; }
.auth-card .sub { margin: 0 0 22px; color: var(--ink-2); font-size: 12.5px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 6px; font-weight: 500; }
.field input {
  width: 100%; padding: 10px 14px; border: 1px solid var(--border-light);
  border-radius: var(--radius-pill); background: #fff; font-size: 13px;
  color: var(--ink); font-family: inherit;
}
.field input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0, 131, 218, 0.12); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: var(--radius-pill);
  padding: 11px 16px; font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.btn-primary { width: 100%; background: var(--blue-action); color: #fff; border-color: var(--blue-action); box-shadow: var(--shadow-btn); }
.btn-primary:hover { background: var(--blue); border-color: var(--blue); }

.alert { background: #FAD7D7; color: #8F2D2D; border-radius: 10px; padding: 9px 12px; font-size: 12px; margin-bottom: 14px; }

/* App shell */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; margin: 14px; border-radius: var(--radius-md);
}
.topbar .user { display: flex; align-items: center; gap: 12px; font-size: 12.5px; color: var(--ink-2); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--blue-action));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; box-shadow: 0 4px 8px -3px rgba(31, 131, 255, 0.45);
}

.container { max-width: 860px; margin: 8px auto 40px; padding: 0 24px; }
.card { padding: 26px 28px; }
.muted { color: var(--ink-2); }

.pill {
  display: inline-block; padding: 4px 12px; border-radius: var(--radius-pill);
  background: var(--faint-blue); color: var(--blue); font-size: 11.5px; font-weight: 700;
  letter-spacing: .1px; margin-right: 6px;
}
.pill.green { background: #E6F6EE; color: #0C5D38; }

.linkrow { margin-top: 18px; }
.linkrow a { font-weight: 600; color: var(--blue); }
.linkbtn { background: none; border: 0; color: var(--blue-link); font: inherit; cursor: pointer; padding: 0; }
.linkbtn:hover { color: var(--blue); }
.note { margin-top: 18px; font-size: 12px; color: var(--ink-3); line-height: 1.5; }

/* ---------------------------------------------------------------------------
   Portal shell (Phase 4): topbar + sidebar + content, KPI tiles, tables,
   status chips, screenshot gallery, review actions.
   --------------------------------------------------------------------------- */

.app-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 22px; margin: 14px 14px 0; border-radius: var(--radius-md);
}
.app-topbar .user { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--ink-2); }

.app-body { display: flex; gap: 14px; padding: 14px; align-items: flex-start; }

.sidebar { width: 210px; flex-shrink: 0; padding: 12px; position: sticky; top: 14px; }
.sidebar a {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 10px; color: var(--ink-2); font-weight: 500; font-size: 13px; margin-bottom: 4px;
}
.sidebar a:hover { background: var(--faint-blue); color: var(--blue); }
.sidebar a.active {
  background: linear-gradient(180deg, #DCEEFF, #BFE4FF);
  color: var(--blue); font-weight: 700;
}
.sidebar a .count { margin-left: auto; }

.main { flex: 1; min-width: 0; }
.page-title { font-size: 22px; font-weight: 700; color: var(--ink); margin: 0 0 4px; }
.page-sub { color: var(--ink-2); font-size: 13px; margin: 0 0 18px; }

/* KPI tiles */
.kpi-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi { padding: 16px 18px; border-radius: var(--radius-md); border: 1px solid var(--border-light); background: #fff; }
.kpi .label { font-size: 10.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .3px; }
.kpi .value { font-size: 26px; font-weight: 700; color: var(--ink); margin-top: 4px; }
.kpi.info { background: #EEF8FF; border-color: #D6ECFF; }
.kpi.success { background: #E6F6EE; border-color: #C9E9D6; }
.kpi.warning { background: #FCF1D8; border-color: #F3DFAA; }
.kpi.violet { background: #F0EDFC; border-color: #DCD5F4; }

/* Panels */
.panel { padding: 18px 20px; border-radius: var(--radius-lg); margin-bottom: 18px; }
.panel h2 { font-size: 15px; font-weight: 700; margin: 0 0 14px; color: var(--ink); }

/* Tables */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .3px;
  color: var(--ink-3); padding: 8px 10px; border-bottom: 1px solid var(--border-light);
}
.table td { padding: 10px; border-bottom: 1px solid var(--divider); color: var(--ink); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: rgba(238, 246, 255, .5); }
.table a { color: var(--blue); font-weight: 600; }

/* Status chips */
.chip { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.chip-tracking { background: #D9ECFF; color: #0E5DA8; }
.chip-pending  { background: #FCE9C8; color: #6E4A00; }
.chip-approved { background: #CCEFDD; color: #0C5D38; }
.chip-rejected { background: #FAD7D7; color: #8F2D2D; }
.chip-synced   { background: #E6F6EE; color: #0B6B45; }

/* Activity meter */
.abar { height: 8px; border-radius: 999px; background: #E4EDF4; overflow: hidden; width: 80px; display: inline-block; vertical-align: middle; }
.abar > span { display: block; height: 100%; background: linear-gradient(90deg, #0083DA, #1F83FF); }
.abar-label { font-size: 12px; color: var(--ink-2); margin-left: 8px; vertical-align: middle; }

/* Buttons */
.btn-sm { padding: 7px 14px; font-size: 12.5px; border-radius: 999px; font-weight: 600; cursor: pointer; border: 1px solid transparent; font-family: inherit; }
.btn-success, .btn-success:visited { background: #20A464; color: #fff !important; }
.btn-success:hover { background: #0B6B45; color: #fff !important; }
.btn-danger { background: #fff; color: #A33F3F; border-color: #F5C6C6; }
.btn-danger:hover { background: #FAD7D7; }
.btn-ghost { background: #fff; border: 1px solid var(--border-light); color: var(--ink-2); }
.btn-ghost:hover { background: var(--faint-blue); color: var(--blue); border-color: var(--pale-border); }

/* Screenshot gallery */
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.shot { border-radius: 10px; overflow: hidden; border: 1px solid var(--border-light); background: #fff; }
.shot a { display: block; }
.shot img { width: 100%; height: 124px; object-fit: cover; display: block; background: #F0F4F8; }
.shot .meta { padding: 7px 9px; font-size: 11px; color: var(--ink-2); }
.shot .meta b { color: var(--ink); font-weight: 600; }

/* Misc */
.empty { padding: 34px; text-align: center; color: var(--ink-3); font-size: 13px; }
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .filter { padding: 7px 12px; border-radius: 999px; border: 1px solid var(--border-light); background: #fff; color: var(--ink-2); font-size: 12.5px; font-weight: 600; cursor: pointer; }
.toolbar .filter.active { background: var(--blue-action); color: #fff; border-color: var(--blue-action); }
.crumb { font-size: 12.5px; color: var(--ink-2); margin-bottom: 10px; }
.crumb a { color: var(--blue); font-weight: 600; }
.meta-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.meta-grid .label { font-size: 10.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .3px; }
.meta-grid .value { font-size: 16px; font-weight: 700; color: var(--ink); margin-top: 3px; }

/* Excluded (deleted) interval rows in review/detail */
.row-excluded td { opacity: .55; }
.row-excluded td:not(:last-child) { text-decoration: line-through; }

/* ---- Interval tiles (merged activity + screenshots) ---- */
.iv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(192px, 1fr)); gap: 12px; }
.iv-tile { border: 1px solid var(--border-light); border-radius: 12px; overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.iv-tile.clickable { cursor: pointer; transition: box-shadow .12s ease, transform .12s ease; }
.iv-tile.clickable:hover { box-shadow: var(--shadow-widget); transform: translateY(-1px); }
.iv-tile.excluded { opacity: .6; }
.iv-thumb { position: relative; height: 112px; background: #E9F1F8 center / cover no-repeat; display: flex; align-items: flex-end; justify-content: flex-end; }
.iv-count { background: rgba(16, 44, 63, .72); color: #fff; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px; margin: 6px; }
.iv-noshot { color: var(--ink-3); font-size: 11px; margin: auto; }
.iv-deleted { position: absolute; top: 6px; left: 6px; background: #FAD7D7; color: #8F2D2D; font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.iv-live { position: absolute; top: 6px; left: 6px; background: #ED1C24; color: #fff; font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 999px; letter-spacing: .3px; }
.iv-tile.idle { background: #FCF8EE; }
.iv-tile.idle .iv-thumb { filter: grayscale(0.55); }
.iv-idle-tag { color: #9A6500; font-weight: 700; }
.livedot { width: 9px; height: 9px; border-radius: 50%; background: #ED1C24; display: inline-block; animation: livepulse 1.6s infinite; }
@keyframes livepulse { 0% { box-shadow: 0 0 0 0 rgba(237,28,36,.5); } 70% { box-shadow: 0 0 0 8px rgba(237,28,36,0); } 100% { box-shadow: 0 0 0 0 rgba(237,28,36,0); } }
.iv-info { padding: 9px 11px; }
.iv-label { font-size: 13px; font-weight: 700; color: var(--ink); margin-bottom: 7px; }
.iv-act { font-size: 11px; color: var(--ink-2); margin-top: 6px; }
.iv-trim { margin: 0 11px 11px; }
.iv-trim button { width: 100%; }

/* ---- Screenshot modal ---- */
.iv-modal { position: fixed; inset: 0; background: rgba(2, 20, 34, .80); display: none; align-items: center; justify-content: center; z-index: 1000; padding: 30px; }
.iv-modal.open { display: flex; }
.iv-stage { max-width: 1100px; width: 100%; display: flex; flex-direction: column; align-items: center; }
.iv-stage img { max-width: 100%; max-height: 72vh; border-radius: 10px; box-shadow: 0 24px 70px rgba(0, 0, 0, .5); background: #fff; }
.iv-cap { margin-top: 14px; background: #fff; border-radius: 12px; padding: 12px 16px; min-width: 340px; max-width: 640px; width: 100%; box-sizing: border-box; }
.iv-cap-top { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--ink); }
.iv-cap-bar { height: 7px; border-radius: 999px; background: #E4EDF4; overflow: hidden; margin: 9px 0 7px; }
.iv-cap-bar > span { display: block; height: 100%; background: linear-gradient(90deg, #0083DA, #1F83FF); }
.iv-cap .muted { font-size: 12px; }
.iv-x { position: absolute; top: 18px; right: 22px; background: rgba(255, 255, 255, .15); color: #fff; border: 0; width: 38px; height: 38px; border-radius: 50%; font-size: 15px; cursor: pointer; }
.iv-x:hover { background: rgba(255, 255, 255, .3); }
.iv-arrow { background: rgba(255, 255, 255, .15); color: #fff; border: 0; width: 50px; height: 50px; border-radius: 50%; font-size: 30px; line-height: 1; cursor: pointer; flex-shrink: 0; }
.iv-arrow:hover { background: rgba(255, 255, 255, .32); }
.iv-arrow-l { margin-right: 18px; }
.iv-arrow-r { margin-left: 18px; }

/* ---- Timezone bar + approve cutoff ---- */
.tzbar { font-size: 12px; color: var(--ink-2); margin-bottom: 14px; background: var(--faint-blue); border: 1px solid var(--pale-border); border-radius: 999px; padding: 6px 14px; display: inline-block; }
.tzbar a { font-weight: 600; }
.approve-upto { display: flex; align-items: center; gap: 14px; margin-top: 14px; flex-wrap: wrap; border-top: 1px solid var(--divider); padding-top: 14px; }
.upto-label { font-size: 10.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .3px; display: flex; align-items: center; gap: 8px; }
.upto-note { font-size: 12px; }

/* ---- Flash messages ---- */
.msgs { margin-bottom: 14px; }
.msg { padding: 11px 14px; border-radius: 10px; font-size: 13px; font-weight: 500; margin-bottom: 8px; }
.msg-success { background: #E6F6EE; color: #0C5D38; border: 1px solid #C9E9D6; }
.msg-error { background: #FAD7D7; color: #8F2D2D; border: 1px solid #F5C6C6; }
.msg-info, .msg-warning { background: #EEF8FF; color: #0E5DA8; border: 1px solid #D6ECFF; }

/* ---- Filter bar ---- */
.filterbar { display: flex; align-items: flex-end; gap: 12px; padding: 12px 16px; border-radius: var(--radius-md); margin-bottom: 16px; flex-wrap: wrap; }
.filter-label { font-size: 10.5px; color: var(--ink-3); display: flex; flex-direction: column; gap: 4px; text-transform: uppercase; letter-spacing: .3px; }
.filter-input { padding: 8px 12px; border: 1px solid var(--border-light); border-radius: 8px; background: #fff; font-size: 13px; color: var(--ink); font-family: inherit; }
select.filter-input { border-radius: 999px; min-width: 180px; }

/* Locked (approved) interval tile footer */
.iv-locked { margin: 0 11px 11px; font-size: 11px; color: var(--ink-3); text-align: center; padding: 6px 0; }

/* ---- Day navigation ---- */
.iv-daynav { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 50%; background: #fff; border: 1px solid var(--border-light); color: var(--blue); font-size: 24px; line-height: 1; text-decoration: none; }
.iv-daynav:hover { background: var(--faint-blue); }
.iv-daynav.disabled { color: #C9D3DC; pointer-events: none; }

/* ============================================================
   Responsive — tablet & mobile (added for small-screen portal)
   ============================================================ */
.nav-toggle {
  display: none;
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 5px 11px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: var(--ink);
}

/* Every .table is auto-wrapped (by base.html) in this scroll box so a wide
   table scrolls sideways INSIDE its card and never widens the whole page. */
.table-scroll { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.main { min-width: 0; }

@media (max-width: 900px) {
  .app-topbar { flex-wrap: wrap; gap: 8px; row-gap: 8px; justify-content: flex-start; }
  .app-topbar .user { margin-left: auto; }
  .nav-toggle { display: inline-flex; align-items: center; }
  .app-body { flex-direction: column; align-items: stretch; padding: 10px; gap: 10px; position: relative; }
  .sidebar { width: auto; position: static; top: auto; display: none; flex-direction: column; }
  /* Open menu floats OVER the content as a dropdown instead of shoving the page down. */
  .sidebar.open {
    display: flex; position: absolute; z-index: 60;
    top: 6px; left: 10px; right: 10px;
    background: #fff; box-shadow: 0 18px 44px rgba(13, 37, 64, .22);
  }
  .sidebar a { width: 100%; box-sizing: border-box; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .meta-grid { grid-template-columns: repeat(2, 1fr); }
  .table { white-space: nowrap; }   /* keep columns intact; the wrapper scrolls */
  select.filter-input, .filter-input { min-width: 0; max-width: 100%; }
}

@media (max-width: 560px) {
  .app-topbar { padding-left: 12px; padding-right: 12px; }
  .kpi-grid, .meta-grid { grid-template-columns: 1fr; }
  .app-topbar .user .name-full { display: none; }
  .app-topbar .user { gap: 8px; font-size: 12px; }
  .page-title { font-size: 1.45rem; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .iv-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

/* Portal footer with the desktop-app download link (all pages). */
.app-foot {
  display: flex; gap: 14px; justify-content: center; align-items: center; flex-wrap: wrap;
  padding: 14px 14px 26px; margin: 0 14px;
  color: var(--ink-2, #6b7f93); font-size: 12.5px; border-top: 1px solid var(--divider, #e4ebf2);
}
.app-foot a { color: var(--blue, #1763d6); font-weight: 600; }

/* Trial / activation banner (SaaS) */
.trial-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin: 10px 14px 0; padding: 9px 16px; border-radius: var(--radius-md, 12px);
  background: linear-gradient(180deg, #FFF6DC, #FDEFC4); border: 1px solid #F3DFAA;
  color: #7a5a12; font-size: 12.5px; font-weight: 500;
}
.trial-bar .trial-cta {
  background: var(--blue-action, #1F83FF); color: #fff; font-weight: 700;
  padding: 6px 14px; border-radius: 999px; white-space: nowrap;
}
.trial-bar .trial-cta:hover { background: var(--blue, #0083DA); color:#fff; }
