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

/* ── Design Tokens ──────────────────────────────────────────────── */
:root {
  --bg:           #f0f4f8;
  --surface:      #ffffff;
  --surface-2:    #f8fafc;
  --border:       #e2e8f0;
  --border-strong:#cbd5e1;

  --text:         #0f172a;
  --text-2:       #475569;
  --text-3:       #94a3b8;

  --sidebar-bg:         #0d1b2a;
  --sidebar-text:       #8ba0b8;
  --sidebar-active:     #f97316;
  --sidebar-active-bg:  rgba(249,115,22,0.13);
  --sidebar-hover:      rgba(255,255,255,0.06);
  --sidebar-border:     rgba(255,255,255,0.07);

  --orange:       #f97316;
  --orange-h:     #ea6c0a;
  --orange-light: #fff7ed;
  --orange-border:#fed7aa;

  --blue:         #3b82f6;
  --blue-h:       #2563eb;
  --blue-light:   #eff6ff;
  --blue-border:  #bfdbfe;

  --green:        #22c55e;
  --green-h:      #16a34a;
  --green-light:  #f0fdf4;
  --green-border: #bbf7d0;

  --red:          #ef4444;
  --red-h:        #dc2626;
  --red-light:    #fef2f2;
  --red-border:   #fecaca;

  --yellow:       #f59e0b;
  --yellow-light: #fffbeb;
  --yellow-border:#fde68a;

  --r-sm:  6px;
  --r:     10px;
  --r-lg:  14px;
  --r-xl:  20px;
  --r-full:9999px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow:    0 2px 8px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.03);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.10), 0 0 0 1px rgba(0,0,0,0.04);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.16);

  --sidebar-w:   240px;
  --content-pad: 28px;
  --content-max: 1200px;
}

/* ── Reset ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }
img { display: block; max-width: 100%; }
ul, ol { list-style: none; }

/* ── App Layout ─────────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }

/* ── Sidebar ────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 50;
  transition: transform 0.25s ease;
}

.sidebar-header {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo-icon {
  width: 36px; height: 36px;
  background: var(--orange);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.4px;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 10px;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,0.25);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 12px 10px 5px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  color: var(--sidebar-text);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-link:hover { background: var(--sidebar-hover); color: #fff; }
.nav-link.active { background: var(--sidebar-active-bg); color: var(--sidebar-active); }
.nav-link svg { width: 17px; height: 17px; flex-shrink: 0; stroke-width: 2; }

.sidebar-footer {
  padding: 12px 12px;
  border-top: 1px solid var(--sidebar-border);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 6px 8px;
}

.user-avatar {
  width: 32px; height: 32px;
  background: var(--orange);
  border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-name {
  font-size: 13px; font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-email {
  font-size: 11px; color: var(--sidebar-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.signout-btn {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 7px 10px;
  border-radius: var(--r-sm);
  background: none; border: none;
  color: var(--sidebar-text);
  font-size: 13px; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.signout-btn:hover { background: rgba(239,68,68,0.1); color: #fca5a5; }
.signout-btn svg { width: 15px; height: 15px; }

/* ── Mobile Header ──────────────────────────────────────────────── */
.mobile-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--sidebar-bg);
  position: sticky; top: 0; z-index: 40;
}
.mobile-logo {
  display: flex; align-items: center; gap: 8px;
  color: #fff; font-weight: 800; font-size: 17px;
}
.hamburger-btn { background: none; border: none; color: #fff; padding: 4px; cursor: pointer; }
.hamburger-btn svg { width: 22px; height: 22px; stroke-width: 2; }

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 45;
}
.sidebar-overlay.show { display: block; }

