/* DataCore hub — same teal/green palette as every application it fronts,
   so the transition between the hub and an application reads as one
   platform, not two unrelated sites (see IMA_ETL_Pipeline's own app.css).
   The tile grid is the whole point of this screen; everything else here is
   deliberately minor - icon-only controls, no competing typography. */

:root {
    color: #30363f;
    background: #ffffff;
    font-family: Manrope, Inter, ui-sans-serif, system-ui, -apple-system,
        BlinkMacSystemFont, "Segoe UI", sans-serif;
    --color-primary-dark: #165f52;
    --color-primary: #006e5f;
    --color-primary-light: #439388;
    --color-primary-soft: #ebf4f3;
    --color-border: #c9cbcd;
    --color-body: #30363f;
    --color-muted: #667078;
    --color-surface: #ffffff;
    --color-error: #a33131;
    --color-error-border: #dfb2b2;

    /* The tile's flat institutional teal - a step lighter than
       --color-primary-dark, a step darker than --color-primary, so a whole
       grid of them reads as a deliberate shade of its own rather than a
       reused link colour. Flat, not a gradient. Hover goes darker, not
       lighter - the description text is white, and darkening (rather than
       lightening) the tile is what actually raises its contrast. */
    --color-tile: #74baa6;
    --color-tile-hover: #3f8a76;

    /* D59: a second tile colour, for an application that wants to read as
       a different kind of thing rather than a different state. Built from
       the teal above by rotating the hue to 205 and keeping saturation
       and lightness identical - #74baa6 is hsl(160 36% 59%), this is
       hsl(205 36% 59%), and the hover pair matches the same way. So the
       two tiles sit at the same weight beside each other; neither reads
       as louder or more important than the other, which a hand-picked
       blue would almost certainly have got wrong.

       Deliberately NOT the --tile--inactive-blue grey-blue below: that one
       is desaturated to say "not available", and an application that is
       perfectly available must not borrow it. */
    --color-tile-blue: #719dbc;
    --color-tile-blue-hover: #3f6a88;

    /* D73: the family name set behind each section's tiles. Three numbers
       tune the whole treatment, and nothing below hardcodes them. All
       three were settled on the rendered page rather than described:

       - size: 3.2 times a tile name. A tile name is 0.175 of a 240px tile
         (MAX_FONT_RATIO in tile_page.html), so 3.2 x 42px.
       - protrude: how much of the word's own size clears the tiles' top
         edge. A capital is only about 0.7 of its font size tall, so 0.53
         leaves roughly three quarters of each letter showing and tucks the
         rest behind the tiles - which is the "carved behind them" read.
         Raise it towards 0.7 and the word sits clear of the tiles instead.
       - tint: pale enough to read as ground rather than as text, since the
         tiles are what this page is for. */
    --section-label-size: 134px;
    --section-label-protrude: 0.53;
    --section-label-tint: rgb(48 54 63 / 7%);

    /* D72: how hard the pinned header and footer press on the scrolling
       area between them. */
    --edge-shadow: rgb(48 54 63 / 18%);
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
}

/* App shell: header and footer are fixed in place (flex's default
   behaviour for a non-growing item); .app-scroll is the only element that
   scrolls, so a long tile grid gets its own scrolling region without ever
   covering the header or the Dalriada mark at the bottom. */
.app-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.app-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: none;      /* Firefox */
    -ms-overflow-style: none;   /* legacy Edge */
}

.app-scroll::-webkit-scrollbar {
    display: none;              /* Chrome, Safari, Chromium Edge */
}

button,
input {
    font: inherit;
}

button {
    border: 0;
    border-radius: 10px;
    background: var(--color-primary);
    color: #ffffff;
    cursor: pointer;
    font-weight: 700;
    min-height: 42px;
    padding: 0 16px;
}

button:hover:not(:disabled) {
    background: var(--color-primary-dark);
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
    outline: 3px solid rgb(67 147 136 / 35%);
    outline-offset: 2px;
}

input[type="text"],
input[type="password"] {
    border: 1px solid var(--color-border);
    border-radius: 12px;
    min-height: 42px;
    padding: 8px 10px;
    width: 100%;
}

