/* Atelo Systems.
 *
 * Layout: a deep navy rail holding the tabs, against a light working
 * canvas, so the control centre keeps its shape without the whole screen
 * being dark. Light is the default; dark follows the viewer.
 *
 * Every colour is a token. Settings writes these same names onto the root
 * element, so changing a colour there changes it everywhere.
 */

:root {
  color-scheme: light;

  /* The website's palette, so the dashboard and the public site are one
   * brand: paper, ink, muted, line and violet are its values exactly. */
  --bg: #faf9fb;
  --panel: #ffffff;
  --panel-2: #f1eef6;
  --field: #fbfafd;
  --line: #e7e2eb;
  --menu: #27243c;

  /* Ink */
  --text: #202033;
  --muted: #696778;
  --menu-text: #bdb9d0;
  --menu-active: #342f4d;

  /* Meaning. Green and amber are the website's own; late takes its
   * burgundy, which is the brand's second colour and reads as a warning
   * without shouting over the violet. */
  --highlight: #5c3cba;
  --on-highlight: #ffffff;
  --done: #3d987b;
  --waiting: #a8701a;
  --late: #8c375a;

  --shadow: 0 1px 2px rgba(32, 32, 51, 0.05), 0 8px 24px -12px rgba(32, 32, 51, 0.16);
  --shadow-lift: 0 2px 6px rgba(32, 32, 51, 0.08), 0 24px 48px -20px rgba(32, 32, 51, 0.28);

  --menu-width: clamp(196px, 17vw, 244px);
  --radius: 12px;
  --radius-sm: 9px;

  --sans: "Instrument Sans", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --serif: "Instrument Serif", Georgia, "Times New Roman", serif;
}

/* No dark pair. The website is light only, and the dashboard shares its
 * palette, so a second set of colours would be a second brand. */

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

[hidden] { display: none !important; }

::selection { background: color-mix(in srgb, var(--highlight) 24%, transparent); }

:focus-visible { outline: 2px solid var(--highlight); outline-offset: 2px; }

/* --- Sign in ------------------------------------------------------------- */

.gate {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background:
    radial-gradient(120% 90% at 50% -10%, color-mix(in srgb, var(--highlight) 10%, transparent), transparent 60%),
    var(--bg);
}

.gate-card {
  width: 100%;
  max-width: 392px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px;
  box-shadow: var(--shadow-lift);
}

.gate-mark {
  font-family: var(--serif);
  font-size: 30px;
  line-height: 1.1;
  font-weight: 400;
  margin: 0 0 24px;
  letter-spacing: -0.2px;
}

.gate-mark span { color: var(--highlight); font-style: italic; }

/* --- Shell --------------------------------------------------------------- */

.shell {
  display: grid;
  grid-template-columns: var(--menu-width) 1fr;
  min-height: 100%;
}

