/* The Sama console in TendaJi Brand 2.2. Every colour, size and font is a token from /brand/tokens.css, which
   sama-setup generates from brand kit 2.2 (B25): no value is typed here. Ink is Sama's primary and Mist the page;
   cards are white with a line border and no shadow; controls are 40 px tall, as dense consoles are, with
   control-border; one focus ring; sentence case everywhere; logical properties, so Arabic mirrors as it should. */

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  background: var(--mist);
  color: var(--ink);
}
body {
  margin: 0;
  font: var(--type-body);
  background: var(--mist);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
:lang(ar) body {
  font: var(--type-body-ar);
}
h1,
h2,
h3,
p {
  margin: 0;
}
a {
  color: var(--ink);
  text-underline-offset: 2px;
}
code,
pre,
.code-area {
  font: var(--type-code);
}
:focus-visible {
  outline: var(--stroke-focus) solid var(--focus);
  outline-offset: 2px;
}
.visually-hidden {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.muted {
  color: var(--muted);
}

/* The page: the header across the top, the sections on the start side, the page beside them. */
.app {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  grid-template-areas: "top top" "side main";
  min-block-size: 100vh;
}
.topbar {
  grid-area: top;
  position: sticky;
  inset-block-start: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-12) var(--space-24);
  padding: var(--space-12) var(--space-24);
  background: var(--surface);
  border-block-end: 1px solid var(--line);
}
.topbar-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-12);
  margin-inline-start: auto;
}
.side {
  grid-area: side;
  padding: var(--space-24) var(--space-16);
  border-inline-end: 1px solid var(--line);
}
.main {
  grid-area: main;
  min-inline-size: 0;
  padding: var(--space-32) var(--space-48) var(--space-64);
  max-inline-size: 1280px;
}
.main:focus {
  outline: none;
}

/* The header lockup (B19): the tile at 32 px, 10 px, TendaJi in Label Muted over Sama in SemiBold 18 Ink. */
.lockup {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
}
.lockup .tile {
  inline-size: 32px;
  block-size: 32px;
  flex: none;
}
.lockup-words {
  display: flex;
  flex-direction: column;
}
.lockup-company {
  font: var(--type-label);
  color: var(--muted);
}
.lockup-product {
  font: 600 18px / 22px var(--font-sans);
  color: var(--ink);
}
.tile-reversed {
  display: none;
}
:root[data-theme="dark"] .tile-standard {
  display: none;
}
:root[data-theme="dark"] .tile-reversed {
  display: block;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tile-standard {
    display: none;
  }
  :root:not([data-theme="light"]) .tile-reversed {
    display: block;
  }
}

/* Controls */
.control {
  min-block-size: 40px;
  padding: 0 var(--space-12);
  font: var(--type-body);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--control-border);
  border-radius: var(--radius-control);
}
textarea.control {
  padding: var(--space-12);
  inline-size: 100%;
  resize: vertical;
}
.control-compact {
  font: var(--type-small);
  min-block-size: 36px;
}
input.control {
  inline-size: 100%;
}
.check {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  min-block-size: 32px;
}
.check input {
  inline-size: 18px;
  block-size: 18px;
  accent-color: var(--ink);
  margin: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-8);
  min-block-size: 40px;
  padding: 0 var(--space-16);
  font: 600 15px / 20px var(--font-sans);
  border-radius: var(--radius-control);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
/* In the dark theme Ink's token is the light one, so Sama's primary turns into a light button with dark text. */
.btn-primary {
  background: var(--ink);
  color: var(--surface);
}
.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--control-border);
}
.btn-secondary:hover {
  border-color: var(--ink);
}
.btn-quiet {
  background: transparent;
  color: var(--ink);
  font-weight: 400;
  padding: 0 var(--space-8);
}
.btn-quiet:hover {
  text-decoration: underline;
}
.btn-danger {
  background: var(--error-fill);
  color: var(--on-fill);
}
.btn-icon {
  padding: 0;
  inline-size: 40px;
}