h1, h2, h3, p {
    margin-top: 0;
}

.flash-messages {
    display: grid;
    gap: 10px;
    margin: 20px auto 0;
    max-width: 1100px;
    padding: 0 28px;
}

.flash-message {
    background: #eef3f8;
    border: 1px solid #c7d7e6;
    border-radius: 8px;
    color: #3d6080;
    font-size: 0.9rem;
    padding: 12px 14px;
}

.flash-message.error {
    background: #faeaea;
    border-color: var(--color-error-border);
    color: var(--color-error);
}

/* --- Topbar: the DataCore wordmark is the one thing here that IS meant
   to carry weight - it is the brand this platform is building. The
   session controls stay icon-only so nothing else competes with it or
   with the tile grid below. --- */
/* D72: the header and the footer are pinned; the area between them is what
   scrolls. They now say so, by casting a shadow onto it - the header
   downward, the footer upward, as two surfaces lying over the page rather
   than under it. The hairline the header wore before is gone: the shadow
   does that job, and both together read as a heavier frame than this page
   wants.

   `position: relative` and the z-index are not decoration: .app-scroll
   comes after the header and before the footer in tree order, so without a
   stacking order of their own the shadows would land underneath it and
   never be seen. The explicit background goes with them - a transparent
   bar would let the scrolled content show through its own shadow. */
.topbar {
    align-items: center;
    background: var(--color-surface);
    box-shadow: 0 7px 16px -8px var(--edge-shadow);
    display: flex;
    flex-shrink: 0;
    justify-content: space-between;
    padding: 22px 28px;
    position: relative;
    z-index: 2;
}

.product-mark {
    color: var(--color-primary);
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    text-decoration: none;
}

.product-mark:hover,
.product-mark:focus-visible {
    opacity: 0.85;
}

.session-tools {
    align-items: center;
    display: flex;
    gap: 10px;
}

.logout-form {
    margin: 0;
}

.icon-button {
    align-items: center;
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    color: var(--color-muted);
    display: inline-flex;
    height: 38px;
    width: 38px;
    justify-content: center;
    padding: 0;
}

.icon-button:hover:not(:disabled) {
    background: var(--color-primary-soft);
    border-color: var(--color-primary-light);
    color: var(--color-primary-dark);
}

.icon-button svg {
    width: 18px;
    height: 18px;
}

/* --- Login --- */
.login-layout {
    align-items: center;
    display: flex;
    justify-content: center;
    min-height: 100%;
    padding: 24px;
}

.login-panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    box-shadow: 0 16px 42px rgb(48 54 63 / 12%);
    max-width: 450px;
    padding: 36px;
    width: 100%;
}

.login-panel h1 {
    font-size: 1.65rem;
    margin: 6px 0 8px;
}

.login-panel form {
    display: grid;
    gap: 16px;
    margin-top: 22px;
}

.login-panel label {
    display: grid;
    gap: 6px;
    font-weight: 700;
}

.muted-text {
    color: var(--color-muted);
    font-size: 0.86rem;
}

.error-panel {
    color: var(--color-error);
}

/* --- The tile grid: the entire point of this screen --- */
/* max-width matches IMA_ETL_Pipeline's own .workspace container, so the
   hub and the application it fronts share the same content width; padding
   is deliberately more generous than the ETL's 28px, giving the tiles
   extra breathing room on the sides. */
/* The top margin is no longer a round number: it is the room the first
   family's name needs above the first row of tiles (D73), which is the part
   of the word that clears them, plus 28px of air under the header. */
.tile-page {
    margin: calc(
        var(--section-label-size) * var(--section-label-protrude) + 28px
    ) auto 60px;
    max-width: 1360px;
    padding: 0 56px;
}

/* Tracks are a near-fixed size (a narrow 210-240px band), not `1fr` - the
   tiles barely change size across window widths, they just wrap to more
   or fewer columns. `auto-fit` (not `auto-fill`) collapses any unused
   track down to 0 instead of reserving it at full width - with `auto-fill`
   a lone extra empty track survived on wide screens, and `justify-content:
   center` was centering that invisible track along with the real tiles,
   which visually reads as everything shifted left. */
