/* =====================================================================
   multimail - warstwa wizualna panelu
   Zrodlo wygladu: mockup/index.html. Wszystkie animacje realizowane sa
   w CSS (transition / @keyframes), bez bibliotek.
   ===================================================================== */

:root {
    --ground:      #eef1f8;
    --surface:     #ffffff;
    --surface-2:   #f5f7fc;
    --surface-3:   #e7ecf7;
    --line:        #dbe2ef;
    --line-soft:   #e9edf6;

    --ink:         #131a28;
    --ink-2:       #4e5c76;
    --ink-3:       #8494ae;

    --accent:      #2b5fe3;
    --accent-ink:  #ffffff;
    --accent-soft: #e4ecfd;
    --accent-line: #bed2fb;

    --violet:      #6b4dff;
    --violet-soft: #ece8ff;

    --ok:          #0f8a4d;
    --ok-soft:     #e0f3e8;
    --warn:        #b76e00;
    --warn-soft:   #fbeeda;
    --bad:         #cf3535;
    --bad-soft:    #fbe8e8;

    --radius:      16px;
    --r-sm:        10px;
    --r-xs:        7px;
    --pill:        999px;

    --shadow-1:    0 1px 2px rgba(19, 33, 68, .07), 0 2px 6px rgba(19, 33, 68, .05);
    --shadow-2:    0 14px 40px rgba(19, 33, 68, .16), 0 2px 8px rgba(19, 33, 68, .08);

    --rail:        266px;
    --top:         60px;
    --ease:        cubic-bezier(.22, .61, .36, 1);

    --f-ui:        "Figtree", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
    --f-display:   "Bricolage Grotesque", "Figtree", "Segoe UI", system-ui, sans-serif;
    --f-mono:      "IBM Plex Mono", "Cascadia Mono", Consolas, "Courier New", monospace;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --ground:      #0d1220;
        --surface:     #151d2e;
        --surface-2:   #131a29;
        --surface-3:   #1e283c;
        --line:        #26314a;
        --line-soft:   #1d2639;

        --ink:         #e7ecf9;
        --ink-2:       #9aa8c4;
        --ink-3:       #6b7a97;

        --accent:      #6d9bff;
        --accent-ink:  #0b1020;
        --accent-soft: #1b2947;
        --accent-line: #2f4470;

        --violet:      #a894ff;
        --violet-soft: #241f45;

        --ok:          #47c98a;
        --ok-soft:     #12301f;
        --warn:        #e6a33c;
        --warn-soft:   #302209;
        --bad:         #f07070;
        --bad-soft:    #331616;

        --shadow-1:    0 1px 2px rgba(0, 0, 0, .4);
        --shadow-2:    0 16px 44px rgba(0, 0, 0, .55);
    }
}

:root[data-theme="dark"] {
    --ground:      #0d1220;
    --surface:     #151d2e;
    --surface-2:   #131a29;
    --surface-3:   #1e283c;
    --line:        #26314a;
    --line-soft:   #1d2639;

    --ink:         #e7ecf9;
    --ink-2:       #9aa8c4;
    --ink-3:       #6b7a97;

    --accent:      #6d9bff;
    --accent-ink:  #0b1020;
    --accent-soft: #1b2947;
    --accent-line: #2f4470;

    --violet:      #a894ff;
    --violet-soft: #241f45;

    --ok:          #47c98a;
    --ok-soft:     #12301f;
    --warn:        #e6a33c;
    --warn-soft:   #302209;
    --bad:         #f07070;
    --bad-soft:    #331616;

    --shadow-1:    0 1px 2px rgba(0, 0, 0, .4);
    --shadow-2:    0 16px 44px rgba(0, 0, 0, .55);
}

/* --- Reset ---------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    background: var(--ground);
    color: var(--ink);
    font-family: var(--f-ui);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
/* SVG bez jawnego rozmiaru rozlewa sie do 300x150 - ustalamy rozmiar bazowy,
   reguly komponentow ponizej go nadpisuja. */
svg { flex: 0 0 auto; width: 18px; height: 18px; }
[hidden] { display: none !important; }

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

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--line);
    border: 3px solid transparent;
    background-clip: content-box;
    border-radius: 8px;
}
::-webkit-scrollbar-thumb:hover { background: var(--ink-3); background-clip: content-box; }

