:root {
  color-scheme: light;
  --bg: #f3f6fa;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: #122238;
  --muted: #64748b;
  --line: #dce4ee;
  --blue: #07549b;
  --blue-dark: #063f75;
  --blue-soft: #eaf3fb;
  --red: #e30613;
  --red-dark: #b80510;
  --warning: #a16207;
  --success: #16794a;
  --danger: #c5222d;
  --shadow: 0 10px 28px rgba(18, 34, 56, 0.07);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  position: relative;
  margin: 0;
  min-height: 100vh;
  isolation: isolate;
  background:
    radial-gradient(circle at 12% 15%, rgba(7, 84, 155, 0.1), transparent 34%),
    radial-gradient(circle at 88% 82%, rgba(227, 6, 19, 0.07), transparent 30%),
    linear-gradient(145deg, #f8fbfe 0%, var(--bg) 48%, #eef3f8 100%);
  color: var(--ink);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  pointer-events: none;
  background-image: url("assets/star-computer-logo-hd-v2.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: min(760px, 70vw) auto;
  filter: blur(3px);
  opacity: 0.075;
  transform: scale(1.04);
}

body > main {
  position: relative;
  z-index: 1;
}

.database-error {
  position: relative;
  z-index: 1000;
  padding: 14px 20px;
  color: #ffffff;
  text-align: center;
  background: var(--danger);
  font-weight: 800;
}

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

button,
a,
summary {
  -webkit-tap-highlight-color: transparent;
}

.role-gateway {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 36px 24px;
  background-color: transparent;
  border-left: 5px solid var(--red);
}

.gateway-panel {
  width: min(1040px, 100%);
}

.login-panel {
  width: min(470px, 100%);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 24px;
  margin-bottom: 30px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.brand-logo {
  display: block;
  width: 205px;
  height: 88px;
  object-fit: contain;
  object-position: center;
  flex: 0 0 auto;
}

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

.brand strong {
  display: none;
}

.brand span {
  color: #c7d6e5;
  font-size: 0.82rem;
  line-height: 1.6;
}

.app-brand {
  position: relative;
  justify-content: center;
  margin: -4px -4px 30px;
  padding: 14px 12px 16px;
  overflow: hidden;
  background: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.16);
}

.app-brand::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 4px;
  content: "";
  background: linear-gradient(90deg, var(--blue) 0 72%, var(--red) 72%);
}

.app-brand .brand-logo {
  width: 100%;
  height: auto;
  aspect-ratio: 1910 / 823;
}

.gateway-brand {
  width: fit-content;
  margin-bottom: 42px;
  padding-bottom: 0;
  border-bottom: 0;
}

.gateway-brand.app-brand {
  width: min(420px, 100%);
  padding: 14px 18px 18px;
}

.gateway-brand .brand-logo {
  width: 290px;
  height: 125px;
}

.gateway-brand span {
  color: var(--muted);
  font-size: 0.9rem;
}

.gateway-heading {
  max-width: 720px;
  margin-bottom: 28px;
}

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

.single-role {
  grid-template-columns: minmax(280px, 420px);
}

.role-card {
  position: relative;
  min-height: 210px;
  padding: 26px;
  overflow: hidden;
  color: var(--ink);
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.role-card::after {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 72px;
  height: 4px;
  content: "";
  background: var(--red);
}

.role-card:hover {
  border-color: #a9c8e4;
  box-shadow: 0 16px 34px rgba(7, 84, 155, 0.12);
  transform: translateY(-3px);
}

.role-icon {
  display: grid;
  width: 46px;
  height: 46px;
  margin-bottom: 24px;
  place-items: center;
  color: var(--blue);
  background: var(--blue-soft);
  border: 1px solid #d4e7f7;
  border-radius: 7px;
  font-weight: 800;
}

.role-card strong {
  display: block;
  margin-bottom: 10px;
  font-size: 1.28rem;
}

.role-card p {
  max-width: 390px;
  margin: 0;
  color: var(--muted);
  line-height: 1.8;
}

.staff-access {
  margin-top: 24px;
  color: var(--muted);
}

.staff-access summary {
  width: fit-content;
  cursor: pointer;
  font-weight: 700;
}

.staff-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.ghost-link {
  display: inline-grid;
  min-height: 42px;
  place-items: center;
  padding: 0 16px;
  color: var(--blue-dark);
  text-decoration: none;
  background: var(--blue-soft);
  border: 1px solid #d8e8f6;
  border-radius: 7px;
  font-weight: 700;
}

.center-link {
  text-align: center;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 20px;
  color: #ffffff;
  background: #0b2744;
  border-right: 5px solid var(--red);
}

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

.nav-item {
  position: relative;
  min-height: 46px;
  padding: 12px 16px;
  color: #d4e2ef;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 7px;
  transition: background 160ms ease, color 160ms ease;
}

.nav-item.active,
.nav-item:hover {
  color: #ffffff;
  background: #123a61;
  border-color: rgba(255, 255, 255, 0.1);
}

.nav-item.active::before {
  position: absolute;
  top: 12px;
  right: 0;
  width: 3px;
  height: 22px;
  content: "";
  background: var(--red);
}

.workspace {
  min-width: 0;
  padding: 32px;
}

.customer-status-shell .workspace {
  display: grid;
  align-content: start;
}

.topbar,
.panel-header,
.ticket-main,
.ticket-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.topbar {
  min-height: 88px;
  padding: 0 0 22px;
  border-bottom: 1px solid var(--line);
}

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

.eyebrow {
  margin: 0 0 7px;
  color: var(--red);
  font-size: 0.78rem;
  font-weight: 800;
}

h1,
h2 {
  margin: 0;
  line-height: 1.35;
}

h1 {
  max-width: 760px;
  font-size: clamp(1.65rem, 3vw, 2.25rem);
}

h2 {
  font-size: 1.24rem;
}

.primary-button,
.ghost-button,
.danger-button,
.whatsapp-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 17px;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 7px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.primary-button {
  color: #ffffff;
  background: var(--blue);
}

.primary-button:hover {
  background: var(--blue-dark);
  transform: translateY(-1px);
}

.ghost-button {
  color: var(--blue-dark);
  background: var(--surface);
  border-color: #bfd3e5;
}

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

.danger-button {
  color: var(--danger);
  background: #fff3f4;
  border-color: #f4c8cc;
}

.whatsapp-button {
  color: #ffffff;
  background: #168c52;
  border-color: #168c52;
}

.whatsapp-button:hover {
  background: #0f7040;
  border-color: #0f7040;
  transform: translateY(-1px);
}

.full-width {
  width: 100%;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 26px 0;
}

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

.stat-card,
.ticket-form,
.tickets-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.stat-card {
  position: relative;
  min-height: 118px;
  padding: 20px;
  overflow: hidden;
}

.stat-card::before {
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  height: 3px;
  content: "";
  background: var(--blue);
}

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

.stat-card strong {
  display: block;
  margin-top: 11px;
  color: var(--blue-dark);
  font-size: 2rem;
}

.content-grid {
  display: grid;
  grid-template-columns: 365px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  margin-top: 26px;
}

.customer-grid {
  margin-top: 26px;
}

.customer-request-grid {
  grid-template-columns: minmax(320px, 560px);
  justify-content: center;
}

.status-lookup {
  width: min(920px, 100%);
  margin: 26px auto 0;
}

.status-card .ticket-title strong {
  font-size: 1.2rem;
}

.status-phone-input {
  min-height: 58px;
  font-size: 1.15rem;
  font-weight: 700;
  direction: ltr;
  text-align: right;
}

.status-search-form {
  display: grid;
  gap: 12px;
  margin: 20px 0 12px;
}

#statusResultPhone {
  direction: ltr;
  color: var(--blue-dark);
  text-align: right;
}

.ticket-form,
.tickets-panel {
  padding: 22px;
}

.ticket-form {
  display: grid;
  gap: 15px;
}

.section-heading {
  margin-bottom: 4px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--line);
}

