/* ===== Geekaca Rental admin =====
   Same cream, graphite and lime as the landing page. Lime marks only "idle" (rentable).
   Status colors are amber (expiring soon) and red (overdue), always paired with a text label.
   The per-machine timeline (rental bars) is the centrepiece; everything else stays quiet. */
:root {
  --paper: #F4F2ED;
  --panel: #FFFFFF;
  --well: #F8F7F3;
  --ink: #121417;
  --ink-2: #5D6168;
  --ink-3: #8C9096;
  --line: #DCDDD8;
  --line-2: #ECEBE6;
  --lime: #C8F53C;
  --lime-deep: #A9D81A;
  --warn: #FAB219;
  --warn-soft: #FFF3D6;
  --warn-ink: #7A5200;
  --crit: #D03B3B;
  --crit-soft: #FCEAEA;
  --crit-ink: #A32626;
  --hard: 0 4px 0 rgba(18, 20, 23, .06);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Helvetica Neue", Arial, sans-serif;
  --week: calc(100% / 9);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font); font-size: 14px; line-height: 1.55; }
h1, h2, p, ul, dl, dd { margin: 0; }
ul { padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--lime-deep); outline-offset: 2px; }
.noscript { padding: 24px; text-align: center; }

/* ===== Buttons (the same black pills as the landing page) ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 18px; border-radius: 999px; border: 2px solid var(--ink);
  font-weight: 600; white-space: nowrap; cursor: pointer;
  transition: transform .1s ease, box-shadow .1s ease;
}
.btn:active { transform: translateY(2px); }
.btn:disabled { opacity: .5; cursor: progress; }
.btn--ink { background: var(--ink); color: #fff; box-shadow: 0 3px 0 rgba(18, 20, 23, .25); }
.btn--line { background: var(--panel); color: var(--ink); box-shadow: 0 3px 0 rgba(18, 20, 23, .1); }
.btn--ghost { background: transparent; border-color: var(--line); }
.btn--danger { background: var(--crit); border-color: var(--crit); color: #fff; }
.btn--danger-text { background: none; border-color: transparent; color: var(--crit-ink); padding-inline: 4px; }
.btn--block { width: 100%; }
.btn--sm { height: 34px; padding: 0 14px; font-size: 13px; }
.btn--xs { height: 28px; padding: 0 11px; font-size: 12.5px; border-width: 1.5px; box-shadow: none; }

/* ===== Login ===== */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login__card {
  width: min(360px, 100%); padding: 28px 24px 24px; border-radius: 20px; background: var(--panel);
  box-shadow: 0 6px 0 rgba(18, 20, 23, .07); display: grid; gap: 14px; justify-items: center;
}
.login__title { font-size: 22px; font-weight: 800; letter-spacing: .02em; }
.login__card .field { width: 100%; }

/* ===== Top bar ===== */
.top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 14px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) max(16px, calc((100% - 1120px) / 2)) 10px;
  background: rgba(244, 242, 237, .92); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.top__brand { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 800; }
.top__today { margin-left: auto; color: var(--ink-2); font-weight: 600; }

/* ===== Main ===== */
.main { max-width: 1120px; margin: 0 auto; padding: 18px 16px 64px; display: grid; gap: 16px; }
.panel { background: var(--panel); border-radius: 18px; box-shadow: var(--hard); padding: 16px 18px 18px; }
.panel__head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 12px; }
.panel__title { font-size: 17px; font-weight: 800; }
.panel__hint { color: var(--ink-3); font-size: 13px; }
.panel__head .btn { margin-left: auto; }
.empty { color: var(--ink-2); padding: 6px 0 2px; }
.muted { color: var(--ink-3); }

