:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: #172033;
  --muted: #5e687a;
  --line: #d9dee8;
  --line-strong: #b9c1cf;
  --teal: #0f766e;
  --blue: #2563eb;
  --amber: #a16207;
  --red: #b91c1c;
  --green: #15803d;
  --violet: #6d28d9;
  --shadow: 0 12px 28px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Tahoma, Arial, sans-serif;
  line-height: 1.6;
}

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

button {
  cursor: pointer;
}

.app-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 20px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(300px, 720px);
  gap: 16px;
  align-items: stretch;
  margin-bottom: 16px;
}

.brand-panel,
.role-panel,
.panel,
.metric-card,
.order-card,
.customer-card,
.notification-card {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
}

.brand-panel {
  padding: 20px;
}

.brand-logo {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-bottom: 14px;
}

.brand-logo img {
  display: block;
  width: min(280px, 100%);
  max-height: 132px;
  object-fit: contain;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}

.eyebrow {
  color: var(--teal);
  font-size: 0.82rem;
  font-weight: 700;
}

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

h1 {
  margin-bottom: 10px;
  font-size: clamp(1.6rem, 3vw, 2.35rem);
  letter-spacing: 0;
}

h2 {
  font-size: 1.1rem;
  margin-bottom: 12px;
}

h3 {
  font-size: 1rem;
  margin-bottom: 8px;
}

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

.role-panel {
  padding: 14px;
}

.role-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 8px;
}

.role-card {
  border: 1px solid var(--line);
  background: var(--surface-soft);
  border-radius: 8px;
  padding: 10px;
  text-align: right;
  color: var(--ink);
  min-height: 78px;
}

.role-card strong,
.role-card span {
  display: block;
}

.role-card span {
  color: var(--muted);
  font-size: 0.8rem;
}

.role-card.is-active {
  border-color: var(--teal);
  background: #ecfdf5;
}

.view-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.view-button,
.action-button,
.secondary-button,
.danger-button {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 9px 12px;
  min-height: 42px;
}

.view-button.is-active,
.action-button.primary {
  border-color: var(--teal);
  background: var(--teal);
  color: white;
}

.secondary-button {
  background: var(--surface-soft);
}

.danger-button {
  border-color: #fecaca;
  background: #fff1f2;
  color: var(--red);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.metric-card {
  padding: 14px;
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.metric-card strong {
  display: block;
  margin-top: 4px;
  font-size: 1.35rem;
  overflow-wrap: anywhere;
}

.workspace-grid {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.panel {
  padding: 16px;
}

.stack {
  display: grid;
  gap: 12px;
}

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

.field label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 10px 12px;
  min-height: 42px;
}

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

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 0.9rem;
}

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 170px 150px;
  gap: 10px;
  margin-bottom: 14px;
}

.board {
  overflow-x: auto;
  padding-bottom: 4px;
}

.lanes {
  display: grid;
  grid-template-columns: repeat(6, minmax(340px, 1fr));
  gap: 10px;
  min-width: 2100px;
}

.lane {
  border: 1px solid var(--line);
  background: var(--surface-soft);
  border-radius: 8px;
  padding: 10px;
  min-height: 420px;
}

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

.lane-header strong {
  font-size: 0.95rem;
}

.count-pill,
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: white;
  min-height: 26px;
  padding: 2px 9px;
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.order-card {
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: 0 8px 18px rgba(23, 32, 51, 0.05);
}

.order-head,
.order-meta-row,
.order-actions,
.status-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.order-head {
  justify-content: space-between;
}

.order-code {
  font-weight: 800;
}

.order-title {
  margin: 8px 0 8px;
}

.order-meta {
  display: grid;
  gap: 6px;
  margin: 10px 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.order-meta-row {
  justify-content: space-between;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 5px;
}

.order-meta-row:last-child {
  border-bottom: 0;
}

.status-row {
  flex-wrap: wrap;
  margin: 8px 0;
}

.badge.urgent {
  border-color: #fed7aa;
  background: #fff7ed;
  color: #9a3412;
}

.badge.high {
  border-color: #fde68a;
  background: #fffbeb;
  color: var(--amber);
}

.badge.normal {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: var(--blue);
}

.badge.delay {
  border-color: #fecaca;
  background: #fff1f2;
  color: var(--red);
}

.badge.done {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: var(--green);
}

.badge.external {
  border-color: #ddd6fe;
  background: #f5f3ff;
  color: var(--violet);
}

.progress {
  position: relative;
  height: 8px;
  overflow: hidden;
  background: #e5e7eb;
  border-radius: 999px;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--teal);
}

.order-note {
  color: var(--muted);
  font-size: 0.84rem;
  border-right: 3px solid var(--line-strong);
  padding: 8px 10px 8px 0;
  margin: 10px 0;
}

.order-actions {
  flex-wrap: wrap;
  margin-top: 10px;
}

.action-button,
.secondary-button,
.danger-button {
  font-size: 0.85rem;
}