/* ── Main ───────────────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.main-inner {
  padding: var(--content-pad);
  max-width: var(--content-max);
  width: 100%;
}

/* ── Page Header ────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 26px;
  gap: 16px;
}
.page-title {
  font-size: 22px; font-weight: 800;
  color: var(--text);
  letter-spacing: -0.4px; line-height: 1.2;
}
.page-subtitle { font-size: 14px; color: var(--text-2); margin-top: 3px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 8px 15px;
  border-radius: var(--r);
  font-size: 14px; font-weight: 600;
  border: none; cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
  white-space: nowrap; line-height: 1;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 15px; height: 15px; stroke-width: 2.5; flex-shrink: 0; }

.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover { background: var(--orange-h); }

.btn-secondary {
  background: var(--surface); color: var(--text);
  border: 1.5px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover { background: var(--bg); }

.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-danger { background: var(--red-light); color: var(--red-h); border: 1.5px solid var(--red-border); }
.btn-danger:hover { background: var(--red); color: #fff; border-color: var(--red); }

.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: var(--r-sm); }
.btn-sm svg { width: 13px; height: 13px; }

.btn-icon { padding: 7px; border-radius: var(--r-sm); }
.btn-icon svg { width: 16px; height: 16px; margin: 0; }

.btn-lg { padding: 11px 22px; font-size: 15px; border-radius: var(--r-lg); }

/* ── Badges ─────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  border-radius: var(--r-full);
  font-size: 11px; font-weight: 700;
  white-space: nowrap; letter-spacing: 0.02em;
}
.badge-green  { background: var(--green-light);  color: var(--green-h);  border: 1px solid var(--green-border); }
.badge-orange { background: var(--orange-light); color: var(--orange-h); border: 1px solid var(--orange-border); }
.badge-red    { background: var(--red-light);    color: var(--red-h);    border: 1px solid var(--red-border); }
.badge-blue   { background: var(--blue-light);   color: var(--blue-h);   border: 1px solid var(--blue-border); }
.badge-yellow { background: var(--yellow-light); color: var(--yellow);   border: 1px solid var(--yellow-border); }
.badge-gray   { background: var(--surface-2);    color: var(--text-2);   border: 1px solid var(--border); }

/* ── Stats Grid ─────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 26px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex; align-items: flex-start; gap: 14px;
}
.stat-icon {
  width: 42px; height: 42px;
  border-radius: var(--r);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 20px;
}
.stat-icon svg { width: 22px; height: 22px; stroke-width: 2; }
.stat-icon-orange { background: var(--orange-light); color: var(--orange); }
.stat-icon-blue   { background: var(--blue-light);   color: var(--blue-h); }
.stat-icon-green  { background: var(--green-light);  color: var(--green-h); }
.stat-icon-red    { background: var(--red-light);    color: var(--red-h); }
.stat-value {
  font-size: 28px; font-weight: 800;
  color: var(--text); line-height: 1.1;
  letter-spacing: -0.5px;
}
.stat-label { font-size: 12px; color: var(--text-2); margin-top: 2px; font-weight: 500; }

/* ── Cards ──────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 14px; font-weight: 700; color: var(--text); }
.card-subtitle { font-size: 11px; color: var(--text-3); margin-top: 1px; }
.card-body { padding: 16px 20px; }

.content-grid { display: grid; gap: 20px; }
.content-grid-2 { grid-template-columns: 1fr 1fr; }

/* ── Filter Row ─────────────────────────────────────────────────── */
.filter-row {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap; margin-bottom: 20px;
}
.filter-row .search-wrap { flex: 1; min-width: 200px; }

/* ── Search Input ───────────────────────────────────────────────── */
.search-wrap { position: relative; }
.search-wrap svg {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--text-3); pointer-events: none; stroke-width: 2;
}
.search-wrap input { padding-left: 34px; }

/* ── Forms ──────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-row { display: grid; gap: 12px; }
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }

label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.req { color: var(--red); margin-left: 2px; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
  padding: 8px 12px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(249,115,22,0.12);
}
textarea { resize: vertical; min-height: 76px; }

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 34px;
}
.form-hint { font-size: 11px; color: var(--text-3); }

/* ── Modal ──────────────────────────────────────────────────────── */
.modal {
  display: none; position: fixed; inset: 0;
  z-index: 100;
  align-items: center; justify-content: center;
  padding: 20px;
}
.modal.open { display: flex; }

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.6);
  backdrop-filter: blur(3px);
}
.modal-box {
  position: relative;
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
  z-index: 1;
}
.modal-box.modal-lg { max-width: 660px; }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: var(--surface); z-index: 1;
}
.modal-title { font-size: 16px; font-weight: 700; letter-spacing: -0.2px; }
.modal-close {
  background: var(--surface-2); border: none; border-radius: var(--r-sm);
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-2);
}
.modal-close:hover { background: var(--border); color: var(--text); }
.modal-close svg { width: 14px; height: 14px; stroke-width: 2.5; }

