/* =========================================================
   MaintainIQ — visual identity
   Concept: the digital equivalent of a stamped equipment
   nameplate. Graphite housing, riveted corner brackets,
   monospace asset codes, signal-colored status LEDs.
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg:        #13161a;
  --surface:   #1c2126;
  --surface-2: #242a31;
  --surface-3: #2c333b;
  --border:    #333c45;
  --border-soft: #262c33;
  --text:      #edf0f3;
  --text-muted:#8f9aa5;
  --text-dim:  #626c76;

  --amber:     #f2a900;
  --amber-dim: #a97b1f;
  --green:     #3fb68b;
  --red:       #e5484d;
  --blue:      #4d9fe5;
  --slate:     #6b7280;

  --font-display: 'JetBrains Mono', ui-monospace, monospace;
  --font-body: 'Inter', -apple-system, sans-serif;

  --radius: 3px;
  --shadow: 0 8px 24px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 1px 1px, rgba(255,255,255,0.035) 1px, transparent 0);
  background-size: 22px 22px;
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--amber); }
button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ---------- layout shells ---------- */
.shell { max-width: 1180px; margin: 0 auto; padding: 0 24px 80px; }
.shell--narrow { max-width: 560px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; border-bottom: 1px solid var(--border-soft);
  position: sticky; top: 0; background: rgba(19,22,26,.9); backdrop-filter: blur(8px); z-index: 40;
}
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; letter-spacing: .02em; }
.brand__mark {
  width: 30px; height: 30px; border: 2px solid var(--amber); border-radius: 6px;
  display: grid; place-items: center; color: var(--amber); font-size: 13px; font-weight: 800;
}
.brand__name { font-size: 15px; }
.brand__tag { color: var(--text-dim); font-weight: 400; font-size: 12px; margin-left: 6px; }

.user-chip { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-muted); }
.user-chip strong { color: var(--text); }
.role-pill {
  font-family: var(--font-display); font-size: 10px; text-transform: uppercase; letter-spacing: .08em;
  padding: 3px 8px; border-radius: 20px; border: 1px solid var(--amber-dim); color: var(--amber);
}

/* ---------- eyebrow / headings ---------- */
.eyebrow {
  font-family: var(--font-display); font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--amber); display: flex; align-items: center; gap: 8px; margin: 32px 0 6px;
}
.eyebrow::before { content: ''; width: 16px; height: 1px; background: var(--amber-dim); }
h1, h2, h3 { font-family: var(--font-body); font-weight: 800; margin: 0 0 8px; letter-spacing: -.01em; }
h1 { font-size: 30px; } h2 { font-size: 21px; } h3 { font-size: 16px; }
.subtle { color: var(--text-muted); font-size: 14px; }

/* ---------- buttons ---------- */
.btn {
  font-family: var(--font-body); font-weight: 600; font-size: 13.5px;
  border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); padding: 10px 16px; cursor: pointer; transition: border-color .15s, transform .1s;
  display: inline-flex; align-items: center; gap: 8px;
}
.btn:hover { border-color: var(--text-dim); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--amber); border-color: var(--amber); color: #1a1300; }
.btn--primary:hover { background: #ffbb1a; border-color: #ffbb1a; }
.btn--ghost { background: transparent; }
.btn--danger { border-color: var(--red); color: var(--red); background: transparent; }
.btn--danger:hover { background: rgba(229,72,77,.1); }
.btn--sm { padding: 6px 11px; font-size: 12.5px; }
.btn--block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- cards / surfaces ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border-soft); border-radius: 8px;
  padding: 22px; box-shadow: var(--shadow);
}
.panel { background: var(--surface); border: 1px solid var(--border-soft); border-radius: 8px; padding: 20px; margin-bottom: 20px; }

/* ---------- forms ---------- */
label { display: block; font-size: 12.5px; color: var(--text-muted); margin-bottom: 6px; font-weight: 600; }
.field { margin-bottom: 16px; }
input, select, textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius); padding: 10px 12px; font-family: var(--font-body); font-size: 14px;
}
input:focus, select:focus, textarea:focus { border-color: var(--amber-dim); }
textarea { resize: vertical; min-height: 84px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.hint { font-size: 12px; color: var(--text-dim); margin-top: 5px; }
fieldset { border: 1px solid var(--border-soft); border-radius: 6px; padding: 14px; margin: 0 0 16px; }
legend { font-family: var(--font-display); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--amber); padding: 0 6px; }