/* Lucide's interface icons and the kit's service glyphs, drawn in the text colour. */
.icon,
.glyph {
  display: inline-block;
  flex: none;
  inline-size: 16px;
  block-size: 16px;
  background: currentColor;
  mask: var(--icon) center / contain no-repeat;
  -webkit-mask: var(--icon) center / contain no-repeat;
}
.glyph {
  inline-size: 20px;
  block-size: 20px;
}
.glyph-48 {
  inline-size: 48px;
  block-size: 48px;
  color: var(--muted);
}
[dir="rtl"] .icon.flips {
  transform: scaleX(-1);
}

/* The header's tools */
.switch,
.tabs {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  background: var(--surface-sunken);
  border-radius: var(--radius-control);
}
.switch a,
.tabs a {
  padding: var(--space-8) var(--space-16);
  border-radius: calc(var(--radius-control) - 2px);
  color: var(--muted);
  font: var(--type-small);
  text-decoration: none;
}
.switch a[aria-current="page"],
.tabs a[aria-current="page"] {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 0 0 1px var(--line);
}
.tabs {
  margin-block-end: var(--space-16);
}
.region {
  font: var(--type-small);
  color: var(--muted);
}
.region code {
  font: var(--type-code);
  color: var(--ink);
}
.person {
  font: var(--type-small);
  color: var(--muted);
}
/* The Sample data badge: Label style, Ink on warning-tint, a pill (B12). */
.badge-sample {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-12);
  font: var(--type-label);
  color: var(--ink);
  background: var(--warning-tint);
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

/* The sections, with the nine services as the brand's service list: glyph, name, job beneath. */
.nav-title {
  margin: var(--space-24) var(--space-12) var(--space-8);
  font: var(--type-label);
  color: var(--muted);
}
.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
}
.nav-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: var(--space-8) var(--space-12);
  border-radius: var(--radius-control);
  color: var(--ink);
  text-decoration: none;
}
.nav-item:hover {
  background: var(--surface-sunken);
}
.nav-item[aria-current="page"] {
  background: var(--sand);
  font-weight: 600;
}
.nav-item .glyph {
  margin-block-start: 2px;
}
.service-words {
  display: flex;
  flex-direction: column;
}
.service-name {
  font-weight: 500;
}
.nav-item[aria-current="page"] .service-name {
  font-weight: 600;
}
.service-job {
  font: var(--type-small);
  color: var(--muted);
}

/* Pages */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-16);
  margin-block-end: var(--space-24);
}
.page-head h1 {
  font: var(--type-heading-1);
}
:lang(ar) .page-head h1 {
  font: var(--type-heading-1-ar);
}
.page-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-8);
  margin-block-start: var(--space-4);
  color: var(--muted);
}
.page-actions,
.row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-8);
}
.row {
  margin-block-start: var(--space-16);
}
.card {
  align-content: start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: var(--space-24);
  margin-block-end: var(--space-24);
  display: grid;
  gap: var(--space-16);
}
.card-title {
  font: var(--type-heading-3);
}
.cards-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
  gap: 0 var(--space-24);
}

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
}
.card .table-wrap {
  border-radius: var(--radius-popover);
}
/* A page's own table with a card below it, as on the Machines page. */
.table-wrap + .card {
  margin-block-start: var(--space-24);
}
table {
  inline-size: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
th {
  text-align: start;
  font: var(--type-label);
  color: var(--muted);
  background: var(--surface-sunken);
  padding: var(--space-12) var(--space-16);
  white-space: nowrap;
}
td {
  padding: var(--space-12) var(--space-16);
  border-block-start: 1px solid var(--line);
  vertical-align: top;
}
th.num,
td.num {
  text-align: end;
  white-space: nowrap;
}
/* A number with a Latin unit (410 MB) reads left to right inside an Arabic table too. */
td.num {
  unicode-bidi: plaintext;
}
.nowrap {
  white-space: nowrap;
}
td.actions {
  text-align: end;
  white-space: nowrap;
}
td.actions .btn + .btn {
  margin-inline-start: var(--space-4);
}
/* More than two actions on a row: one under the other, so the table keeps its width. */
.actions-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-4);
}
td.actions .actions-stack .btn + .btn {
  margin-inline-start: 0;
}
.cell-note {
  display: block;
  font: var(--type-small);
  color: var(--muted);
}
/* One item a line in a narrow column, such as a machine's roles. */
.cell-line {
  display: block;
  white-space: nowrap;
}
.cell-strong {
  display: block;
  font-weight: 600;
}
ul.plain {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-4);
}

