/* ==========================================================================
   N& Co — group portal
   Direction "Paper" — Luxury Financial Report. Warm ivory paper as the
   home base, deep emerald as the trust colour, aged-gold as the accent
   that only ever appears as a thin rule or a small mark — never a fill.
   Cards read as elevated pages resting on a table (a soft shadow, a
   whisper of border) rather than the flat seamless grid of the previous
   direction. Corners soften slightly — a report, not a terminal.
   Dark mode still exists as an override for anyone who wants it, but
   paper-light is the system's home now.
   ========================================================================== */

:root {
    --ink:        #F6F1E7;
    --surface:    #FFFFFF;
    --surface-2:  #F1EADA;
    --surface-3:  #E8DFC8;
    --line:       #DCD0AF;
    --line-soft:  #E9E1CB;
    --text:       #2A2517;
    --text-muted: #6B6146;
    --text-dim:   #9C9070;
    --red:        #1F4D3D;
    --red-bright: #16382C;
    --gold:       #A9812F;
    --gold-soft:  #C9A75C;
    --ok:         #1F7A50;
    --warn:       #9C6A1E;
    --info:       #2A628F;

    --company:    var(--red);

    --radius:     6px;
    --radius-md:  4px;
    --radius-sm:  3px;
    --shell:      1240px;
    --shadow-card: 0 1px 2px rgba(42,37,23,.05), 0 6px 20px rgba(42,37,23,.06);

    --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
    --s5: 24px; --s6: 32px; --s7: 48px;

    --font: "Cairo", system-ui, -apple-system, "Segoe UI", sans-serif;
    --mono: "IBM Plex Mono", ui-monospace, monospace;
}

[data-theme="dark"] {
    --ink:        #0C0C0D;
    --surface:    #15130E;
    --surface-2:  #1B1912;
    --surface-3:  #232016;
    --line:       #2E2A1D;
    --line-soft:  #221F16;
    --text:       #EDEAE0;
    --text-muted: #A79E86;
    --text-dim:   #6B6350;
    --red:        #3F8067;
    --red-bright: #5FAE8C;
    --gold:       #C9A75C;
    --gold-soft:  #DABF83;
    --ok:         #3F8067;
    --warn:       #C9922E;
    --info:       #3B82C4;
    --shadow-card: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.35);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--ink);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 700; line-height: 1.3; letter-spacing: -0.01em; }
p { margin: 0 0 1rem; }
img { max-width: 100%; }

:focus-visible {
    outline: 1.5px solid var(--company);
    outline-offset: 2px;
}

.shell { max-width: var(--shell); margin: 0 auto; padding: 0 var(--s5); }
.stack > * + * { margin-top: var(--s4); }
.row { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.push { margin-inline-start: auto; }

/* --- Top bar: a compact mono path, not a chrome bar -------------------- */

.topbar {
    position: sticky; top: 0; z-index: 50;
    background: rgba(12, 12, 13, 0.94);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
}
/* A thin gradient line rather than a plain border — the smallest
   possible touch of brand colour that still shows on every page,
   without repeating a big coloured band that would fight the content
   underneath it. */
.topbar::after {
    content: "";
    position: absolute; inset-inline: 0; bottom: -1px; height: 2px;
    background: linear-gradient(90deg, var(--company) 0%, color-mix(in srgb, var(--company) 35%, transparent) 55%, transparent 100%);
    pointer-events: none;
}
.topbar__inner { display: flex; align-items: center; gap: var(--s4); height: 52px; }

.brand { display: flex; align-items: center; gap: var(--s2); font-weight: 700; letter-spacing: 0.01em; }
.brand__mark {
    width: 22px; height: 22px;
    display: grid; place-items: center;
    background: var(--company); color: #fff;
    font-family: var(--mono); font-size: 10px; font-weight: 600;
}

.crumb { display: flex; align-items: center; gap: var(--s2); font-family: var(--mono); font-size: 12px; letter-spacing: .04em; color: var(--text-dim); min-width: 0; text-transform: uppercase; }
.crumb__sep { color: var(--text-dim); }
.crumb__here { color: var(--text-muted); display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.crumb__dot { width: 6px; height: 6px; background: var(--company); flex: none; }

.topbar__nav { display: flex; gap: 2px; margin-inline-start: auto; align-items: center; }

.navlink {
    padding: 7px 11px;
    font-family: var(--mono); font-size: 11.5px; letter-spacing: .04em;
    color: var(--text-muted);
    transition: background .15s ease, color .15s ease;
}
.navlink:hover { background: var(--surface-3); color: var(--text); }

.usermenu { display: flex; align-items: center; gap: var(--s2); padding-inline-start: var(--s3); margin-inline-start: var(--s2); border-inline-start: 1px solid var(--line); }
.usermenu__name { font-family: var(--mono); font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--text-dim); }
.usermenu__name:hover { color: var(--text); }

main { padding: var(--s6) 0 var(--s7); }

/* --- Avatars — the one place circles survive ---------------------------- */

.avatar {
    width: 30px; height: 30px; flex: none;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--surface-3);
    border: 1px solid var(--line);
    font-size: 12.5px; font-weight: 600;
    color: var(--text);
}
.avatar--lg { width: 48px; height: 48px; font-size: 17px; border-radius: 50%; }
.avatar--brand { background: color-mix(in srgb, var(--company) 24%, var(--surface-3)); border-color: color-mix(in srgb, var(--company) 45%, var(--line)); color: var(--red-bright); }

/* --- Page heading --------------------------------------------------------
   The eyebrow carries the section's identity — mono, uppercase, dim — the
   same voice the mockup uses for "01 — اختيار الشركة" style labels. We
   don't force a literal step number onto it: a step number only means
   something when screens are a fixed sequence, and most of these aren't. */

.eyebrow {
    font-family: var(--mono); font-size: 11px;
    letter-spacing: 0.16em; text-transform: uppercase;
    color: var(--text-dim); margin-bottom: var(--s2);
}

.page-head { margin-bottom: var(--s5); }
.page-head h1 { font-size: 25px; }
.page-head p { color: var(--text-muted); margin: 6px 0 0; max-width: 68ch; }
.page-head__row { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4); flex-wrap: wrap; }