.menu {
  background: var(--menu);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.menu-mark {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px 20px;
  margin: 0;
}

.menu-badge {
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 10px;
  background: var(--highlight);
  color: var(--on-highlight);
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.menu-name { min-width: 0; }

.menu-name strong {
  display: block;
  color: #ffffff;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-name span {
  display: block;
  color: var(--menu-text);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-list {
  list-style: none;
  margin: 0;
  padding: 6px 12px;
  flex: 1;
  overflow-y: auto;
  display: grid;
  gap: 2px;
  align-content: start;
}

.menu-list button {
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  color: var(--menu-text);
  font: inherit;
  font-weight: 500;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: block;
  transition: background 0.14s, color 0.14s;
}

.menu-list button:hover { background: var(--menu-active); color: #ffffff; }

.menu-list button[aria-current="true"] {
  background: var(--panel);
  color: var(--text);
  font-weight: 600;
}

.menu-foot {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: 16px 22px;
  font-size: 13px;
  color: var(--menu-text);
}

.menu-foot strong {
  display: block;
  color: #ffffff;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}

.main {
  padding: clamp(16px, 2.1vw, 30px) clamp(16px, 2.5vw, 34px) 72px;
  min-width: 0;
  max-width: none;
  width: 100%;
}

.bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.bar h1 {
  font-size: clamp(20px, 2.1vw, 26px);
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.5px;
  text-wrap: balance;
}

.bar-end { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin: 0 0 6px;
}

.eyebrow::before {
  content: "";
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: var(--highlight);
}

.titles { min-width: 0; }

/* Sections within a tab. */
.subtabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.subtabs button {
  background: none;
  border: 1px solid transparent;
  color: var(--muted);
  font-weight: 550;
  padding: 8px 15px;
  border-radius: 999px;
  transition: background 0.14s, color 0.14s;
}

.subtabs button:hover { color: var(--text); background: var(--panel); }

.subtabs button[aria-current="true"] {
  background: var(--menu);
  border-color: var(--menu);
  color: #ffffff;
  font-weight: 600;
}

.menu-open {
  display: none;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius-sm);
  width: 40px;
  height: 40px;
  font-size: 17px;
  cursor: pointer;
}

/* --- Panels -------------------------------------------------------------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(15px, 1.6vw, 22px);
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

.panel > h2 {
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--muted);
  margin: 0 0 18px;
}

.panel-split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
}

/* --- Figures ------------------------------------------------------------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.tile::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--tile-colour, var(--highlight));
}

.tile dt {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 8px;
}

.tile dd {
  margin: 0;
  font-size: 25px;
  font-weight: 650;
  letter-spacing: -0.6px;
  font-variant-numeric: tabular-nums;
}

/* --- Forms --------------------------------------------------------------- */

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 13px;
  font-weight: 550;
  color: var(--muted);
  margin-bottom: 6px;
}

input, select, textarea {
  width: 100%;
  background: var(--field);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font: inherit;
  font-size: 14.5px;
  transition: border-color 0.14s, box-shadow 0.14s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--highlight);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--highlight) 18%, transparent);
}

input[type="color"] { padding: 4px; height: 44px; cursor: pointer; }

textarea { min-height: 120px; resize: vertical; }

.row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0 16px;
}

button { font: inherit; cursor: pointer; }

.btn {
  background: var(--highlight);
  border: 1px solid var(--highlight);
  color: var(--on-highlight);
  font-weight: 600;
  font-size: 14px;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  transition: filter 0.14s;
}

.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.5; cursor: default; filter: none; }

.btn-flat {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  font-weight: 550;
  font-size: 14px;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  transition: border-color 0.14s, background 0.14s;
}

.btn-flat:hover { border-color: var(--highlight); background: var(--field); }

.btn-late {
  background: none;
  border: 1px solid var(--line);
  color: var(--late);
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 550;
}

.btn-late:hover { border-color: var(--late); background: color-mix(in srgb, var(--late) 8%, transparent); }

.btn-small { padding: 6px 11px; font-size: 12.5px; }

/* --- Tables -------------------------------------------------------------- */

.table-wrap { overflow-x: auto; margin-inline: calc(clamp(15px, 1.6vw, 22px) * -1); padding-inline: clamp(15px, 1.6vw, 22px); padding-bottom: 6px; }

table { width: 100%; border-collapse: collapse; }

th {
  text-align: left;
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  padding: 0 16px 11px 0;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

td {
  padding: 13px 16px 13px 0;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover td { background: var(--field); }

th:last-child, td:last-child { padding-right: 0; }

.num { text-align: right; font-variant-numeric: tabular-nums; }
.strong { font-weight: 600; }

/* --- State --------------------------------------------------------------- */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid transparent;
}

.tag::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.tag-done    { color: var(--done);    background: color-mix(in srgb, var(--done) 13%, transparent);    border-color: color-mix(in srgb, var(--done) 26%, transparent); }
.tag-waiting { color: var(--waiting); background: color-mix(in srgb, var(--waiting) 14%, transparent); border-color: color-mix(in srgb, var(--waiting) 28%, transparent); }
.tag-late    { color: var(--late);    background: color-mix(in srgb, var(--late) 12%, transparent);    border-color: color-mix(in srgb, var(--late) 26%, transparent); }
.tag-off     { color: var(--muted);   background: var(--panel-2);                                      border-color: var(--line); }

.empty {
  padding: 46px 0;
  text-align: center;
  color: var(--muted);
}

.notice {
  border-radius: var(--radius-sm);
  padding: 12px 15px;
  margin-bottom: 16px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid;
}

.notice-late    { color: var(--late);    border-color: color-mix(in srgb, var(--late) 32%, transparent);    background: color-mix(in srgb, var(--late) 9%, transparent); }
.notice-done    { color: var(--done);    border-color: color-mix(in srgb, var(--done) 32%, transparent);    background: color-mix(in srgb, var(--done) 9%, transparent); }
.notice-waiting { color: var(--waiting); border-color: color-mix(in srgb, var(--waiting) 34%, transparent); background: color-mix(in srgb, var(--waiting) 10%, transparent); }

/* --- Switches ------------------------------------------------------------ */

.switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  flex: none;
}