/* States: a tint, the status colour on the icon, Ink words (B12); never colour alone. */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px 2px 8px;
  font: var(--type-label);
  color: var(--ink);
  border-radius: var(--radius-pill);
  white-space: nowrap;
  vertical-align: middle;
}
.pill .icon {
  inline-size: 14px;
  block-size: 14px;
}
.pill-success {
  background: var(--success-tint);
}
.pill-success .icon {
  color: var(--success);
}
.pill-warning {
  background: var(--warning-tint);
}
.pill-warning .icon {
  color: var(--warning);
}
.pill-error {
  background: var(--error-tint);
}
.pill-error .icon {
  color: var(--error);
}
.pill-info {
  background: var(--info-tint);
}
.pill-info .icon {
  color: var(--info);
}
.pill-neutral {
  background: var(--surface-sunken);
}
.pill-neutral .icon {
  color: var(--muted);
}

.banner {
  display: flex;
  align-items: flex-start;
  gap: var(--space-12);
  padding: var(--space-12) var(--space-16);
  border-radius: var(--radius-card);
  color: var(--ink);
  margin-block-end: var(--space-16);
}
.banner .icon {
  margin-block-start: 4px;
}
.banner strong {
  font-weight: 600;
}
.banner-success {
  background: var(--success-tint);
}
.banner-success .icon {
  color: var(--success);
}
.banner-warning {
  background: var(--warning-tint);
}
.banner-warning .icon {
  color: var(--warning);
}
.banner-error {
  background: var(--error-tint);
}
.banner-error .icon {
  color: var(--error);
}
.banner-info {
  background: var(--info-tint);
}
.banner-info .icon {
  color: var(--info);
}

/* An empty state: what is true now, what to do, one button; the service's glyph at 48 px in Muted. */
.empty {
  display: grid;
  justify-items: center;
  gap: var(--space-8);
  padding: var(--space-48) var(--space-24);
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
}
.empty-now {
  font-weight: 600;
}
.empty-todo {
  color: var(--muted);
  max-inline-size: 48ch;
}

/* Use against the quota */
.meters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-24);
}
.meter {
  display: grid;
  gap: var(--space-8);
  justify-items: start;
}
.meter-top {
  display: flex;
  justify-content: space-between;
  inline-size: 100%;
  gap: var(--space-8);
}
.meter-num {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.meter-track {
  display: block;
  inline-size: 100%;
  block-size: 8px;
  background: var(--surface-sunken);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.meter-fill {
  display: block;
  block-size: 100%;
  background: var(--ink);
  border-radius: var(--radius-pill);
}

.service-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-8);
}
.service-link {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: var(--space-12);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  color: var(--ink);
  text-decoration: none;
}
.service-link:hover {
  border-color: var(--control-border);
}

.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--space-12) var(--space-24);
  margin: 0;
}
.facts dt {
  font: var(--type-label);
  color: var(--muted);
  padding-block-start: 3px;
}
.facts dd {
  margin: 0;
  min-inline-size: 0;
  overflow-wrap: anywhere;
}