/* ===== State labels (color always comes with text) ===== */
.state {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 999px;
  font-size: 12.5px; font-weight: 700; white-space: nowrap; background: var(--line-2); color: var(--ink-2);
}
.state--idle { background: var(--lime); color: var(--ink); }
.state--rented, .state--ongoing { background: var(--ink); color: #fff; }
.state--expiring { background: var(--warn-soft); color: var(--warn-ink); box-shadow: inset 0 0 0 1.5px var(--warn); }
.state--overdue { background: var(--crit); color: #fff; }
.state--upcoming { background: var(--panel); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.icon { width: 14px; height: 14px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ===== Needs attention ===== */
.alerts { display: grid; gap: 8px; }
.alert {
  display: grid; grid-template-columns: 116px 76px minmax(0, 1fr) auto auto; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 12px; background: var(--warn-soft);
}
.alert--overdue { background: var(--crit-soft); }
.alert__badge { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; color: var(--warn-ink); }
.alert--overdue .alert__badge { color: var(--crit-ink); }
.alert__machine { font-weight: 800; }
.alert__who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.alert__who b { white-space: nowrap; }
.alert__date { color: var(--ink-2); white-space: nowrap; }
.alert__actions { display: flex; gap: 8px; }

.copy {
  min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  height: 24px; padding: 0 9px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255, 255, 255, .7);
  font-size: 12.5px; color: var(--ink-2); cursor: pointer;
}
.copy:hover { border-color: var(--ink-3); color: var(--ink); }

/* ===== Machine timeline (the centrepiece) ===== */
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 14px; color: var(--ink-2); font-size: 13px; }
.legend__item { display: inline-flex; align-items: center; gap: 6px; }
.legend__item b { color: var(--ink); font-weight: 800; }
.swatch { width: 18px; height: 10px; border-radius: 3px; background: var(--ink); flex: none; }
.swatch--idle { background: var(--lime); }
.swatch--expiring { background: var(--warn); }
.swatch--overdue { background: var(--crit); }
.swatch--upcoming { background: repeating-linear-gradient(135deg, rgba(18, 20, 23, .28) 0 2px, transparent 2px 5px), var(--panel); box-shadow: inset 0 0 0 1.5px var(--ink); }
.swatch--maintenance { background: repeating-linear-gradient(135deg, rgba(18, 20, 23, .22) 0 2px, transparent 2px 5px), var(--line-2); }

.board__grid { display: grid; }
.mrow {
  display: grid; grid-template-columns: 150px minmax(0, 1fr) 260px; align-items: center; gap: 16px;
  padding: 10px 0; border-top: 1px solid var(--line-2);
}
.mrow--scale { border-top: 0; padding: 0 0 6px; }
.mrow--retired { opacity: .5; }
.mrow__label { display: grid; justify-items: start; line-height: 1.35; min-width: 0; }
.mrow__code { padding: 0; border: 0; background: none; font-size: 15px; font-weight: 800; cursor: pointer; text-align: left; }
.mrow__code:hover { text-decoration: underline; text-underline-offset: 3px; }
.mrow__kind, .mrow__spec { font-size: 12px; color: var(--ink-3); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mrow__info { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mrow__who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); font-size: 13px; }
.mrow__info .btn { margin-left: auto; }

.track {
  position: relative; height: 32px; border-radius: 8px; background-color: var(--well);
  background-image: repeating-linear-gradient(to right, var(--line-2) 0 1px, transparent 1px var(--week));
}
.track--maintenance {
  background-image:
    repeating-linear-gradient(135deg, rgba(18, 20, 23, .07) 0 4px, transparent 4px 10px),
    repeating-linear-gradient(to right, var(--line-2) 0 1px, transparent 1px var(--week));
}
/* Today marker: a line behind the bars (visible in empty space) plus front notches above and below each bar */
.track__line, .track__today { position: absolute; top: -5px; bottom: -5px; left: var(--x); width: 2px; margin-left: -1px; border-radius: 1px; }
.track__line { background: var(--ink); z-index: 0; }
.track__today { z-index: 2; background: linear-gradient(to bottom, var(--ink) 0 9px, transparent 9px calc(100% - 9px), var(--ink) calc(100% - 9px)); }

.bar {
  position: absolute; top: 5px; bottom: 5px; left: calc(var(--l) + 1px); width: calc(var(--w) - 2px); min-width: 4px;
  padding: 0 7px; border: 0; border-radius: 6px; background: var(--ink); color: #fff;
  font-size: 12px; font-weight: 600; line-height: 22px; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: pointer; z-index: 1;
}
.bar:hover { filter: brightness(1.15); }
.bar--expiring { background: var(--warn); color: var(--ink); }
.bar--overdue { background: var(--crit); }
.bar--upcoming { background: repeating-linear-gradient(135deg, rgba(18, 20, 23, .16) 0 3px, transparent 3px 8px), var(--panel); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink); }
.bar-tail { position: absolute; top: 50%; left: var(--l); width: var(--w); border-top: 2px dashed var(--crit); }

.scale { height: 18px; background: none; }
.scale__tick, .scale__today { position: absolute; top: 0; left: var(--x); transform: translateX(-50%); font-size: 11.5px; color: var(--ink-3); white-space: nowrap; }
.scale__today { padding: 0 6px; border-radius: 4px; background: var(--ink); color: #fff; font-weight: 700; line-height: 18px; }

/* ===== Rentals table ===== */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12.5px; font-weight: 600; color: var(--ink-3); padding: 0 10px 8px; }
.table td { padding: 10px; border-top: 1px solid var(--line-2); vertical-align: middle; }
.table td:first-child { font-weight: 800; }
.table b { font-weight: 700; margin-right: 6px; }
.table__actions { text-align: right; }

/* ===== History ===== */
.history summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
.history summary::-webkit-details-marker { display: none; }
.history summary::before { content: ""; width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform .15s; }
.history[open] summary::before { transform: rotate(45deg); }
.history__body { margin-top: 12px; }
.history__row { display: grid; grid-template-columns: 76px minmax(0, 1fr) auto auto; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line-2); color: var(--ink-2); }
.history__row b { color: var(--ink); }

