/* ==========================================================================
   N& Co — group portal
   Dark, layered, quiet. The company's own colour is the only loud thing
   on the page, and it appears in exactly three places: the hero band, the
   module icons, and the focus ring.
   ========================================================================== */

:root {
    --ink:        #08090B;
    --surface:    #101216;
    --surface-2:  #161920;
    --surface-3:  #1D212A;
    --line:       #232733;
    --line-soft:  #191C24;
    --text:       #ECEEF2;
    --text-muted: #8B919F;
    --text-dim:   #5A6070;
    --red:        #C8102E;
    --ok:         #2E9E6B;
    --warn:       #C9922E;
    --info:       #3B82C4;

    --company:    var(--red);

    --radius:     16px;
    --radius-md:  12px;
    --radius-sm:  9px;
    --shell:      1200px;

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

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

*, *::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: 600; line-height: 1.3; letter-spacing: -0.015em; }
p { margin: 0 0 1rem; }
img { max-width: 100%; }

:focus-visible {
    outline: 2px solid var(--company);
    outline-offset: 3px;
    border-radius: 6px;
}

.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 ------------------------------------------------------------ */

.topbar {
    position: sticky; top: 0; z-index: 50;
    background: rgba(8, 9, 11, 0.9);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--line-soft);
}
.topbar__inner { display: flex; align-items: center; gap: var(--s4); height: 60px; }

.brand { display: flex; align-items: center; gap: var(--s2); font-weight: 600; letter-spacing: 0.01em; }
.brand__mark {
    width: 28px; height: 28px;
    display: grid; place-items: center;
    border-radius: 8px;
    background: var(--red); color: #fff;
    font-family: var(--mono); font-size: 12px; font-weight: 600;
}

.crumb { display: flex; align-items: center; gap: var(--s2); font-size: 14px; color: var(--text-muted); min-width: 0; }
.crumb__sep { color: var(--text-dim); }
.crumb__here { color: var(--text); display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.crumb__dot { width: 8px; height: 8px; border-radius: 3px; background: var(--company); flex: none; }

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

.navlink {
    padding: 7px 11px; border-radius: var(--radius-sm);
    color: var(--text-muted); font-size: 14px;
    transition: background .15s ease, color .15s ease;
}
.navlink:hover { background: var(--surface-2); 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-size: 14px; color: var(--text-muted); }
.usermenu__name:hover { color: var(--text); }

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

/* --- Avatars ------------------------------------------------------------ */

.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: 52px; height: 52px; font-size: 19px; border-radius: 14px; }
.avatar--brand { background: color-mix(in srgb, var(--company) 20%, var(--surface-3)); border-color: color-mix(in srgb, var(--company) 40%, var(--line)); }

/* --- Page heading ------------------------------------------------------- */

.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: 27px; }
.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; }

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

.hero {
    position: relative;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    padding: var(--s5);
    margin-bottom: var(--s5);
    overflow: hidden;
}
.hero::before {
    content: ""; position: absolute; inset-block-start: 0; inset-inline: 0; height: 3px;
    background: var(--company);
}
.hero::after {
    content: ""; position: absolute; inset-block-start: 0; inset-inline-end: 0;
    width: 340px; height: 100%;
    background: radial-gradient(120% 90% at 100% 0%, color-mix(in srgb, var(--company) 14%, 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__title { font-size: 26px; }
.hero__tagline { color: var(--text-muted); font-size: 14.5px; margin-top: 2px; }
.hero__wordmark { font-family: var(--mono); font-size: 12px; 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-soft);
    position: relative; z-index: 1;
}
.stat__value { font-size: 21px; font-weight: 600; line-height: 1.2; }
.stat__label { font-size: 12.5px; color: var(--text-muted); margin-top: 1px; }

/* --- Company plates (home 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);
    overflow: hidden;
    transition: transform .18s ease, border-color .18s ease, background .18s ease;
}
.plate::before {
    content: ""; position: absolute; inset-block-start: 0; inset-inline: 0; height: 2px;
    background: var(--company); opacity: .5;
    transition: opacity .18s ease, height .18s ease;
}
.plate:hover, .plate:focus-visible {
    transform: translateY(-3px);
    border-color: color-mix(in srgb, var(--company) 45%, var(--line));
    background: var(--surface-2);
}
.plate:hover::before { opacity: 1; height: 3px; }

.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__wordmark { font-family: var(--mono); font-size: 19px; font-weight: 500; letter-spacing: -0.02em; }
.plate__wordmark span { color: var(--company); }
.plate__name { font-size: 17px; font-weight: 600; }
.plate__tagline { font-size: 13px; 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-soft);
    font-family: var(--mono); font-size: 11px; letter-spacing: .07em; text-transform: uppercase;
    color: var(--text-dim);
}

/* --- Module tiles ------------------------------------------------------- */

.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-md);
    min-height: 132px;
    transition: transform .16s ease, border-color .16s ease, background .16s ease;
}
.tile:hover {
    transform: translateY(-2px);
    background: var(--surface-2);
    border-color: color-mix(in srgb, var(--company) 42%, var(--line));
}
.tile__icon {
    width: 38px; height: 38px;
    display: grid; place-items: center;
    border-radius: 11px;
    background: color-mix(in srgb, var(--company) 15%, transparent);
    color: var(--company);
}
.tile__name { font-size: 15px; font-weight: 600; }
.tile__summary { font-size: 13px; 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: 11px; color: var(--text-dim);
}
.tile__go { color: var(--text-dim); transition: transform .16s ease, color .16s ease; }
.tile:hover .tile__go { color: var(--company); transform: translateX(-3px); }