/* Dialogs */
.dialog {
  inline-size: min(560px, calc(100vw - 32px));
  max-block-size: calc(100vh - 32px);
  padding: 0;
  color: var(--ink);
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-popover);
}
.dialog::backdrop {
  background: color-mix(in srgb, var(--ink) 40%, transparent);
}
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-16);
  padding: var(--space-16) var(--space-24);
  border-block-end: 1px solid var(--line);
}
.dialog-head h2 {
  font: var(--type-heading-2);
}
.dialog-body {
  display: grid;
  gap: var(--space-16);
  padding: var(--space-24);
}
.dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-8);
  padding: var(--space-16) var(--space-24);
  border-block-start: 1px solid var(--line);
}
.dialog-form {
  margin: 0;
}
.field {
  display: grid;
  gap: 6px;
  border: 0;
  margin: 0;
  padding: 0;
  min-inline-size: 0;
}
.field > label,
.field > legend {
  font: var(--type-label);
  padding: 0;
  margin-block-end: 2px;
}
.field-help {
  font: var(--type-small);
  color: var(--muted);
}
.field-error {
  display: flex;
  align-items: center;
  gap: 6px;
  font: var(--type-small);
  color: var(--error);
}
.field-error[hidden] {
  display: none;
}
.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-16);
}
.permits {
  max-block-size: 240px;
  overflow: auto;
}
.permits .check span {
  font: var(--type-code);
}
.secret {
  display: block;
  padding: var(--space-12);
  background: var(--surface-sunken);
  border-radius: var(--radius-control);
  overflow-wrap: anywhere;
  user-select: all;
}
.log {
  margin: 0;
  max-block-size: 60vh;
  overflow: auto;
  padding: var(--space-12);
  background: var(--surface-sunken);
  border-radius: var(--radius-control);
  white-space: pre-wrap;
}
.log-err {
  color: var(--error);
}

.toasts {
  position: fixed;
  inset-block-end: var(--space-24);
  inset-inline: 0;
  display: grid;
  justify-items: center;
  gap: var(--space-8);
  pointer-events: none;
  z-index: 30;
}
.toast {
  max-inline-size: min(480px, calc(100vw - 32px));
  padding: var(--space-12) var(--space-16);
  background: var(--ink);
  color: var(--surface);
  border-radius: var(--radius-control);
  box-shadow: var(--shadow-popover);
}

.plain-page {
  min-block-size: 100vh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: var(--space-24);
  padding: var(--space-64) var(--space-16);
  text-align: center;
}
.plain-title {
  font: var(--type-heading-2);
}

/* Aql's page: forms, lists and the blocks of code it proposes. */
.form {
  display: grid;
  gap: var(--space-16);
}
.list {
  margin: 0;
  padding-inline-start: var(--space-24);
  display: grid;
  gap: var(--space-4);
}
.card-subtitle {
  font: var(--type-heading-3);
}
.code-block {
  display: grid;
  gap: var(--space-8);
  justify-items: start;
}
.code-block .log {
  inline-size: 100%;
}
.proposal {
  display: grid;
  gap: var(--space-16);
}

/* Sanad's panel (the SanadCard pattern): Sanad keeps its own tile and name on Sand, never Sama's colours. */
.sanad-tile {
  flex: none;
  inline-size: 20px;
  block-size: 20px;
  border-radius: var(--radius-tile);
}
.sanad-panel {
  position: fixed;
  inset-block: 0;
  inset-inline-end: 0;
  z-index: 20;
  inline-size: min(440px, 100vw);
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: var(--space-16);
  padding: var(--space-16) var(--space-24) var(--space-24);
  background: var(--surface-raised);
  border-inline-start: 1px solid var(--line);
  box-shadow: var(--shadow-popover);
  overflow: hidden;
}
@media (min-width: 1100px) {
  .app.sanad-on {
    padding-inline-end: min(440px, 100vw);
  }
}
.sanad-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-16);
}
.sanad-name-row {
  display: flex;
  align-items: center;
  gap: var(--space-8);
}
.sanad-name {
  font: var(--type-body);
  font-weight: 600;
  color: var(--gold);
}
.sanad-intro {
  font: var(--type-small);
  color: var(--muted);
}
.sanad-turns {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  align-content: start;
  gap: var(--space-16);
  overflow-y: auto;
}
.sanad-turn {
  display: grid;
  gap: var(--space-8);
}
.sanad-question {
  justify-self: end;
  max-inline-size: 85%;
  padding: var(--space-8) var(--space-12);
  background: var(--surface-sunken);
  border-radius: var(--radius-control);
  white-space: pre-wrap;
}
.sanad-card {
  display: grid;
  gap: 10px;
  padding: var(--space-16);
  background: var(--sand);
  border-radius: var(--radius-card);
}
.sanad-answer {
  font: var(--type-body);
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.sanad-meta {
  font: var(--type-small);
  color: var(--muted);
}
.sanad-form {
  display: grid;
  gap: var(--space-8);
}

/* Narrow screens: the sections become a row above the page. */
@media (max-width: 900px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "top" "side" "main";
  }
  .side {
    border-inline-end: 0;
    border-block-end: 1px solid var(--line);
    padding: var(--space-8) var(--space-16);
    overflow-x: auto;
  }
  .side .nav-list {
    grid-auto-flow: column;
  }
  .nav-title,
  .service-job {
    display: none;
  }
  .side {
    display: flex;
    gap: var(--space-4);
  }
  .main {
    padding: var(--space-24) var(--space-16) var(--space-48);
  }
  .topbar {
    padding: var(--space-12) var(--space-16);
  }
}