/* ===== Dialogs and forms ===== */
.modal {
  width: min(540px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 0; border-radius: 18px;
  background: var(--panel); color: var(--ink); box-shadow: 0 24px 60px rgba(18, 20, 23, .28);
}
.modal::backdrop { background: rgba(18, 20, 23, .45); }
.modal__head { display: flex; align-items: center; gap: 12px; padding: 16px 18px 0; }
.modal__title { font-size: 17px; font-weight: 800; }
.modal__close { margin-left: auto; width: 32px; height: 32px; border: 0; border-radius: 50%; background: var(--well); font-size: 18px; line-height: 1; cursor: pointer; }
.form { display: grid; gap: 14px; padding: 14px 18px 18px; }
.form__lead { color: var(--ink-2); }
.form__row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; padding-top: 4px; }
.form__actions .spacer { flex: 1; }
.form-error { color: var(--crit-ink); font-weight: 600; min-height: 0; }
.form-error:empty { display: none; }
.field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.field__label { font-size: 13px; font-weight: 700; }
.field__hint { font-size: 12px; color: var(--ink-3); }
.field input, .field select, .field textarea {
  width: 100%; min-height: 42px; padding: 8px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--panel);
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px rgba(200, 245, 60, .7); }
.quick { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { height: 32px; padding: 0 12px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--panel); font-size: 13px; font-weight: 600; cursor: pointer; }
.chip:hover { border-color: var(--ink); }
.summary { display: grid; grid-template-columns: 64px 1fr; gap: 8px 12px; padding: 12px 14px; border-radius: 12px; background: var(--well); }
.summary dt { color: var(--ink-3); }

/* ===== Toast ===== */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); z-index: 50;
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  max-width: calc(100vw - 32px); padding: 10px 18px; border-radius: 999px; background: var(--ink); color: #fff; font-weight: 600;
  transition: opacity .2s ease, transform .2s ease;
}
.toast[data-show="1"] { opacity: 1; transform: translate(-50%, 0); }

/* ===== Narrow screens: the timeline goes full width below the machine name ===== */
@media (max-width: 760px) {
  .top__brand span { display: none; }
  .mrow { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "label info" "track track"; gap: 8px 10px; }
  .mrow__label { grid-area: label; grid-template-columns: auto minmax(0, 1fr); align-items: baseline; column-gap: 8px; }
  .mrow__spec { display: none; }
  .mrow__info { grid-area: info; }
  .mrow__info .mrow__who { display: none; }
  .mrow > .track, .mrow > .scale { grid-area: track; }
  .mrow--scale { grid-template-areas: "track track"; }
  .mrow--scale .mrow__label, .mrow--scale .mrow__info { display: none; }
  .alert { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "badge machine" "who who" "date actions"; gap: 6px 10px; }
  .alert__badge { grid-area: badge; }
  .alert__machine { grid-area: machine; justify-self: end; }
  .alert__who { grid-area: who; }
  .alert__date { grid-area: date; }
  .alert__actions { grid-area: actions; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; }
  .table tr { padding: 10px 0; border-top: 1px solid var(--line-2); display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
  .table td { border: 0; padding: 0; }
  .table td[data-label]::before { content: attr(data-label); display: block; font-size: 11.5px; color: var(--ink-3); }
  .table td:first-child { grid-column: 1 / -1; font-size: 15px; }
  .table td:first-child::before { display: none; }
  .scale__tick--minor { display: none; }
  .table__actions { grid-column: 1 / -1; text-align: left; }
  .history__row { grid-template-columns: minmax(0, 1fr) auto; }
  .form__row { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .btn, .toast { transition: none; }
}