.modal-body {
  padding: 18px 22px;
  display: flex; flex-direction: column; gap: 14px;
}
.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 22px 18px;
  border-top: 1px solid var(--border);
}

/* ── Tool Cards ─────────────────────────────────────────────────── */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 12px;
}
.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s, border-color 0.15s;
  cursor: default;
}
.tool-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }

.tool-card-top {
  display: flex; align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 8px;
}
.tool-card-group {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--orange-h);
  background: var(--orange-light);
  padding: 2px 7px;
  border-radius: var(--r-full);
}
.tool-card-actions { display: flex; gap: 3px; opacity: 0; transition: opacity 0.15s; }
.tool-card:hover .tool-card-actions { opacity: 1; }

.tool-card-name {
  font-size: 14px; font-weight: 600;
  color: var(--text); margin-bottom: 7px;
  line-height: 1.3;
}
.tool-location {
  display: flex; align-items: center; gap: 4px;
  font-size: 12px; color: var(--text-2);
  flex-wrap: wrap;
}
.tool-location svg { width: 12px; height: 12px; color: var(--text-3); flex-shrink: 0; stroke-width: 2; }
.loc-sep { color: var(--text-3); font-size: 10px; }

.tool-card-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--border);
}
.tool-card-notes {
  font-size: 11px; color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 160px;
}

/* ── Group Section ──────────────────────────────────────────────── */
.group-section { margin-bottom: 28px; }
.group-section:last-child { margin-bottom: 0; }

.group-header {
  display: flex; align-items: center; gap: 10px;
  padding-bottom: 10px; margin-bottom: 12px;
  border-bottom: 2px solid var(--border);
}
.group-header-actions { margin-left: auto; display: flex; gap: 4px; }
.group-name { font-size: 15px; font-weight: 700; color: var(--text); }
.group-count {
  font-size: 11px; color: var(--text-3);
  background: var(--surface-2); padding: 2px 8px;
  border-radius: var(--r-full); border: 1px solid var(--border);
}

/* ── Machine Cards ──────────────────────────────────────────────── */
.machines-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 16px;
}
.machine-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s, border-color 0.15s;
  cursor: pointer;
}
.machine-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }

.machine-photo {
  width: 100%; height: 150px;
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  border-bottom: 1px solid var(--border);
  position: relative; overflow: hidden;
}
.machine-photo img { width: 100%; height: 100%; object-fit: cover; }
.machine-photo-ph {
  display: flex; flex-direction: column;
  align-items: center; gap: 5px;
  color: var(--text-3); font-size: 11px;
}
.machine-photo-ph svg { width: 28px; height: 28px; stroke-width: 1.5; }
.machine-status-pos { position: absolute; top: 9px; right: 9px; }

.machine-info { padding: 14px 16px; }
.machine-type-label {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-3); margin-bottom: 3px;
}
.machine-name { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 2px; }
.machine-model { font-size: 12px; color: var(--text-2); margin-bottom: 10px; }
.machine-meta { display: flex; gap: 14px; flex-wrap: wrap; }
.meta-item { display: flex; flex-direction: column; gap: 1px; }
.meta-label {
  font-size: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-3);
}
.meta-value { font-size: 12px; font-weight: 600; color: var(--text-2); }

/* ── Record List (issues / service history) ─────────────────────── */
.record-list { display: flex; flex-direction: column; }
.record-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 13px 20px;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}
.record-item:last-child { border-bottom: none; }
.record-item:hover { background: var(--surface-2); }

.record-icon {
  width: 34px; height: 34px;
  border-radius: var(--r);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 1px;
}
.record-icon svg { width: 16px; height: 16px; stroke-width: 2; }
.ri-orange { background: var(--orange-light); color: var(--orange); }
.ri-green  { background: var(--green-light);  color: var(--green-h); }
.ri-red    { background: var(--red-light);    color: var(--red-h); }
.ri-blue   { background: var(--blue-light);   color: var(--blue-h); }
.ri-gray   { background: var(--surface-2);    color: var(--text-3); }
.ri-yellow { background: var(--yellow-light); color: var(--yellow); }