/* ---- unified module header strip: identity | stat cells | actions ---- */
.mhead {
    display: grid;
    grid-template-areas: "id actions" "stats stats";
    grid-template-columns: 1fr auto;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    margin-bottom: var(--s5); overflow: hidden; position: relative;
}
.mhead::before { content: ''; position: absolute; inset-block-start: 0; inset-inline: 0; height: 2.5px; background: var(--company, var(--red)); }
.mhead__id { grid-area: id; display: flex; align-items: center; gap: 14px; padding: 20px 22px; min-width: 0; }
.mhead__id > div { min-width: 0; }
.mhead__icon {
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
    width: 46px; height: 46px; border-radius: 12px;
    background: color-mix(in srgb, var(--company, var(--red)) 14%, transparent);
    border: 1px solid color-mix(in srgb, var(--company, var(--red)) 32%, transparent);
    color: var(--company, var(--red));
}
.mhead__title { font-size: 21px; font-weight: 800; margin: 0; line-height: 1.25; }
.mhead__tag { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.mhead__eyebrow { font-family: var(--mono); font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--text-dim); margin-bottom: 4px; }
.mhead__icon--lg { width: 62px; height: 62px; border-radius: 14px; font-weight: 800; font-size: 20px; }
.mhead__icon--lg img { max-width: 46px; max-height: 46px; object-fit: contain; }
.mhead__icon--custom { width: 64px; height: 64px; border-radius: 14px; }
.mhead__logo { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; background: #fff; border-radius: 14px; }
.mhead__logo img { max-width: 46px; max-height: 46px; object-fit: contain; }
.mhead__logo-dark { display: none; }
[data-theme="dark"] .mhead__logo-light { display: none; }
[data-theme="dark"] .mhead__logo-dark { display: flex; align-items: center; justify-content: center; }
.mhead__logo-chip { display: none; align-items: center; justify-content: center; background: #fff; border-radius: 8px; padding: 6px; }
.mhead__logo-chip img { max-width: 38px; max-height: 38px; }

/* ---- horizontal module tile cards (workspace) ---- */
.mtiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.mtile {
    display: flex; align-items: center; gap: 14px; padding: 16px 18px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
    text-decoration: none; color: inherit; transition: border-color .15s, transform .15s;
}
.mtile:hover { border-color: color-mix(in srgb, var(--company, var(--red)) 45%, var(--line)); transform: translateY(-1px); }
.mtile--planned { opacity: .55; pointer-events: none; }
.mtile__icon {
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
    width: 40px; height: 40px; border-radius: 10px;
    background: color-mix(in srgb, var(--company, var(--red)) 13%, transparent);
    color: var(--company, var(--red));
}
.mtile__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.mtile__name { font-weight: 700; font-size: 14.5px; }
.mtile__summary { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mtile__foot { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex-shrink: 0; }
.mtile__open { font-size: 12px; color: var(--company, var(--red)); font-weight: 600; }
.mtile__ver { font-family: var(--mono); font-size: 10.5px; color: var(--text-dim); }
.mhead__stats {
    grid-area: stats; display: flex; align-items: stretch; flex-wrap: wrap;
    border-block-start: 1px solid var(--line-soft);
}
.mhead__cell {
    flex: 1 1 0; display: flex; flex-direction: column; justify-content: center; gap: 3px;
    padding: 14px 22px; min-width: 118px; border-inline-start: 1px solid var(--line-soft);
}
.mhead__cell:first-child { border-inline-start: 0; }
.mhead__label { font-family: var(--mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--text-dim); }
.mhead__value { font-family: var(--mono); font-size: 21px; font-weight: 700; line-height: 1.15; }
.mhead__sub { font-size: 11.5px; color: var(--text-muted); }
.mhead__bar { height: 3px; background: var(--surface-3); border-radius: 99px; overflow: hidden; margin-top: 2px; }
.mhead__bar span { display: block; height: 100%; background: var(--company, var(--ok)); border-radius: 99px; }
.mhead__actions { grid-area: actions; display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 20px 22px; flex-wrap: wrap; }
@media (max-width: 860px) {
    .mhead__id { width: 100%; }
    .mhead__stats { margin-inline-start: 0; width: 100%; border-block-start: 1px solid var(--line-soft); }
    .mhead__cell:first-child { border-inline-start: 0; }
    .mhead__actions { width: 100%; border-inline-start: 0; border-block-start: 1px solid var(--line-soft); }
}

/* --- Company hero --------------------------------------------------------- */

.hero {
    position: relative;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-card);
    padding: var(--s5);
    margin-bottom: var(--s5);
    overflow: hidden;
}
.hero::before {
    content: ""; position: absolute; inset-block-start: 0; inset-inline: 0; height: 3px;
    background: linear-gradient(90deg, var(--company), var(--gold));
}
.hero::after {
    content: ""; position: absolute; inset-block-start: 0; inset-inline-end: 0;
    width: 300px; height: 100%;
    background: radial-gradient(120% 90% at 100% 0%, color-mix(in srgb, var(--company) 10%, transparent), transparent 70%);
    pointer-events: none;
}
.hero__top { display: flex; align-items: flex-start; gap: var(--s4); flex-wrap: wrap; position: relative; z-index: 1; }
.hero__logo { height: 54px; display: flex; align-items: center; }
.hero__logo img { max-height: 54px; max-width: 190px; object-fit: contain; }
.hero__logo-dark { display: none; }
[data-theme="dark"] .hero__logo-light { display: none; }
[data-theme="dark"] .hero__logo-dark { display: inline-flex; }
.hero__logo-chip { display: none; align-items: center; background: #fff; border-radius: 8px; padding: 8px 14px; }
.hero__logo-chip img { max-height: 38px; }
.hero__title { font-size: 25px; font-weight: 700; }
.hero__tagline { color: var(--text-muted); font-size: 14px; margin-top: 3px; }
.hero__wordmark { font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-dim); }

.hero__stats {
    display: flex; gap: var(--s6); flex-wrap: wrap;
    margin-top: var(--s5); padding-top: var(--s4);
    border-top: 1px solid var(--line);
    position: relative; z-index: 1;
}
.stat__value { font-family: var(--mono); font-size: 22px; font-weight: 700; line-height: 1.2; }
.stat__label { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

/* --- Company plates (home grid) — elevated pages, not a flat grid ------- */

.plates {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: var(--s4);
}

.plate {
    position: relative; display: block;
    padding: var(--s5) var(--s5) var(--s4);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    transition: transform .15s ease, box-shadow .15s ease;
}
.plate::before {
    content: ""; position: absolute; inset-block-start: 0; inset-inline: 0; height: 3px;
    background: var(--company); opacity: 0; border-radius: var(--radius) var(--radius) 0 0;
    transition: opacity .15s ease;
}
.plate:hover, .plate:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 2px 4px rgba(42,37,23,.08), 0 14px 28px rgba(42,37,23,.1);
}
.plate:hover::before { opacity: 1; }

.plate__logo { height: 46px; display: flex; align-items: center; margin-bottom: var(--s5); }
.plate__logo img { max-height: 46px; max-width: 175px; object-fit: contain; }
.plate__logo-dark { display: none; }
[data-theme="dark"] .plate__logo-light { display: none; }
[data-theme="dark"] .plate__logo-dark { display: inline-flex; }
.plate__logo-chip { display: none; align-items: center; background: #fff; border-radius: 8px; padding: 6px 12px; }
.plate__logo-chip img { max-height: 30px; }
.plate__wordmark { font-family: var(--mono); font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.plate__wordmark span { color: var(--gold); }
.plate__name { font-size: 16px; font-weight: 700; }
.plate__tagline { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; min-height: 22px; }
.plate__foot {
    display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
    margin-top: var(--s4); padding-top: var(--s3);
    border-top: 1px solid var(--line);
    font-family: var(--mono); font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase;
    color: var(--text-dim);
}

/* --- Module tiles — same elevated-card treatment ------------------------- */

.tiles {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(228px, 1fr));
    gap: var(--s3);
}

.tile {
    position: relative;
    display: flex; flex-direction: column; gap: var(--s3);
    padding: var(--s4) var(--s4) var(--s3);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    min-height: 126px;
    transition: transform .15s ease, box-shadow .15s ease;
}
.tile:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(42,37,23,.08), 0 14px 28px rgba(42,37,23,.1); }
.tile__icon {
    width: 34px; height: 34px;
    display: grid; place-items: center;
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--company) 14%, transparent);
    color: var(--red);
}
.tile__name { font-size: 14.5px; font-weight: 700; }
.tile__summary { font-size: 12.5px; color: var(--text-muted); margin-top: -6px; }
.tile__foot {
    margin-top: auto; padding-top: var(--s2);
    display: flex; align-items: center; justify-content: space-between;
    font-family: var(--mono); font-size: 10.5px; color: var(--text-dim);
}
.tile__go { color: var(--text-dim); transition: transform .15s ease, color .15s ease; }
.tile:hover .tile__go { color: var(--red-bright); transform: translateX(-3px); }

