:root {
  color-scheme: light;
  --ink: #1e1e1e; --muted: #5f6b78; --link: #0066cc;
  --face: #f0f0f0; --client: #ffffff; --bar-top: #fbfcfe; --bar-bottom: #e4ebf3; --field: #ffffff;
  --edge: #abadb3; --edge-focus: #3d7bad; --line: #e4e9ef;
  --btn: linear-gradient(#f2f2f2, #ebebeb 48%, #dddddd 50%, #cfcfcf);
  --btn-hover: linear-gradient(#eaf6fd, #d9f0fc 48%, #bee6fd 50%, #a7d9f5);
  --btn-on: linear-gradient(#c2e4f6, #91ccea);
  --row-hover: linear-gradient(#f5fafd, #e3f1fb);
  --row-edge: #b8d6fb;
  --zebra: #f7f9fc;
  --box: #c6cdd5; --shine: rgb(255 255 255 / .55); --btn-edge: #707070; --tab-edge: #898c95;
  --tip: linear-gradient(#ffffff, #e4e5f0); --tip-ink: #4c4c4c; --tip-edge: #767676;
  --done: #1b7f3b; --warn: #a85a00; --danger: #c0362c; --doing: #0066cc;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--face); }
body {
  margin: 0; min-height: 100vh; background: var(--face); color: var(--ink);
  font: 13px/1.4 "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1 { margin: 0; font-size: 13px; font-weight: 600; }
a { color: var(--link); }
[hidden] { display: none !important; }
:focus-visible { outline: 1px dotted var(--ink); outline-offset: 1px; }

/* Explorer's command bar */
.cmdbar {
  display: flex; align-items: center; gap: 2px; min-height: 32px; padding: 2px 6px;
  background: linear-gradient(var(--bar-top), var(--bar-bottom)); border-bottom: 1px solid var(--edge);
}
.spacer { flex: 1; }
.tool, .btn-plain {
  display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 9px; background: none; border: 1px solid transparent; border-radius: 3px; color: var(--ink); white-space: nowrap;
}
.tool:hover, .btn-plain:hover { background: var(--btn-hover); border-color: var(--edge-focus); }
.tool svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.count { font-variant-numeric: tabular-nums; color: var(--muted); }
.pad { padding: 12px; }

/* Buttons */
.btn-primary, .btn-plain.edit-cancel, .chip, .tabs button, .btn-win {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 26px; padding: 0 14px;
  background: var(--btn); border: 1px solid var(--btn-edge); border-radius: 3px; color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--shine); white-space: nowrap; text-decoration: none;
  transition: background-color .15s ease;
}
.btn-primary { border-color: var(--edge-focus); box-shadow: inset 0 0 0 1px var(--shine); min-width: 92px; }
.btn-primary:hover, .chip:hover, .tabs button:hover, .btn-win:hover { background: var(--btn-hover); border-color: var(--edge-focus); }
.btn-primary:active, .chip[aria-pressed="true"], .tabs button[aria-selected="true"] { background: var(--btn-on); border-color: #2c628b; box-shadow: inset 0 1px 3px rgb(0 0 0 / .3); }
.btn-primary kbd { font: inherit; font-size: 11px; opacity: .65; }

/* Fields */
.qa input, .qa textarea, .search, .edit input, .edit textarea, .login input, .stack input {
  width: 100%; border: 1px solid var(--edge); border-top-color: #7a7e86; border-radius: 2px; background: var(--field); padding: 4px 7px; color: var(--ink); outline: 0;
}
.qa input:hover, .qa textarea:hover, .search:hover, .edit input:hover, .edit textarea:hover, .login input:hover, .stack input:hover { border-color: #7eb4ea; }
.qa input:focus, .qa textarea:focus, .search:focus, .edit input:focus, .edit textarea:focus, .login input:focus, .stack input:focus { border-color: var(--edge-focus); box-shadow: 0 0 3px rgb(61 123 173 / .55); }
input::placeholder, textarea::placeholder { color: var(--muted); font-style: italic; font-weight: 400; opacity: .85; }

/* Add form: a group box */
.qa { position: relative; display: grid; grid-template-columns: 118px minmax(0, 1fr); gap: 9px 10px; margin-top: 7px; padding: 15px 11px 11px; border: 1px solid var(--box); border-radius: 3px; }
.group-title { position: absolute; top: -9px; left: 8px; padding: 0 5px; background: var(--face); color: var(--link); }
.popup .group-title { display: none; }
.qa-note, .qa-url, .qa-actions, .qa-saved { grid-column: 1 / -1; }
.qa.is-simple [data-field="order"], .qa.is-simple [data-field="email"] { display: none; }
.qa-field label { display: block; margin-bottom: 3px; white-space: nowrap; }
.qa-input { position: relative; }
.qa input { height: 25px; padding-right: 22px; text-overflow: ellipsis; }
.qa [data-field="order"] input { font-weight: 700; }
.qa textarea, .edit textarea { display: block; resize: vertical; min-height: 62px; }
.qa-field.is-auto input { background: #fbf7d8; }
.qa textarea.is-missing { border-color: var(--danger); box-shadow: 0 0 3px var(--danger); }
.qa-clear { position: absolute; top: 2px; right: 2px; width: 20px; height: 21px; padding: 0; border: 0; border-radius: 2px; background: none; color: var(--muted); font-size: 14px; line-height: 1; display: none; }
.qa-clear:hover { color: var(--danger); }
.qa-field.has-value .qa-clear { display: block; }
.qa-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.qa-reset { margin-right: auto; padding: 0; background: none; border: 0; color: var(--link); }
.qa-reset:hover { text-decoration: underline; }
.qa-saved { margin: 0; color: var(--done); font-weight: 600; }
.qa-saved.is-error { color: var(--danger); }
.qa-saved:empty { display: none; }

/* Popup */
.popup { width: 380px; min-height: 0; }
.popup .qa { margin-top: 0; padding-top: 11px; }
.popup .is-saved { min-height: 170px; }
.popup:has(.is-saved) .qa > :not(.qa-saved) { visibility: hidden; }
.popup .is-saved .qa-saved { position: absolute; inset: 60px 0 auto; text-align: center; font-size: 14px; }

.login { display: grid; gap: 3px; }
.login label { margin-top: 7px; }
.login input { height: 26px; }
.login .btn-primary { justify-self: end; margin-top: 12px; }
.login-error { margin: 8px 0 0; color: var(--danger); }

.pad-list { padding: 0 12px 12px; }
#list { container-type: inline-size; }

/* Tabs on a property sheet: one colour per account */
.board-tabs { display: flex; gap: 2px; padding: 0 3px; position: relative; z-index: 1; margin-top: 8px; margin-bottom: -1px; overflow-x: auto; overflow-y: hidden; }
.board-tab {
  display: inline-flex; align-items: center; gap: 7px; height: 28px; margin-top: 3px; padding: 0 11px; flex: none;
  background: linear-gradient(#f4f6f8, #dde3ea); color: var(--ink); border: 1px solid var(--tab-edge); border-bottom: 0; border-radius: 3px 3px 0 0;
}
.board-tab:hover { background: var(--btn-hover); }
.board-tab[aria-selected="true"] { height: 31px; margin-top: 0; background: var(--client); border-top: 3px solid var(--board); font-weight: 600; }
.board-count {
  min-width: 18px; height: 18px; padding: 0 5px; display: grid; place-items: center; border-radius: 9px; font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums;
  background: linear-gradient(rgb(255 255 255 / .38), rgb(255 255 255 / .05) 50%, rgb(0 0 0 / .1) 50%), var(--board); color: var(--on-board);
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / .25);
}
.tab-page { border: 1px solid var(--tab-edge); background: var(--client); }
.rows:empty { display: none; }

.list-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 8px; background: linear-gradient(var(--bar-top), var(--bar-bottom)); border-bottom: 1px solid var(--line); }
.tabs { display: flex; }
.tabs button { padding: 0 11px; border-radius: 0; margin-left: -1px; }
.tabs button:first-child { border-radius: 3px 0 0 3px; margin-left: 0; }
.tabs button:last-child { border-radius: 0 3px 3px 0; }
.search {
  flex: 1 1 130px; height: 26px; padding-right: 26px; min-width: 0;
  background: var(--field) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23486a93' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat right 7px center / 14px;
}

.list-head { display: none; }
.rows { list-style: none; margin: 0; padding: 3px; }

/* Narrow (side panel, phone): order and email on top, because that's what gets looked for */
.row {
  display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; column-gap: 8px; row-gap: 3px;
  grid-template-areas:
    "check order  actions"
    "check email  actions"
    "check note   note"
    "check url    url"
    "check foot   foot";
  padding: 8px 6px; border: 1px solid transparent; border-bottom-color: var(--line); border-radius: 2px;
}
.row:hover { background: var(--row-hover); border-color: var(--row-edge); }
.row.is-new { animation: row-in .22s ease-out; }
@keyframes row-in { from { opacity: 0; transform: translateY(-5px); } }

.cell { min-width: 0; }
.cell-check { grid-area: check; }
.cell-order { grid-area: order; display: flex; align-items: center; gap: 4px; }
.cell-email { grid-area: email; }
.cell-note { grid-area: note; white-space: pre-wrap; overflow-wrap: anywhere; }
.cell-url { grid-area: url; }
.cell-actions { grid-area: actions; display: flex; margin: -3px -2px 0 0; }
.cell-order:empty, .cell-email:empty, .cell-url:empty { display: none; }
.cell-status { grid-area: foot; justify-self: start; }
.cell-when { grid-area: foot; justify-self: end; align-self: center; color: var(--muted); font-size: 12px; }

.check {
  width: 15px; height: 15px; margin-top: 2px; padding: 0; display: grid; place-items: center; border: 1px solid #8e8f8f; border-radius: 2px;
  background: linear-gradient(#e6e6e6, #fff); box-shadow: inset 0 0 0 1px #fff, inset 0 0 0 2px #cfcfcf;
}
.check svg { width: 13px; height: 13px; fill: none; stroke: #2a5ea0; stroke-width: 3.4; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.check:hover { border-color: var(--edge-focus); box-shadow: inset 0 0 0 1px #fff, inset 0 0 0 2px #a7d9f5; }
.is-done .check svg { opacity: 1; }
.is-done .cell-note { color: var(--muted); }
.row[data-status="done"] .cell-note { text-decoration: line-through; }

.copy { max-width: 100%; padding: 0; background: none; border: 0; color: var(--link); text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.copy:hover { text-decoration: underline; }
.cell-order .copy { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }
.order-open { display: grid; place-items: center; width: 20px; height: 20px; color: var(--muted); border-radius: 2px; }
.order-open:hover { color: var(--link); }
.order-open svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.page-link { display: block; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-link:hover { color: var(--link); }

/* Combo box */
.status-select, .status-pill { height: 22px; font-size: 12px; max-width: 100%; }
.status-select {
  appearance: none; padding: 0 20px 0 6px; border: 1px solid var(--edge); border-radius: 2px; cursor: pointer;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M0 0h10L5 6z' fill='%23506478'/%3E%3C/svg%3E") no-repeat right 6px center / 8px, var(--btn);
}
.status-select:hover { border-color: var(--edge-focus); }
.status-pill { display: inline-flex; align-items: center; font-weight: 600; }
[data-status="doing"].status-select, [data-status="doing"].status-pill { color: var(--doing); font-weight: 600; }
[data-status="waiting"].status-select, [data-status="waiting"].status-pill { color: var(--warn); font-weight: 600; }
[data-status="done"].status-select, [data-status="done"].status-pill { color: var(--done); font-weight: 600; }
[data-status="dropped"].status-select, [data-status="dropped"].status-pill { color: var(--muted); }
.status-select option { color: #1e1e1e; background: #fff; font-weight: 400; }

.icon-btn { width: 24px; height: 24px; padding: 0; display: grid; place-items: center; background: none; border: 1px solid transparent; border-radius: 3px; color: var(--muted); }
.icon-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:hover { background: var(--btn-hover); border-color: var(--edge-focus); color: var(--ink); }

.row-edit { display: block; }
.edit { display: grid; gap: 8px; }
.edit-field { display: block; }
.edit-field span { display: block; margin-bottom: 3px; }
.edit-field input { height: 25px; }
.edit-actions { display: flex; justify-content: flex-end; gap: 6px; align-items: center; }

.empty { display: grid; justify-items: center; gap: 8px; padding: 36px 0; color: var(--muted); }
.empty svg { width: 52px; height: 52px; fill: var(--bar-bottom); stroke: var(--muted); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

/* Status bar */
.statusbar { display: flex; justify-content: space-between; gap: 12px; min-height: 22px; padding: 3px 8px; font-size: 12px; color: var(--muted); background: linear-gradient(var(--bar-top), var(--bar-bottom)); border-top: 1px solid var(--line); }
.pending { margin: 0; color: var(--warn); font-weight: 600; }

/* Tooltip-style message */
.toast {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); display: flex; align-items: center; gap: 12px;
  max-width: calc(100vw - 24px); padding: 5px 10px; border: 1px solid var(--tip-edge); border-radius: 3px; background: var(--tip); color: var(--tip-ink);
  box-shadow: 2px 3px 7px rgb(0 0 0 / .35); white-space: nowrap; z-index: 20;
}
.toast span { overflow: hidden; text-overflow: ellipsis; }
.toast button { padding: 0; background: none; border: 0; color: var(--link); text-decoration: underline; }

/* Wide: the add form becomes one line */
@media (min-width: 900px) {
  .is-wide .qa { grid-template-columns: 130px 240px minmax(0, 1fr) 240px auto; align-items: end; }
  .is-wide .qa.is-simple { grid-template-columns: minmax(0, 1fr) 300px auto; }
  .is-wide .qa-note, .is-wide .qa-url, .is-wide .qa-actions { grid-column: auto; }
  .is-wide .qa-reset { display: none; }
  .is-wide .qa textarea { min-height: 25px; height: 25px; resize: none; padding-top: 3px; padding-bottom: 3px; }
  .is-wide .qa-saved { grid-column: 1 / -1; }
}

/* Wide: Explorer's details view */
@container (min-width: 760px) {
  .list-head, .row:not(.row-edit) {
    display: grid; column-gap: 0; align-items: stretch;
    grid-template-areas: none; grid-template-columns: minmax(0, 1fr) 196px 124px 112px 66px;
  }
  .is-staff .list-head, .is-staff .row:not(.row-edit) {
    grid-template-columns: 30px 106px 196px minmax(0, 1fr) 176px 124px 112px 66px;
  }
  .list-bar .search { flex: 0 1 300px; margin-left: auto; }
  /* A real grid: every cell has its lines, like a desktop ERP */
  .list-head > *, .row:not(.row-edit) > * { padding: 5px 7px; border-right: 1px solid var(--line); min-height: 100%; }
  .list-head > :last-child, .row:not(.row-edit) > :last-child { border-right: 0; }
  .list-head { padding: 0; background: linear-gradient(var(--bar-top), var(--bar-bottom)); border-bottom: 1px solid var(--edge); font-size: 12px; color: var(--ink); }
  .list-head > * { padding: 4px 7px; border-right-color: var(--edge); }
  .rows { padding: 0; }
  .row:not(.row-edit) { padding: 0; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; align-items: stretch; }
  .row:not(.row-edit):nth-child(even) { background: var(--zebra); }
  .row:not(.row-edit):hover { background: var(--row-hover); box-shadow: inset 0 0 0 1px var(--row-edge); }
  #list:not(.is-staff) .list-head > :first-child, #list:not(.is-staff) .h-order, #list:not(.is-staff) .h-email,
  #list:not(.is-staff) .cell-check, #list:not(.is-staff) .cell-order, #list:not(.is-staff) .cell-email { display: none; }
  .row > * { grid-area: auto; }
  .cell-order:empty, .cell-email:empty, .cell-url:empty { display: block; }
  .page-link { font-size: 13px; }
  .cell-when { font-size: 13px; align-self: stretch; justify-self: stretch; }
  .cell-status { justify-self: stretch; padding-top: 4px; }
  .status-select { width: 100%; }
  .cell-actions { justify-content: center; margin: 0; padding: 3px 2px; }
  .row-edit { padding: 8px; }
  .edit { grid-template-columns: 110px 220px minmax(0, 1fr) 240px auto; align-items: end; }
  #list:not(.is-staff) .edit { grid-template-columns: minmax(0, 1fr) 300px auto; }
  .edit-note textarea { min-height: 25px; }
}

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