:root {
  --ink: #111827;
  --muted: #667085;
  --line: #d8dee7;
  --soft-line: #edf1f5;
  --panel: #ffffff;
  --page: #f7f9fc;
  --nav: #0c1c27;
  --nav-2: #132d3b;
  --green: #159947;
  --green-soft: #e7f7ed;
  --amber: #f2a100;
  --amber-soft: #fff4dc;
  --red: #d9291f;
  --red-soft: #ffe8e6;
  --teal: #07979b;
  --teal-soft: #e3f8f8;
  --blue: #0b68cf;
  --shadow: 0 8px 24px rgba(17, 24, 39, 0.06);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  padding: 28px;
  min-width: 0;
}

.clerk-auth {
  width: 100%;
  min-width: 0;
  margin-top: 20px;
}

@media (max-width: 480px) {
  .login-page {
    padding: 16px;
  }

  .login-card {
    padding: 24px 20px;
  }
}

.login-brand {
  display: grid;
  place-items: center;
  margin: 0 0 16px;
}

.login-brand img {
  width: min(220px, 72%);
  height: auto;
  object-fit: contain;
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

.login-form label {
  display: grid;
  gap: 6px;
  color: #344054;
  font-size: 13px;
  font-weight: 800;
}

.login-form input {
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 246px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 24px 16px;
  background: linear-gradient(180deg, var(--nav), var(--nav-2));
  color: #f7fbff;
}

.sidebar-brand {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 58px;
  margin: 0 0 18px;
  padding: 7px 8px;
  border-radius: 12px;
  color: #fff;
  font-weight: 850;
}

.sidebar-brand img {
  width: 46px;
  height: 46px;
  object-fit: contain;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.14);
}

.sidebar-brand span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hamburger {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 0;
  background: transparent;
  color: currentColor;
  font-size: 22px;
}

.nav-list {
  display: grid;
  gap: 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 48px;
  padding: 0 14px;
  border-radius: 8px;
  color: #edf4fb;
  font-weight: 700;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.1);
}

.nav-item.active {
  box-shadow: inset 4px 0 0 #24bd73;
}

.icon {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 6px;
  font-size: 15px;
}

.sidebar-card,
.quick-create {
  margin-top: auto;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
}

.sidebar-card span,
.quick-create span {
  color: #c8d5df;
  font-size: 13px;
}

.sidebar-card strong {
  display: block;
  margin: 8px 0 14px;
  color: #5eb3ff;
  font-size: 34px;
}

.mini-legend {
  display: grid;
  gap: 8px;
}

.mini-legend span {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
}

.urgent,
.high {
  background: var(--red);
}

.medium {
  background: var(--amber);
}

.quick-create {
  display: grid;
  gap: 10px;
}

.quick-create .primary-action,
.quick-create button {
  display: grid;
  min-height: 42px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  color: white;
  font-weight: 800;
}

.quick-create button {
  background: transparent;
}

.main {
  min-width: 0;
  padding: 0 28px 34px;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 82px minmax(0, 1fr);
}

.app-shell.sidebar-collapsed .sidebar {
  padding-inline: 14px;
}

.app-shell.sidebar-collapsed .nav-item {
  justify-content: center;
  padding-inline: 0;
}

.app-shell.sidebar-collapsed .nav-item span:last-child,
.app-shell.sidebar-collapsed .sidebar-brand span,
.app-shell.sidebar-collapsed .sidebar-card,
.app-shell.sidebar-collapsed .quick-create {
  display: none;
}

.app-shell.sidebar-collapsed .sidebar-brand {
  grid-template-columns: 1fr;
  justify-items: center;
  padding-inline: 0;
}

.app-shell.sidebar-collapsed .sidebar-brand img {
  width: 40px;
  height: 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 76px;
  margin: 0 -28px 22px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.filters-bar {
  justify-content: start;
}

.search {
  position: relative;
  flex: 1;
  max-width: 560px;
}

.search span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.search input,
.topbar select,
.log-form input,
.log-form select,
.log-form textarea,
table select,
.small-select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.search input {
  height: 44px;
  padding: 0 44px 0 16px;
}

.search::after {
  content: "⌕";
  position: absolute;
  top: 8px;
  right: 14px;
  color: #344054;
  font-size: 20px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar select {
  max-width: 220px;
  height: 42px;
  padding: 0 12px;
}

.control-pill,
.shift-pill {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #344054;
  white-space: nowrap;
}

.shift-pill b {
  margin-left: 4px;
  color: var(--green);
}

.bell {
  position: relative;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  background: var(--red);
}

.user-dot {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #f2f4f7;
  color: #667085;
  font-weight: 900;
}

.account-menu-wrap {
  position: relative;
  display: inline-flex;
}

.account-button {
  background: #3557ff;
  color: #fff;
  cursor: pointer;
  background-position: center;
  background-size: cover;
}

.account-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.16);
}

.account-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 40;
  display: grid;
  min-width: 240px;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(17, 24, 39, 0.12);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 45px rgba(17, 24, 39, 0.16);
  backdrop-filter: blur(18px);
}

.account-menu[hidden] {
  display: none;
}

.account-menu-user {
  display: grid;
  gap: 3px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--soft-line);
}

.account-menu-user strong {
  color: var(--ink);
}

.account-menu-user span {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.account-signout {
  justify-content: center;
}

.shop-user,
.back-link {
  color: #344054;
  font-weight: 700;
}

.page-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 34px;
  line-height: 1.1;
}

h2 {
  margin-bottom: 0;
  font-size: 19px;
}

h3 {
  margin-bottom: 0;
}

.updated {
  display: grid;
  gap: 4px;
  text-align: right;
}

.updated span,
.subtle,
.machine-meta,
.metric span {
  color: var(--muted);
  font-size: 13px;
}

.summary-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  margin-bottom: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.summary-card {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 50px;
  padding: 0 12px;
  border-left: 1px solid var(--line);
}

.summary-card:first-child {
  border-left: 0;
}

.summary-card strong {
  font-size: 22px;
}

.summary-icon,
.round-status,
.rail-icon {
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font-weight: 900;
}

.summary-icon {
  width: 22px;
  height: 22px;
  font-size: 10px;
  letter-spacing: 0;
  line-height: 1;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 22px;
}

.machine-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  align-content: start;
}

.panel,
.machine-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.machine-card {
  position: relative;
  display: grid;
  gap: 12px;
  min-height: 168px;
  padding: 18px 14px 12px;
  background: #fff;
  color: inherit;
  cursor: pointer;
  overflow: hidden;
  text-decoration: none;
}

.machine-card.status-operational,
.machine-card.status-down,
.machine-card.status-maintenance,
.machine-card.status-inactive,
.machine-card.status-unknown {
  background: #fff;
  color: var(--ink);
}

.machine-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: var(--green);
}

.machine-card.status-down::before {
  background: var(--red);
}

.machine-card.status-maintenance::before,
.machine-card.status-inactive::before {
  background: var(--amber);
}

