@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap");

:root{color-scheme:dark;font:100%/1.55 system-ui,sans-serif;background:#101619;color:#eef5f3;--panel:#192326;--line:#354649;--muted:#b5c9c6;--accent:#a2f1ce}*{box-sizing:border-box}body{margin:0}header{display:flex;justify-content:space-between;align-items:center;padding:1.15rem clamp(1rem,4vw,4rem);border-bottom:1px solid var(--line)}a{color:var(--accent)}.brand{font-size:1.45rem;color:#fff;text-decoration:none;font-weight:750}.brand small{display:block;color:var(--accent);font-size:.76rem;letter-spacing:.16em}.shell{display:grid;grid-template-columns:13rem minmax(0,1fr);max-width:100rem;margin:auto;min-height:80vh}.welcome{max-width:41rem;margin:auto}nav{border-right:1px solid var(--line);padding:1.5rem .85rem}nav a{display:block;text-decoration:none;padding:.7rem .85rem;border-radius:.5rem;color:var(--muted)}nav a[aria-current]{color:var(--accent);background:var(--panel)}main{padding:clamp(1rem,4vw,3rem);min-width:0}h1{font-size:clamp(2rem,4vw,3.2rem);line-height:1.08;margin:0 0 1rem}h2{font-size:1.25rem;margin:0}p{color:var(--muted)}section{padding:1.25rem;background:var(--panel);border-radius:.85rem;border:1px solid var(--line);margin:0 0 1rem}.tiles{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,13rem),1fr));gap:1rem}.tiles strong{display:block;font-size:2rem;color:var(--accent)}form{display:grid;gap:.75rem;margin:0}form+form{margin-top:.85rem}label{display:grid;gap:.3rem}input,select,textarea,button{font:inherit}input,select,textarea{width:100%;padding:.55rem .7rem;color:inherit;background:#101619;border:1px solid var(--line);border-radius:.45rem}button{justify-self:start;padding:.55rem .95rem;background:var(--accent);color:#0c2119;font-weight:700;border:1px solid transparent;border-radius:.45rem;cursor:pointer}.secondary{background:transparent;color:var(--accent);border-color:var(--line)}:focus-visible{outline:2px solid var(--accent);outline-offset:3px}.error{padding:.75rem 1rem;border:1px solid #b27076;border-radius:.5rem;color:#ffd5d7}.table{overflow-x:auto}table{width:100%;border-collapse:collapse}td,th{padding:.65rem;text-align:left;border-bottom:1px solid var(--line);overflow-wrap:anywhere}.table+a,section>a+a{display:inline-block;margin:.85rem .85rem 0 0}.rows{padding:0;list-style:none}.rows li{display:flex;justify-content:space-between;padding:.6rem 0;border-bottom:1px solid var(--line)}.month{display:flex;flex-wrap:wrap;gap:.75rem;justify-content:space-between;margin-bottom:1rem}.calendar{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:.16rem}.calendar div{min-height:3.4rem;border:1px solid var(--line);padding:.2rem;overflow-wrap:anywhere}.calendar span{display:block;font-size:.875rem;color:var(--accent)}.message{white-space:pre-wrap;overflow-wrap:anywhere}article{padding:.6rem 0;border-bottom:1px solid var(--line);margin-bottom:.75rem}@media(max-width:720px){.shell{grid-template-columns:1fr}nav{display:flex;overflow:auto;white-space:nowrap;border-right:0;border-bottom:1px solid var(--line);padding:.5rem}section{padding:.8rem}}

/* REM Agency */
:root {
    color-scheme: light;
    font-family: Manrope, Arial, sans-serif;
    background: #f5f8fc;
    color: #0a1c36;
    --panel: #fff;
    --line: #d9e3ef;
    --muted: #465a75;
    --accent: #0758c8;
    --accent-hover: #0648a4;
    --accent-soft: #e8f1ff;
}
header {
    flex-wrap: wrap;
    gap: .75rem 1.25rem;
    min-height: 5.75rem;
    padding: .85rem clamp(1rem, 5.2vw, 5rem);
    background: var(--panel);
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: clamp(.65rem, 2vw, 1.25rem);
    color: inherit;
    font-size: clamp(.95rem, 2vw, 1.25rem);
    font-weight: 800;
}
.brand small {
    display: grid;
    place-items: center;
    width: clamp(6.75rem, 19vw, 12.8125rem);
    aspect-ratio: 1750 / 411;
    background: url("https://remagency.ru/assets/rem-logo.png") left center / contain no-repeat;
    color: transparent;
    font-size: .75rem;
    font-weight: 800;
}
.welcome { margin: clamp(1rem, 5vw, 4rem) auto; }
nav { background: var(--panel); }
nav a { border-radius: .65rem; font-weight: 700; }
nav a:hover, nav a[aria-current] { color: var(--accent); background: var(--accent-soft); }
h1 { letter-spacing: -.045em; }
section {
    padding: clamp(1rem, 3vw, 1.5rem);
    border-radius: 1rem;
    box-shadow: 0 8px 24px rgb(10 28 54 / 5%);
}
label { font-weight: 700; }
input, select, textarea {
    padding: .6rem .75rem;
    background: #f8fafd;
    border-color: #8498b2;
    border-radius: .55rem;
}
button { padding: .6rem 1.15rem; color: #fff; font-weight: 800; border-radius: 2rem; }
button:hover { background: var(--accent-hover); }
.secondary { background: var(--panel); color: var(--accent); border-color: var(--accent); }
.secondary:hover { background: var(--accent-soft); }
.error { background: #fff1f2; color: #8b2030; }
@media (max-width: 720px) { header { min-height: 4.5rem; } }
@media (forced-colors: active) {
    .brand small { width: auto; aspect-ratio: auto; background: none; color: LinkText; }
}

@media (forced-colors: none) {
    .brand small { background-image: url("rem-logo.png"); }
}

/* Wide desktop layout */
@media (min-width: 100rem) {
    .shell { max-width: none; grid-template-columns: 15rem minmax(0, 1fr); }
    .shell main > section:has(input[name="client_secret"]) { max-width: 54rem; }
}

.history-table table { width: max-content; min-width: 100%; }
.history-table :is(th, td) { min-width: 7rem; max-width: 15rem; overflow-wrap: break-word; }
.history-table :is(th, td):nth-child(2), .history-table :is(th, td):nth-child(6) { min-width: 13rem; }
.history-table thead { background: var(--accent-soft); }
.history-table tbody tr:nth-child(even) { background: #f8fafd; }
.history-table :is(th, td):first-child { position: sticky; left: 0; background: var(--panel); }

.analytics-controls { padding: clamp(1rem, 3vw, 1.75rem); }
.analytics-controls h2 { margin: 0 0 1rem; font-size: 1.125rem; }
.analytics-filters { grid-template-columns: minmax(13rem, 1.35fr) repeat(2, minmax(8rem, 1fr)) auto; align-items: end; gap: 1rem; }
.analytics-filters label, .analytics-account-field { font-size: .875rem; font-weight: 700; }
.analytics-account-field { display: grid; gap: .3rem; min-width: 0; }
.analytics-account-menu { position: relative; }
.analytics-account-menu summary { display: flex; align-items: center; justify-content: space-between; gap: .75rem; min-height: 2.75rem; padding: .55rem .8rem; border: 1px solid var(--line); border-radius: .65rem; background: #f8fafd; cursor: pointer; list-style: none; overflow-wrap: anywhere; }
.analytics-account-menu summary::-webkit-details-marker { display: none; }
.analytics-account-menu summary::after { content: ''; width: .45rem; height: .45rem; flex-shrink: 0; border-right: 2px solid var(--accent); border-bottom: 2px solid var(--accent); transform: rotate(45deg); }
.analytics-account-menu[open] summary { border-color: var(--accent); }
.analytics-account-options { position: absolute; z-index: 5; inset: calc(100% + .4rem) 0 auto; display: grid; gap: .2rem; max-height: 19rem; overflow-y: auto; padding: .5rem; background: var(--panel); border: 1px solid var(--line); border-radius: .75rem; box-shadow: 0 12px 30px rgb(10 28 54 / 15%); }
.analytics-account-options label { display: flex; align-items: start; gap: .6rem; padding: .5rem .6rem; border-radius: .5rem; cursor: pointer; overflow-wrap: anywhere; }
.analytics-account-options label:hover, .analytics-account-options label:has(input:checked) { background: var(--accent-soft); }
.analytics-account-options input { width: 1rem; height: 1rem; flex-shrink: 0; accent-color: var(--accent); }
.analytics-account-options small { display: block; color: var(--muted); font-weight: 400; }
.analytics-account-options button { justify-self: stretch; border-color: transparent; border-radius: .5rem; text-align: left; background: var(--accent-soft); }
.analytics-filters input[type=date] { min-height: 2.75rem; border-color: var(--line); border-radius: .65rem; }
.analytics-submit { min-height: 2.75rem; border-radius: .65rem; font-size: .875rem; white-space: nowrap; }
.analytics-result h2 { margin: 0 0 1rem; }
@media (max-width: 68rem) { .analytics-filters { grid-template-columns: repeat(2, minmax(0,1fr)); } .analytics-account-field { grid-column: 1 / -1; } }
@media (max-width: 32rem) { .analytics-filters { grid-template-columns: minmax(0,1fr); } .analytics-submit { width: 100%; } }

.analytics-sort-controls { grid-column: 1 / -1; grid-row: 2; display: flex; flex-wrap: wrap; gap: .75rem; }
.analytics-sort-controls label { flex: 0 1 16rem; }
.analytics-sort-controls select { min-height: 2.75rem; border-color: var(--line); border-radius: .65rem; }
.avito-live-table th { vertical-align: top; }
.avito-live-table :is(th,td):first-child { min-width: 12rem; max-width: 15rem; border-right: 1px solid var(--line); }
.avito-live-table th button { display: block; width: 100%; text-align: left; padding: .3rem 0; border: 0; border-radius: .3rem; background: transparent; }
.avito-live-table th input { margin-top: .35rem; font-size: .875rem; background: var(--panel); }
@media (max-width: 68rem) { .analytics-sort-controls { grid-row: auto; } }
@media (max-width: 32rem) { .analytics-sort-controls label { flex-basis: 100%; } .avito-live-table :is(th,td):first-child { min-width: 8rem; max-width: 9rem; } }

/* RemAgency workspace */
:root { --panel:#fff; --line:#e1e5eb; --muted:#596474; --accent:#195bd8; --accent-hover:#154bb3; --accent-soft:#edf3ff; --gutter:clamp(1rem,3.5vw,4rem); background:#fafbfc; color:#182231; font-family:system-ui,-apple-system,"Segoe UI",sans-serif; }
body > header { min-height:4rem; padding:.7rem var(--gutter); background:#f3f5f8; }
.brand { gap:.9rem; font-size:1rem; letter-spacing:-.025em; }
.brand small { width:clamp(6rem,10vw,8rem); }
.shell { display:block; max-width:none; }
.shell > nav { display:flex; align-items:stretch; gap:clamp(.8rem,1.4vw,1.75rem); padding:0 var(--gutter); background:#f3f5f8; border:0; border-bottom:1px solid var(--line); overflow-x:auto; scrollbar-width:thin; }
.shell > nav a { display:flex; align-items:center; flex:none; min-height:3rem; padding:.65rem .1rem; border-radius:0; border-bottom:3px solid transparent; color:#535f70; font-size:.9rem; font-weight:550; white-space:nowrap; }
.shell > nav a:hover,.shell > nav a[aria-current] { background:transparent; color:var(--accent); border-bottom-color:var(--accent); }
.shell main { padding:clamp(1.4rem,3vw,3rem) var(--gutter); }
h1 { font-size:clamp(1.8rem,3vw,2.55rem); font-weight:700; letter-spacing:-.035em; }
h2 { letter-spacing:-.02em; }
main section { border-radius:16px; border-color:var(--line); box-shadow:0 3px 14px rgb(25 41 70 / 4%); }
.tiles strong,.dashboard-metrics dd,.dashboard-funnel-value { font-variant-numeric:tabular-nums; }
.tiles strong { color:#182231; letter-spacing:-.035em; }
label { font-weight:550; }
input:not([type=checkbox]):not([type=radio]),select,textarea { border:1px solid #dce1e8; border-radius:10px; background:#f3f5f8; padding:.67rem .85rem; }
input:focus,select:focus,textarea:focus { background:white; }
button { border-radius:10px; font-weight:600; }
button.secondary { background:#edf1f6; border-color:transparent; color:#324156; }
th { background:#f4f6f9; color:#435063; font-size:.875rem; font-weight:600; }
td { font-variant-numeric:tabular-nums; }
.calendar div { border-radius:.45rem; background:#fff; }
.welcome { max-width:31rem; }
@media(max-width:720px){ body > header { min-height:3.5rem; } .shell > nav { gap:1rem; } .shell main { padding-top:1.25rem; } }

/* Dashboard account cards */
.shell .dashboard-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: .75rem;
    max-width: 82rem;
}
.shell .dashboard-card { min-width: 0; max-width: none; padding: .9rem; }
.shell .dashboard-funnel { gap: .4rem; }
.shell .dashboard-funnel-metric { min-width: 0; overflow-wrap: anywhere; }
@media (min-width: 34rem) {
    .shell .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 49rem) {
    .shell .dashboard-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 64rem) {
    .shell .dashboard-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Align corresponding sections in each row of account cards. */
.shell .dashboard-grid { row-gap: 1rem; }
.shell .dashboard-card {
    display: grid;
    grid-row: span 4;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: subgrid;
    row-gap: 0;
}
.shell .dashboard-card[hidden] { display: none; }
.dashboard-card > .dashboard-card-head { grid-row: 1; align-items: start; }
.dashboard-card > .dashboard-metrics { grid-row: 2; }
.dashboard-card > .dashboard-funnel { grid-row: 3; align-items: start; }
.dashboard-card > .dashboard-funnel + .dashboard-metrics { grid-row: 4; }
.dashboard-card .dashboard-conversion { align-self: center; }
.dashboard-card .dashboard-funnel-value {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-height: 2.9rem;
}
.dashboard-card .dashboard-funnel-metric:last-child .dashboard-funnel-value {
    align-items: flex-end;
    justify-content: flex-start;
}