details.delay-box {
  margin-top: 10px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

details.delay-box summary,
details.edit-box summary {
  color: var(--red);
  cursor: pointer;
  font-weight: 700;
  font-size: 0.88rem;
}

details.edit-box {
  margin-top: 10px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

details.edit-box summary {
  color: var(--teal);
}

.delay-form,
.edit-order-form {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.notification-card {
  padding: 12px;
  margin-bottom: 8px;
}

.notification-card strong {
  display: block;
  font-size: 0.9rem;
}

.notification-card span {
  color: var(--muted);
  font-size: 0.82rem;
}

.role-summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fafc;
}

.permission-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.permission-list li {
  border-right: 3px solid var(--teal);
  padding-right: 10px;
  color: var(--muted);
}

.customer-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.customer-card {
  padding: 16px;
}

.timeline {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  align-items: start;
}

.timeline-dot {
  width: 12px;
  height: 12px;
  margin-top: 7px;
  border-radius: 999px;
  background: var(--line-strong);
}

.timeline-item.is-public .timeline-dot {
  background: var(--teal);
}

.timeline-item strong {
  display: block;
}

.timeline-item span {
  color: var(--muted);
  font-size: 0.82rem;
}

.customer-stage {
  display: grid;
  grid-template-columns: repeat(7, minmax(90px, 1fr));
  gap: 8px;
  margin: 14px 0;
}

.stage-step {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  background: var(--surface-soft);
  min-height: 64px;
  color: var(--muted);
  font-size: 0.82rem;
}

.stage-step.is-active,
.stage-step.is-done {
  border-color: var(--teal);
  background: #ecfdf5;
  color: var(--ink);
}

.empty-state {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  background: var(--surface-soft);
}

.sync-status {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 14px;
  font-weight: 700;
}

.sync-status.is-online {
  border-color: rgba(21, 128, 61, 0.3);
  background: #ecfdf5;
  color: var(--green);
}

.sync-status.is-local {
  border-color: rgba(161, 98, 7, 0.35);
  background: #fffbeb;
  color: var(--amber);
}

.toast {
  position: fixed;
  bottom: 18px;
  left: 18px;
  max-width: 360px;
  border: 1px solid var(--line);
  border-right: 5px solid var(--teal);
  background: white;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.site-footer {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  padding: 14px 18px;
  text-align: center;
  font-weight: 700;
}

.login-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(320px, 1fr);
  gap: 16px;
  min-height: calc(100vh - 40px);
  align-items: center;
}

.login-brand {
  min-height: 360px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-panel {
  box-shadow: var(--shadow);
}

.employee-login-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(140px, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.employee-login-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 10px;
  text-align: right;
  color: var(--ink);
}

.employee-login-card strong,
.employee-login-card span,
.employee-login-card small {
  display: block;
}

.employee-login-card span,
.employee-login-card small {
  color: var(--muted);
}

.account-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.account-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

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

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

.employee-management {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.employee-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  background: var(--surface-soft);
}

.employee-row-wide {
  align-items: flex-start;
}

.employee-row strong,
.employee-row small {
  display: block;
}

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

.employee-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.permissions-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
}

.permissions-box h3 {
  margin-bottom: 10px;
}

.permission-check {
  border-bottom: 1px dashed var(--line);
  padding-bottom: 8px;
  margin-bottom: 8px;
}

.permission-check:last-child {
  border-bottom: 0;
  margin-bottom: 0;
  padding-bottom: 0;
}

.mini {
  min-height: 34px;
  padding: 6px 9px;
  font-size: 0.78rem;
}

.invoice-card {
  display: grid;
  gap: 10px;
}

.invoice-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

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

.invoice-grid div,
.finance-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: var(--surface-soft);
}

.invoice-grid span,
.finance-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
}

.invoice-grid strong,
.finance-grid strong {
  display: block;
  overflow-wrap: anywhere;
}

.invoice-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid var(--line);
  font-size: 0.84rem;
}

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

.invoice-table th {
  background: #eef2f7;
  color: var(--muted);
  font-size: 0.76rem;
}

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

.finance-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.finance-grid .done {
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.finance-grid .delay {
  border-color: #fecaca;
  background: #fff1f2;
}

.customer-finance {
  margin: 12px 0;
}

.reminder-strip {
  border: 1px solid #fde68a;
  border-radius: 8px;
  background: #fffbeb;
  color: var(--amber);
  padding: 8px 10px;
  font-size: 0.82rem;
}

.action-button.whatsapp {
  border-color: #86efac;
  background: #f0fdf4;
  color: #166534;
}

.action-button.warning {
  border-color: #fde68a;
  background: #fffbeb;
  color: var(--amber);
}

.action-button.review {
  border-color: #c4b5fd;
  background: #f5f3ff;
  color: var(--violet);
}

@media (max-width: 1100px) {
  .topbar,
  .workspace-grid,
  .customer-layout,
  .login-layout,
  .employee-management {
    grid-template-columns: 1fr;
  }

  .role-grid {
    grid-template-columns: repeat(2, minmax(130px, 1fr));
  }

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

@media (max-width: 760px) {
  .app-shell {
    padding: 12px;
  }

  .brand-logo {
    justify-content: center;
  }

  .brand-logo img {
    width: min(220px, 100%);
    max-height: 112px;
  }

  .filters,
  .two-fields,
  .invoice-grid,
  .finance-grid,
  .employee-login-grid {
    grid-template-columns: 1fr;
  }

  .customer-stage {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

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

  .account-panel,
  .employee-row {
    align-items: stretch;
    flex-direction: column;
  }

  .employee-actions {
    justify-content: stretch;
  }

  .employee-actions button {
    width: 100%;
  }
}
