/* =====================================================================
   Sand Mixer Cleaning & Repair Log — styles.css
   Industrial style: charcoal structure, safety-yellow accent.
   Mobile-first. Large touch targets. Visible focus. Reduced motion honored.
   ===================================================================== */

:root {
  --charcoal: #1A1A1A;
  --charcoal-2: #262626;
  --paper: #F2F2F0;
  --card: #FFFFFF;
  --line: #D7D7D3;
  --ink: #1A1A1A;
  --muted: #6B6B6B;

  --yellow: #FFCD11;        /* safety yellow accent */
  --yellow-dark: #D9AE00;

  --green: #1E8E3E;  --green-bg: #E6F4EA;
  --amber: #C77700;  --amber-bg: #FCEFD6;
  --red:   #C5221F;  --red-bg:   #FCE8E6;
  --gray:  #80868B;  --gray-bg:  #ECECEC;

  --radius: 4px;            /* squared, industrial */
  --tap: 48px;              /* minimum touch target */
  --maxw: 1100px;
  --shadow: 0 1px 2px rgba(0,0,0,.12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Arial, "Helvetica Neue", Helvetica, "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 16px;            /* 16px base prevents iOS input zoom */
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { margin: 0 0 .4rem; line-height: 1.2; }
code { background: #00000010; padding: 1px 5px; border-radius: 3px; font-size: .9em; }
.muted { color: var(--muted); font-size: .92rem; }
.req { color: var(--red); }

/* ---------- Header ---------- */
.app-header { background: var(--charcoal); color: #fff; border-bottom: 4px solid var(--yellow); position: sticky; top: 0; z-index: 30; }
.app-header__bar { max-width: var(--maxw); margin: 0 auto; padding: .8rem 1rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.app-header__title { display: flex; align-items: center; gap: .75rem; }
.app-header__mark { width: 14px; height: 28px; background: var(--yellow); display: inline-block; clip-path: polygon(0 0, 100% 0, 70% 100%, 0% 100%); }
.app-header h1 { font-size: 1.05rem; letter-spacing: .03em; text-transform: uppercase; }
.app-header__sub { margin: 0; font-size: .76rem; color: #B9B9B9; letter-spacing: .02em; }

.pill { font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: .35rem .6rem; border-radius: 2px; white-space: nowrap; }
.pill--locked { background: #3a3a3a; color: #cfcfcf; }
.pill--admin { background: var(--yellow); color: #1A1A1A; }

/* ---------- Tabs ---------- */
.tabs { max-width: var(--maxw); margin: 0 auto; display: flex; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tab {
  flex: 1 0 auto; min-height: var(--tap); padding: 0 1rem;
  background: var(--charcoal-2); color: #cfcfcf; border: 0; border-right: 1px solid #000;
  font-size: .82rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; cursor: pointer;
}
.tab:last-child { border-right: 0; }
.tab.is-active { background: var(--yellow); color: #1A1A1A; }
.tab:focus-visible { outline: 3px solid #fff; outline-offset: -3px; }

/* ---------- Layout ---------- */
.container { max-width: var(--maxw); margin: 0 auto; padding: 1rem; }
.view { display: none; }
.view.is-active { display: block; animation: fade .18s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- Dashboard summary ---------- */
.summary { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; margin-bottom: 1rem; }
.summary__item { background: var(--card); border: 1px solid var(--line); border-left: 6px solid var(--gray); border-radius: var(--radius); padding: .7rem .9rem; box-shadow: var(--shadow); }
.summary__num { font-size: 1.7rem; font-weight: 800; display: block; line-height: 1; }
.summary__lbl { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.summary--current { border-left-color: var(--green); }
.summary--due { border-left-color: var(--amber); }
.summary--overdue { border-left-color: var(--red); }
.summary--none { border-left-color: var(--gray); }

/* ---------- Cards ---------- */
.cards { display: grid; grid-template-columns: 1fr; gap: .75rem; }
.card { background: var(--card); border: 1px solid var(--line); border-top: 6px solid var(--gray); border-radius: var(--radius); padding: .85rem 1rem; box-shadow: var(--shadow); }
.card--current { border-top-color: var(--green); }
.card--due { border-top-color: var(--amber); }
.card--overdue { border-top-color: var(--red); }
.card--none { border-top-color: var(--gray); }
.card__top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .5rem; }
.card__name { font-size: 1.05rem; font-weight: 800; letter-spacing: .01em; }
.card__rows { font-size: .9rem; }
.card__row { display: flex; justify-content: space-between; gap: .75rem; padding: .15rem 0; border-bottom: 1px dashed #ededed; }
.card__row:last-child { border-bottom: 0; }
.card__row span:first-child { color: var(--muted); }
.card__row span:last-child { font-weight: 600; text-align: right; }

/* ---------- Status badge ---------- */
.badge { font-size: .68rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; padding: .3rem .55rem; border-radius: 2px; white-space: nowrap; }
.badge--current { background: var(--green-bg); color: var(--green); }
.badge--due { background: var(--amber-bg); color: var(--amber); }
.badge--overdue { background: var(--red-bg); color: var(--red); }
.badge--none { background: var(--gray-bg); color: var(--gray); }
.dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; margin-right: .35rem; vertical-align: -1px; }
.dot--good, .dot--none-repair { background: var(--green); }
.dot--warn { background: var(--amber); }
.dot--bad { background: var(--red); }
.dot--neutral { background: var(--gray); }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr; gap: .8rem; }
.field { display: flex; flex-direction: column; }
.field label { font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin-bottom: .3rem; color: #333; }
.hint-inline { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--muted); font-size: .72rem; }
.field-hint { margin: .3rem 0 0; font-size: .74rem; color: var(--muted); }

input, select, textarea {
  font: inherit; min-height: var(--tap); padding: .5rem .65rem;
  background: #fff; color: var(--ink); border: 1px solid #B8B8B4; border-radius: var(--radius); width: 100%;
}
textarea { min-height: 64px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible,
.btn:focus-visible { outline: 3px solid var(--charcoal); outline-offset: 1px; }
select:focus-visible { outline-color: var(--yellow-dark); }
.input-error { border-color: var(--red); background: #fff7f7; }

/* ---------- Checklist ---------- */
.checklist { margin: 1.1rem 0; border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem 1rem; background: #fafafa; }
.checklist legend { font-size: .82rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; padding: 0 .4rem; }
.checklist__grid { display: grid; grid-template-columns: 1fr; gap: .15rem; }
.check { display: flex; align-items: center; gap: .7rem; min-height: var(--tap); padding: .2rem .25rem; border-bottom: 1px dashed #e3e3e3; cursor: pointer; }
.check:last-child { border-bottom: 0; }
.check input { width: 26px; height: 26px; min-height: 0; flex: 0 0 auto; accent-color: var(--charcoal); }
.check span { font-size: .95rem; }

/* ---------- Buttons ---------- */
.btn {
  min-height: var(--tap); padding: 0 1.1rem; border-radius: var(--radius); border: 1px solid var(--charcoal);
  background: #fff; color: var(--charcoal); font-size: .9rem; font-weight: 700; letter-spacing: .02em;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
}
.btn:hover { background: #f3f3f3; }
.btn--primary { background: var(--yellow); border-color: var(--yellow-dark); color: #1A1A1A; }
.btn--primary:hover { background: var(--yellow-dark); }
.btn--ghost { background: transparent; }
.btn--warn { background: var(--red-bg); border-color: var(--red); color: var(--red); }
.btn--warn:hover { background: #f9d6d3; }
.btn--sm { min-height: 36px; padding: 0 .7rem; font-size: .78rem; }
.btn--file { position: relative; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.form-actions { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }
.btn-row, .pin-row { display: flex; gap: .6rem; flex-wrap: wrap; margin: .6rem 0; }
.pin-row input { max-width: 160px; }

/* ---------- Errors ---------- */
.errors { background: var(--red-bg); border: 1px solid var(--red); color: var(--red); border-radius: var(--radius); padding: .65rem .8rem; margin-top: .9rem; font-size: .9rem; }
.errors ul { margin: .3rem 0 0; padding-left: 1.1rem; }

/* ---------- Filters / table ---------- */
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-bottom: .8rem; }
.field--btn, .field--wide { grid-column: 1 / -1; }
.field--btn { align-self: end; }
.result-count { font-size: .82rem; color: var(--muted); margin: .2rem 0 .6rem; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; -webkit-overflow-scrolling: touch; }
.log-table { width: 100%; border-collapse: collapse; min-width: 720px; font-size: .88rem; }
.log-table th { background: var(--charcoal); color: #fff; text-align: left; padding: .6rem .7rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; position: sticky; top: 0; }
.log-table td { padding: .55rem .7rem; border-bottom: 1px solid #ededed; vertical-align: middle; }
.log-table tr:nth-child(even) td { background: #fafafa; }
.lock-tag { font-size: .66rem; font-weight: 800; letter-spacing: .05em; color: var(--muted); }

/* ---------- Admin ---------- */
.admin-lock, .admin-panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--shadow); }
.admin-banner { background: var(--yellow); color: #1A1A1A; border-radius: var(--radius); padding: .55rem .8rem; font-weight: 700; font-size: .88rem; display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: 1rem; flex-wrap: wrap; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; z-index: 50; padding: 0; }
.modal__box { background: #fff; width: 100%; max-width: 560px; border-radius: 10px 10px 0 0; padding: 1.1rem; max-height: 92vh; overflow-y: auto; animation: slideup .2s ease both; }
.modal__box--lg { max-width: 680px; }
@keyframes slideup { from { transform: translateY(16px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .5rem; }
.modal__close { background: none; border: 0; font-size: 1.8rem; line-height: 1; cursor: pointer; color: var(--muted); min-height: var(--tap); min-width: var(--tap); }
.modal__body { font-size: .92rem; }
.modal__actions { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: 42% 58%; gap: .25rem .5rem; margin: .2rem 0 .6rem; }
.kv dt { color: var(--muted); font-size: .8rem; }
.kv dd { margin: 0; font-weight: 600; word-break: break-word; }
.warn-line { background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber); border-radius: var(--radius); padding: .5rem .7rem; margin: .6rem 0; font-size: .85rem; font-weight: 600; }
.edit-grid { display: grid; grid-template-columns: 1fr; gap: .7rem; }
.edit-hist { margin-top: .8rem; border-top: 1px solid var(--line); padding-top: .6rem; }
.edit-hist li { font-size: .8rem; color: #444; margin-bottom: .4rem; }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: 1.1rem; transform: translateX(-50%); background: var(--charcoal); color: #fff; border-left: 5px solid var(--green); padding: .7rem 1rem; border-radius: var(--radius); box-shadow: 0 4px 14px rgba(0,0,0,.3); z-index: 60; font-size: .9rem; max-width: 92%; animation: fade .2s ease both; }
.toast--warn { border-left-color: var(--amber); }
.toast--err { border-left-color: var(--red); }

/* ---------- Responsive up-scaling ---------- */
@media (min-width: 600px) {
  .summary { grid-template-columns: repeat(4, 1fr); }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .checklist__grid { grid-template-columns: 1fr 1fr; }
  .filters { grid-template-columns: repeat(4, 1fr); }
  .modal { align-items: center; }
  .modal__box { border-radius: 10px; }
}
@media (min-width: 900px) {
  .cards { grid-template-columns: repeat(3, 1fr); }
  .form-grid { grid-template-columns: 1fr 1fr 1fr; }
  .app-header h1 { font-size: 1.2rem; }
}

/* ---------- Accessibility ---------- */
@media (prefers-reduced-motion: reduce) {
  *, .view.is-active, .modal__box, .toast { animation: none !important; transition: none !important; }
}
