/* The foundation every page stands on: fonts, colours, type, the app's frame, and the
   screens shown while loading or when something fails. Components and pages add their
   own files in css/components/ and css/pages/. */

/* ------------------------------------------------------------------ fonts */
/* Inter carries the interface and the numbers; Manrope the titles and big figures.
   Both have Greek. The browser fetches the Greek files only when Greek is on screen. */
@font-face {
  font-family: Inter; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url(../public/fonts/inter-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: Inter; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url(../public/fonts/inter-greek.woff2) format("woff2");
  unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}
@font-face {
  font-family: Manrope; font-style: normal; font-weight: 500 800; font-display: swap;
  src: url(../public/fonts/manrope-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: Manrope; font-style: normal; font-weight: 500 800; font-display: swap;
  src: url(../public/fonts/manrope-greek.woff2) format("woff2");
  unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF;
}

/* ------------------------------------------------------------------ colours */
/* Colours are RGB triplets so they mix with alpha: rgb(var(--good) / var(--tint)).
   Values were measured from the reference screenshots. */
:root {
  --bg: 244 244 241;
  --panel: 255 255 255;
  --panel2: 237 237 233;
  --line: 217 217 211;
  --ink: 11 12 14;
  --ink2: 75 77 82;
  --muted: 138 140 145;
  --accent: 31 94 255;
  --accent-ink: 31 94 255;      /* accent used as text */
  --on-accent: 255 255 255;
  --good: 11 138 62;
  --warn: 178 107 0;
  --bad: 200 50 47;
  --gold: 183 132 26;
  --amber: 237 161 0;
  --c1: 42 120 214;             /* chart series */
  --c2: 237 161 0;
  --c3: 27 175 122;
  --c4: 227 73 72;
  --grid: 225 224 217;
  --axis: 137 135 129;
  --tint: 0.12;
  --tint-strong: 0.18;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.04), 0 1px 1px rgb(0 0 0 / 0.02);
  --shadow: 0 4px 14px rgb(0 0 0 / 0.08);
  --shadow-lg: 0 16px 40px rgb(0 0 0 / 0.14);
  --light: 255 255 255;         /* these three hold in both themes */
  --shade: 0 0 0;
  --scrim: 11 12 14;            /* behind a modal */

  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --radius-pill: 999px;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --sidebar: 260px;
  --sidebar-collapsed: 72px;
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: Manrope, Inter, system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --ring: 0 0 0 3px rgb(var(--accent) / 0.18);     /* a text box being typed in */
  --focus: 3px solid rgb(var(--accent) / 0.35);    /* anything reached by keyboard */

  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: 11 13 16;
  --panel: 20 23 27;
  --panel2: 27 31 37;
  --line: 38 43 51;
  --ink: 243 244 242;
  --ink2: 180 184 190;
  --muted: 118 123 132;
  --accent: 31 94 255;
  --accent-ink: 107 155 255;
  --on-accent: 255 255 255;
  --good: 42 191 108;
  --warn: 224 160 48;
  --bad: 232 90 85;
  --gold: 217 164 65;
  --amber: 201 133 0;
  --c1: 57 135 229;
  --c2: 201 133 0;
  --c3: 25 158 112;
  --c4: 230 103 103;
  --grid: 44 47 53;
  --axis: 137 135 129;
  --tint: 0.16;
  --tint-strong: 0.24;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.3);
  --shadow: 0 6px 18px rgb(0 0 0 / 0.36);
  --shadow-lg: 0 20px 48px rgb(0 0 0 / 0.5);

  color-scheme: dark;
}

