:root {
  --ink: #282828;
  --muted: #6d6d6d;
  --line: #d7dde0;
  --soft: #f4f7f9;
  --panel: #ffffff;
  --accent: #00ace5;
  --accent-hover: #0094c8;
  --accent-soft: #f2fbfe;
  --accent-2: #2ec510;
  --charcoal: #282828;
  --danger: #b42318;
  --warning: #9a6700;
  --ok: #067647;
  --shadow: 0 0 1.0668rem rgba(201, 201, 201, 0.75);
  font-family: Roboto, Arial, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: #f4f4f4;
}

button,
input,
select,
textarea {
  font: inherit;
  min-width: 0;
}

button {
  border: 0;
  cursor: pointer;
  white-space: normal;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  background:
    linear-gradient(180deg, rgba(0, 172, 229, 0.16) 0, rgba(0, 172, 229, 0) 170px),
    var(--charcoal);
  color: #fff;
  padding: 22px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: grid;
  gap: 10px;
}

.brand-mark {
  width: 100%;
  max-width: 218px;
  display: block;
  background: #fff;
  border-radius: 5px;
  padding: 10px 12px 8px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
}

.brand-mark img {
  display: block;
  width: 100%;
  height: auto;
}

.brand span {
  display: block;
  color: #d7eef7;
  font-size: 13px;
  margin-top: 2px;
  line-height: 1.35;
}

.brand strong {
  color: #fff;
  font-size: 16px;
  letter-spacing: 0;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav button {
  min-height: 42px;
  text-align: left;
  color: #e8e8e8;
  background: transparent;
  border-radius: 5px;
  padding: 10px 12px;
  border-left: 3px solid transparent;
}

.nav button.active,
.nav button:hover {
  background: rgba(255, 255, 255, 0.12);
  border-left-color: var(--accent);
  color: #fff;
}

.main {
  min-width: 0;
}

.topbar {
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 3;
  backdrop-filter: blur(12px);
  box-shadow: 0 1px 0 rgba(0, 172, 229, 0.22);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0;
  font-weight: 700;
}

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

h1 {
  margin-bottom: 0;
  font-size: 28px;
}

h2 {
  font-size: 20px;
}

h3 {
  font-size: 16px;
}

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

.icon-button {
  min-width: 42px;
  height: 42px;
  border-radius: 5px;
  background: var(--soft);
  border: 1px solid transparent;
  position: relative;
}

.icon-button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

#notification-count {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 19px;
  height: 19px;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.user-switch {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

.user-switch select,
.field input,
.field select,
.field textarea,
.admin-grid input,
.admin-grid select,
.admin-grid textarea {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 5px;
  padding: 10px 11px;
  width: 100%;
}

.user-switch select:focus,
.field input:focus,
.field select:focus,
.field textarea:focus,
.admin-grid input:focus,
.admin-grid select:focus,
.admin-grid textarea:focus,
.signature-actions input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 172, 229, 0.14);
  outline: none;
}

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

.notification-panel {
  margin: 18px 28px 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 5px;
  box-shadow: var(--shadow);
  padding: 14px;
}

.hidden {
  display: none !important;
}

.grid {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.grid > * {
  min-width: 0;
}

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

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

.panel,
.card,
.work-order-form,
.admin-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 5px;
  box-shadow: 0 0 1.0668rem rgba(201, 201, 201, 0.42);
  min-width: 0;
}

.panel {
  padding: 18px;
}

.card {
  padding: 16px;
}

.stat {
  display: grid;
  gap: 6px;
}

.stat strong {
  font-size: 28px;
}