/* ---------- status badges (signal LEDs) ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-display);
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em; padding: 4px 9px 4px 7px;
  border-radius: 20px; border: 1px solid var(--border); white-space: nowrap;
}
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 6px currentColor; }
.badge--Operational { color: var(--green); border-color: rgba(63,182,139,.35); }
.badge--IssueReported, .badge--Reported { color: var(--amber); border-color: rgba(242,169,0,.35); }
.badge--UnderInspection, .badge--InspectionStarted { color: var(--blue); border-color: rgba(77,159,229,.35); }
.badge--UnderMaintenance, .badge--MaintenanceInProgress { color: #c084fc; border-color: rgba(192,132,252,.35); }
.badge--OutOfService { color: var(--red); border-color: rgba(229,72,77,.35); }
.badge--Retired, .badge--Closed { color: var(--slate); border-color: rgba(107,114,128,.35); }
.badge--WaitingforParts { color: var(--amber); border-color: rgba(242,169,0,.35); }
.badge--Assigned { color: var(--blue); border-color: rgba(77,159,229,.35); }
.badge--Resolved { color: var(--green); border-color: rgba(63,182,139,.35); }
.badge--Reopened { color: var(--red); border-color: rgba(229,72,77,.35); }

.priority { font-family: var(--font-display); font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; padding: 2px 7px; border-radius: 3px; }
.priority--Low { background: rgba(107,114,128,.15); color: var(--slate); }
.priority--Medium { background: rgba(77,159,229,.15); color: var(--blue); }
.priority--High { background: rgba(242,169,0,.15); color: var(--amber); }
.priority--Critical { background: rgba(229,72,77,.18); color: var(--red); font-weight: 700; }
.priority--Critical::before { content: '▲ '; }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border-soft); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border-soft); white-space: nowrap; }
th { font-family: var(--font-display); font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-dim); background: var(--surface-2); }
tbody tr { cursor: pointer; transition: background .1s; }
tbody tr:hover { background: var(--surface-2); }
td.code { font-family: var(--font-display); color: var(--amber); }
.empty-row td { color: var(--text-dim); cursor: default; text-align: center; padding: 40px; }
.empty-row td:hover { background: none; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border-soft); margin: 22px 0 18px; }
.tab {
  font-family: var(--font-display); font-size: 12px; letter-spacing: .04em; text-transform: uppercase;
  padding: 10px 16px; background: none; border: none; color: var(--text-dim); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab.active { color: var(--amber); border-bottom-color: var(--amber); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- toolbar ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.toolbar__filters { display: flex; flex-wrap: wrap; gap: 8px; }
.toolbar__filters select, .toolbar__filters input { width: auto; min-width: 140px; }

/* ---------- nameplate: signature component ----------
   A riveted metal-tag card, used for the asset detail view
   and the public asset page. */
.nameplate {
  position: relative; background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border); border-radius: 10px; padding: 26px 26px 22px;
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(255,255,255,.02);
}
.nameplate::before, .nameplate::after,
.nameplate .rivet-tl, .nameplate .rivet-tr, .nameplate .rivet-bl, .nameplate .rivet-br { content: ''; }
.nameplate .rivet-tl, .nameplate .rivet-tr, .nameplate .rivet-bl, .nameplate .rivet-br {
  position: absolute; width: 9px; height: 9px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #525b64, #14171b 70%);
  box-shadow: inset 0 0 2px #000;
}
.nameplate .rivet-tl { top: 12px; left: 12px; } .nameplate .rivet-tr { top: 12px; right: 12px; }
.nameplate .rivet-bl { bottom: 12px; left: 12px; } .nameplate .rivet-br { bottom: 12px; right: 12px; }

.nameplate__code { font-family: var(--font-display); font-size: 12px; color: var(--amber); letter-spacing: .08em; }
.nameplate__name { font-size: 24px; font-weight: 800; margin: 4px 0 14px; }
.nameplate__meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 20px; font-size: 13px; margin-bottom: 16px; }
.nameplate__meta div span { display: block; }
.nameplate__meta .k { color: var(--text-dim); font-family: var(--font-display); font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; }
.nameplate__meta .v { color: var(--text); margin-top: 2px; }

.qr-block { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.qr-frame { background: #fff; padding: 10px; border-radius: 6px; display: inline-block; }
.qr-actions { display: flex; flex-direction: column; gap: 8px; }

/* ---------- history timeline ---------- */
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ''; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 1px; background: var(--border); }
.timeline-item { position: relative; padding-bottom: 18px; }
.timeline-item::before { content: ''; position: absolute; left: -22px; top: 4px; width: 9px; height: 9px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 3px var(--bg); }
.timeline-item .action { font-weight: 700; font-size: 13.5px; }
.timeline-item .meta { color: var(--text-dim); font-size: 12px; margin-top: 2px; }
.timeline-item .details { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

/* ---------- summary cards ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 8px; }
.stat-card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: 8px; padding: 16px 18px; }
.stat-card .n { font-family: var(--font-display); font-size: 28px; font-weight: 700; color: var(--amber); }
.stat-card .l { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(8,10,12,.72); backdrop-filter: blur(2px);
  display: none; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 100;
}
.modal-backdrop.open { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; width: 100%; max-width: 640px; padding: 24px; box-shadow: var(--shadow); }
.modal__head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.modal__close { background: none; border: none; color: var(--text-dim); font-size: 20px; cursor: pointer; line-height: 1; }

/* ---------- ai suggestion box ---------- */
.ai-box { border: 1px dashed var(--amber-dim); border-radius: 8px; padding: 16px; background: rgba(242,169,0,.05); margin: 14px 0; }
.ai-box__head { display: flex; align-items: center; gap: 8px; font-family: var(--font-display); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--amber); margin-bottom: 10px; }
.ai-box__head .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--amber); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }
.ai-note { font-size: 12.5px; color: var(--text-dim); margin-top: 8px; }
.ai-note.safety { color: var(--red); font-weight: 600; }

/* ---------- toast ---------- */
.toast-host { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--surface-3); border: 1px solid var(--border); border-left: 3px solid var(--amber); color: var(--text); padding: 12px 16px; border-radius: 6px; font-size: 13.5px; box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); transition: opacity .25s, transform .25s; max-width: 320px; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast--error { border-left-color: var(--red); }
.toast--success { border-left-color: var(--green); }

/* ---------- public page hero ---------- */
.public-hero { text-align: center; padding: 40px 0 10px; }
.public-hero .brand { justify-content: center; }

/* ---------- utility ---------- */
.flex { display: flex; align-items: center; gap: 10px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.center { text-align: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.divider { height: 1px; background: var(--border-soft); margin: 20px 0; }
.small { font-size: 12px; color: var(--text-dim); }
.hidden { display: none !important; }

@media (max-width: 720px) {
  .field-row, .grid-2, .nameplate__meta { grid-template-columns: 1fr; }
  .shell { padding: 0 16px 60px; }
}