/* Billing (sama-billing): an invoice laid out as the document it is, and printed without the console around it. */
.card-subtitle {
  font: var(--type-label);
  color: var(--muted);
}
.back-link {
  margin-block-end: var(--space-16);
}
/* The invoice is TendaJi's: the symbol and wordmark from the kit, never mirrored (B80). */
.tendaji-mark {
  display: inline-flex;
  align-items: center;
  gap: var(--space-8);
  direction: ltr;
}
.tendaji-mark .wordmark {
  height: 25px;
  width: auto;
}
.invoice-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-16);
  padding-block-end: var(--space-16);
  border-block-end: 1px solid var(--line);
}
.invoice-head > div {
  display: flex;
  align-items: center;
  gap: var(--space-12);
}
.invoice-title {
  font: var(--type-heading-2);
}
.invoice-parties {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: var(--space-24);
}
.invoice-party h3 {
  font: var(--type-label);
  color: var(--muted);
  margin-block-end: var(--space-4);
}
.invoice-sums {
  display: flex;
  justify-content: flex-end;
}
.invoice-sums .facts dd {
  text-align: end;
  font-variant-numeric: tabular-nums;
}
.invoice-pay {
  padding: var(--space-16);
  background: var(--surface-sunken);
  border-radius: var(--radius-control);
}
@media print {
  .topbar,
  .side,
  .page-head,
  .back-link,
  .toasts {
    display: none;
  }
  .app {
    display: block;
  }
  .main {
    padding: 0;
    max-inline-size: none;
  }
  html,
  body {
    background: var(--surface);
  }
  .invoice-doc {
    border: none;
    padding: 0;
  }
}

/* Requests and Visits (sama-website): the request's words as they wrote them, the dialog's sections, and the counts. */
.quote {
  margin: 0;
  padding: var(--space-12) var(--space-16);
  border-inline-start: 3px solid var(--line);
  background: var(--surface-sunken);
  border-radius: var(--radius-control);
  white-space: pre-wrap;
}
.dialog-lead {
  color: var(--muted);
}
.dialog-section {
  font: var(--type-heading-3);
  margin: var(--space-8) 0 0;
}
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: var(--space-16);
  margin-block-end: var(--space-24);
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: var(--space-16) var(--space-24);
}
.stat p {
  margin: 0;
}
.stat-label {
  font: var(--type-label);
  color: var(--muted);
}
.stat-value {
  font: var(--type-heading-1);
  font-variant-numeric: tabular-nums;
}
.stat-detail {
  font: var(--type-small);
  color: var(--muted);
}
/* One series: the first chart colour, never a status colour (B13). */
.chart {
  inline-size: 100%;
  block-size: auto;
  max-block-size: 200px;
}
.chart-bar {
  fill: var(--chart-1);
}
.chart-table summary {
  cursor: pointer;
  color: var(--muted);
}
.site-pick {
  margin-block-end: var(--space-16);
}