.stat span {
  color: var(--muted);
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.toolbar h2,
.toolbar h3 {
  margin-bottom: 0;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.button,
.secondary,
.danger,
.ghost {
  min-height: 40px;
  border-radius: 5px;
  padding: 9px 13px;
  font-weight: 700;
  line-height: 1.25;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.button {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 7px 18px rgba(0, 172, 229, 0.2);
}

.button:hover {
  background: var(--accent-hover);
}

.secondary {
  background: #eaeaea;
  color: var(--ink);
  border: 1px solid transparent;
}

.secondary:hover {
  background: #fff;
  border-color: var(--accent);
  color: var(--accent-hover);
}

.danger {
  background: #fee4e2;
  color: var(--danger);
}

.danger:hover {
  background: #ffd6d3;
}

.ghost {
  background: transparent;
  color: var(--accent);
}

.ghost:hover {
  background: var(--accent-soft);
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 5px;
  overflow: hidden;
}

.table th,
.table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.table th {
  background: #f4f4f4;
  color: var(--muted);
  font-size: 13px;
}

.table tbody tr:hover {
  background: var(--accent-soft);
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 800;
  background: #edf2f4;
  color: #41515e;
}

.status.approved,
.status.exported {
  background: #f2fbf5;
  color: var(--ok);
}

.status.revision {
  background: #fef0c7;
  color: var(--warning);
}

.status.draft {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.status.submitted {
  background: var(--accent-soft);
  color: #007ea8;
}

.work-order-form {
  padding: 20px;
}

.work-order-layout {
  grid-template-columns: repeat(auto-fit, minmax(min(520px, 100%), 1fr));
  align-items: start;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field label,
.check span {
  color: #333;
  font-size: 13px;
  font-weight: 700;
}

.field textarea {
  min-height: 110px;
  resize: vertical;
}

.checks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
  gap: 10px;
}

.check {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  background: #f4f4f4;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 9px 10px;
  width: 100%;
  min-width: 0;
  line-height: 1.35;
  white-space: normal;
}

.check input {
  margin-top: 2px;
}

.check span {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: normal;
}

.service-row {
  display: grid;
  grid-template-columns: minmax(160px, 2fr) minmax(72px, 0.65fr) minmax(130px, 1.4fr) 42px;
  gap: 8px;
  margin-bottom: 8px;
  min-width: 0;
}

.service-row select,
.service-row input,
.service-row button {
  width: 100%;
  min-width: 0;
}

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

.rule {
  border-radius: 5px;
  padding: 10px;
  background: #f4f4f4;
  border: 1px solid var(--line);
}

.rule.blocker {
  background: #fff4ed;
  border-color: #ffcfb0;
}

.rule.warning {
  background: #fffaeb;
  border-color: #fedf89;
}

.signature-pad canvas {
  width: 100%;
  max-width: 640px;
  height: 220px;
  border: 1px dashed #8a8a8a;
  border-radius: 5px;
  background: #fff;
  touch-action: none;
}

.signature-pad canvas:hover {
  border-color: var(--accent);
  background: linear-gradient(180deg, #fff 0, #f8fdff 100%);
}

.signature-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  margin-top: 10px;
}

.signature-actions input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 10px 11px;
  min-height: 42px;
}

.signature-action-buttons {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.35fr);
  gap: 8px;
  align-items: stretch;
}

.signature-action-buttons button {
  width: 100%;
  min-width: 0;
}

.signature-action-buttons [data-action="clear"] {
  border: 1px solid var(--line);
  background: #f4f4f4;
  color: #333;
}

.signature-action-buttons [data-action="save"] {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 7px 18px rgba(0, 172, 229, 0.2);
}

.signature-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.comment {
  padding: 12px;
  background: #f4f4f4;
  border: 1px solid var(--line);
  border-radius: 5px;
}

.comment small {
  color: var(--muted);
}

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.admin-tabs button {
  border-radius: 5px;
  padding: 9px 12px;
  background: #eaeaea;
  color: var(--ink);
  border: 1px solid transparent;
}

.admin-tabs button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.admin-tabs button:hover {
  border-color: var(--accent);
}

.admin-section {
  padding: 18px;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  gap: 14px;
}

.admin-grid > * {
  min-width: 0;
}

.notice {
  padding: 12px;
  border: 1px solid #40c1ec;
  background: var(--accent-soft);
  border-radius: 5px;
  color: #006b91;
}

.danger-zone {
  border-color: #fecdca;
  background: #fffbfa;
}

.audio-box,
.ocr-box,
.chat-box {
  display: grid;
  gap: 10px;
}

.chat-log {
  min-height: 180px;
  max-height: 280px;
  overflow: auto;
  background: #f4f4f4;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 12px;
}

.chat-message {
  margin-bottom: 10px;
}

.chat-message strong {
  display: block;
  margin-bottom: 2px;
}

.pdf-preview {
  background: #fff;
  color: var(--charcoal);
  border: 1px solid var(--line);
  padding: 24px;
  max-width: 100%;
  overflow-wrap: anywhere;
  box-shadow: 0 0 1.0668rem rgba(201, 201, 201, 0.42);
}

.pdf-preview h2 {
  color: var(--accent);
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.pdf-preview hr {
  border: 0;
  border-top: 2px solid var(--charcoal);
}

.pdf-preview table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.pdf-preview td,
.pdf-preview th {
  border: 1px solid #111;
  padding: 6px;
}

@media (max-width: 1500px) {
  .service-row {
    grid-template-columns: minmax(0, 1fr) 72px;
  }

  .service-row input[name="note"] {
    grid-column: 1 / 2;
  }

  .service-row .danger {
    grid-column: 2 / 3;
  }
}

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

  .sidebar {
    position: static;
    padding: 18px 16px;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar {
    align-items: flex-start;
    gap: 14px;
    flex-direction: column;
    padding: 18px 16px;
  }

  .topbar-actions {
    align-items: stretch;
    flex-wrap: wrap;
    width: 100%;
  }

  .user-switch {
    min-width: min(220px, 100%);
  }

  .content {
    padding: 18px 16px;
  }

  .notification-panel {
    margin: 14px 16px 0;
  }

  .grid.two,
  .grid.three,
  .admin-grid {
    grid-template-columns: 1fr;
  }

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

  .service-row {
    grid-template-columns: 1fr;
  }

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

  .signature-action-buttons {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  h1 {
    font-size: 24px;
  }

  h2 {
    font-size: 18px;
  }

  .nav {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .nav button {
    min-height: 40px;
    padding: 9px 10px;
  }

  .panel,
  .card,
  .work-order-form,
  .admin-section {
    padding: 14px;
  }

  .toolbar-left,
  .toolbar-right,
  .toolbar-left button,
  .toolbar-right button {
    width: 100%;
  }

  .table {
    display: block;
    width: 100%;
    border: 0;
    background: transparent;
    overflow: visible;
  }

  .table thead {
    display: none;
  }

  .table tbody,
  .table tr,
  .table td {
    display: block;
    width: 100%;
  }

  .table tr {
    overflow: hidden;
    margin-bottom: 10px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: #fff;
  }

  .table td {
    border-bottom: 1px solid var(--line);
    overflow-wrap: anywhere;
    padding: 10px 12px;
  }

  .table td:last-child {
    border-bottom: 0;
  }

  .table td button {
    width: 100%;
  }

  .pdf-preview {
    padding: 14px;
    font-size: 12px;
    overflow: hidden;
  }

  .pdf-preview * {
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  .pdf-preview > div {
    flex-wrap: wrap !important;
    min-width: 0;
  }

  .pdf-preview table {
    table-layout: fixed;
  }

  .pdf-preview td,
  .pdf-preview th {
    padding: 5px;
  }
}

@media print {
  body {
    background: #fff;
  }

  .sidebar,
  .topbar,
  .toolbar,
  .notification-panel,
  .nav,
  button,
  input,
  select,
  textarea {
    display: none !important;
  }

  .app-shell {
    display: block;
  }

  .content {
    padding: 0;
  }

  .panel,
  .card,
  .pdf-preview {
    box-shadow: none;
    border: 0;
  }
}