.record-body { flex: 1; min-width: 0; }
.record-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.record-desc {
  font-size: 12px; color: var(--text-2); margin-bottom: 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.record-meta {
  display: flex; align-items: center; gap: 10px;
  font-size: 11px; color: var(--text-3); flex-wrap: wrap;
}
.record-meta svg { width: 11px; height: 11px; stroke-width: 2; }
.record-actions { display: flex; gap: 3px; flex-shrink: 0; }

/* ── Interval Cards ─────────────────────────────────────────────── */
.interval-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
  padding: 16px 20px;
}
.interval-card {
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg); padding: 13px 15px;
  background: var(--surface); transition: border-color 0.15s;
  position: relative;
}
.interval-card.overdue  { border-color: var(--red);    background: var(--red-light); }
.interval-card.due-soon { border-color: var(--yellow);  background: var(--yellow-light); }
.interval-card.good     { border-color: var(--green); }
.interval-card.no-date  { border-color: var(--border-strong); }

.interval-name { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.interval-schedule { font-size: 12px; color: var(--text-2); margin-bottom: 10px; }
.interval-bottom { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.interval-due { font-size: 12px; font-weight: 600; }
.interval-card.overdue  .interval-due { color: var(--red-h); }
.interval-card.due-soon .interval-due { color: var(--yellow); }
.interval-card.good     .interval-due { color: var(--green-h); }
.interval-card.no-date  .interval-due { color: var(--text-3); }
.interval-card-actions { display: flex; gap: 3px; }

/* ── Tabs ───────────────────────────────────────────────────────── */
.tab-list {
  display: flex; gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 18px;
}
.tab {
  padding: 9px 16px;
  font-size: 13px; font-weight: 600;
  color: var(--text-3);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  background: none;
  border-top: none; border-left: none; border-right: none;
  transition: color 0.15s, border-color 0.15s;
  display: flex; align-items: center; gap: 6px;
}
.tab:hover { color: var(--text-2); }
.tab.active { color: var(--orange); border-bottom-color: var(--orange); }
.tab-count {
  font-size: 10px;
  background: var(--surface-2); color: var(--text-3);
  padding: 1px 6px; border-radius: var(--r-full);
  border: 1px solid var(--border);
}
.tab.active .tab-count {
  background: var(--orange-light); color: var(--orange-h);
  border-color: var(--orange-border);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Machine Detail Header ──────────────────────────────────────── */
.mdetail-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-sm);
  display: flex; gap: 20px; align-items: flex-start;
}
.mdetail-photo {
  width: 90px; height: 90px;
  border-radius: var(--r-lg);
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; overflow: hidden;
  border: 1px solid var(--border);
}
.mdetail-photo img { width: 100%; height: 100%; object-fit: cover; }
.mdetail-photo-ph { font-size: 36px; }

.mdetail-info { flex: 1; min-width: 0; }
.mdetail-type-label {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-3); margin-bottom: 3px;
}
.mdetail-name {
  font-size: 22px; font-weight: 800;
  color: var(--text); letter-spacing: -0.4px;
  margin-bottom: 2px;
}
.mdetail-model { font-size: 14px; color: var(--text-2); margin-bottom: 12px; }
.mdetail-specs { display: flex; gap: 18px; flex-wrap: wrap; }
.spec { display: flex; flex-direction: column; gap: 1px; }
.spec-label {
  font-size: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3);
}
.spec-value { font-size: 13px; font-weight: 600; color: var(--text-2); }

.mdetail-actions { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }

/* ── Back Link ──────────────────────────────────────────────────── */
.back-link {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 13px; font-weight: 500;
  color: var(--text-3);
  margin-bottom: 14px;
  background: none; border: none;
  cursor: pointer; transition: color 0.15s;
}
.back-link:hover { color: var(--text-2); }
.back-link svg { width: 13px; height: 13px; stroke-width: 2.5; }