.tile--planned .tile__icon { background: var(--surface-3); color: var(--text-dim); }
.tile--planned .tile__name { color: var(--text-muted); }
.tile--planned:hover .tile__go { color: var(--text-muted); }

/* --- Panels ------------------------------------------------------------- */

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: var(--s5);
}
.panel + .panel { margin-top: var(--s4); }
.panel--flush { padding: 0; overflow: hidden; }
.panel--flush .panel__head { padding: var(--s4) var(--s5); margin: 0; border-bottom: 1px solid var(--line); }
.panel--flush .table { margin: 0; }
.panel--flush .table th { padding-inline: var(--s5); }
.panel--flush .table td { padding-inline: var(--s5); }

.panel__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); margin-bottom: var(--s4); }
.panel__head h2 { font-size: 15px; font-weight: 700; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: var(--s4); align-items: start; }
.grid-side { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: var(--s4); align-items: start; }

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

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
    text-align: start;
    font-family: var(--mono); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase;
    color: var(--text-dim); font-weight: 500;
    padding: 0 var(--s3) var(--s2);
    border-bottom: 1px solid var(--line);
}
.table td { padding: var(--s3); border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s ease; }
.table--hover tbody tr:hover { background: var(--surface-2); }

.cell-main { display: flex; align-items: center; gap: var(--s3); }
.cell-title { font-weight: 600; }
.cell-sub { font-family: var(--mono); font-size: 11.5px; color: var(--text-dim); }

/* --- Status: a coloured bullet and text, no badge box -------------------- */

.tag {
    display: inline-block; padding: 3px 8px;
    background: var(--surface-3); border: 1px solid var(--line);
    font-family: var(--mono); font-size: 10.5px; color: var(--text-muted);
    white-space: nowrap;
}