.fee-notice,
.payment-summary,
.appointment-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  color: var(--ink);
  background: var(--blue-soft);
  border: 1px solid #d6e7f5;
  border-radius: 7px;
}

.fee-notice strong {
  color: var(--blue-dark);
  font-size: 1.08rem;
}

.payment-summary,
.appointment-summary {
  margin-top: 10px;
  font-size: 0.9rem;
}

.payment-summary span:last-child {
  color: var(--success);
  font-weight: 800;
}

.workflow-box,
.appointment-form,
.quote-form,
.part-form,
.engineer-workflow {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  padding: 15px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.workflow-box p,
.appointment-form p {
  margin: 0;
  line-height: 1.7;
}

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

.appointment-form > p,
.appointment-form > button {
  grid-column: 1 / -1;
}

.quote-form,
.part-form {
  min-width: min(280px, 100%);
}

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

@media (max-width: 620px) {
  .repair-options {
    grid-template-columns: 1fr;
  }
}

.working-hours {
  margin-top: 12px;
  padding: 10px 12px;
  background: #fff8e6;
  border-right: 3px solid #d99a19;
}

.login-form {
  margin-top: 18px;
}

.login-panel .gateway-brand {
  margin-right: auto;
  margin-left: auto;
  text-align: center;
}

.login-error {
  min-height: 22px;
  margin: 0;
  color: var(--danger);
  font-weight: 700;
}

.map-picker {
  display: grid;
  gap: 8px;
}

.helper-text {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.7;
}

.helper-text a,
.map-link {
  color: var(--blue);
  font-weight: 700;
  text-decoration: none;
}

.helper-text a:hover,
.map-link:hover {
  text-decoration: underline;
}

label {
  display: grid;
  gap: 7px;
  color: #4c5d70;
  font-size: 0.92rem;
  font-weight: 700;
}

.inline-filter {
  min-width: 250px;
}

input,
select,
textarea {
  width: 100%;
  padding: 12px 13px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid #cdd8e5;
  border-radius: 7px;
  outline: none;
}

input,
select {
  min-height: 46px;
}

textarea {
  min-height: 100px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(7, 84, 155, 0.12);
}

.search-input {
  max-width: 330px;
}

.ticket-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.ticket-card {
  padding: 17px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-right: 3px solid var(--blue);
  border-radius: 7px;
}

.ticket-main {
  align-items: flex-start;
}

.ticket-title {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 9px;
}

.ticket-title strong {
  font-size: 1.06rem;
}

.ticket-meta,
.ticket-issue,
.ticket-note {
  margin: 0;
  color: var(--muted);
}

.ticket-meta + .ticket-meta {
  margin-top: 4px;
}

.ticket-issue,
.ticket-note {
  margin-top: 10px;
  line-height: 1.7;
}

.ticket-note {
  color: #3f5063;
}

.status-badge {
  padding: 5px 10px;
  color: var(--blue-dark);
  background: var(--blue-soft);
  border-radius: 999px;
  font-size: 0.77rem;
  font-weight: 800;
}

.status-badge.repair,
.status-badge.waiting {
  color: var(--warning);
  background: #fff6df;
}

.status-badge.ready,
.status-badge.closed {
  color: var(--success);
  background: #eaf8f0;
}

.status-badge.open {
  color: var(--blue);
  background: var(--blue-soft);
}

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

.ticket-controls {
  min-width: min(420px, 100%);
}

.ticket-controls label {
  min-width: 180px;
  flex: 1 1 180px;
}

.engineer-note {
  margin-top: 14px;
}

.empty-state {
  padding: 30px;
  color: var(--muted);
  text-align: center;
  background: var(--surface-soft);
  border: 1px dashed #bbc9d8;
  border-radius: 7px;
}

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

  .sidebar {
    padding: 20px 16px;
  }

  .brand-logo {
    width: 175px;
    height: 76px;
  }

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

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

@media (max-width: 760px) {
  body::before {
    background-size: min(560px, 92vw) auto;
    opacity: 0.065;
  }

  .role-gateway {
    place-items: start center;
    padding: 24px 18px;
  }

  .gateway-brand {
    margin-bottom: 28px;
  }

  .gateway-brand .brand-logo {
    width: min(280px, 72vw);
    height: auto;
    aspect-ratio: 1910 / 823;
  }

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

  .sidebar {
    position: static;
    height: auto;
    padding: 16px 18px;
    border-right: 0;
    border-bottom: 4px solid var(--red);
  }

  .sidebar .brand {
    margin-bottom: 14px;
    padding-bottom: 12px;
  }

  .sidebar .brand-logo {
    width: 160px;
    height: 68px;
  }

  .sidebar .app-brand {
    width: min(320px, 100%);
    margin: 0 auto 14px;
    padding: 8px 12px 10px;
  }

  .sidebar .app-brand .brand-logo {
    width: 100%;
    height: auto;
  }

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

  .nav-item {
    display: grid;
    min-height: 44px;
    place-items: center;
    padding: 8px;
    text-align: center;
    font-size: 0.86rem;
  }

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

  .workspace {
    padding: 22px 18px;
  }

  .topbar,
  .panel-header,
  .ticket-main,
  .ticket-controls,
  .topbar-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    min-height: 0;
  }

  .panel-header .search-input,
  .inline-filter {
    max-width: none;
    min-width: 0;
  }

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

  .stats-grid,
  .compact-stats {
    grid-template-columns: 1fr 1fr;
  }

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

  .ticket-actions button {
    flex: 1 1 auto;
  }
}

@media (max-width: 480px) {
  .role-card,
  .ticket-form,
  .tickets-panel {
    padding: 18px;
  }

  .stats-grid,
  .compact-stats {
    grid-template-columns: 1fr;
  }

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

  .brand {
    flex-direction: column;
    align-items: flex-start;
  }

  .sidebar .brand span {
    margin-top: -8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