.switch input { opacity: 0; width: 0; height: 0; position: absolute; }

.switch span {
  position: absolute;
  inset: 0;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: background 0.16s, border-color 0.16s;
}

.switch span::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.16s, background 0.16s;
}

.switch input:checked + span { background: var(--highlight); border-color: var(--highlight); }
.switch input:checked + span::after { transform: translateX(18px); background: var(--on-highlight); }
.switch input:disabled + span { opacity: 0.45; }
.switch input:focus-visible + span { outline: 2px solid var(--highlight); outline-offset: 2px; }

/* --- Side panel ---------------------------------------------------------- */

.drawer-back {
  position: fixed;
  inset: 0;
  background: rgba(14, 14, 16, 0.45);
  backdrop-filter: blur(2px);
  z-index: 40;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 460px;
  max-width: 100%;
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lift);
  z-index: 41;
  display: flex;
  flex-direction: column;
}

.drawer-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
}

.drawer-head h2 { font-size: 17px; font-weight: 600; margin: 0; letter-spacing: -0.3px; }

.drawer-close {
  margin-left: auto;
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 6px;
}

.drawer-close:hover { color: var(--text); background: var(--field); }

.drawer-body { padding: 24px; overflow-y: auto; flex: 1; }

.drawer-body > h2 {
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--muted);
}

.drawer-foot {
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 8px;
  background: var(--panel-2);
}

.drawer-foot .btn-late { margin-left: auto; }

/* --- Email Studio -------------------------------------------------------- */

.mail-list { display: grid; gap: 10px; }

.mail-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.mail-row > div { flex: 1; min-width: 0; }
.mail-row strong { font-weight: 600; display: block; }
.mail-row small { color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.mail-preview {
  background: #ffffff;
  color: #1a1a1a;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 22px;
  font: 14px/1.6 Arial, Helvetica, sans-serif;
  word-break: break-word;
}

.mail-preview-head {
  border-bottom: 1px solid #e3e3e3;
  padding-bottom: 12px;
  margin-bottom: 14px;
  font-size: 13px;
  color: #555;
}

/* --- Invoice lines ------------------------------------------------------- */

.lines { display: grid; gap: 10px; margin-bottom: 14px; }

.line {
  display: grid;
  grid-template-columns: 1fr 76px 108px 38px;
  gap: 8px;
  align-items: start;
}

.line-drop { display: none; }

.totals {
  display: grid;
  gap: 9px;
  margin-left: auto;
  max-width: 290px;
  font-variant-numeric: tabular-nums;
}

.totals div { display: flex; justify-content: space-between; gap: 20px; }
.totals span:first-child { color: var(--muted); }
.totals .big {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  font-weight: 650;
  font-size: 18px;
}
.totals .big span:first-child { color: var(--text); }

/* --- Control centre grid ------------------------------------------------- */

.control-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.control-acts { display: flex; gap: 8px; margin-left: auto; }

.tally { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* The first column stays put, so it is always clear which row is being set. */
.ctl td.name, .ctl th:first-child {
  position: sticky;
  left: 0;
  background: var(--panel);
  z-index: 1;
  font-weight: 600;
}

.ctl td.name.sub { padding-left: 22px; font-weight: 400; color: var(--muted); }

.ctl td.group, .ctl tr:has(.group) td {
  background: var(--panel-2);
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--muted);
  padding-top: 10px;
  padding-bottom: 10px;
}

.ctl tr.off td.name { opacity: 0.5; }
.ctl td.set { text-align: center; width: 1%; white-space: nowrap; }
.ctl th:not(:first-child) { text-align: center; }

/* --- Phone --------------------------------------------------------------- */

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }

  .menu {
    position: fixed;
    inset: 0 auto 0 0;
    width: 272px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-lift);
  }

  .menu[data-open="true"] { transform: none; }

  .menu-back { position: fixed; inset: 0; background: rgba(14, 14, 16, 0.45); z-index: 49; }

  .menu-open { display: block; }

  .main { padding: 18px 16px 64px; }

  .bar h1 { font-size: 21px; }

  .panel { padding: 18px; }

  .table-wrap { margin: 0 -18px -18px; padding: 0 18px 6px; }

  .drawer { width: 100%; }

  .line { grid-template-columns: 1fr 1fr; }
  .line-drop { display: block; grid-column: 1 / -1; }
  .line > button { grid-column: 1 / -1; }
  .totals { max-width: none; }

  /* Sections scroll sideways rather than stacking into a block of pills. */
  .subtabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    margin-left: -16px;
    margin-right: -16px;
    padding: 0 16px 2px;
  }

  .subtabs::-webkit-scrollbar { display: none; }
  .subtabs button { flex: none; }

  .control-bar { gap: 10px; }
  .control-acts { margin-left: 0; width: 100%; }
  .control-acts button { flex: 1; }

  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile { padding: 14px 16px; }
  .tile dd { font-size: 21px; }

  .row { grid-template-columns: 1fr; }

  .drawer-foot { flex-wrap: wrap; }
  .drawer-foot button { flex: 1; }
  .drawer-foot .btn-late { margin-left: 0; }

  .mail-row { flex-wrap: wrap; gap: 10px; }
  .mail-row > div { flex-basis: 100%; }

  /* Tap targets stay comfortable. */
  input, select, textarea { padding: 11px 13px; font-size: 16px; }
  .btn, .btn-flat, .btn-late { padding: 11px 16px; }
}

