/* Eight OS custom screens. Colours come from Filament's theme variables so
   light and dark mode both work. */

.e8-toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: space-between; }
.e8-seg { display: inline-flex; border: 1px solid var(--gray-200); border-radius: .6rem; overflow: hidden; }
.e8-seg button { padding: .4rem .9rem; font-size: .875rem; color: var(--gray-600); }
.e8-seg button.is-active { background: var(--primary-600); color: #fff; }
.dark .e8-seg { border-color: var(--gray-700); }
.dark .e8-seg button { color: var(--gray-300); }
.e8-select { border: 1px solid var(--gray-200); border-radius: .6rem; padding: .4rem 2rem .4rem .75rem; font-size: .875rem; background-color: transparent; color: inherit; }
.dark .e8-select { border-color: var(--gray-700); }

/* Kanban */
.e8-board { display: grid; grid-template-columns: repeat(4, minmax(13rem, 1fr)); gap: .75rem; overflow-x: auto; padding-bottom: .5rem; scroll-snap-type: x proximity; }
.e8-col { background: var(--gray-100); border-radius: .9rem; padding: .6rem; min-height: 12rem; scroll-snap-align: start; transition: outline-color .15s; outline: 2px dashed transparent; }
.dark .e8-col { background: rgb(255 255 255 / .04); }
.e8-col.is-over { outline-color: var(--primary-500); }
.e8-col-head { display: flex; justify-content: space-between; align-items: center; padding: .25rem .4rem .6rem; font-weight: 700; font-size: .9rem; }
.e8-count { font-weight: 500; font-size: .75rem; color: var(--gray-500); background: var(--gray-200); border-radius: 999px; padding: .05rem .55rem; }
.dark .e8-count { background: var(--gray-800); color: var(--gray-400); }
.e8-card { display: block; background: #fff; border: 1px solid var(--gray-200); border-radius: .7rem; padding: .65rem .75rem; margin-bottom: .5rem; cursor: grab; border-inline-start: 4px solid var(--gray-300); }
.dark .e8-card { background: var(--gray-900); border-color: var(--gray-800); border-inline-start-color: var(--gray-600); }
.e8-card.p-high { border-inline-start-color: var(--warning-500); }
.e8-card.p-urgent { border-inline-start-color: var(--danger-500); }
.e8-card.p-low { border-inline-start-color: var(--gray-200); }
.e8-card-title { font-weight: 600; font-size: .9rem; line-height: 1.5; color: inherit; }
.e8-card-title:hover { color: var(--primary-600); }
.e8-meta { display: flex; flex-wrap: wrap; gap: .25rem .75rem; margin-top: .35rem; font-size: .75rem; color: var(--gray-500); }
.e8-late { color: var(--danger-600); font-weight: 600; }
.e8-flag { display: inline-block; margin-top: .4rem; font-size: .7rem; font-weight: 600; color: var(--danger-600); background: var(--danger-50); border-radius: .4rem; padding: .1rem .45rem; }
.dark .e8-flag { background: rgb(239 68 68 / .12); color: var(--danger-400); }
.e8-moves { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .55rem; }
.e8-moves button { font-size: .72rem; border: 1px solid var(--gray-200); border-radius: .45rem; padding: .15rem .5rem; color: var(--gray-600); }
.e8-moves button:hover { border-color: var(--primary-500); color: var(--primary-600); }
.dark .e8-moves button { border-color: var(--gray-700); color: var(--gray-300); }
.e8-empty { text-align: center; font-size: .8rem; color: var(--gray-400); padding: 1.5rem 0; }

/* Calendar */
.e8-cal-title { font-weight: 700; font-size: 1.05rem; min-width: 9rem; text-align: center; }
.e8-cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--gray-200); border-radius: .9rem; overflow: hidden; }
.dark .e8-cal { border-color: var(--gray-800); }
.e8-cal-dow { padding: .45rem; font-size: .75rem; font-weight: 600; text-align: center; color: var(--gray-500); background: var(--gray-50); }
.dark .e8-cal-dow { background: rgb(255 255 255 / .04); }
.e8-day { min-height: 6.5rem; padding: .35rem; border-top: 1px solid var(--gray-200); border-inline-start: 1px solid var(--gray-200); }
.dark .e8-day { border-color: var(--gray-800); }
.e8-day:nth-child(7n + 1) { border-inline-start: 0; }
.e8-day.is-out { opacity: .4; }
.e8-day-num { font-size: .75rem; color: var(--gray-500); }
.e8-day.is-today .e8-day-num { display: inline-block; background: var(--primary-600); color: #fff; border-radius: 999px; padding: 0 .4rem; }
.e8-chip { display: block; margin-top: .2rem; font-size: .72rem; line-height: 1.5; padding: .05rem .4rem; border-radius: .35rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: var(--gray-100); color: inherit; }
.dark .e8-chip { background: var(--gray-800); }
.e8-chip.is-done { text-decoration: line-through; opacity: .55; }
.e8-chip.is-late { background: var(--danger-50); color: var(--danger-700); }
.dark .e8-chip.is-late { background: rgb(239 68 68 / .15); color: var(--danger-400); }
.e8-chip.is-project { background: var(--primary-50); color: var(--primary-700); font-weight: 600; }
.dark .e8-chip.is-project { background: rgb(212 98 42 / .18); color: var(--primary-400); }
.e8-agenda { display: none; }
.e8-agenda-day { font-size: .8rem; font-weight: 700; color: var(--gray-500); margin: .9rem 0 .3rem; }
.e8-agenda .e8-chip { white-space: normal; padding: .45rem .6rem; font-size: .85rem; }

@media (max-width: 640px) {
    .e8-cal { display: none; }
    .e8-agenda { display: block; }
}

/* Reports */
.e8-table { width: 100%; font-size: .875rem; border-collapse: collapse; }
.e8-table th { text-align: start; font-weight: 600; color: var(--gray-500); padding: .5rem .6rem; border-bottom: 1px solid var(--gray-200); white-space: nowrap; }
.e8-table td { padding: .5rem .6rem; border-bottom: 1px solid var(--gray-100); }
.dark .e8-table th { border-color: var(--gray-700); }
.dark .e8-table td { border-color: var(--gray-800); }
.e8-table tfoot td { font-weight: 700; border-top: 2px solid var(--gray-300); border-bottom: 0; }
.e8-num { text-align: end; white-space: nowrap; font-variant-numeric: tabular-nums; }
.e8-neg { color: var(--danger-600); }
.e8-scroll { overflow-x: auto; }

/* "Enable notifications" prompt */
.e8-push { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center; justify-content: space-between; margin-bottom: 1rem; padding: .7rem 1rem; border: 1px solid var(--primary-500); border-radius: .8rem; font-size: .875rem; background: var(--primary-50); }
.dark .e8-push { background: rgb(212 98 42 / .12); }
.e8-push-actions { display: inline-flex; gap: .5rem; }
.e8-push button { padding: .3rem .9rem; border-radius: .5rem; font-size: .8rem; border: 1px solid var(--gray-300); }
.dark .e8-push button { border-color: var(--gray-600); }
.e8-push button.is-primary { background: var(--primary-600); border-color: var(--primary-600); color: #fff; }
[x-cloak] { display: none !important; }

/* Assistant */
.e8-ai-text { font-size: .95rem; line-height: 1.9; }
.e8-ai-text p { margin: 0 0 .4rem; }
.e8-ai-text ul, .e8-ai-text ol { margin: .2rem 0 .5rem; padding-inline-start: 1.3rem; list-style: disc; }
.e8-ai-text ol { list-style: decimal; }
.e8-ai-note { margin-top: .6rem; font-size: .75rem; color: var(--gray-500); }
.e8-chat { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .9rem; }
.e8-bubble { align-self: flex-start; max-width: 92%; padding: .55rem .85rem; border-radius: .9rem; background: var(--gray-100); font-size: .95rem; }
.dark .e8-bubble { background: rgb(255 255 255 / .06); }
.e8-bubble.is-user { align-self: flex-end; background: var(--primary-600); color: #fff; }
.e8-ask { display: flex; gap: .5rem; }
.e8-ask input { flex: 1; min-width: 0; border: 1px solid var(--gray-300); border-radius: .6rem; padding: .5rem .8rem; background: transparent; color: inherit; }
.dark .e8-ask input { border-color: var(--gray-700); }

/* Brand mark, greeting */
.e8-brand { display: inline-flex; white-space: nowrap; align-items: center; gap: .55rem; font-weight: 800; font-size: 1.05rem; letter-spacing: -.01em; }
.e8-brand b { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: .6rem; background: #14171c; color: #d4622a; font-size: 1.25rem; font-weight: 800; }
.dark .e8-brand b { background: #d4622a; color: #14171c; }
.e8-greeting { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.e8-greeting-hello { font-size: 1.35rem; font-weight: 800; line-height: 1.5; }
.e8-greeting-date { font-size: .85rem; color: var(--gray-500); }
.e8-greeting-role { flex: none; font-size: .75rem; font-weight: 600; padding: .25rem .7rem; border-radius: 999px; background: var(--primary-50); color: var(--primary-700); }
.dark .e8-greeting-role { background: rgb(212 98 42 / .18); color: var(--primary-400); }

/* ---- Phone experience: on a phone the system looks and behaves like an app ---- */
.e8-tabbar { display: none; }

@media (max-width: 1023px) {
    /* Bottom bar. It sits below the side menu and dialogs (z 30+), never over them. */
    .e8-tabbar { position: fixed; inset-inline: 0; bottom: 0; z-index: 25; display: block; padding: 0 max(.35rem, env(safe-area-inset-left)) max(1.25rem, calc(env(safe-area-inset-bottom) + .4rem)) max(.35rem, env(safe-area-inset-right)); pointer-events: none; transition: transform .2s ease, opacity .2s ease; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
    .e8-tabbar.is-hidden { transform: translateY(120%); opacity: 0; }
    .e8-tabbar-row { pointer-events: auto; display: flex; align-items: center; justify-content: space-around; gap: .15rem; height: 4.4rem; padding: 0 .5rem; border-radius: 1.6rem; background: rgb(255 255 255 / .86); border: 1px solid rgb(0 0 0 / .06); box-shadow: 0 8px 28px rgb(0 0 0 / .16); -webkit-backdrop-filter: saturate(160%) blur(18px); backdrop-filter: saturate(160%) blur(18px); }
    .dark .e8-tabbar-row { background: rgb(24 26 31 / .86); border-color: rgb(255 255 255 / .08); box-shadow: 0 8px 28px rgb(0 0 0 / .5); }

    /* Each tab is one big target; nothing overlaps its neighbours. */
    .e8-tab { flex: 1 1 0; min-width: 0; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem; font-size: .72rem; font-weight: 500; color: var(--gray-500); touch-action: manipulation; -webkit-tap-highlight-color: transparent; transition: transform .12s ease, color .15s ease; }
    .dark .e8-tab { color: var(--gray-400); }
    .e8-tab i { display: grid; place-items: center; width: 3.4rem; height: 2rem; border-radius: 999px; transition: background-color .15s ease; }
    .e8-tab svg { width: 1.55rem; height: 1.55rem; pointer-events: none; }
    .e8-tab span { pointer-events: none; }
    .e8-tab:active { transform: scale(.92); }
    .e8-tab.is-active { color: var(--primary-600); font-weight: 700; }
    .dark .e8-tab.is-active { color: var(--primary-400); }
    .e8-tab.is-active i { background: var(--primary-50); }
    .dark .e8-tab.is-active i { background: rgb(212 98 42 / .2); }
    .e8-tab-add { flex: 0 0 3.8rem; }
    .e8-tab-add i { width: 3.2rem; height: 3.2rem; background: var(--primary-600); color: #fff; box-shadow: 0 4px 12px rgb(212 98 42 / .45); transition: transform .2s ease; }
    .e8-tab-add svg { width: 1.6rem; height: 1.6rem; }
    .e8-tab-add.is-open i { transform: rotate(45deg); }

    /* "+" sheet */
    .e8-sheet-backdrop { pointer-events: auto; position: fixed; inset: 0; background: rgb(0 0 0 / .45); }
    .e8-sheet { pointer-events: auto; position: relative; display: grid; gap: .15rem; margin-bottom: .6rem; padding: .45rem; background: #fff; border-radius: 1.3rem; box-shadow: 0 10px 30px rgb(0 0 0 / .25); }
    .dark .e8-sheet { background: var(--gray-900); border: 1px solid rgb(255 255 255 / .08); }
    .e8-sheet a { display: flex; align-items: center; gap: .8rem; min-height: 3.4rem; padding: 0 1rem; border-radius: .9rem; font-size: 1rem; font-weight: 600; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
    .e8-sheet a:active { background: var(--gray-100); }
    .dark .e8-sheet a:active { background: var(--gray-800); }
    .e8-sheet svg { width: 1.45rem; height: 1.45rem; color: var(--primary-600); }
    .e8-tabbar-row { position: relative; }

    /* Top bar: brand, bell and profile only. The menu lives in the bottom bar. */
    .fi-topbar-open-sidebar-btn, .fi-topbar-close-sidebar-btn { display: none !important; }
    .fi-topbar { min-height: 3.4rem; padding-top: env(safe-area-inset-top); padding-inline: 1rem; background: rgb(255 255 255 / .85) !important; -webkit-backdrop-filter: saturate(160%) blur(16px); backdrop-filter: saturate(160%) blur(16px); box-shadow: none !important; border-bottom: 1px solid rgb(0 0 0 / .05); }
    .dark .fi-topbar { background: rgb(12 13 16 / .82) !important; border-color: rgb(255 255 255 / .06); }
    .fi-topbar-start { display: flex !important; margin-inline-end: auto; }
    .fi-topbar .fi-global-search-ctn { display: none; }
    .fi-topbar-end { gap: .5rem; }
    /* The home screen opens with the greeting, not a page title */
    .fi-page:has(.e8-greeting) .fi-header { display: none; }

    /* Pages: a big title, no breadcrumb trail, rounder cards, a soft entrance */
    .fi-breadcrumbs { display: none; }
    .fi-main { padding-inline: 1rem; padding-bottom: calc(7.5rem + env(safe-area-inset-bottom)); animation: e8-enter .22s ease-out; }
    .fi-header { gap: .75rem; }
    .fi-header-heading { font-size: 1.6rem; font-weight: 800; letter-spacing: -.01em; }
    .fi-page-content { gap: 1rem; }
    .fi-section, .fi-ta-ctn, .fi-wi-stats-overview-stat { border-radius: 1.1rem; }
    .fi-ta-record, .fi-ta-row { min-height: 3.4rem; }
    .fi-ta-cell, .fi-ta-header-cell { padding-inline: .6rem; }
    .fi-ta-text { font-size: .9rem; }

    /* Dashboard numbers two to a row, so the day fits on one screen */
    .fi-wi-stats-overview .fi-section-content { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: .6rem; }
    .fi-wi-stats-overview-stat { padding: .8rem .9rem; }
    .fi-wi-stats-overview-stat-value { font-size: 1.2rem; line-height: 1.6; overflow-wrap: anywhere; }

    /* The board stacks into one scrolling list: no sideways swiping on a phone */
    .e8-board { grid-template-columns: minmax(0, 1fr); overflow-x: visible; }
    .e8-col { min-height: 0; border-radius: 1.1rem; }
    .e8-col .e8-empty { padding: .4rem 0 .6rem; }
    .e8-card { border-radius: .9rem; padding: .8rem .9rem; }

    /* Comfortable taps and no zoom-on-focus on iPhone (needs 16px text) */
    .fi-input, .fi-select-input, .fi-fo-textarea textarea, .e8-select, .e8-ask input { font-size: 16px; }
    .fi-btn, .e8-seg button, .e8-moves button, .e8-push button { min-height: 2.75rem; touch-action: manipulation; }
    .e8-moves button { padding-inline: .9rem; font-size: .82rem; border-radius: .6rem; }
    a, button { -webkit-tap-highlight-color: transparent; }
    html { -webkit-text-size-adjust: 100%; }
    body { overscroll-behavior-y: contain; }
}

@keyframes e8-enter {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .fi-main, .e8-tabbar, .e8-tab, .e8-tab-add i { animation: none; transition: none; }
}

/* Opened from the home screen: no browser around it, so behave fully like an app */
@media (display-mode: standalone) {
    body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
    input, textarea, [contenteditable], .e8-ai-text, .fi-ta-text, .fi-in-text { -webkit-user-select: text; user-select: text; }
}