.pill {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12.5px; font-weight: 500;
    background: none; border: 0; padding: 0;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.pill--ok      { color: #6FD3A5; }
.pill--lead    { color: #E5B65C; }
.pill--muted   { color: var(--text-dim); }
.pill--danger  { color: var(--red-bright); }

.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; background: var(--text-dim); }

/* ---- filled status badge — bolder than .pill, for states that need to read at a glance ---- */
.status-badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 11px; border-radius: 99px;
    font-size: 12px; font-weight: 700; white-space: nowrap;
    border: 1px solid transparent;
}
.status-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.status-badge--draft   { background: color-mix(in srgb, var(--text-dim) 14%, transparent); color: var(--text-muted); border-color: color-mix(in srgb, var(--text-dim) 28%, transparent); }
.status-badge--issued  { background: color-mix(in srgb, #5B9EE5 16%, transparent); color: #5B9EE5; border-color: color-mix(in srgb, #5B9EE5 34%, transparent); }
.status-badge--partial { background: color-mix(in srgb, #E5B65C 18%, transparent); color: #E5B65C; border-color: color-mix(in srgb, #E5B65C 36%, transparent); }
.status-badge--paid    { background: color-mix(in srgb, #6FD3A5 18%, transparent); color: #6FD3A5; border-color: color-mix(in srgb, #6FD3A5 36%, transparent); }
.status-badge--void    { background: color-mix(in srgb, var(--red-bright) 16%, transparent); color: var(--red-bright); border-color: color-mix(in srgb, var(--red-bright) 32%, transparent); text-decoration: line-through; text-decoration-thickness: 1.5px; }
.dot--on { background: var(--ok); }

.chip {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 6px 12px;
    background: var(--surface-2); border: 1px solid var(--line);
    font-size: 13px; color: var(--text-muted);
    transition: border-color .15s ease, color .15s ease;
}
a.chip:hover { border-color: color-mix(in srgb, var(--company) 55%, var(--line)); color: var(--text); }
.chip svg { color: var(--text-dim); flex: none; }
.chip__value { font-family: var(--mono); font-size: 12.5px; color: var(--text); direction: ltr; }

/* --- Segmented filter ----------------------------------------------------- */

.segmented { display: inline-flex; padding: 2px; background: var(--surface-2); border: 1px solid var(--line); gap: 1px; }
.segmented a {
    padding: 6px 13px;
    font-family: var(--mono); font-size: 11.5px; letter-spacing: .02em;
    color: var(--text-muted);
    transition: background .15s ease, color .15s ease;
}
.segmented a:hover { color: var(--text); }
.segmented a.on { background: var(--surface-3); color: var(--text); }
.segmented .count { font-family: var(--mono); font-size: 11px; color: var(--text-dim); margin-inline-start: 5px; }

/* --- Timeline --------------------------------------------------------------- */

.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before {
    content: ""; position: absolute; inset-block: 14px 14px;
    inset-inline-start: 15px; width: 1px; background: var(--line);
}
.timeline li { position: relative; display: flex; gap: var(--s3); padding: var(--s3) 0; }
.timeline__mark {
    width: 30px; height: 30px; flex: none;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--surface-2);
    border: 1px solid var(--line);
    color: var(--text-dim);
    position: relative; z-index: 1;
}
.timeline__mark--brand { color: var(--red-bright); border-color: color-mix(in srgb, var(--company) 40%, var(--line)); }
.timeline__body { min-width: 0; flex: 1; }
.timeline__meta { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; font-size: 12px; color: var(--text-dim); }
.timeline__who { color: var(--text-muted); }
.timeline__text { font-size: 13.5px; margin-top: 2px; overflow-wrap: anywhere; }

/* --- Activity strip (under the tiles) ------------------------------------- */

.strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.strip__item {
    display: flex; gap: var(--s3);
    padding: var(--s3) var(--s4);
    background: var(--ink);
}
.strip__icon { color: var(--text-dim); flex: none; margin-top: 2px; }
.strip__what { font-size: 13px; }
.strip__when { font-size: 11.5px; color: var(--text-dim); font-family: var(--mono); }

.activity-panel { padding-bottom: var(--s3); }
.activity-panel__scroll { max-height: 480px; overflow-y: auto; padding-inline-end: 4px; }
.activity-panel__scroll::-webkit-scrollbar { width: 6px; }
.activity-panel__scroll::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
.activity-panel__scroll .strip__item:last-child { border-bottom: 0 !important; }

/* --- Empty states ----------------------------------------------------------- */

.empty { padding: var(--s7) var(--s5); text-align: center; border: 1px dashed var(--line); color: var(--text-muted); }
.empty__icon { color: var(--text-dim); margin-bottom: var(--s3); }
.empty h3 { font-size: 15px; margin-bottom: 6px; color: var(--text); }
.empty p { max-width: 46ch; margin-inline: auto; }

/* --- Forms and buttons -------------------------------------------------- */

.field { margin-bottom: var(--s4); }
.field label { display: block; font-family: var(--mono); font-size: 11.5px; letter-spacing: .03em; color: var(--text-muted); margin-bottom: 7px; }
.fields-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.fields-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--s3); }

.input {
    width: 100%; padding: 10px 13px;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    color: var(--text); font-family: inherit; font-size: 15px;
    transition: border-color .15s ease, background .15s ease;
}
.input:hover { border-color: color-mix(in srgb, var(--text-dim) 60%, var(--line)); }
.input:focus { border-color: var(--company); outline: none; }
.input--error { border-color: var(--red-bright); }
textarea.input { resize: vertical; line-height: 1.6; }

.field__error { display: block; margin-top: 6px; font-size: 12.5px; color: var(--red-bright); }
.field__hint  { display: block; margin-top: 6px; font-size: 12.5px; color: var(--text-dim); }

.searchbar { position: relative; flex: 1; min-width: 200px; }
.searchbar svg { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); color: var(--text-dim); pointer-events: none; }
.searchbar .input { padding-inline-start: 40px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 10px 17px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    /* A gradient toward a darker shade of the SAME company colour,
       computed from it rather than a second hardcoded colour — this is
       what keeps every company's own brand colour intact while still
       giving every button a bit of depth instead of a flat fill. */
    background: linear-gradient(155deg, var(--company) 0%, color-mix(in srgb, var(--company) 60%, #000 40%) 130%);
    color: #fff;
    font-family: inherit; font-size: 13.5px; font-weight: 700;
    cursor: pointer; white-space: nowrap;
    box-shadow: 0 1px 2px rgba(0,0,0,.14);
    transition: filter .15s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease, transform .05s ease;
}
.btn:hover { filter: brightness(1.1); box-shadow: 0 5px 16px -5px color-mix(in srgb, var(--company) 55%, transparent); }
.btn:active { transform: translateY(1px); filter: brightness(.97); }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--text); box-shadow: none; }
.btn--ghost:hover { background: var(--surface-3); border-color: var(--line); filter: none; box-shadow: none; }
.btn--sm { padding: 7px 13px; font-size: 12.5px; }
.btn--block { width: 100%; }
.btn svg { flex: none; }

.linkbtn { background: none; border: 0; padding: 0; color: var(--text-muted); font: inherit; cursor: pointer; }
.linkbtn:hover { color: var(--text); }

.actions { display: flex; gap: 6px; justify-content: flex-end; }

/* --- Flash ---------------------------------------------------------------- */

.flash {
    display: flex; align-items: center; gap: var(--s3);
    padding: 12px 16px;
    border: 1px solid var(--line); background: var(--surface);
    margin-bottom: var(--s4); font-size: 13.5px;
    border-inline-start: 2px solid var(--line);
}
.flash svg { flex: none; }
.flash--success { border-inline-start-color: var(--ok); color: #A8E5C8; }
.flash--error   { border-inline-start-color: var(--red-bright); color: #F0AEB6; }

/* --- Code block ------------------------------------------------------------- */

.code {
    background: var(--ink); border: 1px solid var(--line);
    padding: var(--s3); overflow: auto;
    font-family: var(--mono); font-size: 12px; line-height: 1.65; margin: 0;
    direction: ltr; text-align: left;
}

/* --- Auth ------------------------------------------------------------------- */

.auth { min-height: 100dvh; display: grid; place-items: center; padding: var(--s6) var(--s4); }
.auth__card {
    width: 100%; max-width: 400px;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: var(--s6) var(--s5);
}
.auth__head { text-align: center; margin-bottom: var(--s5); }
.auth__head .brand { justify-content: center; margin-bottom: var(--s4); }
.auth__head h1 { font-size: 19px; }
.auth__head p { color: var(--text-muted); font-size: 13.5px; margin: 6px 0 0; }
.auth__foot { margin-top: var(--s4); text-align: center; font-family: var(--mono); font-size: 10.5px; color: var(--text-dim); letter-spacing: .1em; }

/* --- Error pages -------------------------------------------------------- */

.errorpage { min-height: 100dvh; display: grid; place-items: center; text-align: center; padding: var(--s5); }
.errorpage__code { font-family: var(--mono); font-size: 60px; font-weight: 700; color: var(--red-bright); line-height: 1; }
.errorpage p { color: var(--text-muted); margin: var(--s3) 0 var(--s5); }

/* --- Responsive ----------------------------------------------------------- */

@media (max-width: 900px) {
    .grid-2, .grid-side { grid-template-columns: 1fr; }
    .fields-3 { grid-template-columns: 1fr; }
    .topbar__inner { height: 52px; gap: var(--s2); }
    .usermenu__name, .crumb__root { display: none; }
    main { padding: var(--s5) 0 var(--s6); }
    .page-head h1 { font-size: 20px; }
    .hero { padding: var(--s4); }
    .hero__title { font-size: 20px; }
    .hero__stats { gap: var(--s5); }
}

@media (max-width: 560px) {
    .plates { grid-template-columns: 1fr; }
    .tiles  { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
    .fields-2 { grid-template-columns: 1fr; }
    .shell  { padding: 0 var(--s4); }
    .navlink { padding: 7px 9px; font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}


/* --- Office document preview (rendered by mammoth.js / SheetJS) --------- */
#office-preview table { border-collapse: collapse; font-size: 13px; width: max-content; }
#office-preview td, #office-preview th { border: 1px solid #ddd; padding: 4px 8px; }
#office-preview img { max-width: 100%; }
#office-preview p { margin: 0 0 0.8em; line-height: 1.6; }


/* --- File type badges (Drive) -------------------------------------------- */
.filebadge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 46px; height: 46px; padding: 0 9px;
    border-radius: 9px;
    font-family: var(--mono); font-size: 11.5px; font-weight: 700;
    letter-spacing: .02em; flex: none;
}
.fb-pdf   { background: rgba(220, 68, 68, .16);  color: #FF8B8B; }
.fb-doc   { background: rgba(59, 130, 196, .16);  color: #7FBCEE; }
.fb-xls   { background: rgba(46, 158, 107, .16);  color: #7BD8AC; }
.fb-ppt   { background: rgba(201, 146, 46, .16);  color: #F0BE73; }
.fb-img   { background: rgba(139, 92, 246, .16);  color: #C4A8FA; }
.fb-video { background: rgba(236, 72, 153, .16);  color: #F5A0C6; }
.fb-audio { background: rgba(20, 184, 166, .16);  color: #7FE0D3; }
.fb-zip   { background: rgba(148, 163, 184, .16); color: #C4CCDA; }
.fb-default { background: var(--surface-3); color: var(--text-dim); }

/* --- Drive: dropzone, grid view, upload toasts --------------------------- */
.dropzone {
    border: 1.5px dashed var(--line);
    border-radius: var(--radius);
    padding: var(--s5) var(--s4); text-align: center; color: var(--text-muted);
    margin-bottom: var(--s4); cursor: pointer;
    /* The whole zone is a click target, so a click-drag on it used to
       select the label text and leave it sitting under a highlight. */
    user-select: none;
    transition: border-color .15s ease, background .15s ease;
}
.dropzone:hover { border-color: var(--company); background: var(--surface-2); }
.dropzone:focus-visible { outline: 2px solid var(--company); outline-offset: 2px; }
.dropzone__main { font-size: 14px; font-weight: 700; color: var(--text); }
.dropzone--active { border-color: var(--company); background: color-mix(in srgb, var(--company) 6%, transparent); color: var(--text); }
.dropzone__icon { color: var(--text-dim); margin-bottom: var(--s2); }
.dropzone--active .dropzone__icon { color: var(--red-bright); }
.dropzone small { display: block; margin-top: 4px; font-size: 12px; color: var(--text-dim); }

.view-toggle { display: inline-flex; padding: 2px; background: var(--surface-2); border: 1px solid var(--line); gap: 1px; }
.view-toggle button {
    display: grid; place-items: center; width: 28px; height: 24px;
    border: 0; background: transparent; color: var(--text-dim); cursor: pointer;
}
.view-toggle button.on { background: var(--surface-3); color: var(--text); }

.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.file-card {
    display: flex; flex-direction: column; align-items: center; gap: var(--s2);
    padding: var(--s4) var(--s3); text-align: center;
    background: var(--ink);
    cursor: pointer; transition: background .15s ease;
}
.file-card:hover { background: var(--surface-2); }
.file-card .filebadge { width: 44px; height: 44px; font-size: 11px; }
.file-card__thumb { width: 84px; height: 84px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line-soft); flex: none; }
.file-card__name { font-size: 12.5px; overflow-wrap: anywhere; line-height: 1.4; max-height: 2.8em; overflow: hidden; }
.file-card__meta { font-size: 11px; color: var(--text-dim); }
.file-row__thumb { width: 46px; height: 46px; object-fit: cover; border-radius: 7px; border: 1px solid var(--line-soft); flex: none; }
.file-list-row { display: none; }
[data-view="list"] .file-grid { display: none; }
[data-view="grid"] .panel--filetable { display: none; }

.toasts { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; padding: 8px; }

/* Uploads tray — a real anchored panel instead of loose floating toasts,
   so a batch upload reads as one thing with a header and a count. */
.uptray {
    position: fixed; inset-inline-end: 20px; inset-block-end: 20px; z-index: 90;
    width: 330px; background: var(--surface);
    border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(42,37,23,.18); overflow: hidden;
}
.uptray[hidden] { display: none; }
.uptray__head {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 11px 14px; background: var(--surface-2);
    border-bottom: 1px solid var(--line-soft);
}
.uptray__title { font-size: 13px; font-weight: 800; color: var(--text); }
.uptray__acts { display: flex; gap: 2px; }
.uptray__btn {
    background: none; border: 0; cursor: pointer; color: var(--text-muted);
    font-size: 17px; line-height: 1; padding: 2px 8px; border-radius: var(--radius-sm);
}
.uptray__btn:hover { background: var(--surface-3); color: var(--text); }
.uptray.is-min .toasts { display: none; }
.toast {
    background: var(--surface-2); border: 1px solid var(--line);
    padding: 10px 14px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.toast__row { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; overflow-wrap: anywhere; }
.toast__bar { height: 3px; background: var(--surface-3); overflow: hidden; }
.toast__fill { height: 100%; background: var(--company); width: 0%; transition: width .15s ease; }
.toast--done .toast__fill { background: var(--ok); width: 100%; }
.toast--error .toast__fill { background: var(--red-bright); width: 100%; }

/* --- Admin nav dropdown -------------------------------------------------- */
.navdrop { position: relative; }
.navdrop__trigger { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; font-family: inherit; border: 0; background: none; color: var(--text-muted); }
.navdrop__trigger svg { transform: rotate(-90deg); transition: transform .15s ease; }
.navdrop.open .navdrop__trigger svg { transform: rotate(90deg); }
.navdrop__menu {
    display: none;
    position: absolute; inset-inline-end: 0; top: calc(100% + 6px);
    min-width: 170px;
    background: var(--surface-2); border: 1px solid var(--line);
    padding: 4px; box-shadow: 0 12px 32px rgba(0,0,0,.55);
    z-index: 60;
}
.navdrop.open .navdrop__menu { display: block; }
.navdrop__menu a {
    display: block; padding: 8px 12px;
    font-family: var(--mono); font-size: 11.5px; letter-spacing: .02em; color: var(--text-muted);
}
.navdrop__menu a:hover { background: var(--surface-3); color: var(--text); }

/* --- Kanban board (Projects) --------------------------------------------- */
.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); align-items: start; }
.board__col { background: var(--ink); padding: var(--s3); display: flex; flex-direction: column; gap: var(--s2); }
.board__head { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px var(--s2); font-family: var(--mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; font-weight: 600; color: var(--text-muted); }
.board__count { font-family: var(--mono); }
.board__cards { display: flex; flex-direction: column; gap: 1px; min-height: 40px; background: var(--line); transition: background .12s ease; }
.board__cards:not(:empty) { border: 1px solid var(--line); }
.board__cards--over { outline: 1px dashed color-mix(in srgb, var(--company) 55%, var(--line)); }

.taskcard {
    position: relative;
    background: var(--surface-2);
    padding: 10px 12px; cursor: grab;
}
.taskcard.dragging { opacity: .4; }
.taskcard__title { display: block; font-size: 13px; font-weight: 500; overflow-wrap: anywhere; padding-inline-end: 16px; color: var(--text); }
.taskcard__title:hover { color: var(--red-bright); text-decoration: underline; }
.taskcard__desc { font-size: 11.5px; color: var(--text-dim); margin-top: 4px; overflow-wrap: anywhere; }
.taskcard__meta { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.taskcard__del {
    position: absolute; top: 6px; inset-inline-end: 6px;
    opacity: 0; transition: opacity .12s ease;
}
.taskcard:hover .taskcard__del { opacity: 1; }
.taskcard__del button { background: none; border: 0; color: var(--text-dim); cursor: pointer; padding: 2px; }
.taskcard__del button:hover { color: var(--red-bright); }

.board__add {
    background: none; border: 1px dashed var(--line);
    color: var(--text-muted); font-size: 12px; padding: 8px; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 6px;
}
.board__add:hover { border-color: color-mix(in srgb, var(--company) 50%, var(--line)); color: var(--text); }
.board__addform { padding: 8px; background: var(--ink); border: 1px solid var(--line); }

@media (max-width: 760px) {
    .board { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Light theme — same tokens, inverted values. Every component already
   reads color through these custom properties, so switching themes is
   just swapping the token block — nothing else in the file needs to
   know which one is active. Company colours (--company, set inline per
   company) are untouched — they work the same in both themes.
   ========================================================================== */

[data-theme="dark"] .errorpage__code { color: var(--red-bright); }

/* --- Theme toggle button -------------------------------------------------- */
.theme-toggle {
    display: grid; place-items: center; width: 30px; height: 30px;
    border: 1px solid var(--line); background: none; color: var(--text-muted);
    cursor: pointer; flex: none;
}
.theme-toggle:hover { background: var(--surface-3); color: var(--text); }
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* --- Social Media Plan: Instagram-style feed grid ------------------------ */
.ig-grid {
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 2px; background: var(--line); border: 1px solid var(--line);
    max-width: 640px;
}
.ig-cell {
    position: relative; aspect-ratio: 1 / 1; overflow: hidden;
    background: var(--surface-2); cursor: grab; display: block;
}
.ig-cell.dragging { opacity: .35; }
.ig-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ig-cell__empty { width: 100%; height: 100%; display: grid; place-items: center; color: var(--text-dim); }
.ig-cell__badge {
    position: absolute; bottom: 6px; inset-inline-start: 6px;
    background: rgba(255,255,255,.88); padding: 3px 7px;
    font-size: 10px; color: var(--text);
}
[data-theme="dark"] .ig-cell__badge { background: rgba(12,12,13,.82); color: var(--text); }

/* --- Pagination --------------------------------------------------------- */

.pagination { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: var(--s5); flex-wrap: wrap; }
.pagination a, .pagination span {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 34px; height: 34px; padding: 0 8px;
    border: 1px solid var(--line); border-radius: 8px;
    font-size: 13px; color: var(--text-muted); text-decoration: none;
}
.pagination a:hover { border-color: var(--company); color: var(--text); }
.pagination .on { background: var(--company); border-color: var(--company); color: #fff; font-weight: 700; }
.pagination .disabled { opacity: .35; pointer-events: none; }
.pagination .dots { border: 0; color: var(--text-dim); }


/* ---------------------------------------------------------------
   Workspace sidebar — module navigation inside a company.
   Only rendered when there's an active company; group-level pages
   keep the original full-width layout.
   --------------------------------------------------------------- */
.worklayout { display: flex; align-items: flex-start; }

.worknav {
    width: 248px;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    background: var(--surface);
    border-inline-end: 1px solid var(--line);
    padding: var(--s5) var(--s3) var(--s6);
}
.worknav__head {
    display: flex; align-items: center; justify-content: space-between;
    gap: var(--s2); padding: 0 var(--s3) var(--s4);
    margin-bottom: var(--s3); border-bottom: 1px solid var(--line-soft);
}
.worknav__company {
    flex: 1; min-width: 0;
    font-size: 14px; font-weight: 800; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.worknav__logo { width: 30px; height: 30px; object-fit: contain; flex-shrink: 0; border-radius: var(--radius-sm); }
.worknav__chip {
    width: 30px; height: 30px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm); background: var(--company); color: #fff;
    font-size: 11.5px; font-weight: 800;
}
.worknav__close { display: none; background: none; border: 0; font-size: 24px; line-height: 1; color: var(--text-muted); cursor: pointer; padding: 0 4px; }

.worknav__section {
    font-size: 10.5px; font-weight: 800; letter-spacing: .09em;
    color: var(--text-dim); text-transform: uppercase;
    padding: var(--s4) var(--s3) var(--s2);
}
.worknav__list { display: flex; flex-direction: column; gap: 2px; }
.worknav__group { display: flex; flex-direction: column; }

.worknav__item {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 9px var(--s3); border: 0; background: none;
    border-radius: var(--radius-md);
    font-family: var(--font); font-size: 13.5px; font-weight: 600;
    line-height: 1.3; color: var(--text-muted);
    text-align: start; cursor: pointer;
    transition: background .12s, color .12s;
}
.worknav__item:hover { background: var(--surface-2); color: var(--text); }
.worknav__item.is-active { background: var(--surface-2); color: var(--text); font-weight: 800; }
/* The label takes the free space and truncates instead of wrapping to a
   second line, which pushed the chevron out of alignment before. */
.worknav__label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.worknav__item svg { flex-shrink: 0; opacity: .75; }
.worknav__item.is-active svg { opacity: 1; }

.worknav__chev { display: inline-flex; flex-shrink: 0; transition: transform .15s; opacity: .5; }
.worknav__group.is-open .worknav__chev { transform: rotate(-90deg); }
html[dir="rtl"] .worknav__chev { transform: rotate(180deg); }
html[dir="rtl"] .worknav__group.is-open .worknav__chev { transform: rotate(-90deg); }

.worknav__sub {
    display: none; flex-direction: column; gap: 1px;
    margin: 2px 0 var(--s2);
    padding-inline-start: var(--s4);
    border-inline-start: 1px solid var(--line-soft);
    margin-inline-start: calc(var(--s3) + 8px);
}
.worknav__group.is-open .worknav__sub { display: flex; }
.worknav__link {
    padding: 7px var(--s3);
    border-radius: var(--radius-md);
    font-size: 12.5px; color: var(--text-muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    transition: background .12s, color .12s;
}
.worknav__link:hover { background: var(--surface-2); color: var(--text); }
.worknav__link.is-active { color: var(--company); font-weight: 800; }

.worklayout__main { flex: 1; min-width: 0; }
.worklayout__main > .shell { padding-inline: var(--s5); }
.worknav__open { display: none; }

@media (max-width: 900px) {
    .worknav {
        position: fixed; inset-block: 0; inset-inline-start: 0;
        z-index: 60; width: 268px;
        transform: translateX(-105%);
        transition: transform .2s ease;
        box-shadow: 0 0 40px rgba(0,0,0,.2);
    }
    html[dir="rtl"] .worknav { transform: translateX(105%); }
    .worknav.is-open, html[dir="rtl"] .worknav.is-open { transform: translateX(0); }
    .worknav__close { display: block; }
    .worknav__open {
        display: inline-flex; align-items: center; gap: 7px;
        margin: var(--s3) var(--s4) 0;
        padding: 8px 14px; border: 1px solid var(--line);
        border-radius: var(--radius-md); background: var(--surface);
        font-family: var(--font); font-size: 13px; font-weight: 700;
        color: var(--text); cursor: pointer;
    }
    .worklayout__main > .shell { padding-inline: var(--s4); }
}

/* --- company dashboard (replaces the old tiles grid) --------------- */
.dash__kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--s3); margin-bottom: var(--s5); }
.dash__kpi {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: var(--s4) var(--s5);
    box-shadow: var(--shadow-card);
}
.dash__kpi-label { font-size: 10.5px; font-weight: 800; letter-spacing: .09em; color: var(--text-dim); text-transform: uppercase; margin-bottom: 8px; }
.dash__kpi-value { font-size: 26px; font-weight: 800; font-family: var(--mono); line-height: 1.1; color: var(--text); }
.dash__kpi-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.dash__cols { display: grid; grid-template-columns: 1.4fr 1fr; gap: var(--s4); align-items: start; }
@media (max-width: 900px) { .dash__cols { grid-template-columns: 1fr; } }

.dash__quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s2); }
.dash__quick a {
    display: flex; align-items: center; gap: 9px;
    padding: 11px var(--s3); border: 1px solid var(--line);
    border-radius: var(--radius-md); background: var(--surface);
    font-size: 13px; font-weight: 700; color: var(--text);
    transition: border-color .12s, background .12s;
}
.dash__quick a:hover { border-color: var(--company); background: var(--surface-2); }
.dash__quick svg { opacity: .7; flex-shrink: 0; }

/* Module header on narrow screens — identity and actions stack instead
   of fighting for the same row. */
@media (max-width: 700px) {
    .mhead { grid-template-areas: "id" "actions" "stats"; grid-template-columns: 1fr; }
    .mhead__actions { justify-content: flex-start; padding-block-start: 0; }
    .mhead__cell { min-width: 100px; padding-inline: 16px; }
}

/* --- file row three-dot menu ---------------------------------------
   Replaces the row of cramped icon buttons: one dots button opens a
   panel with the file's details plus every action on it.
   ------------------------------------------------------------------ */
.fmenu { position: relative; display: inline-block; }
.fmenu__dots {
    background: none; border: 1px solid transparent; border-radius: var(--radius-md);
    font-size: 20px; line-height: 1; color: var(--text-muted);
    padding: 4px 10px; cursor: pointer; transition: background .12s, border-color .12s;
}
.fmenu__dots:hover { background: var(--surface-2); border-color: var(--line); color: var(--text); }
.fmenu.is-open .fmenu__dots { background: var(--surface-2); border-color: var(--line); color: var(--text); }

/* Fixed, not absolute: the table sits inside .panel--flush, which sets
   overflow:hidden — an absolutely positioned menu inside it gets clipped
   at the panel edge, which is why the last rows' menus appeared cut off.
   Fixed takes it out of that clipping context; JS places it. */
.fmenu__panel {
    display: none; position: fixed; z-index: 200; width: 262px; text-align: start;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow-card);
    padding: 6px;
}
.fmenu.is-open .fmenu__panel { display: block; }

.fmenu__info { padding: 10px 10px 12px; border-bottom: 1px solid var(--line-soft); margin-bottom: 6px; }
.fmenu__name { font-size: 13px; font-weight: 800; color: var(--text); overflow-wrap: anywhere; margin-bottom: 4px; }
.fmenu__meta { font-size: 11.5px; color: var(--text-muted); line-height: 1.6; }

.fmenu__act {
    display: flex; align-items: center; gap: 9px; width: 100%;
    padding: 9px 10px; border: 0; background: none;
    border-radius: var(--radius-md);
    font-family: var(--font); font-size: 13px; font-weight: 600;
    color: var(--text); text-align: start; cursor: pointer;
    transition: background .12s;
}
.fmenu__act:hover { background: var(--surface-2); }
.fmenu__act--danger { color: var(--red-bright); }
.fmenu__act svg { opacity: .7; flex-shrink: 0; }

.fmenu__form { padding: 6px 10px 4px; border-top: 1px solid var(--line-soft); margin-top: 4px; }
.fmenu__form .fmenu__act { padding-inline: 0; margin-top: 6px; }
.fmenu__lbl { display: block; font-size: 11px; font-weight: 700; color: var(--text-muted); margin-bottom: 4px; }
.fmenu__form .input { width: 100%; }

/* --- task visibility panel ------------------------------------------
   Collapsible so it stops dominating the task page, with the current
   state readable from the closed summary alone.
   -------------------------------------------------------------------- */
.vis-panel { margin-bottom: var(--s5); }
.vis-panel__summary {
    display: flex; align-items: center; justify-content: space-between;
    gap: var(--s3); cursor: pointer; list-style: none;
}
.vis-panel__summary::-webkit-details-marker { display: none; }
.vis-panel__title { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 800; color: var(--text); }
.vis-panel__title svg { opacity: .7; }

.vis-panel__list {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 2px;
    max-height: 220px; overflow-y: auto;
    border: 1px solid var(--line-soft); border-radius: var(--radius-md); padding: 6px;
}
.vis-panel__row {
    display: flex; align-items: center; gap: 9px; cursor: pointer;
    padding: 8px 10px; border-radius: var(--radius-md);
    transition: background .12s;
}
.vis-panel__row:hover { background: var(--surface-2); }
.vis-panel__row input { width: 16px; height: 16px; accent-color: var(--company, var(--red)); flex-shrink: 0; }
.vis-panel__who { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Company logo in the header breadcrumb — the group mark and the
   company's own brand read together instead of a generic dot. */
.crumb__logo {
    width: 22px; height: 22px; object-fit: contain;
    border-radius: 4px; background: #fff; padding: 2px;
    margin-inline-end: 7px; vertical-align: middle; flex-shrink: 0;
}

/* --- folder tile with its own actions menu --------------------------
   The menu button has to sit above the tile's full-area link without
   the link swallowing its clicks, so the tile is wrapped rather than
   having the button placed inside the anchor.
   -------------------------------------------------------------------- */
.ftile { position: relative; }
.ftile__link { width: 100%; }
.ftile__menu { position: absolute; inset-block-start: 8px; inset-inline-end: 8px; z-index: 5; }
.ftile__menu .fmenu__dots { font-size: 18px; padding: 2px 8px; background: var(--surface); border-color: var(--line); }
.ftile:hover .fmenu__dots { border-color: var(--company); }
.fmenu__act[disabled] { opacity: .45; cursor: not-allowed; }
.fmenu__act[disabled]:hover { background: none; }

/* --- bulk action bar + review stage pills --------------------------- */
.bulkbar {
    display: flex; align-items: center; justify-content: space-between;
    gap: var(--s3); flex-wrap: wrap;
    padding: 10px 14px; margin-bottom: var(--s2);
    background: var(--surface-2); border: 1px solid var(--line);
    border-radius: var(--radius);
}
.bulkbar[hidden] { display: none; }
.bulkbar__count { font-size: 13px; font-weight: 800; color: var(--text); }
.bulkbar__acts { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.bulkbar__sel { max-width: 160px; padding: 5px 9px; font-size: 12.5px; }

.stagepill {
    display: inline-flex; align-items: center;
    padding: 3px 9px; border-radius: 99px;
    font-size: 11px; font-weight: 700; white-space: nowrap;
}
.stagepill--in_review         { background: rgba(42,98,143,.16);  color: var(--info); }
.stagepill--changes_requested { background: rgba(156,106,30,.16); color: var(--warn); }
.stagepill--approved          { background: rgba(31,122,80,.16);  color: var(--ok); }
.stagepill--rejected          { background: rgba(220,68,68,.16);  color: var(--red-bright); }

/* Toolbar groups stay on one line; the cloud menu collapses the
   secondary integration links that used to wrap onto a second row. */
.dtools { flex-wrap: wrap; align-items: center; }

/* --- real content thumbnails in the file grid ------------------------
   Video and PDF cards render their own first frame / first page rather
   than a type badge. Both are made inert so the card's own click still
   opens the preview instead of the embedded player or PDF viewer
   swallowing it.
   -------------------------------------------------------------------- */
video.file-card__thumb { background: var(--surface-2); pointer-events: none; object-fit: cover; }

.file-card__pdf {
    width: 84px; height: 84px; flex: none;
    border-radius: 10px; border: 1px solid var(--line-soft);
    overflow: hidden; background: #fff; position: relative;
    pointer-events: none;
}
.file-card__pdf iframe {
    /* Rendered wider then scaled down, so the page fits the tile
       legibly instead of showing a cropped top-left corner. */
    width: 300px; height: 300px; border: 0;
    transform: scale(.28); transform-origin: top left;
    position: absolute; inset-block-start: 0; inset-inline-start: 0;
}

/* =====================================================================
   CLIENT PORTAL
   Its own shell, mobile-first. Built to be read on a phone and scale up
   to a laptop, rather than the staff layout squeezed down.
   ===================================================================== */
.portal-body { background: var(--ink-soft, var(--surface-2)); min-height: 100vh; display: flex; flex-direction: column; }

.pheader { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 40; }
.pheader__inner {
    max-width: 900px; margin: 0 auto; padding: 12px var(--s4);
    display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
}
.pheader__brands { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pheader__mark {
    width: 30px; height: 30px; flex: none; border-radius: 7px;
    background: var(--red); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 12px;
}
.pheader__x { color: var(--text-dim); font-size: 13px; flex: none; }
.pheader__clogo { width: 30px; height: 30px; flex: none; object-fit: contain; background: #fff; border-radius: 7px; padding: 2px; border: 1px solid var(--line-soft); }
.pheader__name { font-size: 14px; font-weight: 800; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pheader__right { display: flex; align-items: center; gap: var(--s3); flex: none; }
.pheader__who { font-size: 12.5px; color: var(--text-muted); }
.pheader__out { font-size: 12.5px; font-weight: 700; color: var(--text-muted); }
.pheader__out:hover { color: var(--red-bright); }

.pnav { background: var(--surface); border-bottom: 1px solid var(--line); overflow-x: auto; -webkit-overflow-scrolling: touch; }
.pnav__inner { max-width: 900px; margin: 0 auto; padding: 0 var(--s4); display: flex; gap: 2px; }
.pnav__item {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 12px 14px; white-space: nowrap;
    font-size: 13.5px; font-weight: 700; color: var(--text-muted);
    border-bottom: 2px solid transparent;
}
.pnav__item svg { opacity: .7; }
.pnav__item:hover { color: var(--text); }
.pnav__item.is-active { color: var(--text); border-bottom-color: var(--red); }
.pnav__item.is-active svg { opacity: 1; }

.pmain { flex: 1; width: 100%; max-width: 900px; margin: 0 auto; padding: var(--s4) var(--s4) var(--s6); }

.pcard {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: var(--s4);
    margin-bottom: var(--s4);
}
.pcard--hero { padding: var(--s5) var(--s4); }
.pcard__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s3); }
.pcard__title { font-size: 15px; font-weight: 800; margin: 0; }
.pcard__count { font-size: 12px; font-weight: 700; color: var(--text-muted); background: var(--surface-2); padding: 2px 9px; border-radius: 99px; }
.plink { font-size: 13px; font-weight: 700; color: var(--red); }
.pempty { color: var(--text-muted); font-size: 13.5px; text-align: center; padding: var(--s5) 0; margin: 0; }

.phero { display: flex; align-items: center; gap: var(--s4); flex-wrap: wrap; }
.phero__logo { width: 56px; height: 56px; flex: none; object-fit: contain; background: #fff; border-radius: 12px; padding: 5px; border: 1px solid var(--line-soft); }
.phero__chip {
    width: 56px; height: 56px; flex: none; border-radius: 12px;
    background: var(--red); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 17px; font-weight: 800;
}
.phero__text { flex: 1; min-width: 0; }
.phero__text h1 { font-size: 20px; font-weight: 800; margin: 0 0 3px; }
.phero__text p { font-size: 13px; color: var(--text-muted); margin: 0; }
.phero__due { text-align: end; }
.phero__due span { display: block; font-size: 11.5px; color: var(--text-muted); }
.phero__due strong { font-size: 20px; font-family: var(--mono); color: var(--warn); }

.pstats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s3); margin-bottom: var(--s4); }
.pstat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s4); }
.pstat--warn { border-color: var(--warn); }
.pstat__label { display: block; font-size: 11px; font-weight: 800; letter-spacing: .06em; color: var(--text-dim); text-transform: uppercase; margin-bottom: 6px; }
.pstat__value { display: block; font-size: 22px; font-weight: 800; font-family: var(--mono); line-height: 1.1; }
.pstat--warn .pstat__value { color: var(--warn); }
.pstat__sub { display: block; font-size: 12px; color: var(--text-muted); margin-top: 3px; }

.pcos { display: flex; flex-wrap: wrap; gap: var(--s2); }
.pco { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border: 1px solid var(--line-soft); border-radius: 99px; font-size: 13px; font-weight: 700; }
.pco img { width: 20px; height: 20px; object-fit: contain; border-radius: 4px; }
.pco__chip { width: 20px; height: 20px; border-radius: 4px; color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 800; }

.plist { display: flex; flex-direction: column; }
.pitem {
    display: flex; align-items: center; justify-content: space-between;
    gap: var(--s3); padding: 13px 0; border-top: 1px solid var(--line-soft);
    flex-wrap: wrap;
}
.pitem:first-child { border-top: 0; }
.pitem:hover .pitem__no { color: var(--red); }
.pitem__co { font-size: 11px; font-weight: 800; color: var(--text-dim); background: var(--surface-2); padding: 2px 8px; border-radius: 99px; flex: none; }
.pitem__main { flex: 1; min-width: 0; }
.pitem__no { display: block; font-size: 14px; font-weight: 800; color: var(--text); font-family: var(--mono); }
.pitem__date { display: block; font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.pitem__amt { text-align: end; flex: none; }
.pitem__total { display: block; font-size: 14.5px; font-weight: 800; font-family: var(--mono); }
.pitem__due { display: block; font-size: 11.5px; font-weight: 700; color: var(--warn); margin-top: 2px; }
.pitem__paid { display: block; font-size: 11.5px; font-weight: 700; color: var(--ok); margin-top: 2px; }

.pfooter { max-width: 900px; margin: 0 auto; padding: var(--s4) var(--s4) var(--s6); width: 100%; }
.pfooter__cos { font-size: 12px; color: var(--text-dim); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pfooter__co { font-weight: 700; color: var(--text-muted); }
.pfooter__co:not(:last-child)::after { content: '،'; }

@media (max-width: 560px) {
    .pheader__who { display: none; }
    .pmain { padding-inline: var(--s3); }
    .pcard { padding: var(--s3); }
    .phero__text h1 { font-size: 18px; }
    .pitem__co { order: -1; width: 100%; }
}

/* Drop target feedback while dragging a file onto a folder. Without a
   visible cue the drop is a guess — you can't tell which folder will
   receive it. */
.ftile[data-drop-folder].is-drop {
    outline: 2px dashed var(--company, var(--red));
    outline-offset: 2px;
    background: color-mix(in srgb, var(--company, var(--red)) 8%, transparent);
}
.js-file-row[draggable="true"] { user-select: none; }