.machine-top {
  display: grid;
  grid-template-columns: 22px 78px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.round-status {
  width: 16px;
  height: 16px;
  font-size: 0;
  background: var(--green);
}

.status-down.round-status,
.status-down.summary-icon,
.status-urgent.summary-icon,
.status-urgent.rail-icon {
  background: var(--red);
}

.status-maintenance.round-status,
.status-maintenance.summary-icon {
  background: var(--amber);
}

.status-operational.round-status,
.status-operational.summary-icon {
  background: var(--green);
}

.status-unknown.summary-icon {
  background: #98a2b3;
}

.machine-art,
.mini-machine,
.photo-machine,
.photo-thumb {
  display: grid;
  place-items: center;
  border: 1px solid #cfd8e3;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.65), rgba(218, 229, 238, 0.9)),
    #edf3f8;
  color: #203241;
  font-weight: 900;
}

.machine-art {
  width: 76px;
  height: 50px;
  font-size: 18px;
}

.machine-art.photo-art {
  object-fit: contain;
  padding: 4px;
}

.machine-art.lifting,
.photo-machine {
  background: linear-gradient(180deg, #ffd978, #d79a12);
}

.machine-art.utilities {
  background: linear-gradient(180deg, #dceaf5, #9fb6ca);
}

.machine-heading {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.machine-heading h3 {
  overflow: hidden;
  font-size: 17px;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.machine-top h3 {
  font-size: 17px;
}

.status-chip,
.priority-chip {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 25px;
  padding: 0 9px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 800;
  text-transform: capitalize;
}

.status-operational {
  background: var(--green-soft);
  color: var(--green);
}

.summary-icon.status-operational {
  background: var(--green);
  color: #fff;
}

.summary-icon.status-down,
.summary-icon.status-urgent {
  background: var(--red);
  color: #fff;
}

.status-down,
.status-urgent,
.priority-urgent,
.priority-high {
  background: var(--red-soft);
  color: var(--red);
}

.status-maintenance,
.status-inactive,
.status-due-soon,
.status-overdue,
.priority-medium {
  background: var(--amber-soft);
  color: #a76500;
}

.status-scheduled,
.priority-low {
  background: var(--teal-soft);
  color: var(--teal);
}

.status-unknown {
  background: #eef2f6;
  color: #475467;
}

.machine-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  padding-top: 2px;
}

.metric {
  display: grid;
  gap: 2px;
  min-width: 0;
  border-left: 1px solid var(--soft-line);
  padding-left: 12px;
}

.metric:first-child {
  border-left: 0;
  padding-left: 0;
}

.metric strong {
  font-size: 18px;
  font-weight: 500;
}

.machine-footer {
  padding-top: 10px;
  border-top: 1px solid var(--soft-line);
  margin: 0;
  color: #667085;
  font-size: 12px;
}

.status-down .machine-footer {
  color: var(--red);
  font-weight: 800;
}

.status-maintenance .machine-footer {
  color: var(--amber);
  font-weight: 800;
}

.right-rail,
.left-stack,
.middle-stack {
  display: grid;
  gap: 16px;
  align-content: start;
}

.panel {
  padding: 18px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-title small {
  display: inline-grid;
  min-width: 22px;
  height: 22px;
  place-items: center;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-size: 12px;
}

#pmBadge {
  background: var(--amber);
}

.text-button,
.table-link {
  border: 0;
  background: transparent;
  color: var(--blue);
  font-weight: 800;
}

.rail-card {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid var(--soft-line);
}

.rail-card:first-child {
  border-top: 0;
  padding-top: 0;
}

.rail-icon,
.mini-machine {
  width: 36px;
  height: 36px;
}

.rail-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.rail-card p {
  margin: 4px 0;
  color: #475467;
  font-size: 13px;
}

.alert-time {
  color: var(--red);
  font-size: 12px;
  font-weight: 800;
}

.pm-time {
  color: var(--amber);
  font-size: 12px;
  font-weight: 800;
}

.timeline {
  max-height: 520px;
  overflow: auto;
}

.timeline.compact {
  max-height: 330px;
}

.timeline-item {
  position: relative;
  display: grid;
  gap: 4px;
  padding: 12px 0 12px 24px;
  border-top: 1px solid var(--soft-line);
}

.timeline-item:first-child {
  border-top: 0;
  padding-top: 0;
}

.timeline-item::before {
  content: "";
  position: absolute;
  top: 18px;
  left: 3px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
}

.timeline-item.status-down::before {
  background: var(--red);
}

.timeline-item.status-maintenance::before {
  background: var(--amber);
}

.timeline-item p {
  margin: 0;
  color: #475467;
  font-size: 13px;
}

.timeline-item-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.timeline-item-head strong {
  min-width: 0;
}

.log-edit-action {
  flex-shrink: 0;
  min-height: 26px;
  padding: 0 10px;
  border: 1px solid rgba(0, 122, 255, 0.22);
  border-radius: 8px;
  background: rgba(0, 122, 255, 0.08);
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
}

.log-edit-action:hover {
  background: rgba(0, 122, 255, 0.14);
}

.log-list {
  max-height: none;
}

.log-filter-bar {
  display: flex;
  justify-content: flex-end;
  margin: -6px 0 16px;
}

.log-filter-bar .date-range-control {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
}

.log-filter-bar .text-button {
  min-height: 34px;
  align-self: end;
  padding-inline: 12px;
  flex-shrink: 0;
}

.detail-hero {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 0;
  padding: 0;
  overflow: hidden;
}

.machine-photo {
  display: grid;
  min-height: 180px;
  place-items: center;
  background:
    linear-gradient(rgba(16, 24, 32, 0.1), rgba(16, 24, 32, 0.1)),
    repeating-linear-gradient(90deg, #d9e1e8 0 1px, transparent 1px 80px),
    linear-gradient(180deg, #eef3f6, #c6d3dc);
}

.photo-machine {
  width: 220px;
  height: 90px;
  border-radius: 8px;
  font-size: 36px;
  letter-spacing: 0.08em;
}

.photo-machine.real-photo {
  width: min(88%, 520px);
  height: 170px;
  object-fit: contain;
  border: 0;
  border-radius: 0;
  background: transparent;
  letter-spacing: 0;
}

.detail-summary {
  padding: 34px;
}

.detail-summary h1 {
  margin-bottom: 22px;
}

.detail-facts.inline {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.detail-facts span {
  display: block;
  margin-bottom: 8px;
  color: #667085;
  font-size: 13px;
}

.date-range-control {
  display: flex;
  align-items: end;
  gap: 10px;
}

.date-range-control label {
  display: grid;
  gap: 4px;
  color: #667085;
  font-size: 12px;
  font-weight: 800;
}

.date-range-control input {
  min-height: 34px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.record-tabs {
  display: flex;
  gap: 42px;
  margin: 0 0 20px;
  padding: 0 34px;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  background: #fff;
}

.record-tabs button {
  padding: 18px 0 14px;
  border: 0;
  background: transparent;
  color: #344054;
  font-weight: 700;
  border-bottom: 3px solid transparent;
}

.record-tabs button.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

.machine-page-grid {
  display: grid;
  grid-template-columns: 330px minmax(360px, 1fr);
  gap: 18px;
  align-items: start;
}

.hidden-panel {
  display: none;
}

.machine-pm-panel {
  grid-column: 1 / -1;
}

.issue-card {
  position: relative;
  display: grid;
  gap: 5px;
  margin-top: 10px;
  padding: 14px;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: #fff;
}

.issue-card span {
  color: #667085;
  font-size: 13px;
}

.issue-card b {
  position: absolute;
  right: 12px;
  bottom: 12px;
}

.recent-log {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 13px 0;
  border-top: 1px solid var(--soft-line);
}

.recent-log:first-child {
  border-top: 0;
}

.recent-log > span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
}

.recent-log.status-down > span {
  background: var(--red);
}

.recent-log.status-maintenance > span {
  background: var(--amber);
}

.recent-log a {
  color: var(--blue);
  font-weight: 800;
}

.recent-log p {
  margin: 4px 0 0;
  color: #667085;
  font-size: 13px;
}

.log-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.log-form label {
  display: grid;
  gap: 6px;
  color: #344054;
  font-size: 13px;
  font-weight: 800;
}

.log-form input,
.log-form select,
.log-form textarea {
  min-height: 42px;
  padding: 10px 12px;
}

.time-field input {
  min-width: 0;
  font-size: 14px;
}

.log-form textarea {
  resize: vertical;
}

.wide {
  grid-column: 1 / -1;
}

.photo-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.photo-box {
  min-height: 78px;
  border: 1px dashed #b8c3cf;
  border-radius: 8px;
  background: #fbfcfe;
  color: #344054;
  font-weight: 800;
}

.photo-thumb {
  min-height: 78px;
  color: #344054;
  font-size: 13px;
}

.recurring-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: #fbfcfe;
}

.work-order-form-panel {
  margin-bottom: 16px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(2, 8, 23, 0.45);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-card {
  width: min(760px, 100%);
  max-height: calc(100vh - 48px);
  margin: 0;
  overflow: auto;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.24);
}

.modal-open {
  overflow: hidden;
}

.work-order-form {
  display: grid;
  grid-template-columns: 150px repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.work-order-form label,
.asset-form label,
.settings-add-form label,
.user-role-form label {
  display: grid;
  gap: 6px;
  color: #344054;
  font-size: 13px;
  font-weight: 800;
}

.work-order-form input,
.work-order-form select,
.asset-form input,
.asset-form select,
.asset-form textarea,
.settings-add-form input,
.settings-add-form select,
.user-role-form input,
.user-role-form select,
.user-access-controls select {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.compact-field {
  max-width: 150px;
}

.asset-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.asset-image-field {
  display: grid;
  gap: 8px;
  color: #344054;
  font-size: 13px;
  font-weight: 800;
}

.asset-drop-zone {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  min-height: 128px;
  padding: 14px;
  border: 1px dashed #b8c3cf;
  border-radius: 12px;
  background: #fbfcfe;
  cursor: pointer;
}

.recent-log-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.asset-drop-zone p {
  margin: 4px 0 12px;
  color: #667085;
  font-size: 13px;
  font-weight: 600;
}

.asset-drop-zone.drag-over {
  border-color: var(--blue);
  background: #f0f7ff;
}

.asset-image-preview {
  display: grid;
  width: 112px;
  height: 88px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.65), rgba(218, 229, 238, 0.9)),
    #edf3f8;
  color: #203241;
  font-size: 18px;
  font-weight: 900;
  overflow: hidden;
}

.asset-image-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.asset-image-preview.has-image {
  background: #fff;
}

.asset-image-remove {
  justify-self: start;
}

.settings-add-form {
  display: grid;
  grid-template-columns: 220px minmax(240px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.user-access-card {
  margin-top: 16px;
}

.user-role-form {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 220px auto;
  gap: 12px;
  align-items: end;
}

.user-access-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.user-access-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px;
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.user-access-person {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.user-access-avatar {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 0%;
  background: linear-gradient(180deg, #f7f9ff, #e7eef8);
  color: #0f172a;
  font-weight: 900;
  box-shadow: inset 0 0 0 1px rgba(17, 24, 39, 0.08);
}

.user-access-person strong,
.user-access-person small {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.user-access-person small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.user-access-controls {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
}

.user-access-controls select {
  min-width: 150px;
}

.compact-empty {
  min-height: 78px;
  margin: 0;
}

.settings-save-status {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.settings-save-status[data-tone="success"] {
  color: var(--green);
}

.settings-save-status[data-tone="error"] {
  color: var(--red);
}

.page-toast {
  width: fit-content;
  max-width: min(520px, 100%);
  margin: 14px 0 0;
  padding: 10px 14px;
  border: 1px solid rgba(22, 163, 74, 0.18);
  border-radius: 12px;
  background: rgba(240, 253, 244, 0.88);
  color: var(--green);
  font-size: 14px;
  font-weight: 800;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.08);
}

.page-toast[hidden] {
  display: none;
}

.page-toast[data-tone="error"] {
  border-color: rgba(220, 38, 38, 0.2);
  background: rgba(254, 242, 242, 0.9);
  color: var(--red);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.settings-list {
  display: grid;
  gap: 8px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: #fbfcfe;
}

.settings-row span {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.disabled-preview {
  opacity: 0.45;
  cursor: not-allowed;
}

.detail-edit {
  justify-self: start;
  margin-top: 16px;
}

.recurring-form label {
  display: grid;
  gap: 6px;
  color: #344054;
  font-size: 13px;
  font-weight: 800;
}

.recurring-form input,
.recurring-form select {
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.recurring-actions,
.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.recurring-actions {
  align-self: end;
}

.row-actions .outline-button,
.row-actions .danger-action {
  min-height: 32px;
  padding-inline: 10px;
}

.primary-action,
.danger-action,
.outline-button {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 8px;
  font-weight: 800;
}

.primary-action {
  border: 0;
  background: var(--green);
  color: white;
}

.danger-action {
  border: 0;
  background: var(--red);
  color: white;
}

.outline-button {
  border: 1px solid var(--green);
  background: #fff;
  color: var(--green);
}

.close-order {
  min-height: 34px;
  padding-inline: 12px;
}

.save-state {
  color: #667085;
  font-size: 13px;
  font-weight: 800;
}

.planning-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(420px, 0.95fr);
  gap: 16px;
  margin-bottom: 16px;
}

.schedule-stack {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.lower-planning {
  grid-template-columns: 1fr 1fr;
}

.calendar {
  position: relative;
  display: grid;
  grid-template-columns: repeat(7, minmax(92px, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.calendar-empty {
  position: absolute;
  inset: 58px 16px 16px;
  display: grid;
  place-items: center;
  color: #667085;
  font-weight: 800;
  pointer-events: none;
}

.empty-state {
  display: grid;
  min-height: 90px;
  place-items: center;
  color: #667085;
  font-weight: 800;
  text-align: center;
}

.day {
  min-height: 360px;
  padding: 12px;
  border-left: 1px solid var(--line);
  background: #fbfcfe;
}

.day:first-child {
  border-left: 0;
}

.day strong {
  display: block;
  margin-bottom: 12px;
  font-size: 13px;
}

.calendar-event {
  display: grid;
  gap: 3px;
  margin-bottom: 8px;
  padding: 9px;
  border-left: 4px solid var(--green);
  border-radius: 6px;
  background: var(--green-soft);
  color: #145336;
  font-size: 12px;
}

.calendar-event.status-overdue {
  border-color: var(--red);
  background: var(--red-soft);
  color: var(--red);
}

.calendar-event.status-due-soon {
  border-color: var(--amber);
  background: var(--amber-soft);
  color: #8a5a00;
}

.calendar.schedule-month {
  grid-template-columns: repeat(7, minmax(76px, 1fr));
}

.month-day {
  min-height: 96px;
  padding: 9px;
  border-left: 1px solid var(--line);
  border-top: 1px solid var(--line);
  background: #fbfcfe;
}

.month-day:nth-child(7n + 1) {
  border-left: 0;
}

.month-day:nth-child(-n + 7) {
  border-top: 0;
}

.muted-day {
  background: #f2f4f7;
}

.month-day strong {
  display: block;
  margin-bottom: 8px;
  color: #344054;
  font-size: 12px;
}

.month-event {
  display: block;
  margin-top: 5px;
  padding: 5px 6px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
}

.calendar.schedule-list {
  display: block;
}

.schedule-list-wrap {
  overflow: auto;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.month-picker {
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-weight: 800;
}

.segmented button,
.tabs button {
  min-height: 34px;
  border: 0;
  background: white;
  color: #475467;
  font-weight: 800;
}

.segmented button {
  min-width: 72px;
}

.segmented .active,
.tabs .active {
  background: var(--green);
  color: white;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.tabs button {
  min-width: 100px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 10px;
  border-bottom: 1px solid var(--soft-line);
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

th {
  color: #667085;
  font-size: 12px;
  text-transform: uppercase;
}

table select {
  max-width: 120px;
  min-height: 34px;
  padding: 0 8px;
}

.progress {
  width: 120px;
  height: 10px;
  border-radius: 999px;
  background: #edf1f5;
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--amber);
}

.chart-card {
  display: flex;
  align-items: end;
  justify-content: space-around;
  min-height: 200px;
  padding: 22px 14px 8px;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: linear-gradient(180deg, #fff 0, #fff 24%, #f7f9fc 24%, #f7f9fc 25%, #fff 25%);
}

.bar-row {
  display: grid;
  grid-template-rows: 1fr auto auto;
  align-items: end;
  justify-items: center;
  gap: 8px;
  height: 160px;
  color: #667085;
  font-size: 12px;
}

.bar-track {
  display: flex;
  align-items: end;
  width: 36px;
  height: 120px;
  border-radius: 4px 4px 0 0;
  background: transparent;
}

.bar-fill {
  width: 100%;
  min-height: 3px;
  border-radius: 4px 4px 0 0;
  background: var(--red);
}

@media (max-width: 1280px) {
  .dashboard-grid,
  .machine-page-grid,
  .planning-grid,
  .lower-planning {
    grid-template-columns: 1fr;
  }

  .right-rail {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  }
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    width: min(82vw, 280px);
    height: 100vh;
    transform: translateX(-105%);
    transition: transform 180ms ease;
    box-shadow: 20px 0 40px rgba(17, 24, 39, 0.24);
  }

  .app-shell.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .app-shell.sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .nav-list {
    grid-template-columns: 1fr;
  }

  .main {
    padding: 0 16px 28px;
  }

  .topbar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: start;
    margin: 0 -16px 18px;
    padding: 14px 16px;
  }

  .page-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar .hamburger {
    grid-column: 1;
    grid-row: 1;
  }

  .topbar .search {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    max-width: none;
    margin-top: 10px;
  }

  .topbar-actions {
    grid-column: 3;
    grid-row: 1;
    align-items: center;
    justify-content: end;
    gap: 8px;
  }

  .account-menu-wrap {
    order: 2;
  }

  .shop-user {
    order: 1;
    max-width: 120px;
    overflow: hidden;
    text-align: right;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .summary-row,
  .right-rail,
  .detail-facts.inline,
  .photo-row,
  .settings-grid,
  .settings-add-form,
  .user-role-form,
  .asset-form,
  .work-order-form {
    grid-template-columns: 1fr;
  }

  .user-access-row,
  .user-access-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .user-access-controls select {
    width: 100%;
  }

  .compact-field {
    max-width: none;
  }

  .summary-card {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .summary-card:first-child {
    border-top: 0;
  }

  .detail-hero {
    grid-template-columns: 1fr;
  }

  .record-tabs {
    gap: 20px;
    overflow: auto;
    padding: 0 16px;
  }

  .calendar {
    grid-template-columns: 1fr;
  }

  .day {
    min-height: auto;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .form-actions {
    grid-template-columns: 1fr;
  }
}

/* Apple-inspired polish layer */
:root {
  --ink: #111827;
  --muted: #6b7280;
  --line: rgba(17, 24, 39, 0.11);
  --soft-line: rgba(17, 24, 39, 0.07);
  --panel: rgba(255, 255, 255, 0.88);
  --page: #f5f5f7;
  --nav: #111827;
  --nav-2: #1f2937;
  --green: #28a745;
  --green-soft: #eaf8ee;
  --amber: #ff9f0a;
  --amber-soft: #fff3dc;
  --red: #ff3b30;
  --red-soft: #ffe9e7;
  --teal: #00a7a7;
  --teal-soft: #e6f8f8;
  --blue: #007aff;
  --shadow: 0 10px 30px rgba(17, 24, 39, 0.06), 0 1px 2px rgba(17, 24, 39, 0.06);
}

body {
  background:
    radial-gradient(circle at 18% 0%, rgba(255, 255, 255, 0.92), transparent 34%),
    linear-gradient(180deg, #fbfbfd 0%, #f5f5f7 36%, #f2f4f7 100%);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", Inter, "Segoe UI", sans-serif;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}

.sidebar {
  background:
    linear-gradient(180deg, rgba(17, 24, 39, 0.98), rgba(31, 41, 55, 0.98)),
    var(--nav);
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.08);
}

.nav-list {
  gap: 8px;
}

.nav-item {
  min-height: 46px;
  border-radius: 14px;
  color: rgba(255, 255, 255, 0.88);
  font-weight: 700;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.nav-item.active {
  background: rgba(255, 255, 255, 0.14);
  box-shadow: inset 3px 0 0 #34c759;
  color: #fff;
}

.icon {
  border-color: rgba(255, 255, 255, 0.2);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.04);
}

.sidebar-card,
.quick-create {
  border-color: rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

.main {
  padding-bottom: 44px;
}

.topbar {
  min-height: 74px;
  border-bottom-color: rgba(17, 24, 39, 0.08);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(18px);
}

h1 {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  font-weight: 800;
}

.panel,
.machine-card,
.summary-row,
.record-tabs,
.issue-card,
.settings-row,
.recurring-form,
.modal-card {
  border-color: var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel {
  padding: 20px;
}

.summary-row {
  background: rgba(255, 255, 255, 0.9);
}

.summary-card {
  min-height: 44px;
  padding: 0 18px;
}

.summary-icon,
.round-status,
.rail-icon {
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.12);
}

.machine-card {
  min-height: 156px;
  padding: 18px 16px 12px;
  background: rgba(255, 255, 255, 0.9);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.machine-card[draggable="true"] {
  cursor: grab;
}

.machine-card.dragging {
  cursor: grabbing;
  opacity: 0.58;
  transform: scale(0.985);
}

.machine-card.drag-over {
  border-color: rgba(0, 122, 255, 0.5);
  box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.12), var(--shadow);
}

.machine-card:hover {
  border-color: rgba(0, 122, 255, 0.26);
  box-shadow: 0 16px 42px rgba(17, 24, 39, 0.1), 0 2px 6px rgba(17, 24, 39, 0.05);
  transform: translateY(-2px);
}

.machine-card.dragging,
.machine-card.dragging:hover {
  cursor: grabbing;
  opacity: 0.58;
  transform: scale(0.985);
}

.machine-card:focus-visible {
  border-color: rgba(0, 122, 255, 0.55);
  box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.14), var(--shadow);
  outline: none;
}

.machine-card::before {
  height: 3px;
}

.machine-top {
  grid-template-columns: 20px 74px minmax(0, 1fr);
}

.machine-art,
.mini-machine,
.photo-machine,
.photo-thumb {
  border-color: rgba(17, 24, 39, 0.1);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(226, 232, 240, 0.78)),
    #edf2f7;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.machine-heading h3,
.machine-top h3 {
  font-size: 16px;
  font-weight: 800;
}

.status-chip,
.priority-chip {
  min-height: 24px;
  border-radius: 8px;
  font-size: 12px;
}

.metric strong {
  font-size: 17px;
  font-weight: 650;
}

.machine-footer {
  border-top-color: var(--soft-line);
}

.right-rail,
.left-stack,
.middle-stack,
.schedule-stack {
  gap: 14px;
}

.detail-hero {
  border-radius: 18px 18px 0 0;
}

.machine-photo {
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 255, 255, 0.8), transparent 45%),
    repeating-linear-gradient(90deg, rgba(17, 24, 39, 0.045) 0 1px, transparent 1px 80px),
    linear-gradient(180deg, #eef1f4, #d0d7df);
}

.record-tabs {
  border-radius: 0 0 18px 18px;
}

.search input,
.topbar select,
.log-form input,
.log-form select,
.log-form textarea,
table select,
.small-select,
.date-range-control input,
.work-order-form input,
.work-order-form select,
.asset-form input,
.asset-form select,
.asset-form textarea,
.settings-add-form input,
.settings-add-form select,
.user-role-form input,
.user-role-form select,
.user-access-controls select,
.recurring-form input,
.recurring-form select {
  border-color: rgba(17, 24, 39, 0.13);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: inset 0 1px 2px rgba(17, 24, 39, 0.04);
}

.search input:focus,
.topbar select:focus,
.log-form input:focus,
.log-form select:focus,
.log-form textarea:focus,
table select:focus,
.small-select:focus,
.date-range-control input:focus,
.work-order-form input:focus,
.work-order-form select:focus,
.asset-form input:focus,
.asset-form select:focus,
.asset-form textarea:focus,
.settings-add-form input:focus,
.settings-add-form select:focus,
.user-role-form input:focus,
.user-role-form select:focus,
.user-access-controls select:focus,
.recurring-form input:focus,
.recurring-form select:focus,
.asset-drop-zone:focus-visible {
  border-color: rgba(0, 122, 255, 0.55);
  box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.12);
}

.asset-drop-zone {
  border-color: rgba(17, 24, 39, 0.14);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.asset-drop-zone.drag-over {
  border-color: rgba(0, 122, 255, 0.55);
  background: rgba(0, 122, 255, 0.07);
}

.primary-action,
.danger-action,
.outline-button,
.quick-create .primary-action,
.quick-create button {
  border-radius: 12px;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.primary-action {
  background: linear-gradient(180deg, #34c759, #1f9f45);
  box-shadow: 0 6px 14px rgba(40, 167, 69, 0.18);
}

.danger-action {
  background: linear-gradient(180deg, #ff453a, #d92d20);
  box-shadow: 0 6px 14px rgba(255, 59, 48, 0.16);
}

.outline-button {
  border-color: rgba(40, 167, 69, 0.65);
  background: rgba(255, 255, 255, 0.86);
}

.primary-action:hover,
.danger-action:hover,
.outline-button:hover {
  transform: translateY(-1px);
}

.primary-action:disabled,
.danger-action:disabled,
.outline-button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.segmented {
  border-color: rgba(17, 24, 39, 0.1);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

.segmented button {
  background: transparent;
}

.segmented .active,
.tabs .active {
  background: #111827;
  color: #fff;
}

.tabs button {
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.85);
}

.calendar {
  border-color: var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.86);
}

.day,
.month-day {
  background: rgba(255, 255, 255, 0.44);
}

.calendar-event,
.month-event {
  border-radius: 10px;
}

th {
  color: #6b7280;
  font-weight: 800;
  letter-spacing: 0;
}

td {
  color: #1f2937;
}

tr:hover td {
  background: rgba(0, 122, 255, 0.035);
}

.chart-card {
  border-color: var(--soft-line);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(249, 250, 251, 0.95)),
    #fff;
}

.bar-fill {
  border-radius: 999px 999px 4px 4px;
  background: linear-gradient(180deg, #ff453a, #d92d20);
}

.modal-backdrop {
  background: rgba(17, 24, 39, 0.36);
  backdrop-filter: blur(10px);
}

.modal-card {
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 28px 80px rgba(17, 24, 39, 0.22);
}

.user-dot,
.bell,
.control-pill,
.shift-pill {
  border-color: rgba(17, 24, 39, 0.1);
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.04);
}

.user-dot {
  background: rgba(255, 255, 255, 0.85);
}

.user-dot.account-button {
  background: #3557ff;
  color: #fff;
}

/* Native Apple/macOS treatment for the Tickets dashboard */
body[data-page="workorders"] {
  --background: #f5f5f7;
  --surface: #ffffff;
  --primary-text: #1d1d1f;
  --secondary-text: #6e6e73;
  --tertiary-text: #86868b;
  --border: rgba(0, 0, 0, 0.08);
  --apple-blue: #007aff;
  --apple-red: #ff3b30;
  --apple-green: #34c759;
  --apple-orange: #ff9500;
  background: var(--background);
  color: var(--primary-text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
}

body[data-page="workorders"] .app-shell {
  grid-template-columns: 246px minmax(0, 1fr);
}

body[data-page="workorders"] .sidebar {
  background: rgba(246, 246, 246, 0.88);
  backdrop-filter: blur(20px);
  border-right: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: none;
  color: var(--primary-text);
}

body[data-page="workorders"] .nav-list {
  gap: 6px;
}

body[data-page="workorders"] .nav-item {
  min-height: 38px;
  padding: 0 10px;
  border-radius: 10px;
  color: var(--primary-text);
  font-size: 14px;
  font-weight: 600;
  transition: background-color 150ms ease, color 150ms ease;
}

body[data-page="workorders"] .nav-item:hover {
  background: rgba(0, 0, 0, 0.045);
}

body[data-page="workorders"] .nav-item.active {
  background: rgba(0, 0, 0, 0.07);
  box-shadow: none;
  color: var(--primary-text);
}

body[data-page="workorders"] .icon {
  width: 22px;
  height: 22px;
  border-color: rgba(0, 0, 0, 0.12);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.54);
  color: var(--secondary-text);
  font-size: 13px;
}

body[data-page="workorders"] .sidebar-card {
  border-color: rgba(0, 0, 0, 0.06);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.58);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

body[data-page="workorders"] .sidebar-card span,
body[data-page="workorders"] .mini-legend span {
  color: var(--secondary-text);
}

body[data-page="workorders"] .sidebar-card strong {
  color: var(--apple-blue);
  font-weight: 700;
}

body[data-page="workorders"] .main {
  padding: 0 28px 48px;
}

body[data-page="workorders"] .topbar {
  min-height: 68px;
  margin: 0 -28px;
  padding: 0 28px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(18px);
}

body[data-page="workorders"] .hamburger {
  color: var(--primary-text);
}

body[data-page="workorders"] .search {
  width: min(560px, 48vw);
}

body[data-page="workorders"] .search input {
  height: 38px;
  border: 0;
  border-radius: 10px;
  background: rgba(118, 118, 128, 0.08);
  box-shadow: none;
  color: var(--primary-text);
}

body[data-page="workorders"] .search input::placeholder {
  color: var(--tertiary-text);
}

body[data-page="workorders"] .search::after {
  color: var(--secondary-text);
}

body[data-page="workorders"] .topbar-actions {
  gap: 8px;
}

body[data-page="workorders"] .user-dot {
  width: 34px;
  height: 34px;
  border-color: rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.86);
  color: var(--apple-blue);
}

body[data-page="workorders"] .user-dot.account-button {
  background: var(--apple-blue);
  color: #fff;
}

body[data-page="workorders"] .shop-user {
  color: var(--secondary-text);
  font-size: 14px;
  font-weight: 500;
}

body[data-page="workorders"] .page-heading {
  align-items: end;
  margin: 34px 0 22px;
}

body[data-page="workorders"] .page-heading h1 {
  margin: 0;
  color: var(--primary-text);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

body[data-page="workorders"] .page-heading p {
  margin: 5px 0 0;
  color: var(--secondary-text);
  font-size: 14px;
  font-weight: 500;
}

body[data-page="workorders"] .primary-action {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 10px;
  background: var(--apple-blue);
  box-shadow: none;
  color: #fff;
  font-weight: 600;
}

body[data-page="workorders"] .primary-action:hover {
  background: #006edc;
  box-shadow: none;
  transform: none;
}

body[data-page="workorders"] .tickets-panel {
  padding: 20px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03), 0 8px 30px rgba(0, 0, 0, 0.04);
}

body[data-page="workorders"] .tabs {
  display: inline-flex;
  gap: 0;
  margin-bottom: 20px;
  padding: 3px;
  border-radius: 9px;
  background: rgba(118, 118, 128, 0.12);
}

body[data-page="workorders"] .tabs button {
  min-width: 94px;
  min-height: 30px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #3a3a3c;
  font-size: 14px;
  font-weight: 600;
  transition: background-color 150ms ease, box-shadow 150ms ease, color 150ms ease;
}

body[data-page="workorders"] .tabs button.active {
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  color: var(--primary-text);
}

body[data-page="workorders"] .table-wrap {
  border-radius: 12px;
}

body[data-page="workorders"] table {
  min-width: 980px;
}

body[data-page="workorders"] th {
  padding: 12px 10px;
  color: var(--tertiary-text);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

body[data-page="workorders"] td {
  height: 68px;
  padding: 14px 10px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  color: var(--primary-text);
  font-size: 13px;
}

body[data-page="workorders"] tr:hover td {
  background: rgba(0, 0, 0, 0.015);
}

body[data-page="workorders"] .ticket-id,
body[data-page="workorders"] .ticket-date {
  display: block;
}

body[data-page="workorders"] .ticket-id {
  color: var(--primary-text);
  font-weight: 600;
}

body[data-page="workorders"] .ticket-date {
  margin-top: 2px;
  color: var(--tertiary-text);
  font-size: 12px;
}

body[data-page="workorders"] .table-link {
  color: var(--apple-blue);
  font-weight: 500;
}

body[data-page="workorders"] .priority-chip,
body[data-page="workorders"] .status-chip {
  min-height: 0;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
}

body[data-page="workorders"] .priority-medium {
  background: rgba(255, 149, 0, 0.12);
  color: #b56700;
}

body[data-page="workorders"] .priority-high,
body[data-page="workorders"] .priority-urgent {
  background: rgba(255, 59, 48, 0.1);
  color: #d70015;
}

body[data-page="workorders"] .priority-low {
  background: rgba(52, 199, 89, 0.12);
  color: #248a3d;
}

body[data-page="workorders"] .status-scheduled {
  background: rgba(0, 122, 255, 0.1);
  color: var(--apple-blue);
}

body[data-page="workorders"] .status-open {
  background: rgba(255, 149, 0, 0.12);
  color: #b56700;
}

body[data-page="workorders"] .status-completed {
  background: rgba(52, 199, 89, 0.12);
  color: #248a3d;
}

body[data-page="workorders"] table select {
  width: 128px;
  max-width: 128px;
  height: 36px;
  min-height: 36px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.8);
  box-shadow: none;
  color: var(--primary-text);
  transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

body[data-page="workorders"] table select:focus {
  border-color: var(--apple-blue);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
  outline: none;
}

body[data-page="workorders"] .ticket-actions {
  position: relative;
  justify-content: flex-start;
  gap: 10px;
}

body[data-page="workorders"] .ticket-edit-action,
body[data-page="workorders"] .ticket-action-menu button {
  border: 0;
  background: transparent;
  color: var(--apple-blue);
  font-size: 13px;
  font-weight: 600;
}

body[data-page="workorders"] .ticket-edit-action:hover,
body[data-page="workorders"] .ticket-action-menu button:hover {
  color: #005ecb;
}

body[data-page="workorders"] .ticket-action-menu {
  position: relative;
}

body[data-page="workorders"] .ticket-action-menu summary {
  display: grid;
  width: 32px;
  height: 30px;
  place-items: center;
  border-radius: 8px;
  color: var(--secondary-text);
  cursor: pointer;
  list-style: none;
  transition: background-color 150ms ease;
}

body[data-page="workorders"] .ticket-action-menu summary::-webkit-details-marker {
  display: none;
}

body[data-page="workorders"] .ticket-action-menu summary:hover,
body[data-page="workorders"] .ticket-action-menu[open] summary {
  background: rgba(118, 118, 128, 0.12);
}

body[data-page="workorders"] .ticket-menu-popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 10;
  display: grid;
  min-width: 168px;
  padding: 6px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(18px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
}

body[data-page="workorders"] .ticket-menu-popover button,
body[data-page="workorders"] .ticket-closed {
  width: 100%;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--primary-text);
  text-align: left;
}

body[data-page="workorders"] .ticket-menu-popover button:hover {
  background: rgba(0, 0, 0, 0.045);
  color: var(--primary-text);
}

body[data-page="workorders"] .ticket-menu-popover .danger-menu-item {
  color: var(--apple-red);
}

body[data-page="workorders"] .ticket-menu-popover .danger-menu-item:hover {
  color: var(--apple-red);
}

body[data-page="workorders"] .ticket-menu-popover hr {
  width: 100%;
  height: 1px;
  margin: 5px 0;
  border: 0;
  background: rgba(0, 0, 0, 0.08);
}

body[data-page="workorders"] .ticket-closed {
  display: flex;
  align-items: center;
  color: var(--tertiary-text);
  font-size: 12px;
  font-weight: 600;
}

body[data-page="workorders"] .tickets-empty {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 54px 20px;
  text-align: center;
}

body[data-page="workorders"] .tickets-empty strong {
  font-size: 17px;
  font-weight: 700;
}

body[data-page="workorders"] .tickets-empty p {
  margin: 0 0 6px;
  color: var(--secondary-text);
  font-size: 14px;
}

@media (max-width: 860px) {
  body[data-page="workorders"] .main {
    padding: 0 16px 32px;
  }

  body[data-page="workorders"] .topbar {
    margin: 0 -16px;
    padding: 12px 16px;
  }

  body[data-page="workorders"] .search {
    width: 100%;
  }

  body[data-page="workorders"] .page-heading {
    align-items: start;
    gap: 14px;
    margin-top: 24px;
  }

  body[data-page="workorders"] .tickets-panel {
    padding: 14px;
  }
}

/* Shared Apple-style application system */
:root {
  --app-bg: #f5f5f7;
  --surface: #ffffff;
  --surface-secondary: rgba(118, 118, 128, 0.08);
  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;
  --border: rgba(0, 0, 0, 0.07);
  --border-strong: rgba(0, 0, 0, 0.11);
  --blue: #007aff;
  --green: #34c759;
  --orange: #ff9500;
  --red: #ff3b30;
  --radius-control: 9px;
  --radius-button: 10px;
  --radius-card: 16px;
  --system-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
  --page: var(--app-bg);
  --panel: rgba(255, 255, 255, 0.92);
  --ink: var(--text-primary);
  --muted: var(--text-secondary);
  --line: var(--border);
  --soft-line: rgba(0, 0, 0, 0.06);
  --accent: var(--blue);
  --accent-soft: rgba(0, 122, 255, 0.1);
  --green-soft: rgba(52, 199, 89, 0.12);
  --amber: var(--orange);
  --amber-soft: rgba(255, 149, 0, 0.12);
  --red-soft: rgba(255, 59, 48, 0.1);
  --teal: var(--blue);
  --teal-soft: rgba(0, 122, 255, 0.1);
}

body {
  background: var(--app-bg);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
}

.app-shell {
  grid-template-columns: 220px minmax(0, 1fr);
}

.sidebar {
  padding: 20px 12px;
  border-right: 1px solid rgba(0, 0, 0, 0.06);
  background: rgba(246, 246, 246, 0.92);
  box-shadow: none;
  color: var(--text-primary);
}

.nav-list {
  gap: 6px;
}

.nav-item {
  min-height: 38px;
  padding: 0 10px;
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
}

.nav-item::before {
  display: none;
}

.nav-item:hover {
  background: rgba(0, 0, 0, 0.045);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(0, 0, 0, 0.06);
  box-shadow: none;
  color: var(--text-primary);
}

.nav-item .icon,
.icon {
  width: 22px;
  height: 22px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.64);
  color: var(--text-secondary);
  font-size: 13px;
}

.sidebar-card,
.quick-create {
  display: none;
}

.main {
  width: 100%;
  max-width: 1540px;
  padding: 0 30px 44px;
}

.topbar {
  min-height: 68px;
  margin: 0 -30px;
  padding: 0 30px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(18px);
}

.hamburger {
  color: var(--text-primary);
}

.search {
  width: min(560px, 48vw);
}

.search input,
.search input:disabled {
  height: 38px;
  border: 0;
  border-radius: 10px;
  background: var(--surface-secondary);
  box-shadow: none;
  color: var(--text-primary);
  opacity: 1;
}

.topbar-actions {
  gap: 10px;
}

.shop-user {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
}

.user-dot {
  width: 34px;
  height: 34px;
  border-color: rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.86);
  color: var(--blue);
}

.user-dot.account-button {
  background: var(--blue);
  color: #fff;
}

.page-heading {
  align-items: end;
  margin: 30px 0 22px;
}

.page-heading h1 {
  margin: 0;
  color: var(--text-primary);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-heading p {
  margin: 5px 0 0;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
}

.updated {
  color: var(--text-secondary);
}

.panel,
.summary-row,
.record-tabs,
.issue-card,
.settings-row,
.recurring-form,
.modal-card,
.machine-card,
.tickets-panel {
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: var(--radius-card);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--system-shadow);
}

.panel {
  padding: 20px;
}

.panel-title {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  min-width: 0;
}

.panel-title h2 {
  min-width: 0;
  color: var(--text-primary);
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.panel-title small {
  flex-shrink: 0;
  background: var(--red);
  color: #fff;
}

.panel-title > a,
.panel-title .text-button,
.panel-title .segmented,
.panel-title .tabs {
  flex-shrink: 0;
}

.text-button,
.table-link,
.back-link {
  color: var(--blue);
  font-weight: 600;
}

.primary-action,
.danger-action,
.outline-button,
.quick-create .primary-action,
.quick-create button,
.icon-button,
.photo-box {
  min-height: 40px;
  border-radius: var(--radius-button);
  box-shadow: none;
  font-weight: 600;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}

.primary-action {
  background: var(--blue);
  color: #fff;
}

.primary-action:hover {
  background: #006edc;
  box-shadow: none;
  transform: none;
}

.danger-action {
  background: var(--red);
  color: #fff;
}

.danger-action:hover {
  background: #d70015;
  box-shadow: none;
  transform: none;
}

.outline-button,
.icon-button,
.photo-box {
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: rgba(255, 255, 255, 0.82);
  color: var(--text-primary);
}

.outline-button:hover,
.icon-button:hover,
.photo-box:hover {
  background: rgba(0, 0, 0, 0.035);
  box-shadow: none;
  transform: none;
}

button[name="eventAction"][value="operational"] {
  background: var(--green);
}

input,
select,
textarea,
.topbar select,
table select,
.small-select,
.date-range-control input,
.month-picker,
.control-pill {
  min-height: 38px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: var(--radius-control);
  background-color: rgba(255, 255, 255, 0.86);
  box-shadow: none;
  color: var(--text-primary);
}

input:focus,
select:focus,
textarea:focus,
.date-range-control input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
  outline: none;
}

label span,
.compact-field span,
.asset-image-field > span {
  color: #515767;
  font-size: 12px;
  font-weight: 650;
}

.tabs,
.segmented,
.record-tabs {
  display: inline-flex;
  align-items: center;
  gap: 0;
  width: max-content;
  max-width: 100%;
  padding: 3px;
  border: 0;
  border-radius: var(--radius-control);
  background: rgba(118, 118, 128, 0.12);
  box-shadow: none;
}

.tabs button,
.segmented button,
.record-tabs button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  min-width: 0;
  padding: 0 14px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #3a3a3c;
  font-weight: 600;
  line-height: 1.15;
  white-space: nowrap;
}

.tabs button.active,
.segmented button.active,
.record-tabs button.active {
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  color: var(--text-primary);
}

.table-wrap {
  border-radius: 12px;
}

table {
  min-width: 980px;
}

th {
  padding: 12px 10px;
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

td {
  height: 68px;
  padding: 14px 10px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  color: var(--text-primary);
  font-size: 13px;
}

tr:hover td {
  background: rgba(0, 0, 0, 0.015);
}

.priority-chip,
.status-chip,
.status-label {
  min-height: 0;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 650;
  text-transform: capitalize;
}

.status-operational,
.status-completed,
.priority-low {
  background: rgba(52, 199, 89, 0.12);
  color: #248a3d;
}

.status-down,
.status-urgent,
.priority-high,
.priority-urgent {
  background: rgba(255, 59, 48, 0.1);
  color: #d70015;
}

.status-maintenance,
.status-open,
.status-overdue,
.status-due-soon,
.priority-medium {
  background: rgba(255, 149, 0, 0.12);
  color: #b56700;
}

.status-scheduled {
  background: rgba(0, 122, 255, 0.1);
  color: var(--blue);
}

.summary-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  min-height: 56px;
  padding: 0;
  overflow: hidden;
}

.summary-card {
  min-height: 56px;
  padding: 0 18px;
  border-left: 1px solid rgba(0, 0, 0, 0.07);
  background: transparent;
}

.summary-card:first-child {
  border-left: 0;
}

.summary-icon {
  box-shadow: none;
}

.summary-icon.status-operational,
.summary-icon.status-down,
.summary-icon.status-maintenance,
.summary-icon.status-urgent {
  color: #fff;
}

.summary-card strong {
  color: var(--text-primary);
  font-size: 24px;
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
}

.machine-grid {
  gap: 16px;
}

.machine-card {
  min-height: 150px;
  padding: 16px;
  overflow: hidden;
}

.machine-card::before {
  display: none;
}

.machine-card:hover {
  border-color: rgba(0, 122, 255, 0.28);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
}

.machine-card-top {
  gap: 12px;
}

.machine-status-dot {
  width: 14px;
  height: 14px;
}

.machine-art {
  width: 74px;
  height: 48px;
  border-radius: 10px;
}

.machine-card h3 {
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 650;
}

.machine-metrics {
  grid-template-columns: repeat(2, 1fr);
  margin-top: 14px;
}

.machine-metrics span {
  color: var(--text-secondary);
  font-size: 12px;
}

.machine-metrics strong {
  color: var(--text-primary);
  font-size: 17px;
}

.machine-footer {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.right-rail {
  gap: 16px;
}

.rail-card {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 0;
  background: transparent;
  align-items: start;
}

.rail-card-schedule {
  grid-template-columns: 44px minmax(0, 1fr) auto;
  column-gap: 12px;
}

.rail-card:first-child {
  border-top: 0;
  padding-top: 0;
}

.rail-card:hover {
  background: transparent;
}

.rail-card .machine-art.placeholder,
.rail-card .status-dot {
  box-shadow: none;
}

.rail-card .mini-machine,
.rail-card .rail-icon {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}

.rail-card .ticket-badge-icon {
  border: 1px solid rgba(0, 122, 255, 0.18);
  background: rgba(0, 122, 255, 0.1);
  color: var(--blue);
}

.rail-content {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.rail-content strong,
.rail-line strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text-primary);
  font-weight: 650;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rail-content p,
.rail-content .subtle {
  min-width: 0;
  overflow-wrap: anywhere;
}

.rail-line {
  min-width: 0;
}

.alert-time,
.pm-time {
  flex-shrink: 0;
  white-space: nowrap;
}

.rail-card-schedule .pm-time {
  align-self: start;
  justify-self: end;
}

.timeline-item,
.recent-log {
  padding: 14px 0 14px 28px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 0;
  background: transparent !important;
}

.timeline-item:first-child,
.recent-log:first-child {
  border-top: 0;
}

.timeline-item strong,
.recent-log strong {
  color: var(--text-primary);
  font-size: 14px;
}

.timeline-item span,
.timeline-item p,
.recent-log span,
.recent-log p {
  color: var(--text-secondary);
}

.timeline-item::before,
.recent-log::before {
  left: 2px;
}

.filter-panel {
  display: grid;
  grid-template-columns: repeat(5, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
  padding: 16px;
}

.filter-panel select,
.filter-panel .control-pill {
  width: 100%;
  height: 38px;
}

.control-pill {
  display: flex;
  align-items: center;
  padding: 0 12px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
}

.schedule-stack {
  display: grid;
  gap: 16px;
}

.calendar-panel {
  padding: 20px;
}

.calendar {
  border-color: rgba(0, 0, 0, 0.07);
  border-radius: 14px;
}

.calendar-day {
  border-color: rgba(0, 0, 0, 0.06);
}

.calendar-event {
  border-radius: 8px;
}

.calendar-event.status-scheduled {
  background: rgba(0, 122, 255, 0.08);
  color: #005ecb;
}

.calendar-event.status-open,
.calendar-event.status-urgent,
.calendar-event.priority-high,
.calendar-event.priority-urgent {
  background: rgba(255, 59, 48, 0.09);
  color: #d70015;
}

.asset-context-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 24px 0 14px;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.detail-hero {
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 0;
  padding: 0;
  overflow: hidden;
}

.machine-photo {
  min-height: 150px;
  background: var(--surface-secondary);
}

.machine-info {
  padding: 22px 26px;
}

.machine-info h1 {
  color: var(--text-primary);
  font-size: 28px;
  letter-spacing: -0.02em;
}

.machine-facts {
  gap: 18px;
}

.record-tabs {
  margin: 14px 0 16px;
}

.machine-page-grid {
  gap: 16px;
}

.chart-card {
  border-color: rgba(0, 0, 0, 0.06);
  border-radius: 14px;
  background: #fff;
}

.bar {
  background: var(--red);
  border-radius: 7px 7px 0 0;
}

.settings-add-form,
.user-role-form {
  align-items: end;
  gap: 12px;
}

.settings-grid {
  gap: 16px;
}

.settings-row,
.user-access-row {
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: none;
}

.settings-row .danger-action,
.user-access-row .danger-action,
.remove-user-access,
.danger-menu-item {
  background: transparent;
  color: var(--red);
}

.settings-row .danger-action:hover,
.user-access-row .danger-action:hover,
.remove-user-access:hover {
  background: rgba(255, 59, 48, 0.08);
  color: var(--red);
}

.ticket-id,
.ticket-date {
  display: block;
}

.ticket-id {
  color: var(--text-primary);
  font-weight: 600;
}

.ticket-date {
  margin-top: 2px;
  color: var(--text-tertiary);
  font-size: 12px;
}

.ticket-actions {
  position: relative;
  justify-content: flex-start;
  gap: 10px;
}

.ticket-edit-action,
.ticket-action-menu button {
  border: 0;
  background: transparent;
  color: var(--blue);
  font-size: 13px;
  font-weight: 600;
}

.ticket-action-menu summary {
  display: grid;
  width: 32px;
  height: 30px;
  place-items: center;
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  list-style: none;
}

.ticket-action-menu summary::-webkit-details-marker {
  display: none;
}

.ticket-action-menu summary:hover,
.ticket-action-menu[open] summary {
  background: rgba(118, 118, 128, 0.12);
}

.ticket-menu-popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 10;
  display: grid;
  min-width: 168px;
  padding: 6px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(18px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
}

.ticket-menu-popover button,
.ticket-closed {
  width: 100%;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--text-primary);
  text-align: left;
}

.ticket-menu-popover button:hover {
  background: rgba(0, 0, 0, 0.045);
}

.ticket-menu-popover hr {
  width: 100%;
  height: 1px;
  margin: 5px 0;
  border: 0;
  background: rgba(0, 0, 0, 0.08);
}

.ticket-closed {
  display: flex;
  align-items: center;
  color: var(--text-tertiary);
  font-size: 12px;
  font-weight: 600;
}

.tickets-empty,
.empty-state {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 46px 20px;
  color: var(--text-secondary);
  text-align: center;
}

@media (max-width: 1180px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .right-rail {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  }
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    z-index: 30;
    width: min(280px, 82vw);
    transform: translateX(-100%);
  }

  body.nav-open .sidebar {
    transform: translateX(0);
  }

  .main {
    padding: 0 16px 32px;
  }

  .topbar {
    min-height: 64px;
    margin: 0 -16px;
    padding: 10px 16px;
  }

  .search {
    width: 100%;
  }

  .page-heading {
    align-items: start;
    gap: 12px;
    margin-top: 24px;
  }

  .summary-row,
  .filter-panel,
  .right-rail,
  .detail-hero,
  .machine-page-grid,
  .settings-add-form,
  .user-role-form {
    grid-template-columns: 1fr;
  }

  .summary-card {
    border-top: 1px solid rgba(0, 0, 0, 0.07);
    border-left: 0;
  }

  .summary-card:first-child {
    border-top: 0;
  }

  .asset-context-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .page-actions {
    width: 100%;
    justify-content: stretch;
  }

  .page-actions > * {
    flex: 1;
  }

  .log-filter-bar {
    justify-content: stretch;
  }

  .log-filter-bar .date-range-control {
    width: 100%;
    align-items: stretch;
    flex-wrap: wrap;
  }

  .log-filter-bar .date-range-control label {
    flex: 1 1 135px;
  }

  .log-filter-bar .text-button {
    flex: 1 1 100%;
  }
}

/* Final layout hardening: prevent crowded controls and dynamic text from overlapping. */
body[data-page="workorders"] .tabs,
body[data-page="schedule"] .segmented,
.tabs,
.segmented,
.record-tabs {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  width: max-content;
  max-width: 100%;
  padding: 3px;
  overflow: visible;
}

body[data-page="workorders"] .tabs button,
body[data-page="schedule"] .segmented button,
.tabs button,
.segmented button,
.record-tabs button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  min-width: max-content;
  padding: 0 14px;
  line-height: 1.15;
  white-space: nowrap;
}

body[data-page="workorders"] .tabs button.active,
body[data-page="schedule"] .segmented button.active,
.tabs button.active,
.segmented button.active,
.record-tabs button.active {
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.panel-title > div {
  min-width: 0;
}

.panel-title .text-button,
.table-actions button,
.ticket-actions button,
.ticket-action-menu,
.priority-chip,
.status-chip,
.status-label {
  flex-shrink: 0;
}

.rail-card {
  min-width: 0;
}

.rail-card > * {
  min-width: 0;
}

.rail-card-schedule .mini-machine {
  justify-self: start;
}

.calendar-event {
  min-width: 0;
  overflow: hidden;
}

.calendar-event strong,
.calendar-event span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.machine-card h3,
.machine-card-title,
.detail-summary,
.detail-facts,
td,
th {
  min-width: 0;
}

.machine-card h3,
.table-link {
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 640px) {
  .panel-title {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .panel-title .text-button {
    margin-left: auto;
  }

  .record-tabs,
  .tabs,
  .segmented {
    overflow-x: auto;
    max-width: 100%;
  }
}

/* Tickets mobile presentation: same data, native list layout. */
.mobile-ticket-list {
  display: none;
}

@media (max-width: 767px) {
  html,
  body[data-page="workorders"] {
    width: 100%;
    overflow-x: hidden;
  }

  body[data-page="workorders"] .app-shell {
    display: block;
    width: 100%;
    min-width: 0;
  }

  body[data-page="workorders"] .main {
    display: block;
    width: 100vw;
    max-width: none;
    min-width: 0;
    padding: 0 16px 32px;
  }

  body[data-page="workorders"] .topbar {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    width: 100vw;
    min-height: 116px;
    margin: 0 -16px;
    padding: 10px 16px 12px;
  }

  body[data-page="workorders"] .hamburger {
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
  }

  body[data-page="workorders"] .topbar-actions {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
  }

  body[data-page="workorders"] .shop-user {
    display: none;
  }

  body[data-page="workorders"] .search {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
  }

  body[data-page="workorders"] .search input {
    width: 100%;
  }

  body[data-page="workorders"] .page-heading {
    display: grid;
    align-items: start;
    gap: 14px;
    margin: 24px 0 20px;
  }

  body[data-page="workorders"] .page-heading h1 {
    font-size: 30px;
  }

  body[data-page="workorders"] #createWorkOrder {
    justify-self: start;
    min-height: 40px;
  }

  body[data-page="workorders"] .tickets-panel {
    width: calc(100vw - 32px);
    max-width: none;
    padding: 14px;
    overflow: hidden;
  }

  body[data-page="workorders"] .tabs {
    display: flex;
    width: 100%;
    max-width: 100%;
    margin-bottom: 14px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  body[data-page="workorders"] .tabs::-webkit-scrollbar {
    display: none;
  }

  body[data-page="workorders"] .tabs button {
    flex: 0 0 auto;
    min-width: 0;
    padding: 0 14px;
  }

  body[data-page="workorders"] .table-wrap {
    display: none;
  }

  body[data-page="workorders"] .mobile-ticket-list {
    display: grid;
    gap: 12px;
  }

  body[data-page="workorders"] .mobile-ticket-card {
    display: grid;
    gap: 8px;
    width: 100%;
    max-width: none;
    min-width: 0;
    padding: 14px;
    border: 1px solid rgba(0, 0, 0, 0.07);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.92);
  }

  body[data-page="workorders"] .mobile-ticket-topline,
  body[data-page="workorders"] .mobile-ticket-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-width: 0;
  }

  body[data-page="workorders"] .mobile-ticket-main {
    align-items: flex-start;
  }

  body[data-page="workorders"] .mobile-ticket-title {
    min-width: 0;
    overflow: hidden;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 700;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body[data-page="workorders"] .mobile-ticket-date {
    margin: -4px 0 2px;
    color: var(--text-secondary);
    font-size: 13px;
  }

  body[data-page="workorders"] .mobile-ticket-meta {
    display: grid;
    gap: 7px;
    margin: 0;
  }

  body[data-page="workorders"] .mobile-ticket-meta div {
    display: grid;
    gap: 2px;
    min-width: 0;
  }

  body[data-page="workorders"] .mobile-ticket-meta dt {
    color: var(--text-tertiary);
    font-size: 11px;
    font-weight: 650;
    letter-spacing: 0.03em;
    text-transform: uppercase;
  }

  body[data-page="workorders"] .mobile-ticket-meta dd {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.25;
  }

  body[data-page="workorders"] .mobile-ticket-menu {
    flex-shrink: 0;
  }

  body[data-page="workorders"] .mobile-ticket-menu summary {
    width: 34px;
    height: 32px;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 1px;
    line-height: 1;
  }

  body[data-page="workorders"] .mobile-ticket-menu .ticket-menu-popover {
    right: 0;
  }

  body[data-page="workorders"] .mobile-tickets-empty {
    padding: 28px 12px;
  }
}

/* Ticket workflow refinements and app theme toggle. */
.sidebar-brand {
  grid-template-columns: 46px;
  justify-content: center;
}

.sidebar-brand img {
  display: block;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  height: 34px;
  padding: 0;
  border: 0;
  background: transparent;
}

.theme-toggle-track {
  position: relative;
  display: block;
  width: 54px;
  height: 30px;
  border-radius: 999px;
  background: rgba(118, 118, 128, 0.2);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
  transition: background-color 180ms ease, box-shadow 180ms ease;
}

.theme-toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 7px rgba(0, 0, 0, 0.18);
  transition: transform 180ms ease;
}

.theme-toggle-thumb::before {
  content: "";
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #ffcc00;
}

.theme-toggle[aria-pressed="true"] .theme-toggle-track {
  background: #34c759;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.theme-toggle[aria-pressed="true"] .theme-toggle-thumb {
  transform: translateX(24px);
}

.theme-toggle[aria-pressed="true"] .theme-toggle-thumb::before {
  background: #111827;
  box-shadow: inset -4px -1px 0 #fff;
}

body[data-page="workorders"] .tickets-panel {
  min-height: min(620px, calc(100vh - 190px));
}

body[data-page="workorders"] .table-wrap {
  overflow-x: auto;
  overflow-y: visible;
}

.clickable-ticket-row {
  cursor: pointer;
}

.clickable-ticket-row:focus-visible {
  outline: 3px solid rgba(0, 122, 255, 0.3);
  outline-offset: -3px;
}

.clickable-ticket-row:hover td {
  background: rgba(0, 122, 255, 0.035);
}

.mobile-ticket-card {
  cursor: pointer;
}

.mobile-ticket-card:focus-visible {
  outline: 3px solid rgba(0, 122, 255, 0.35);
  outline-offset: 2px;
}

.ticket-menu-popover {
  cursor: default;
}

:root[data-theme="dark"] {
  --app-bg: #111113;
  --surface: #1c1c1e;
  --surface-secondary: rgba(118, 118, 128, 0.2);
  --text-primary: #f5f5f7;
  --text-secondary: #c7c7cc;
  --text-tertiary: #98989d;
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.16);
  --system-shadow: 0 1px 2px rgba(0, 0, 0, 0.36);
  --page: #111113;
  --panel: rgba(28, 28, 30, 0.92);
  --ink: #f5f5f7;
  --muted: #c7c7cc;
  --line: rgba(255, 255, 255, 0.11);
  --soft-line: rgba(255, 255, 255, 0.08);
}

:root[data-theme="dark"] body {
  background: var(--app-bg);
  color: var(--text-primary);
}

:root[data-theme="dark"] .sidebar {
  border-right-color: rgba(255, 255, 255, 0.08);
  background: rgba(28, 28, 30, 0.92);
  color: var(--text-primary);
}

:root[data-theme="dark"] .topbar {
  border-bottom-color: rgba(255, 255, 255, 0.09);
  background: rgba(28, 28, 30, 0.78);
}

:root[data-theme="dark"] .panel,
:root[data-theme="dark"] .summary-row,
:root[data-theme="dark"] .record-tabs,
:root[data-theme="dark"] .issue-card,
:root[data-theme="dark"] .settings-row,
:root[data-theme="dark"] .recurring-form,
:root[data-theme="dark"] .modal-card,
:root[data-theme="dark"] .machine-card,
:root[data-theme="dark"] .tickets-panel,
:root[data-theme="dark"] .mobile-ticket-card {
  border-color: rgba(255, 255, 255, 0.09);
  background: rgba(28, 28, 30, 0.9);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.36);
}

:root[data-theme="dark"] .nav-item,
:root[data-theme="dark"] .page-heading h1,
:root[data-theme="dark"] .panel-title h2,
:root[data-theme="dark"] .ticket-id,
:root[data-theme="dark"] .mobile-ticket-title,
:root[data-theme="dark"] td,
:root[data-theme="dark"] .machine-card h3,
:root[data-theme="dark"] .modal-card h2 {
  color: var(--text-primary);
}

:root[data-theme="dark"] .nav-item:hover,
:root[data-theme="dark"] .nav-item.active {
  background: rgba(255, 255, 255, 0.08);
}

:root[data-theme="dark"] .icon,
:root[data-theme="dark"] .user-dot,
:root[data-theme="dark"] .outline-button,
:root[data-theme="dark"] .icon-button,
:root[data-theme="dark"] .photo-box {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea,
:root[data-theme="dark"] .topbar select,
:root[data-theme="dark"] table select,
:root[data-theme="dark"] .small-select,
:root[data-theme="dark"] .date-range-control input,
:root[data-theme="dark"] .month-picker,
:root[data-theme="dark"] .control-pill,
:root[data-theme="dark"] .search input {
  border-color: rgba(255, 255, 255, 0.12);
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

:root[data-theme="dark"] input::placeholder,
:root[data-theme="dark"] textarea::placeholder {
  color: var(--text-tertiary);
}

:root[data-theme="dark"] .tabs,
:root[data-theme="dark"] .segmented,
:root[data-theme="dark"] .record-tabs {
  background: rgba(118, 118, 128, 0.24);
}

:root[data-theme="dark"] .tabs button,
:root[data-theme="dark"] .segmented button,
:root[data-theme="dark"] .record-tabs button {
  color: var(--text-secondary);
}

:root[data-theme="dark"] .tabs button.active,
:root[data-theme="dark"] .segmented button.active,
:root[data-theme="dark"] .record-tabs button.active {
  background: rgba(255, 255, 255, 0.14);
  color: var(--text-primary);
}

:root[data-theme="dark"] th,
:root[data-theme="dark"] .ticket-date,
:root[data-theme="dark"] .page-heading p,
:root[data-theme="dark"] .updated,
:root[data-theme="dark"] .shop-user,
:root[data-theme="dark"] .subtle,
:root[data-theme="dark"] .mobile-ticket-date,
:root[data-theme="dark"] .mobile-ticket-meta dt {
  color: var(--text-tertiary);
}

:root[data-theme="dark"] td,
:root[data-theme="dark"] th,
:root[data-theme="dark"] .timeline-item,
:root[data-theme="dark"] .machine-footer,
:root[data-theme="dark"] .rail-card,
:root[data-theme="dark"] body[data-page="workorders"] td {
  border-color: rgba(255, 255, 255, 0.08);
}

:root[data-theme="dark"] tr:hover td,
:root[data-theme="dark"] .clickable-ticket-row:hover td {
  background: rgba(255, 255, 255, 0.045);
}

:root[data-theme="dark"] .ticket-menu-popover,
:root[data-theme="dark"] body[data-page="workorders"] .ticket-menu-popover {
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(44, 44, 46, 0.96);
}

:root[data-theme="dark"] .ticket-menu-popover button:hover {
  background: rgba(255, 255, 255, 0.08);
}

:root[data-theme="dark"] .log-edit-action {
  border-color: rgba(10, 132, 255, 0.34);
  background: rgba(10, 132, 255, 0.16);
  color: #0a84ff;
}

@media (max-width: 767px) {
  body[data-page="workorders"] .tickets-panel {
    min-height: 0;
  }
}