/* ── Empty State ────────────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 44px 20px;
}
.empty svg { width: 36px; height: 36px; color: var(--text-3); stroke-width: 1.5; margin: 0 auto 10px; }
.empty-title { font-size: 15px; font-weight: 600; color: var(--text-2); margin-bottom: 5px; }
.empty-text {
  font-size: 13px; color: var(--text-3);
  max-width: 260px; margin: 0 auto 18px;
}

/* ── Photo Upload ───────────────────────────────────────────────── */
.photo-upload-area {
  border: 2px dashed var(--border-strong);
  border-radius: var(--r-lg); padding: 20px;
  text-align: center; cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.photo-upload-area:hover { border-color: var(--orange); background: var(--orange-light); }
.photo-upload-area input { display: none; }
.photo-upload-area svg { width: 26px; height: 26px; color: var(--text-3); stroke-width: 1.5; margin: 0 auto 6px; }
.photo-upload-text { font-size: 13px; font-weight: 600; color: var(--text-2); }
.photo-upload-hint { font-size: 11px; color: var(--text-3); margin-top: 2px; }

.photo-preview-wrap { position: relative; display: inline-block; }
.photo-preview-wrap img {
  width: 100%; height: 120px; object-fit: cover;
  border-radius: var(--r); border: 1px solid var(--border);
}
.photo-remove-btn {
  position: absolute; top: -8px; right: -8px;
  width: 22px; height: 22px;
  background: var(--red); border: 2px solid #fff;
  border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: #fff;
}
.photo-remove-btn svg { width: 10px; height: 10px; stroke-width: 3; }

/* ── Toast ──────────────────────────────────────────────────────── */
.toast-stack {
  position: fixed; bottom: 20px; right: 20px;
  z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--text); color: #fff;
  padding: 11px 16px; border-radius: var(--r-lg);
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 9px;
  min-width: 240px;
  animation: toast-in 0.22s ease;
  pointer-events: auto;
}
.toast.success { background: var(--green-h); }
.toast.error   { background: var(--red-h); }
.toast svg { width: 15px; height: 15px; flex-shrink: 0; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Spinner ────────────────────────────────────────────────────── */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}
.spinner.dark { border-color: rgba(0,0,0,0.1); border-top-color: var(--orange); }
@keyframes spin { to { transform: rotate(360deg); } }

.page-loader {
  display: flex; align-items: center; justify-content: center;
  padding: 80px 20px;
}