/* D62: at most three tiles per row. The max-width is exactly three of the
   widest tracks plus the two gaps between them, so a fourth track can never
   fit and the grid wraps instead - the track sizing above is unchanged, so
   narrower windows still drop to two columns, then one. */
.tile-grid {
    display: grid;
    gap: 26px;
    grid-template-columns: repeat(auto-fit, minmax(210px, 240px));
    justify-content: center;
    max-width: calc(3 * 240px + 2 * 26px);
    margin: 0 auto;
}

/* D73: a section is a family of applications, and it says which one. The
   name is set large and pale BEHIND its own tiles, so it reads as ground
   the tiles sit on rather than a heading stacked above them. At this tint
   it is ground and little else, which is why D62's hairline rule between
   sections stays rather than being replaced by it: the word says which
   family, the rule still says where one ends.

   The band is the same width as the grid it belongs to, so the name starts
   on the band's left edge whatever the row holds: three tiles or one
   centred tile, every family's name begins on the same line down the page.
   The tiles keep their own centring inside it. */
.tile-section {
    position: relative;
    container-type: inline-size;
    max-width: calc(3 * 240px + 2 * 26px);
    margin: 0 auto;
}

/* `~`, not `+`: anything ever placed between two sections - a note, a
   heading, the <hr> D62 used before this rule moved onto the section
   itself - silently kills an adjacent-sibling match and leaves the
   sections flush, which drops the next family's name onto the previous
   family's tiles. The general sibling combinator cannot be broken that
   way. */
.tile-section ~ .tile-section {
    margin-top: calc(
        var(--section-label-size) * var(--section-label-protrude) + 70px
    );
}

/* D62's hairline, kept: at --section-label-tint the family name is ground,
   not structure, so it names a section without marking where the previous
   one ended. The rule does that, and it belongs to the section it precedes
   rather than to an <hr> between them - one element fewer, and the gap
   above and below it cannot be broken by margin collapsing.

   It sits 30px under the previous family's tiles, which leaves the rest of
   the gap to the next family's word: the word's capitals start 40px below
   the rule, wherever the two numbers above put them. */
.tile-section ~ .tile-section::before {
    content: "";
    position: absolute;
    right: 0;
    left: 0;
    top: calc(
        -1 * (var(--section-label-size) * var(--section-label-protrude) + 40px)
    );
    border-top: 1px solid var(--color-border);
}

.tile-section-label {
    position: absolute;
    left: 0;
    /* The word's own size times --section-label-protrude is what has to
       clear the tiles; the extra 0.214em is the gap between the top of a
       line box and the top of its capitals, which is a property of the
       font rather than a constant - measured in the browser, in the face
       this stack actually resolves to, since the hub loads no webfont and
       that face differs by machine. The faces in the stack (Manrope,
       Inter, Segoe UI) agree to within a pixel or two at this size.
       `em` here is this element's own font size, so both terms follow the
       size set below. */
    top: calc(-1em * var(--section-label-protrude) - 0.214em);
    /* Behind the tiles. .tile already carries `position: relative`, so the
       z-index pair - 0 here, 1 there - is the whole of what decides which
       of the two wins; neither relies on source order. */
    z-index: 0;
    color: var(--section-label-tint);
    /* The band is 772px wide at full size, and the name is sized for it.
       Below that - a narrow window, or a phone - cqw shrinks the word with
       its band instead of letting it run off the side of the page.

       19.5cqw, because the longest name on the page sets it: "Scilligence"
       is almost exactly 5.1 times its own font size wide, and 1 / 5.1 is
       19.5% of whatever the band happens to be. It is deliberately looser
       than --section-label-size / 772 - at the full band this cap must not
       bite, or the word would render smaller than the size asked for,
       which is what a 16.4 tuned against the previous size did. Raise it
       if a future family's name is longer than this one. */
    font-size: min(var(--section-label-size), 19.5cqw);
    font-weight: 900;
    letter-spacing: -0.01em;
    line-height: 1;
    pointer-events: none;
    user-select: none;
    white-space: nowrap;
}

