:root {
  --green: #078a3d;
  --green-dark: #05602d;
  --green-soft: #e8f7ee;
  --orange: #f97316;
  --orange-soft: #fff1e8;
  --ink: #14213d;
  --muted: #61708a;
  --line: #dce4ef;
  --panel: #ffffff;
  --page: #f4f7fb;
  --danger: #dc2626;
  --warning: #b45309;
  --shadow: 0 16px 40px rgba(18, 33, 61, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--page);
  font-family: Arial, "Segoe UI", Tahoma, sans-serif;
  letter-spacing: 0;
}

body:not(.is-authenticated) .app-shell {
  display: none;
}

body.is-authenticated .auth-screen {
  display: none;
}

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

button {
  cursor: pointer;
}

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

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(7, 138, 61, 0.16), transparent 34%),
    linear-gradient(135deg, #f7fbf8 0%, #eef5fb 100%);
}

.auth-card {
  width: min(430px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  background: #fff;
  box-shadow: var(--shadow);
}

.auth-brand {
  color: var(--ink);
  border-bottom: 0;
  padding-bottom: 0;
  margin-bottom: 18px;
}

.auth-brand .brand-mark {
  color: #fff;
  background: var(--green);
}

.auth-card h1 {
  margin: 0 0 8px;
  font-size: 26px;
  line-height: 1.2;
}

.auth-card p {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.5;
}

.auth-card .primary-button {
  width: 100%;
}

.demo-accounts {
  display: grid;
  gap: 5px;
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

.demo-accounts strong {
  color: var(--ink);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  color: #fff;
  background: var(--green);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.24);
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  color: var(--green);
  background: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 22px;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 24px;
  line-height: 1;
}

.brand span {
  margin-top: 3px;
  font-size: 13px;
  opacity: 0.9;
}

.role-tabs {
  display: grid;
  gap: 8px;
}

.role-tab {
  width: 100%;
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  padding: 10px 12px;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  text-align: left;
  font-weight: 700;
}

.role-tab.is-active {
  color: var(--green-dark);
  background: #fff;
}

.sidebar-card {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.1);
}

.user-card {
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.1);
}

.user-card strong,
.user-card p {
  display: block;
}

.user-card strong {
  margin: 6px 0 2px;
  font-size: 17px;
}

.user-card p {
  margin: 0 0 12px;
  color: rgba(255, 255, 255, 0.86);
  font-size: 13px;
}

.user-card .secondary-button {
  width: 100%;
  margin-top: 8px;
}

.sidebar-card strong {
  display: block;
  margin: 6px 0;
  font-size: 20px;
}

.sidebar-card p {
  margin: 0;
  color: rgba(255, 255, 255, 0.86);
  font-size: 14px;
  line-height: 1.45;
}

.workspace {
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.view-header h1 {
  margin: 4px 0 6px;
  font-size: 30px;
  line-height: 1.16;
}

.view-header p {
  max-width: 680px;
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

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

.panel h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

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

.panel-title-row h2 {
  margin: 0;
}

.customer-layout,
.admin-grid,
.provider-grid,
.management-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(360px, 0.95fr);
  gap: 18px;
  align-items: start;
}

.admin-grid {
  grid-template-columns: minmax(400px, 0.95fr) minmax(420px, 1.05fr);
}

.management-grid {
  grid-template-columns: repeat(2, minmax(360px, 1fr));
  margin-top: 18px;
}

.order-form-panel {
  position: sticky;
  top: 18px;
}

.field,
.field-grid {
  margin-bottom: 12px;
}

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

label {
  display: block;
  margin-bottom: 6px;
  color: #263652;
  font-size: 13px;
  font-weight: 700;
}

.field-hint {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cfd8e6;
  border-radius: 8px;
  padding: 10px 11px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(7, 138, 61, 0.13);
}

.service-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0 14px;
}

.service-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
  background: #fff;
  text-align: left;
}

.service-card strong {
  display: block;
  margin-bottom: 6px;
  font-size: 15px;
}

.service-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.service-card small {
  display: inline-block;
  margin-top: 8px;
  color: var(--green-dark);
  font-weight: 800;
}

.service-card.is-selected {
  border-color: var(--green);
  background: var(--green-soft);
  box-shadow: inset 0 0 0 1px var(--green);
}

.summary-box {
  border: 1px dashed #b9c8d8;
  border-radius: 8px;
  padding: 12px;
  margin: 6px 0 14px;
  color: #31415c;
  background: #f8fafc;
  font-size: 13px;
  line-height: 1.45;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 10px 14px;
  font-weight: 800;
}