@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes riseIn  { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes slideL  { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
@keyframes spin    { to { transform: rotate(360deg); } }
@keyframes popIn   { from { opacity: 0; transform: scale(.97) translateY(8px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        transition-duration: .001ms !important;
    }
}

/* --- Szkielet -------------------------------------------------------- */

.app { display: flex; flex-direction: column; height: 100vh; }

.shell {
    flex: 1;
    display: flex;
    min-height: 0;
    gap: 0;
}

/* --- Górny pasek ----------------------------------------------------- */

.topbar {
    height: var(--top);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 16px 0 12px;
    background: var(--ground);
    flex: 0 0 auto;
}

.brand { display: flex; align-items: center; gap: 10px; width: calc(var(--rail) - 12px); flex: 0 0 auto; }

.mark {
    width: 34px; height: 34px;
    border-radius: 11px;
    background: linear-gradient(140deg, var(--accent), var(--violet));
    display: grid; place-items: center;
    color: #fff;
    box-shadow: 0 4px 12px rgba(43, 95, 227, .35);
}
.mark svg { width: 19px; height: 19px; }

.wordmark {
    font-family: var(--f-display);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -.02em;
}
.wordmark em { font-style: normal; color: var(--ink-3); font-weight: 600; }

.search {
    flex: 1;
    max-width: 760px;
    display: flex;
    align-items: center;
    gap: 10px;
    height: 44px;
    padding: 0 8px 0 14px;
    background: var(--surface-3);
    border: 1px solid transparent;
    border-radius: var(--pill);
    transition: background .18s var(--ease), box-shadow .18s var(--ease), border-color .18s var(--ease);
}
.search:focus-within {
    background: var(--surface);
    border-color: var(--line);
    box-shadow: var(--shadow-1);
}
.search input {
    flex: 1;
    border: 0; background: none; outline: 0;
    font-size: 14.5px;
}
.search input::placeholder { color: var(--ink-3); }
.search .ico { color: var(--ink-2); }

.topbar .spacer { flex: 1; }

.iconbtn {
    width: 38px; height: 38px;
    border-radius: 50%;
    display: grid; place-items: center;
    color: var(--ink-2);
    transition: background .15s var(--ease), color .15s var(--ease);
}
.iconbtn:hover { background: var(--surface-3); color: var(--ink); }
.iconbtn svg { width: 19px; height: 19px; }

.iconbtn.on { color: var(--accent); background: var(--accent-soft); }
.iconbtn.on:hover { background: var(--accent-soft); }

.avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: linear-gradient(150deg, #f97316, #d93a3a);
    color: #fff;
    display: grid; place-items: center;
    font-weight: 700; font-size: 13px;
    letter-spacing: .02em;
}

/* --- Lewa szyna ------------------------------------------------------ */

.rail {
    width: var(--rail);
    flex: 0 0 auto;
    padding: 0 8px 16px 12px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.compose {
    display: flex; align-items: center; gap: 10px;
    height: 50px;
    padding: 0 22px 0 18px;
    margin: 0 4px 14px;
    border-radius: var(--pill);
    background: var(--surface);
    color: var(--ink);
    font-weight: 600;
    box-shadow: var(--shadow-1);
    transition: box-shadow .18s var(--ease), transform .18s var(--ease), background .18s var(--ease);
}
.compose:hover { box-shadow: var(--shadow-2); transform: translateY(-1px); }
.compose svg { width: 20px; height: 20px; color: var(--accent); }

.railgroup { margin-bottom: 6px; }
.railtitle {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 14px 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--ink-3);
}
.railtitle button { color: var(--ink-3); display: grid; place-items: center; }
.railtitle button:hover { color: var(--ink); }
.railtitle svg { width: 15px; height: 15px; }

.navitem {
    display: flex; align-items: center; gap: 13px;
    width: 100%;
    height: 36px;
    padding: 0 14px 0 13px;
    border-radius: 0 var(--pill) var(--pill) 0;
    color: var(--ink-2);
    font-size: 13.5px;
    text-align: left;
    transition: background .14s var(--ease), color .14s var(--ease);
}
.navitem:hover { background: var(--surface-3); color: var(--ink); }
.navitem svg { width: 18px; height: 18px; }
.navitem .lbl { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.navitem .n { font-size: 12px; font-weight: 600; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.navitem.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.navitem.on .n { color: var(--accent); }
.navitem.unread { color: var(--ink); font-weight: 600; }
.navitem.unread .n { color: var(--ink); }

.navitem .swatch { width: 9px; height: 9px; border-radius: 3px; margin: 0 4px; }
.navitem .warnbadge { width: 7px; height: 7px; border-radius: 50%; background: var(--bad); }

/* --- Obszar roboczy -------------------------------------------------- */

.work {
    flex: 1;
    min-width: 0;
    display: flex;
    background: var(--surface);
    border-radius: var(--radius) 0 0 0;
    border-top: 1px solid var(--line-soft);
    border-left: 1px solid var(--line-soft);
    overflow: hidden;
}

.mailview { flex: 1; display: flex; min-width: 0; }

.listpane {
    flex: 1 1 46%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--line);
}

/* --- Pasek narzędzi listy -------------------------------------------- */

.listbar {
    display: flex; align-items: center; gap: 4px;
    height: 48px;
    padding: 0 8px 0 14px;
    flex: 0 0 auto;
}
.listbar .spacer { flex: 1; }
.listbar .count { font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; padding-right: 6px; }
.listbar .iconbtn { width: 34px; height: 34px; }
.listbar .iconbtn svg { width: 17px; height: 17px; }

.check {
    width: 17px; height: 17px;
    border: 1.6px solid var(--ink-3);
    border-radius: 4px;
    display: grid; place-items: center;
    color: transparent;
    flex: 0 0 auto;
    transition: background .12s var(--ease), border-color .12s var(--ease), color .12s var(--ease);
}
.check svg { width: 12px; height: 12px; }
.check.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.check:hover { border-color: var(--ink); }

.bulkbar {
    display: flex; align-items: center; gap: 6px;
    padding-left: 8px;
    animation: fadeIn .2s var(--ease) both;
}
.bulkbar .sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }

/* --- Pasek skrzynek (widok zbiorczy) --------------------------------- */

.strip {
    display: flex;
    gap: 7px;
    padding: 0 14px 12px;
    overflow-x: auto;
    scrollbar-width: thin;
    flex: 0 0 auto;
}
.strip::-webkit-scrollbar { height: 6px; }

.chip {
    display: inline-flex; align-items: center; gap: 7px;
    height: 30px;
    padding: 0 12px;
    border-radius: var(--pill);
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink-2);
    font-size: 12.5px;
    white-space: nowrap;
    transition: border-color .15s var(--ease), background .15s var(--ease), color .15s var(--ease);
}
.chip:hover { background: var(--surface-2); color: var(--ink); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.chip .n {
    font-weight: 700; font-size: 11px;
    font-variant-numeric: tabular-nums;
    padding: 1px 6px;
    border-radius: var(--pill);
    background: var(--surface-3);
    color: var(--ink-2);
}
.chip.on { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.chip.on .n { background: var(--accent); color: var(--accent-ink); }

/* --- Lista wiadomości ------------------------------------------------ */

.list {
    flex: 1;
    overflow-y: auto;
    border-top: 1px solid var(--line-soft);
    background: var(--surface-2);
}

/* Wiersz przeczytany jest tlem listy, nieprzeczytany bielszy i pogrubiony -
   tak samo jak w Gmailu, bez dodatkowych ozdobnikow. */
.row + .row { border-top: 0; }

.row {
    position: relative;
    display: grid;
    grid-template-columns: auto auto auto minmax(0, 176px) minmax(0, 1fr) auto;
    align-items: center;
    gap: 0 12px;
    min-height: 40px;
    padding: 0 12px 0 14px;
    border-bottom: 1px solid var(--line-soft);
    cursor: pointer;
    color: var(--ink-2);
    transition: background .12s var(--ease), box-shadow .12s var(--ease);
}
.row:hover { background: var(--surface); box-shadow: inset 1px 0 0 var(--line), var(--shadow-1); z-index: 2; }
.row.unread { background: var(--surface); color: var(--ink); }
.row.unread .who, .row.unread .subj, .row.unread .when { font-weight: 700; }
.row.unread::before {
    content: "";
    position: absolute; left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--acc, var(--accent));
}
.row.sel { background: var(--accent-soft); }
.row.open { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }

.row .star { color: var(--ink-3); display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; }
.row .star:hover { background: var(--surface-3); color: var(--ink); }
.row .star svg { width: 17px; height: 17px; }
.row .star.on { color: #eab308; }

.row .who { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .who .thr { color: var(--ink-3); font-weight: 500; font-size: 12px; }

.row .subj {
    font-size: 13.5px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    display: flex; align-items: center; gap: 8px; min-width: 0;
}
.row .subj .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 0 1 auto; max-width: 100%; }
.row .subj .snip { color: var(--ink-3); font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 0; min-width: 0; }

.tag {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 1px 8px;
    border-radius: var(--pill);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .01em;
    white-space: nowrap;
    flex: 0 0 auto;
}
.tag .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* Skrzynka, do ktorej przyszedl list: kolorowa kropka zamiast nazwy tekstowej.
   Pelny adres zostaje w tytule, wiec nadal da sie go sprawdzic kursorem. */
.acctdot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex: 0 0 auto;
    box-shadow: 0 0 0 2px var(--surface);
}
.row.unread .acctdot { box-shadow: 0 0 0 2px var(--surface); }

.mbox {
    font-family: var(--f-mono);
    font-size: 10.5px;
    font-weight: 500;
    padding: 2px 7px;
    border-radius: var(--r-xs);
    white-space: nowrap;
    flex: 0 0 auto;
    max-width: 132px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cardsub .mbox { max-width: none; }

.row .meta { display: flex; align-items: center; gap: 8px; justify-self: end; }
.row .when { font-size: 11.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; min-width: 54px; text-align: right; }
.row .clip { color: var(--ink-3); display: grid; place-items: center; }
.row .clip svg { width: 15px; height: 15px; }
.row .hoveracts { display: none; gap: 2px; }
.row:hover .when { display: none; }
.row:hover .hoveracts { display: flex; }
.row .hoveracts .iconbtn { width: 28px; height: 28px; }
.row .hoveracts .iconbtn svg { width: 16px; height: 16px; }

.empty {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 12px;
    padding: 80px 20px;
    color: var(--ink-3);
    text-align: center;
}
.empty svg { width: 40px; height: 40px; opacity: .5; }

/* --- Panel czytania -------------------------------------------------- */

.readpane {
    flex: 1 1 54%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--surface);
}

.readbar {
    display: flex; align-items: center; gap: 2px;
    height: 48px;
    padding: 0 10px;
    flex: 0 0 auto;
    border-bottom: 1px solid var(--line-soft);
}
.readbar .spacer { flex: 1; }
.readbar .iconbtn { width: 34px; height: 34px; }
.readbar .iconbtn svg { width: 17px; height: 17px; }
.readbar .sep { width: 1px; height: 20px; background: var(--line); margin: 0 6px; }

.readbody { flex: 1; overflow-y: auto; padding: 22px 28px 40px; animation: slideL .26s var(--ease) both; }

.readhead { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.readhead h2 {
    font-family: var(--f-display);
    font-size: 21px;
    font-weight: 600;
    line-height: 1.3;
    text-wrap: balance;
    flex: 1;
}

.msg { border-top: 1px solid var(--line-soft); padding-top: 18px; margin-top: 4px; }
.msg:first-of-type { border-top: 0; padding-top: 0; }

.msghead { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.ava {
    width: 38px; height: 38px;
    border-radius: 50%;
    display: grid; place-items: center;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    flex: 0 0 auto;
}
.msghead .who { flex: 1; min-width: 0; }
.msghead .nm { font-weight: 600; font-size: 14px; }
.msghead .em { font-family: var(--f-mono); font-size: 11.5px; color: var(--ink-3); }
.msghead .rcpt { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.msghead .stamp { font-size: 12px; color: var(--ink-3); white-space: nowrap; font-variant-numeric: tabular-nums; }

.prose { font-size: 14px; line-height: 1.72; color: var(--ink); max-width: 66ch; }
.prose p { margin-bottom: 14px; }
.prose .sig { color: var(--ink-2); font-size: 13px; border-left: 2px solid var(--line); padding-left: 12px; margin-top: 20px; }
.prose .quote { color: var(--ink-3); font-size: 13px; border-left: 2px solid var(--line); padding-left: 12px; }

/* Wcześniejsze wiadomości wątku: jedna linijka na list. Dłuższa rozmowa
   zwija się do paska z liczbą, żeby otwarty list został na wierzchu. */
/* minmax(0, 1fr) jest tu konieczne: bez tego dlugie zajawki rozpychaja
   track grida ponad szerokosc panelu i data ucieka poza krawedz. */
.thread { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1px; margin-bottom: 18px; }
.thread.folded .tmsg { display: none; }

.threadbar {
    display: flex; align-items: center; gap: 8px;
    width: 100%; text-align: left; cursor: pointer;
    padding: 7px 10px;
    border: 1px solid var(--line-soft);
    border-radius: var(--r-sm);
    background: var(--surface-2);
    font-size: 12.5px; color: var(--ink-3);
    transition: background .14s var(--ease);
}
.threadbar:hover { background: var(--surface-3); }
.threadbar svg {
    width: 15px; height: 15px; flex: 0 0 auto;
    transition: transform .16s var(--ease);
}
/* Strzalka w dol = jest co rozwinac, w gore = klik zwija liste. */
.thread.folded .threadbar svg { transform: rotate(90deg); }
.thread:not(.folded) .threadbar svg { transform: rotate(-90deg); }
/* Po rozwinieciu nazwiska widac w wierszach - w pasku byly juz zbedne. */
.thread:not(.folded) .threadbar span { display: none; }
.threadbar b { color: var(--ink-2); font-weight: 600; flex: 0 0 auto; }
.threadbar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tmsg {
    display: flex; align-items: center; gap: 8px;
    width: 100%; text-align: left; cursor: pointer;
    padding: 5px 8px;
    border-radius: var(--r-xs);
    font-size: 12.5px; color: var(--ink-2);
    transition: background .12s var(--ease);
}
.tmsg:hover { background: var(--surface-2); }
.tmsg .ava { width: 20px; height: 20px; font-size: 9px; font-weight: 600; }
.tmsg b {
    font-weight: 500; color: var(--ink); flex: 0 0 auto;
    max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tmsg.new b { font-weight: 700; }
.tmsg .snip { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-3); }
.tmsg .when { color: var(--ink-3); font-size: 11.5px; flex: 0 0 auto; }

.notice {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 11px 14px;
    border-radius: var(--r-sm);
    background: var(--violet-soft);
    color: var(--violet);
    font-size: 12.5px;
    margin-bottom: 18px;
    line-height: 1.5;
}
.notice svg { width: 17px; height: 17px; margin-top: 1px; }
.notice b { font-weight: 600; }
.notice .when { color: inherit; opacity: .8; }

.files { display: flex; flex-wrap: wrap; gap: 10px; margin: 20px 0 4px; }
.file {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 14px 9px 11px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface-2);
    transition: border-color .15s var(--ease), background .15s var(--ease);
}
.file:hover { border-color: var(--accent-line); background: var(--accent-soft); }
.file .ficon { width: 30px; height: 30px; border-radius: var(--r-xs); display: grid; place-items: center; color: #fff; font-size: 9.5px; font-weight: 700; font-family: var(--f-mono); }
.file .fn { font-size: 12.5px; font-weight: 500; }
.file .fs { font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

.replybox {
    display: flex; align-items: center; gap: 10px;
    margin-top: 26px;
    padding: 12px 16px;
    border: 1px solid var(--line);
    border-radius: var(--pill);
    background: var(--surface-2);
    color: var(--ink-3);
    cursor: text;
    max-width: 66ch;
    transition: box-shadow .16s var(--ease), border-color .16s var(--ease);
}
.replybox:hover { border-color: var(--accent-line); box-shadow: var(--shadow-1); }
.replybox svg { width: 17px; height: 17px; }
.replybox .as { font-family: var(--f-mono); font-size: 11.5px; margin-left: auto; color: var(--ink-3); }

.btn {
    display: inline-flex; align-items: center; gap: 8px;
    height: 36px;
    padding: 0 16px;
    border-radius: var(--pill);
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    font-size: 13px;
    font-weight: 600;
    transition: background .15s var(--ease), border-color .15s var(--ease), box-shadow .15s var(--ease), transform .15s var(--ease);
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-3); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { box-shadow: 0 6px 16px rgba(43, 95, 227, .32); }
.btn.ghost { border-color: transparent; background: none; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-3); color: var(--ink); }
.btn.sm { height: 30px; padding: 0 12px; font-size: 12.5px; }

/* --- Ekrany ustawień -------------------------------------------------- */

.screen { flex: 1; overflow-y: auto; padding: 0; animation: fadeIn .22s var(--ease) both; }
.screenin { max-width: 1200px; padding: 30px 40px 60px; }

.screenhead { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 6px; }
.screenhead h1 {
    font-family: var(--f-display);
    font-size: 27px;
    font-weight: 700;
    letter-spacing: -.02em;
    flex: 1;
}
.lede { color: var(--ink-2); font-size: 13.5px; max-width: 68ch; margin: 6px 0 26px; }

.cards { display: grid; gap: 14px; }

.card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    padding: 18px 20px;
    transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
.card:hover { border-color: var(--accent-line); box-shadow: var(--shadow-1); }
.card.off { background: var(--surface-2); }
.card.off .cardtitle { color: var(--ink-2); }

.cardtop { display: flex; align-items: flex-start; gap: 14px; }
.cardtitle { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 9px; }
.cardsub { font-size: 12.5px; color: var(--ink-3); margin-top: 3px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.switch {
    width: 42px; height: 24px;
    border-radius: var(--pill);
    background: var(--surface-3);
    border: 1px solid var(--line);
    position: relative;
    flex: 0 0 auto;
    transition: background .18s var(--ease), border-color .18s var(--ease);
}
.switch::after {
    content: "";
    position: absolute; top: 2px; left: 2px;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: var(--surface);
    box-shadow: var(--shadow-1);
    transition: transform .2s var(--ease);
}
.switch.on { background: var(--ok); border-color: var(--ok); }
.switch.on::after { transform: translateX(18px); background: #fff; }

.quote-body {
    margin-top: 14px;
    padding: 14px 16px;
    border-radius: var(--r-sm);
    background: var(--surface-2);
    border: 1px dashed var(--line);
    font-size: 13px;
    line-height: 1.65;
    color: var(--ink-2);
    max-width: 70ch;
}
.quote-body .subj { font-weight: 600; color: var(--ink); margin-bottom: 8px; }
.quote-body code {
    font-family: var(--f-mono);
    font-size: 12px;
    background: var(--accent-soft);
    color: var(--accent);
    padding: 1px 5px;
    border-radius: 5px;
}

.facts { display: flex; flex-wrap: wrap; gap: 22px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.fact .k { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); font-weight: 600; }
.fact .v { font-size: 13.5px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }
.fact .v small { font-weight: 500; color: var(--ink-3); font-size: 12px; }

.rule { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; font-size: 12.5px; color: var(--ink-2); }
.rule .kw { font-weight: 700; font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.cond {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px;
    border-radius: var(--r-xs);
    background: var(--surface-2);
    border: 1px solid var(--line);
    font-size: 12px;
}
.cond b { font-weight: 600; }
.cond code { font-family: var(--f-mono); font-size: 11.5px; color: var(--accent); }
.cond.act { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.cond.act code { color: inherit; }

.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
    text-align: left;
    font-size: 10.5px; letter-spacing: .07em; text-transform: uppercase;
    color: var(--ink-3); font-weight: 600;
    padding: 0 14px 10px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.tbl tbody tr { transition: background .13s var(--ease); }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl .mono { font-family: var(--f-mono); font-size: 12px; color: var(--ink-2); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tblwrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 16px 6px 6px; }

.state { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; padding: 3px 10px 3px 8px; border-radius: var(--pill); }
.state .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.state.ok { background: var(--ok-soft); color: var(--ok); }
.state.warn { background: var(--warn-soft); color: var(--warn); }
.state.bad { background: var(--bad-soft); color: var(--bad); }

.acctname { display: flex; align-items: center; gap: 10px; }
.acctname .swatch { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.acctname .em { font-family: var(--f-mono); font-size: 12.5px; }
.acctname .lbl { font-size: 11.5px; color: var(--ink-3); }

/* --- Okno tworzenia wiadomości --------------------------------------- */

.composer {
    position: fixed;
    right: 22px; bottom: 0;
    width: 594px;
    max-width: calc(100vw - 32px);
    background: var(--surface);
    border: 1px solid var(--line);
    border-bottom: 0;
    border-radius: var(--radius) var(--radius) 0 0;
    box-shadow: var(--shadow-2);
    display: flex;
    flex-direction: column;
    z-index: 60;
    animation: popIn .22s var(--ease) both;
}
.composer .chead {
    display: flex; align-items: center; gap: 8px;
    height: 46px;
    padding: 0 8px 0 18px;
    background: var(--surface-3);
    border-radius: var(--radius) var(--radius) 0 0;
    font-size: 13.5px;
    font-weight: 600;
}
.composer .chead .spacer { flex: 1; }
.composer .chead .iconbtn { width: 30px; height: 30px; }
.composer .chead .iconbtn svg { width: 16px; height: 16px; }

.cfield {
    display: flex; align-items: center; gap: 10px;
    padding: 0 18px;
    height: 42px;
    border-bottom: 1px solid var(--line-soft);
    font-size: 13.5px;
}
.cfield .k { color: var(--ink-3); font-size: 12.5px; width: 34px; flex: 0 0 auto; }
.cfield input { flex: 1; border: 0; outline: 0; background: none; }
.cfield select {
    flex: 1;
    border: 0; outline: 0; background: none;
    font-family: var(--f-mono);
    font-size: 12.5px;
    color: var(--ink);
    padding: 4px 0;
}
.cfield .cc { color: var(--ink-3); font-size: 12.5px; }
.cfield .cc:hover { color: var(--ink); }

/* Odslania pola DW i UDW - domyslnie schowane, bo rzadko sa potrzebne. */
.ccopies {
    color: var(--ink-3); font-size: 11.5px; letter-spacing: .03em;
    padding: 3px 8px; border-radius: var(--pill);
    flex: 0 0 auto;
}
.ccopies:hover { background: var(--surface-3); color: var(--ink); }

.cbody {
    padding: 16px 18px;
    height: 232px;
    overflow-y: auto;
    font-size: 13.5px;
    line-height: 1.7;
    outline: 0;
}
.cbody .ph { color: var(--ink-3); }
.cbody .sig { color: var(--ink-2); font-size: 12.5px; border-left: 2px solid var(--line); padding-left: 10px; margin-top: 18px; }

.cfoot { display: flex; align-items: center; gap: 4px; padding: 10px 14px 14px; }
.cfoot .spacer { flex: 1; }
.cfoot .iconbtn { width: 32px; height: 32px; }
.cfoot .iconbtn svg { width: 17px; height: 17px; }
.sendbtn { display: inline-flex; align-items: center; }
.sendbtn .btn { border-radius: var(--pill); padding-right: 12px; }

.composer.min { width: 320px; }
.composer.min .cfield, .composer.min .cbody, .composer.min .cfoot { display: none; }

/* --- Modal ------------------------------------------------------------ */

.veil {
    position: fixed; inset: 0;
    background: rgba(10, 16, 30, .48);
    backdrop-filter: blur(2px);
    display: grid; place-items: center;
    padding: 24px;
    z-index: 80;
    animation: fadeIn .18s var(--ease) both;
}
.modal {
    width: 640px; max-width: 100%;
    max-height: 88vh;
    display: flex; flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-2);
    animation: popIn .22s var(--ease) both;
}
.mhead { display: flex; align-items: center; gap: 12px; padding: 18px 20px 14px; border-bottom: 1px solid var(--line-soft); }
.mhead > svg { width: 20px; height: 20px; color: var(--violet); }
.mhead h3 { font-family: var(--f-display); font-size: 18px; flex: 1; }
.mbody { padding: 20px; overflow-y: auto; display: grid; gap: 16px; }
.mfoot { display: flex; align-items: center; gap: 10px; padding: 14px 20px 18px; border-top: 1px solid var(--line-soft); }
.mfoot .spacer { flex: 1; }

.field { display: grid; gap: 6px; }
.field > label { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.field input[type="text"], .field input[type="date"], .field input[type="email"], .field input[type="password"], .field select, .field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface-2);
    outline: 0;
    font-size: 13.5px;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease);
}
.field textarea { resize: vertical; min-height: 118px; line-height: 1.65; }
.field input:focus, .field select:focus, .field textarea:focus {
    border-color: var(--accent);
    background: var(--surface);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.field .hint { font-size: 11.5px; color: var(--ink-3); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.opt { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.opt input { width: 16px; height: 16px; accent-color: var(--accent); }

/* --- Ekran logowania -------------------------------------------------- */

.login {
    position: fixed; inset: 0;
    display: grid;
    grid-template-columns: 1.05fr .95fr;
    background: var(--surface);
    z-index: 100;
    animation: fadeIn .25s var(--ease) both;
}
.loginart {
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(900px 620px at 18% 12%, rgba(107, 77, 255, .5), transparent 62%),
        radial-gradient(760px 560px at 82% 88%, rgba(43, 95, 227, .55), transparent 60%),
        linear-gradient(150deg, #16204a, #0b1024 70%);
    color: #fff;
    padding: 56px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.loginart::after {
    content: "";
    position: absolute; inset: 0;
    background-image: linear-gradient(rgba(255, 255, 255, .05) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .05) 1px, transparent 1px);
    background-size: 46px 46px;
    mask-image: radial-gradient(700px 520px at 30% 30%, #000, transparent 78%);
}
.loginart > * { position: relative; z-index: 1; }
.loginart h2 {
    font-family: var(--f-display);
    font-size: 40px;
    font-weight: 700;
    line-height: 1.12;
    letter-spacing: -.025em;
    max-width: 15ch;
    text-wrap: balance;
}
.loginart p { color: rgba(255, 255, 255, .7); font-size: 14.5px; max-width: 46ch; margin-top: 16px; line-height: 1.65; }
.loginart .stats { display: flex; gap: 40px; }
.loginart .stats .v { font-family: var(--f-display); font-size: 30px; font-weight: 700; }
.loginart .stats .k { font-size: 12px; color: rgba(255, 255, 255, .6); letter-spacing: .04em; }
.loginart .wordmark { color: #fff; }

.loginform { display: grid; place-items: center; padding: 40px; }
.loginform .box { width: 100%; max-width: 372px; display: grid; gap: 18px; }
.loginform h1 { font-family: var(--f-display); font-size: 26px; }
.loginform .sub { color: var(--ink-2); font-size: 13.5px; margin-top: 4px; }
.loginform .btn { width: 100%; justify-content: center; height: 44px; }
.loginform .demo {
    font-size: 12px; color: var(--ink-3);
    border-top: 1px solid var(--line-soft);
    padding-top: 16px;
    line-height: 1.6;
}
.loginform .demo code { font-family: var(--f-mono); color: var(--ink-2); }

/* --- Powiadomienia ---------------------------------------------------- */

.toasts { position: fixed; left: 24px; bottom: 24px; display: grid; gap: 10px; z-index: 200; }
.toast {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 18px;
    border-radius: var(--r-sm);
    background: #1d2436;
    color: #eef2fb;
    font-size: 13px;
    box-shadow: var(--shadow-2);
    animation: riseIn .24s var(--ease) both;
}
.toast a { color: #8fb2ff; font-weight: 600; text-decoration: none; cursor: pointer; }
.toast a:hover { text-decoration: underline; }

/* --- Responsywność ----------------------------------------------------- */

@media (max-width: 1280px) {
    .readpane { flex-basis: 48%; }
    .row { grid-template-columns: auto auto auto minmax(0, 140px) minmax(0, 1fr) auto; }
}

@media (max-width: 1080px) {
    .listpane { flex-basis: 100%; border-right: 0; }
    .readpane { display: none; }
    .app.reading .listpane { display: none; }
    .app.reading .readpane { display: flex; }
}

@media (max-width: 860px) {
    :root { --rail: 0px; }
    .rail { display: none; }
    .brand { width: auto; }
    .work { border-radius: 0; border-left: 0; }
    .screenin { padding: 24px 20px 50px; }
    .login { grid-template-columns: 1fr; }
    .loginart { display: none; }
}

/* --- Elementy wystepujace tylko w aplikacji ---------------------------- */

#root { display: contents; }

.boot {
    position: fixed; inset: 0;
    display: grid; place-items: center;
    background: var(--ground);
    color: var(--ink-3);
    gap: 14px;
    z-index: 90;
}
.boot .spinner {
    width: 26px; height: 26px;
    border: 2.5px solid var(--line);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

.formerr { color: var(--bad); font-size: 12.5px; min-height: 18px; }

.field.bad input, .field.bad select, .field.bad textarea { border-color: var(--bad); }

.testresult { display: grid; gap: 8px; font-size: 12.5px; }
.testresult .line { display: flex; align-items: flex-start; gap: 8px; }
.testresult .line b { min-width: 44px; }
.testresult .line.ok { color: var(--ok); }
.testresult .line.bad { color: var(--bad); }

.skeleton {
    height: 46px;
    border-bottom: 1px solid var(--line-soft);
    background: linear-gradient(90deg, transparent, var(--surface-3), transparent);
    background-size: 420px 100%;
    animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer { 0% { background-position: -420px 0; } 100% { background-position: 420px 0; } }


/* Tresc HTML wiadomosci - ramka z sandboxem, bez skryptow i bez dostepu do sesji. */
.htmlbody {
    width: 100%;
    min-height: 420px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: #fff;
}

/* Akcje w wierszu tabeli - przyciski trzymaja sie jednej linii po prawej. */
.tbl .rowacts { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
.tbl .rowacts .iconbtn { width: 30px; height: 30px; color: var(--ink-3); }
.tbl .rowacts .iconbtn:hover { background: var(--bad-soft); color: var(--bad); }

/* Przycisk odswiezania listy w trakcie pracy - ta sama ikona, tylko wiruje. */
.listbar .iconbtn.busy svg { animation: spin .9s linear infinite; }
.listbar .iconbtn.busy { color: var(--accent); }

/* Dodawanie skrzynki: dostawcy z logowaniem tokenem nad zwyklym formularzem. */
.providers { display: grid; gap: 8px; }
.providers .btn { justify-content: center; height: 42px; text-decoration: none; }
.providers .btn[disabled] { opacity: .55; cursor: not-allowed; }

.orline { display: flex; align-items: center; gap: 12px; color: var(--ink-3); font-size: 12.5px; }
.orline::before, .orline::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* --- Edytor regul: wiersze warunkow i czynnosci --------------------------- */

.parts { display: grid; gap: 8px; }
.partshead { display: flex; align-items: center; gap: 10px; }
.partshead b { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.partshead .btn { margin-left: auto; }

.partrow {
    display: flex; align-items: center; gap: 6px;
    padding: 6px; border-radius: var(--r-sm);
    background: var(--surface-2); border: 1px solid var(--line-soft);
}
.partrow select, .partrow input {
    border: 1px solid var(--line); border-radius: var(--r-xs);
    background: var(--surface); outline: 0;
    padding: 6px 8px; font-size: 12.5px; min-width: 0;
}
.partrow select { flex: 0 0 auto; max-width: 150px; }
.partrow input { flex: 1; }
.partrow select:focus, .partrow input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.partrow .iconbtn { width: 26px; height: 26px; color: var(--ink-3); flex: 0 0 auto; }
.partrow .iconbtn:hover { background: var(--bad-soft); color: var(--bad); }
.partrow .iconbtn svg { width: 13px; height: 13px; }

/* Czynnosc odroznia sie kolorem od warunku - inaczej karta reguly zlewa sie w jedno. */
.rule .cond.act { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); }

/* --- Serwery robocze ------------------------------------------------------ */

/* Pasek obciazenia workera - jedno spojrzenie mowi, czy jest jeszcze zapas. */
.bar { height: 4px; border-radius: 2px; background: var(--surface-3); margin-top: 5px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; transition: width .3s var(--ease); }

.mono { font-family: var(--f-mono); font-size: 11.5px; color: var(--ink-3); }

.cmd {
    font-family: var(--f-mono); font-size: 12px; line-height: 1.6;
    padding: 12px 14px; border-radius: var(--r-sm);
    background: var(--surface-3); color: var(--ink);
    white-space: pre-wrap; word-break: break-all;
    user-select: all;
}
.hint.ok { color: var(--ok); }
.fs.bad { color: var(--bad); }