/* ── Auth Pages ─────────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--sidebar-bg);
  padding: 20px;
}
.auth-card {
  background: var(--surface);
  border-radius: var(--r-xl);
  padding: 38px;
  width: 100%; max-width: 420px;
  box-shadow: var(--shadow-lg);
}
.auth-logo {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 26px;
}
.auth-logo-icon {
  width: 40px; height: 40px;
  background: var(--orange); border-radius: var(--r);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.auth-logo-text { font-size: 20px; font-weight: 800; color: var(--text); letter-spacing: -0.4px; }
.auth-title { font-size: 20px; font-weight: 700; color: var(--text); margin-bottom: 5px; letter-spacing: -0.3px; }
.auth-subtitle { font-size: 14px; color: var(--text-2); margin-bottom: 26px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-error {
  background: var(--red-light); border: 1px solid var(--red-border);
  border-radius: var(--r); padding: 10px 13px;
  font-size: 13px; color: var(--red-h); display: none;
}
.auth-error.show { display: block; }
.auth-footer {
  text-align: center; font-size: 13px; color: var(--text-2); margin-top: 18px;
}
.auth-footer a { color: var(--orange); font-weight: 600; }
.auth-footer a:hover { text-decoration: underline; }

/* ── Divider ────────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 14px 0; }

/* ── Dashboard Sections ─────────────────────────────────────────── */
.dash-sections { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-sections { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .content-grid-2 { grid-template-columns: 1fr; }
  .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
  .mdetail-header { flex-direction: column; }
  .mdetail-actions { flex-direction: row; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .mobile-header { display: flex; }
  .main { margin-left: 0; }
  .main-inner { padding: 16px; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  :root { --content-pad: 16px; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 24px 20px; }
  .modal { padding: 0; align-items: flex-end; }
  .modal-box { border-radius: var(--r-lg) var(--r-lg) 0 0; }
  .tools-grid, .machines-grid { grid-template-columns: 1fr; }
}

/* ── Utilities ──────────────────────────────────────────────────── */
.hidden { display: none !important; }
.w-full { width: 100%; }
.text-muted { color: var(--text-3); font-size: 12px; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.flex { display: flex; } .items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; }

/* ── View Toggle ────────────────────────────────────────────────── */
.view-toggle {
  display: flex;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  padding: 3px; gap: 2px;
}
.view-toggle-btn {
  padding: 6px 14px;
  border-radius: calc(var(--r) - 3px);
  font-size: 13px; font-weight: 600;
  color: var(--text-2);
  background: none; border: none; cursor: pointer;
  transition: background 0.15s, color 0.15s;
  display: flex; align-items: center; gap: 5px;
}
.view-toggle-btn svg { width: 14px; height: 14px; stroke-width: 2; }
.view-toggle-btn.active {
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ── Location Cards ─────────────────────────────────────────────── */
.locations-grid { display: flex; flex-direction: column; gap: 14px; }

.location-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm); overflow: hidden;
  transition: box-shadow 0.15s;
}
.location-card:hover { box-shadow: var(--shadow); }

.location-card-header {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; cursor: pointer;
  user-select: none; transition: background 0.12s;
}
.location-card-header:hover { background: var(--surface-2); }

.location-icon {
  width: 42px; height: 42px; border-radius: var(--r);
  background: var(--orange-light);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.location-icon svg { width: 22px; height: 22px; stroke-width: 1.8; color: var(--orange-h); }

/* Type-specific icon colours */
.location-icon.loc-type-cart     { background: var(--orange-light); }
.location-icon.loc-type-cart svg { color: var(--orange-h); }
.location-icon.loc-type-cabinet     { background: var(--blue-light); }
.location-icon.loc-type-cabinet svg { color: var(--blue-h); }
.location-icon.loc-type-chest     { background: #f3e8ff; }
.location-icon.loc-type-chest svg { color: #7c3aed; }
.location-icon.loc-type-shelf     { background: var(--green-light); }
.location-icon.loc-type-shelf svg { color: var(--green-h); }
.location-icon.loc-type-pegboard     { background: #ccfbf1; }
.location-icon.loc-type-pegboard svg { color: #0d9488; }
.location-icon.loc-type-rack     { background: var(--red-light); }
.location-icon.loc-type-rack svg { color: var(--red-h); }
.location-icon.loc-type-bag     { background: #e0e7ff; }
.location-icon.loc-type-bag svg { color: #4338ca; }
.location-icon.loc-type-other     { background: var(--surface-2); }
.location-icon.loc-type-other svg { color: var(--text-3); }
.location-info { flex: 1; min-width: 0; }
.location-name { font-size: 15px; font-weight: 700; color: var(--text); }
.location-meta { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.location-card-actions { display: flex; gap: 3px; opacity: 0; transition: opacity 0.15s; }
.location-card:hover .location-card-actions { opacity: 1; }

.location-chevron {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3); flex-shrink: 0;
  transition: transform 0.25s ease;
}
.location-chevron svg { width: 16px; height: 16px; stroke-width: 2.5; }
.location-card.open .location-chevron { transform: rotate(180deg); }

.location-body {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease;
}
.location-card.open .location-body { max-height: 3000px; }

.location-body-content {
  border-top: 1px solid var(--border);
  padding: 0;
}

.location-section-block {
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
}
.location-section-block:last-child { border-bottom: none; }

.location-section-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-3); margin-bottom: 8px;
}
.location-section-label svg { width: 11px; height: 11px; stroke-width: 2; flex-shrink: 0; }

.location-tool-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.location-tool-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border: 1px solid var(--border);
  border-radius: var(--r-full); font-size: 12px; font-weight: 500;
  color: var(--text-2); background: var(--surface);
  cursor: pointer; transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.location-tool-chip:hover { border-color: var(--orange); color: var(--orange-h); background: var(--orange-light); }
.location-tool-chip svg { width: 10px; height: 10px; stroke-width: 2; opacity: 0.5; }
.location-empty-text { font-size: 12px; color: var(--text-3); font-style: italic; padding: 2px 0; }

.location-notes {
  padding: 10px 18px;
  font-size: 12px; color: var(--text-2); font-style: italic;
  border-bottom: 1px solid var(--border);
}

.loc-stats-bar {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-3);
  margin-bottom: 14px;
}
.loc-stats-dot { color: var(--border-strong); }
.loc-stats-warn { color: var(--yellow); font-weight: 600; }

.sections-list { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.section-row { display: flex; align-items: center; gap: 8px; }
.section-row input { flex: 1; }
.remove-section-btn {
  width: 30px; height: 30px; flex-shrink: 0;
  border: none; border-radius: var(--r-sm);
  background: var(--surface-2); color: var(--text-3);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background 0.12s, color 0.12s;
}
.remove-section-btn:hover { background: var(--red-light); color: var(--red-h); }
.remove-section-btn svg { width: 13px; height: 13px; stroke-width: 2.5; }

/* ── Parts ──────────────────────────────────────────────────────── */
.parts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
}
.part-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg); padding: 14px 16px;
  box-shadow: var(--shadow-sm); cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
  display: flex; flex-direction: column; gap: 10px;
}
.part-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.part-card.low-stock { border-color: var(--orange-border); }
.part-card.out-of-stock { border-color: var(--red-border); }

.part-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.part-card-left { flex: 1; min-width: 0; }
.part-card-name { font-size: 14px; font-weight: 700; color: var(--text); line-height: 1.3; }
.part-card-sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }

.part-qty-badge {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 6px 10px; border-radius: var(--r);
  background: var(--green-light); border: 1.5px solid var(--green-border);
  flex-shrink: 0; min-width: 52px;
}
.part-qty-badge.low  { background: var(--orange-light); border-color: var(--orange-border); }
.part-qty-badge.out  { background: var(--red-light);    border-color: var(--red-border); }
.part-qty-num { font-size: 20px; font-weight: 800; line-height: 1; color: var(--green-h); }
.part-qty-badge.low  .part-qty-num { color: var(--orange-h); }
.part-qty-badge.out  .part-qty-num { color: var(--red-h); }
.part-qty-unit { font-size: 9px; font-weight: 700; text-transform: uppercase; color: var(--text-3); letter-spacing: 0.06em; margin-top: 2px; }

.part-card-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 8px; border-top: 1px solid var(--border);
  font-size: 11px; color: var(--text-3); gap: 8px;
}

.part-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 16px; }
.part-detail-field { display: flex; flex-direction: column; gap: 3px; }
.part-detail-field-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-3); }
.part-detail-field-value { font-size: 14px; color: var(--text); font-weight: 500; }