/* Before the app has read the saved choice, follow the system. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: 11 13 16;
    --panel: 20 23 27;
    --panel2: 27 31 37;
    --line: 38 43 51;
    --ink: 243 244 242;
    --ink2: 180 184 190;
    --muted: 118 123 132;
    --accent-ink: 107 155 255;
    color-scheme: dark;
  }
}

/* ------------------------------------------------------------------ reset and type */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font: 400 0.875rem/1.5 var(--font);
  color: rgb(var(--ink));
  background: rgb(var(--bg));
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg { display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
a:hover { color: rgb(var(--accent-ink)); }
table { border-collapse: collapse; }
[hidden] { display: none !important; }

:focus-visible {
  outline: var(--focus);
  outline-offset: 1px;
  border-radius: var(--radius-sm);
}

::selection { background: rgb(var(--accent) / 0.25); }

.title {
  font: 700 1.875rem/1.15 var(--display);
  letter-spacing: -0.035em;
}
.heading {
  font: 700 1.125rem/1.3 var(--display);
  letter-spacing: -0.02em;
}
/* Captions every card, field and tile. */
.label {
  font-size: 0.6875rem;
  font-weight: 500;
  line-height: 1.3;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: rgb(var(--muted));
}
.muted { color: rgb(var(--muted)); }
.small { font-size: 0.75rem; }
.micro { font-size: 0.6875rem; }
.num { font-variant-numeric: tabular-nums; }
.good { color: rgb(var(--good)); }
.warn { color: rgb(var(--warn)); }
.bad { color: rgb(var(--bad)); }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.link { color: rgb(var(--accent-ink)); }
.link:hover { text-decoration: underline; }
:where(button).link { padding: 0; border: 0; background: none; }   /* a button that reads as a link */

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ------------------------------------------------------------------ layout helpers */
.stack { display: flex; flex-direction: column; gap: var(--gap, 16px); }
.row { display: flex; align-items: center; gap: var(--gap, 8px); min-width: 0; }
.row--between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }

/* Page grids. A page names its columns in its own CSS; these cover the common ones. */
.grid { display: grid; gap: 16px; align-items: stretch; }
.grid > * { min-width: 0; }
.grid > :only-child { grid-column: 1 / -1; }   /* the other card of a pair was switched off */
.grid--3:has(> :nth-child(2):last-child) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.grid--wide-left { grid-template-columns: minmax(0, 1.9fr) minmax(0, 1fr); }
@media (max-width: 1280px) {
  .grid--6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .grid--3, .grid--wide-left { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .grid--2 { grid-template-columns: minmax(0, 1fr); }
  .grid--6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ------------------------------------------------------------------ the app's frame */
.app {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}
.app.is-collapsed { grid-template-columns: var(--sidebar-collapsed) minmax(0, 1fr); }

.main {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.page {
  flex: 1 0 auto;
  width: 100%;
  max-width: 1680px;
  padding: 24px 32px 32px;
}
/* Pages that fill the height themselves, like mail and chat. */
.page:has(> .page__view--full) {
  max-width: none;
  padding: 0;
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
}
.page__view { display: flex; flex-direction: column; gap: 16px; animation: view-in 160ms var(--ease); }
.page__view--full { flex: 1 1 auto; min-width: 0; min-height: 0; animation: none; }

.bare { min-height: 100vh; min-height: 100dvh; }

@media (max-width: 991px) {
  .app, .app.is-collapsed { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .page { padding: 16px 16px 24px; }
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* A thin bar across the top while a page is on its way. */
.loading-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 2px;
  margin-bottom: -2px;
  background: rgb(var(--accent));
  transform-origin: left;
  transform: scaleX(0);
  opacity: 0;
}
.app.is-loading .loading-bar {
  opacity: 1;
  animation: loading 1.4s var(--ease) infinite;
}
@keyframes loading {
  0% { transform: scaleX(0); }
  60% { transform: scaleX(0.7); }
  100% { transform: scaleX(0.95); opacity: 0.4; }
}

/* ------------------------------------------------------------------ boot and failure */
.boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgb(var(--bg));
  z-index: 100;
}
.boot__mark { --mark: 44px; font-size: 0.9375rem; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.55; } }

/* Shown instead of a page, or instead of the whole app, when something didn't load. */
.failure {
  max-width: 520px;
  margin: 12vh auto;
  padding: 28px;
  border: 1px solid rgb(var(--line));
  border-radius: var(--radius);
  background: rgb(var(--panel));
  box-shadow: var(--shadow-sm);
}
.failure__title { font: 700 1.25rem/1.3 var(--display); letter-spacing: -0.02em; margin-bottom: 8px; }
.failure__text { color: rgb(var(--ink2)); }
.failure__list { margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.failure__list code {
  font: 500 0.75rem/1 var(--mono);
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  background: rgb(var(--bad) / var(--tint));
  color: rgb(var(--bad));
}
.failure__retry {
  margin-top: 20px;
  padding: 9px 16px;
  border: 1px solid rgb(var(--line));
  border-left: 3px solid rgb(var(--accent));
  border-radius: var(--radius-sm);
  background: rgb(var(--panel));
  font-weight: 600;
}
.failure__retry:hover { background: rgb(var(--panel2)); }

.noscript { padding: 24px; text-align: center; }

/* Components show only once their file has loaded. */
:not(:defined) { visibility: hidden; }

/* ------------------------------------------------------------------ small shared pieces */
/* Native popovers: menus. Closed ones stay hidden, whatever display a class sets. */
[popover]:not(:popover-open) { display: none !important; }
[popover] {
  margin: 0;
  padding: 6px;
  border: 1px solid rgb(var(--line));
  border-radius: var(--radius);
  background: rgb(var(--panel));
  color: rgb(var(--ink));
  box-shadow: var(--shadow-lg);
}

/* An email's text, wherever it is read: its line breaks kept. Its attachments follow. */
.mail-body { max-width: 72ch; white-space: pre-wrap; line-height: 1.65; overflow-wrap: anywhere; }
.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }

/* A messaging app's logo: its icon on the app's own colour. Pages size it with --logo. */
.logo {
  display: grid;
  place-items: center;
  flex: none;
  width: var(--logo, 34px);
  height: var(--logo, 34px);
  border-radius: var(--radius-sm);
  color: rgb(var(--on-accent));
}
.logo--whatsapp { background: #25d366; }
.logo--messenger { background: #0a7cff; }
.logo--telegram { background: #229ed9; }
.logo--viber { background: #7360f2; }

/* A row in a list you move between, the sidebar's or the mail folders': quiet, and tinted
   where you are (aria-current). Each list sizes its own. */
.navlink { display: flex; align-items: center; border-radius: var(--radius-sm); color: rgb(var(--ink)); font-weight: 500; }
.navlink mp-icon { color: rgb(var(--ink2)); }
.navlink:hover { background: rgb(var(--panel2)); color: rgb(var(--ink)); }
.navlink[aria-current="page"] { background: rgb(var(--accent) / var(--tint)); color: rgb(var(--accent-ink)); font-weight: 600; }
.navlink[aria-current="page"] mp-icon { color: rgb(var(--accent-ink)); }

/* The firm's mark: its letters on the accent. --mark sizes it. */
.mark {
  --mark: 32px;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: var(--mark);
  height: var(--mark);
  border-radius: calc(var(--mark) / 4);
  background: rgb(var(--accent));
  color: rgb(var(--on-accent));
  font: 800 0.8125rem/1 var(--display);
}

/* A bordered box inside a card or window, with its own small headings. */
.panel {
  --list-x: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 14px 16px 16px;
  border: 1px solid rgb(var(--line));
  border-radius: var(--radius);
  background: rgb(var(--panel));
}
.panel > .label:not(:first-child) { margin-top: 6px; }
.panel--flush { padding: 14px 0 6px; }   /* lists inside run edge to edge */
.panel--flush > .label { padding: 0 16px; }

/* A big figure under its label: a total, a goal's overall share. */
.figure { display: block; margin-top: 4px; font: 700 1.5rem/1.1 var(--display); }

/* A tinted bar that explains something; --warn and --bad when something is wrong. */
.notice { padding: 10px 12px; border-radius: var(--radius-sm); background: rgb(var(--accent) / var(--tint)); font-size: 0.8125rem; }
.notice--warn { background: rgb(var(--warn) / var(--tint)); color: rgb(var(--warn)); }
.notice--bad { background: rgb(var(--bad) / var(--tint)); color: rgb(var(--bad)); }

/* A text box, list or area: mp-field draws one, and every other place you type uses it. */
.input {
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: rgb(var(--panel2));
  transition: border-color 150ms var(--ease), background-color 150ms var(--ease);
}
.input::placeholder { color: rgb(var(--muted)); }
.input:focus { outline: none; border-color: rgb(var(--accent) / 0.5); background: rgb(var(--panel)); box-shadow: var(--ring); }
.input:disabled { opacity: 0.6; }
.input--small { height: 32px; padding: 0 10px; font-size: 0.8125rem; }
select.input { padding-right: 8px; }
textarea.input { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.5; }

/* An icon on a plate, round for a group in place of an avatar; --plate sizes it. */
.plate {
  display: grid;
  place-items: center;
  flex: none;
  width: var(--plate, 36px);
  height: var(--plate, 36px);
  border-radius: 50%;
  background: rgb(var(--accent) / var(--tint));
  color: rgb(var(--accent-ink));
}
.plate--square { border-radius: var(--radius-sm); }

/* A raised surface: a card, a figure's tile. */
.surface {
  overflow: hidden;
  border: 1px solid rgb(var(--line));
  border-radius: var(--radius);
  background: rgb(var(--panel));
  box-shadow: var(--shadow-sm);
}

/* A box you press: a calendar day, a meeting on Profile, a box in Customize. */
.pressable {
  border: 1px solid rgb(var(--line));
  border-radius: var(--radius-sm);
  background: rgb(var(--panel));
  color: rgb(var(--ink));
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 150ms var(--ease), background-color 150ms var(--ease);
}

/* A chip: mp-chip, and a field's ticks. Pressed or ticked, it is the accent, tinted. */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  height: 28px;
  padding: 0 11px;
  border: 1px solid rgb(var(--line));
  border-radius: var(--radius-pill);
  background: rgb(var(--panel));
  color: rgb(var(--ink));
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease);
}
.chip:hover { background: rgb(var(--panel2)); color: rgb(var(--ink)); }
.chip[aria-pressed="true"], .chip--removable, :checked + .chip {
  border-color: transparent;
  background: rgb(var(--accent) / var(--tint-strong));
  color: rgb(var(--accent-ink));
  font-weight: 600;
}

/* Someone's email, phone and place, each with its icon. */
.contacts { display: flex; flex-wrap: wrap; gap: 6px 22px; color: rgb(var(--ink2)); }
.contacts > * { display: inline-flex; align-items: center; gap: 8px; color: inherit; overflow-wrap: anywhere; }
.contacts mp-icon { color: rgb(var(--muted)); }

/* An empty list or card. */
.empty {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 40px 16px;
  color: rgb(var(--muted));
  text-align: center;
}
.empty mp-icon { font-size: 1.5rem; }

/* Rows of label and value, as on the client page. */
.facts { display: grid; grid-template-columns: minmax(96px, auto) minmax(0, 1fr); }
.facts > dt, .facts > dd {
  margin: 0;
  padding: 10px 0;
  border-bottom: 1px solid rgb(var(--line));
}
.facts > dt { color: rgb(var(--muted)); font-size: 0.75rem; padding-right: 16px; }
.facts > dd { overflow-wrap: anywhere; }
.facts > :nth-last-child(-n + 2) { border-bottom: 0; }

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

/* Scrollbars that fit both themes. */
* { scrollbar-width: thin; scrollbar-color: rgb(var(--line)) transparent; }