/* Structure: .tile is the grid cell and the only click target. Its visual
   card is a separate child, .tile-surface, which is what actually clips to
   the (small) rounded corner and swaps colour on hover - kept separate so
   .tile-name can be positioned within .tile but outside .tile-surface's
   clipping, letting it spill a few pixels past the card's own right edge,
   like a nameplate that reads as carved from the shape rather than sitting
   on top of it. */
.tile {
    position: relative;
    /* D73: over the family name behind it. */
    z-index: 1;
    aspect-ratio: 1 / 1;
    display: block;
    text-decoration: none;
    color: #ffffff;
    transition: transform 0.3s ease;
}

.tile:hover,
.tile:focus-visible {
    transform: translateY(-3px);
}

.tile-surface {
    position: absolute;
    inset: 0;
    border-radius: 10px;
    background: var(--color-tile);
    overflow: hidden;
    transition: background 0.3s ease;
}

.tile:hover .tile-surface,
.tile:focus-visible .tile-surface {
    background: var(--color-tile-hover);
}

/* D59. Applied by tile_page.html only to a tile this user can open, so it
   never collides with the inactive treatments below - and kept above them
   here as well, so source order agrees with that intent rather than
   quietly depending on it. */
.tile--accent-blue .tile-surface {
    background: var(--color-tile-blue);
}

.tile--accent-blue:hover .tile-surface,
.tile--accent-blue:focus-visible .tile-surface {
    background: var(--color-tile-blue-hover);
}

/* RESERVED - designed and approved 2026-09-04, not wired to anything real
   yet (see tiles/applications.py's Application.status and
   docs/DECISIONS.md). Two colour treatments for a tile whose application
   is not currently reachable:
   - inactive-blue keeps the normal hover animation (lift + darken) - it
     reads as a different but still-interactive tile.
   - inactive-grey is the "truly inactive" one: pale grey, and neither
     lifts nor darkens on hover. The description still reveals either way -
     the tile is inert, not hidden information. */
.tile--inactive-blue .tile-surface,
.tile--inactive-blue:hover .tile-surface,
.tile--inactive-blue:focus-visible .tile-surface {
    background: #7d92a3;
}

.tile--inactive-grey .tile-surface,
.tile--inactive-grey:hover .tile-surface,
.tile--inactive-grey:focus-visible .tile-surface {
    background: #d4d4d4;
}

.tile--inactive-grey:hover,
.tile--inactive-grey:focus-visible {
    transform: none;
}

/* D73: what a declared but empty family shows instead of tiles. Outline
   only - it is a space being held, not an application, and the two must
   never be mistaken for each other. Deliberately NOT one of the inactive
   treatments above: those are filled tiles standing for something real
   that this user cannot reach. */
.tile--placeholder .tile-surface {
    background: transparent;
    border: 2px dashed #d9dedf;
}

.tile--placeholder .tile-placeholder-note {
    position: absolute;
    right: 18px;
    bottom: 20px;
    left: 22px;
    color: #b3babc;
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-align: right;
    text-transform: uppercase;
}

/* Percentage-based, like .tile-name's left-start - so the icon scales and
   repositions with the tile itself instead of staying a fixed px size
   across a range of tile widths. */
.tile-icon {
    position: absolute;
    top: 8%;
    left: 8%;
    width: 15%;
    aspect-ratio: 1 / 1;
    color: #ffffff;
}

.tile-icon svg {
    display: block;
    width: 100%;
    height: 100%;
    stroke-width: 2.5;
}

/* No background panel - the description sits directly on the tile's own
   flat colour and simply fades/slides in.

   D61: anchored to the TOP of the tile, not floated above the name.
   Bottom-anchoring put it a fixed distance above a name whose height is
   not fixed - two-line names are twice as tall as one-line ones - so a
   long description on a two-line name ran straight into it. Protein DB
   had both and showed the collision.

   Top-anchored, the two grow away from each other instead of towards
   each other: the name grows upward from the bottom edge, the
   description downward from the top, and the gap between them is
   whatever is left rather than a guess.

   `top` matches .tile-icon's own `top`, so the text starts on the icon's
   line, and `left` clears the icon's right edge (8% + 15% width, plus a
   gap) so the two never share horizontal space. Percentages throughout,
   like the icon, so this holds at any tile size. */