.primary-button {
  color: #fff;
  background: var(--green);
}

.primary-button:hover {
  background: var(--green-dark);
}

.secondary-button {
  color: var(--green-dark);
  border-color: #b8d9c5;
  background: #fff;
}

.ghost-button {
  color: var(--ink);
  border-color: var(--line);
  background: #fff;
}

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

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

.order-list.compact {
  max-height: calc(100vh - 245px);
  overflow: auto;
  padding-right: 4px;
}

.order-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: #fff;
}

.order-card.is-selected {
  border-color: var(--green);
  box-shadow: inset 0 0 0 1px var(--green);
}

.order-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.order-card h3 {
  margin: 3px 0 0;
  font-size: 16px;
  line-height: 1.25;
}

.order-code {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.status-pill,
.count-badge,
.quote-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-new,
.status-confirmed {
  color: #075985;
  background: #e0f2fe;
}

.status-assigned,
.status-in_progress {
  color: #854d0e;
  background: #fef3c7;
}

.status-quoted {
  color: #9a3412;
  background: var(--orange-soft);
}

.status-completed {
  color: #166534;
  background: #dcfce7;
}

.status-cancelled {
  color: #991b1b;
  background: #fee2e2;
}

.count-badge {
  color: var(--green-dark);
  background: var(--green-soft);
}

.quote-pill {
  color: #9a3412;
  background: var(--orange-soft);
}

.order-meta {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 6px 10px;
  margin: 0;
  color: #31415c;
  font-size: 13px;
}

.order-meta dt {
  color: var(--muted);
  font-weight: 700;
}

.order-meta dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.order-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.attachment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.attachment-item {
  display: block;
  min-height: 80px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  color: var(--ink);
  background: #f8fafc;
  text-decoration: none;
}

.attachment-item img,
.attachment-item video {
  display: block;
  width: 100%;
  height: 72px;
  object-fit: cover;
  background: #e5e7eb;
}

.attachment-item span {
  display: block;
  padding: 6px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-actions button {
  min-height: 36px;
  padding: 8px 10px;
  font-size: 13px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
  box-shadow: var(--shadow);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 5px;
  font-size: 24px;
}

.detail-panel {
  min-height: 340px;
}

.detail-section {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 14px;
}

.detail-section:first-of-type {
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
}

.empty-state {
  border: 1px dashed #bdc8d8;
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  background: #f8fafc;
  text-align: center;
}

.provider-profile {
  display: grid;
  gap: 10px;
}

.manager-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  max-height: 420px;
  overflow: auto;
  padding-right: 4px;
}

.manager-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.manager-item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.manager-item h3 {
  margin: 0 0 4px;
  font-size: 15px;
}

.manager-item p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.manager-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.manager-item-actions button {
  min-height: 32px;
  padding: 6px 9px;
  font-size: 12px;
}

.profile-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 9px;
}

.profile-row span:first-child {
  color: var(--muted);
  font-weight: 700;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 10;
  min-width: min(360px, calc(100vw - 32px));
  border-radius: 8px;
  padding: 12px 14px;
  color: #fff;
  background: #0f172a;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.25);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 14px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.inline-form {
  display: grid;
  gap: 10px;
}

.inline-form .field-grid {
  margin-bottom: 0;
}

.rating-row {
  display: flex;
  gap: 6px;
}

.rating-row button {
  min-width: 38px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--warning);
  background: #fff;
  font-weight: 800;
}

.rating-row button.is-selected {
  border-color: var(--orange);
  background: var(--orange-soft);
}

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

  .sidebar {
    position: static;
    height: auto;
    padding: 14px;
  }

  .role-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .role-tab {
    text-align: center;
  }

  .sidebar-card {
    display: none;
  }

  .workspace {
    padding: 16px;
  }

  .order-form-panel {
    position: static;
  }

  .customer-layout,
  .admin-grid,
  .provider-grid,
  .management-grid {
    grid-template-columns: 1fr;
  }

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

  .order-list.compact {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }
}

@media (max-width: 640px) {
  .brand strong {
    font-size: 20px;
  }

  .role-tabs {
    grid-template-columns: 1fr;
  }

  .workspace {
    padding: 12px;
  }

  .view-header {
    display: grid;
  }

  .view-header h1 {
    font-size: 24px;
  }

  .panel {
    padding: 13px;
  }

  .service-grid,
  .field-grid,
  .metrics {
    grid-template-columns: 1fr;
  }

  .order-meta {
    grid-template-columns: 88px minmax(0, 1fr);
  }
}