.compat-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.compat-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border: 1px solid var(--blue-border);
  border-radius: var(--r-full); font-size: 12px; font-weight: 500;
  color: var(--blue-h); background: var(--blue-light);
}

.usage-list { display: flex; flex-direction: column; }
.usage-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13px;
}
.usage-item:last-child { border-bottom: none; }
.usage-item-machine { font-weight: 600; color: var(--text); flex: 1; }
.usage-item-qty { color: var(--text-2); white-space: nowrap; }
.usage-item-date { color: var(--text-3); font-size: 11px; white-space: nowrap; }

.qty-adj-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; background: var(--surface-2); border-radius: var(--r-lg);
}
.qty-adj-label { font-size: 13px; font-weight: 600; color: var(--text-2); flex: 1; }
.qty-adj-controls { display: flex; align-items: center; gap: 8px; }
.qty-adj-btn {
  width: 32px; height: 32px; border-radius: var(--r-sm);
  border: 1.5px solid var(--border-strong); background: var(--surface);
  color: var(--text); display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 18px; font-weight: 600; transition: background 0.12s;
}
.qty-adj-btn:hover { background: var(--surface-2); }
.qty-adj-num { font-size: 20px; font-weight: 800; min-width: 44px; text-align: center; }

.low-stock-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0;
}
.low-stock-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--orange); }
.low-stock-row label { font-size: 13px; font-weight: 500; color: var(--text-2); margin: 0; flex: 1; }
.low-stock-threshold { width: 80px !important; }

.part-modal-section-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--text-3); margin-bottom: 8px;
}

.compat-machine-select-list { display: flex; flex-direction: column; gap: 4px; max-height: 160px; overflow-y: auto; }
.compat-machine-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: var(--r-sm);
  transition: background 0.1s; cursor: pointer;
}
.compat-machine-item:hover { background: var(--surface-2); }
.compat-machine-item input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--orange); flex-shrink: 0; }
.compat-machine-item label { font-size: 13px; font-weight: 500; color: var(--text); margin: 0; cursor: pointer; flex: 1; }