.tile-description {
    position: absolute;
    top: 8%;
    right: 8%;
    left: 30%;
    text-align: right;
    /* D61: reduced again, from 1.05rem. In a container this much narrower
       it has to be - and it is support text revealed on hover, which
       should never compete with the name for the same glance. */
    font-size: 0.8rem;
    line-height: 1.4;
    color: rgb(255 255 255 / 92%);
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.tile:hover .tile-description,
.tile:focus-visible .tile-description {
    opacity: 1;
    transform: translateY(0);
}

/* Name: sits on .tile, not on .tile-surface, so it is never clipped by the
   card's rounded corner - it is allowed to run a few pixels past the
   card's own right edge, which is the "carved from the shape" read the
   design calls for, rather than a label placed on top of it. No shadow -
   it muddied the letterforms rather than helping them. */
.tile-name {
    position: absolute;
    right: -8px;
    bottom: 18px;
    left: 22px;
    z-index: 1;
    overflow: hidden;
    text-align: right;
    /* Only the size before the script below runs (and the size if it never
       does) - the real one is computed per tile from MAX_FONT_RATIO in
       tile_page.html. Reduced with it at D59 so the two agree. */
    font-size: 3.2rem;
    font-weight: 900;
    line-height: 1.1;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.empty-state {
    color: var(--color-muted);
    margin-top: 20px;
}

/* D72, the other half: the Dalriada mark sits on top of the scrolling
   area, which is what the shadow above it says. See .topbar for why the
   stacking order and the background are part of the treatment rather than
   tidiness. */
.site-footer {
    background: var(--color-surface);
    box-shadow: 0 -7px 16px -8px var(--edge-shadow);
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    padding: 14px 28px;
    position: relative;
    z-index: 2;
}

.site-footer img {
    height: 48px;
    width: auto;
}

/* --- P3: user administration (accounts app) - plain workspace/panel/table
   conventions, matching IMA_ETL_Pipeline's own admin screens (this is a
   Superadmin-only tool ported from there) so the layout is instantly
   familiar to anyone who used the old one, restyled to the hub's own
   palette. --- */
.workspace {
    margin: 40px auto;
    max-width: 1360px;
    padding: 0 28px 40px;
}

.workspace-heading {
    align-items: flex-start;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin-bottom: 24px;
}

.section-kicker {
    color: var(--color-primary);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.data-panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    margin-bottom: 20px;
    padding: 24px;
}

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

.table-wrap {
    overflow-x: auto;
}

table {
    border-collapse: collapse;
    width: 100%;
}

th, td {
    border-bottom: 1px solid var(--color-border);
    padding: 10px 12px;
    text-align: left;
}

thead th {
    color: var(--color-muted);
    font-size: 0.78rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.status-badge {
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 3px 10px;
}

.status-success {
    background: var(--color-primary-soft);
    color: var(--color-primary-dark);
}

.status-failed {
    background: #faeaea;
    color: var(--color-error);
}

.empty-note {
    color: var(--color-muted);
}

.submission-form {
    display: grid;
    gap: 12px;
}

.radio-line {
    align-items: center;
    display: flex;
    gap: 8px;
}

/* Several permission checkboxes sharing one table cell (see
   accounts/user_detail.html) render inline, side by side. */
td .radio-line {
    display: inline-flex;
    margin-right: 20px;
}

.primary-action {
    justify-self: start;
}

.secondary-action {
    background: #ffffff;
    border: 1px solid var(--color-border);
    color: var(--color-primary-dark);
    min-height: 38px;
}

.secondary-action:hover:not(:disabled) {
    background: var(--color-primary-soft);
}

.field-help {
    color: var(--color-muted);
    font-size: 0.82rem;
}

.flash-message.credential {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.95rem;
    font-weight: 700;
}