.tile--planned { border-style: dashed; }
.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);
    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-soft); }
.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: 16px; }

.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: 14px; }
.table th {
    text-align: start;
    font-family: var(--mono); font-size: 11px; 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: 12px; color: var(--text-dim); }

/* --- Pills, tags, dots -------------------------------------------------- */

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

.pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 11px; border-radius: 100px;
    font-size: 12.5px; font-weight: 500;
    border: 1px solid transparent;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill--ok      { color: #6FD3A5; background: rgba(46,158,107,.12); border-color: rgba(46,158,107,.3); }
.pill--lead    { color: #E5B65C; background: rgba(201,146,46,.12); border-color: rgba(201,146,46,.3); }
.pill--muted   { color: var(--text-muted); background: var(--surface-3); border-color: var(--line); }
.pill--danger  { color: #FF8195; background: rgba(200,16,46,.14); border-color: rgba(200,16,46,.34); }

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

.chip {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 6px 12px; border-radius: var(--radius-sm);
    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) 45%, 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: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); gap: 2px; }
.segmented a {
    padding: 6px 13px; border-radius: 7px;
    font-size: 13px; 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: 31px; height: 31px; 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(--company); border-color: color-mix(in srgb, var(--company) 35%, var(--line)); }
.timeline__body { min-width: 0; flex: 1; }
.timeline__meta { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; font-size: 12.5px; color: var(--text-dim); }
.timeline__who { color: var(--text-muted); }
.timeline__text { font-size: 14px; margin-top: 2px; overflow-wrap: anywhere; }

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

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

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

.empty { padding: var(--s7) var(--s5); text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--text-muted); }
.empty__icon { color: var(--text-dim); margin-bottom: var(--s3); }
.empty h3 { font-size: 16px; 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-size: 13px; 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: 11px 13px;
    background: var(--ink); 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: var(--line); background: #0B0C0F; }
.input:focus { border-color: var(--company); outline: none; }
.input--error { border-color: var(--red); }
textarea.input { resize: vertical; line-height: 1.6; }

.field__error { display: block; margin-top: 6px; font-size: 12.5px; color: #FF8195; }
.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);
    background: var(--red); color: #fff;
    font-family: inherit; font-size: 14px; font-weight: 600;
    cursor: pointer; white-space: nowrap;
    transition: filter .15s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { filter: brightness(1.12); }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn--ghost:hover { background: var(--surface-2); border-color: var(--line); filter: none; }
.btn--sm { padding: 7px 13px; font-size: 13px; }
.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-radius: var(--radius-sm);
    border: 1px solid var(--line); background: var(--surface);
    margin-bottom: var(--s4); font-size: 14px;
}
.flash svg { flex: none; }
.flash--success { border-color: rgba(46,158,107,.4); background: rgba(46,158,107,.09); color: #A8E5C8; }
.flash--error   { border-color: rgba(200,16,46,.45); background: rgba(200,16,46,.1); color: #FFB3BE; }

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

.code {
    background: var(--ink); border: 1px solid var(--line); border-radius: var(--radius-sm);
    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);
    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: 20px; }
.auth__head p { color: var(--text-muted); font-size: 14px; margin: 6px 0 0; }
.auth__foot { margin-top: var(--s4); text-align: center; font-family: var(--mono); font-size: 11px; 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: 64px; font-weight: 600; color: var(--red); 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: 56px; gap: var(--s2); }
    .usermenu__name, .crumb__root { display: none; }
    main { padding: var(--s5) 0 var(--s6); }
    .page-head h1 { font-size: 22px; }
    .hero { padding: var(--s4); }
    .hero__title { font-size: 21px; }
    .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: 13px; }
}

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