@media (max-width: 420px) {
  .tiles { grid-template-columns: 1fr; }
  .bar h1 { font-size: 19px; }
}

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

/* --- Website --------------------------------------------------------------
 *
 * Three columns: which part of the page, its fields, and the page itself.
 * Each is a panel, like every other screen.
 */

.site-edit {
  display: grid;
  grid-template-columns: clamp(150px, 14vw, 190px) minmax(260px, 1fr) minmax(360px, 1.25fr);
  gap: 14px;
  align-items: start;
}

/* Which part of the page. */
.site-places {
  padding: 8px;
  display: grid;
  gap: 2px;
  position: sticky;
  top: 18px;
}

.place {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  color: var(--muted);
  font: 550 14px var(--sans, inherit);
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.place span:first-child { flex: 1; min-width: 0; }
.place:hover { background: var(--field); color: var(--text); }
.place.on { background: var(--panel-2); color: var(--text); font-weight: 600; }

/* The fields. */
.site-fields { min-width: 0; display: grid; gap: 14px; }
.site-fields .field:last-child { margin-bottom: 0; }

/* Colour rows, which read better than a grid of unlabelled squares. */
.swatch {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.swatch:last-of-type { border-bottom: 0; margin-bottom: 12px; }
.swatch input[type="color"] { width: 44px; height: 36px; flex: none; padding: 3px; }
.swatch strong { display: block; font-weight: 600; font-size: 14.5px; }
.swatch small { color: var(--muted); font-size: 12.5px; }

.rank {
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 50%;
  background: var(--panel-2);
  color: var(--muted);
  display: grid;
  place-items: center;
  font-size: 11.5px;
  font-weight: 650;
}

/* The page itself. */
.site-preview { position: sticky; top: 18px; padding: 0; overflow: hidden; }

.site-preview-bar {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
}

#site-frame {
  display: block;
  width: 100%;
  border: 0;
  background: #fff;
  height: clamp(420px, calc(100vh - 250px), 900px);
  transition: width 0.18s ease;
}

#site-frame.phone { width: 375px; margin-inline: auto; border-inline: 1px solid var(--line); }

@media (max-width: 1240px) {
  .site-edit { grid-template-columns: minmax(240px, 1fr) minmax(320px, 1.1fr); }
  .site-places { grid-column: 1 / -1; position: static; display: flex; flex-wrap: wrap; }
  .place { width: auto; }
}

@media (max-width: 880px) {
  .site-edit { grid-template-columns: 1fr; }
  .site-preview { position: static; }
  #site-frame { height: 62vh; }
}
