:root {
  --bg: #f4f7fa;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #d8e1eb;
  --brand: #176b87;
  --brand-dark: #0f4f63;
  --green: #13795b;
  --yellow: #a16207;
  --red: #b42318;
  --blue: #1d4ed8;
  --purple: #6d28d9;
  --shadow: 0 14px 34px rgba(15, 23, 42, 0.07);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  letter-spacing: 0;
  overflow-x: hidden;
}

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  color: var(--brand-dark);
}

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

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  display: flex;
  width: min(86vw, 292px);
  transform: translateX(-100%);
  flex-direction: column;
  gap: 22px;
  border-right: 1px solid var(--line);
  background: #ffffff;
  padding: 18px;
  transition: transform 180ms ease;
}

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

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
  background: rgba(15, 23, 42, 0.45);
}

.sidebar-open .sidebar-backdrop {
  display: block;
}

.sidebar-brand,
.brand-lockup,
.sidebar-client,
.client-strip,
.user-chip {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-brand small,
.sidebar-client small,
.muted-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.sidebar-brand strong,
.sidebar-client strong {
  display: block;
  line-height: 1.2;
}

.brand-logo,
.client-logo {
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  object-fit: contain;
  border: 1px solid var(--line);
  background: #fff;
}

.brand-mark,
.client-mark,
.avatar {
  display: inline-grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--brand);
  color: #fff;
  font-weight: 800;
}

.client-mark {
  background: #334155;
}

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

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: var(--radius);
  color: #334155;
  min-height: 46px;
  padding: 12px;
  font-weight: 650;
}

.sidebar-nav a.active,
.sidebar-nav a:hover {
  background: #e8f4f7;
  color: var(--brand-dark);
}

.nav-icon {
  display: inline-grid;
  width: 22px;
  place-items: center;
}

.sidebar-client {
  margin-top: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.sidebar-client span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.logout-link {
  color: var(--red);
  font-weight: 700;
}

.main-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  min-height: 66px;
  padding: 11px 14px;
  backdrop-filter: blur(10px);
}

.icon-button {
  display: inline-grid;
  gap: 4px;
  width: 42px;
  height: 42px;
  place-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.icon-button span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--ink);
}

.topbar-title {
  min-width: 0;
  flex: 1;
}

.page-kicker {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.topbar h1 {
  margin: 0;
  overflow: hidden;
  font-size: 18px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.topbar-actions > .env-badge,
.topbar-actions > .btn,
.topbar-actions > .user-chip {
  display: none;
}

.env-badge,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.env-badge {
  background: #eef2ff;
  color: #3730a3;
}

.env-production {
  background: #e8f7ef;
  color: var(--green);
}

.env-staging {
  background: #fff7ed;
  color: #9a3412;
}

.env-testing {
  background: #e8f4f7;
  color: var(--brand-dark);
}

.notification-menu {
  position: relative;
}

.notification-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
  padding: 7px 10px;
}

.notification-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand);
}

.notification-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  display: none;
  width: min(360px, calc(100vw - 28px));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}

.notification-menu.open .notification-panel {
  display: block;
}

.notification-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 12px;
}

.notification-panel-head button {
  border: 0;
  background: transparent;
  color: var(--brand);
  cursor: pointer;
  font-weight: 800;
}

.notification-list {
  max-height: 340px;
  overflow-y: auto;
}

.notification-list a {
  display: grid;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  padding: 12px;
}

.notification-list a:hover,
.notification-list a.unread {
  background: #f0f7fa;
}

.notification-list span,
.notification-list small,
.notification-empty {
  color: var(--muted);
  font-size: 12px;
}

.notification-empty {
  padding: 16px;
}

.user-chip {
  border-left: 1px solid var(--line);
  padding-left: 10px;
}

.avatar {
  width: 34px;
  height: 34px;
}

.user-chip-text strong,
.user-chip-text small {
  display: block;
  line-height: 1.1;
}

.user-chip-text small {
  color: var(--muted);
  font-size: 11px;
}

.page-content {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  flex: 1;
  padding: 16px 12px 28px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.dashboard-widgets {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

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

.stat-card {
  display: grid;
  min-height: 116px;
  align-content: space-between;
  color: var(--ink);
  padding: 16px;
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.stat-card:hover {
  border-color: #b7c7d7;
  box-shadow: 0 18px 38px rgba(15, 23, 42, 0.1);
  color: var(--ink);
  transform: translateY(-1px);
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 32px;
  line-height: 1;
}

.stat-warning {
  border-left: 4px solid var(--yellow);
}

.stat-info {
  border-left: 4px solid var(--blue);
}

.stat-success {
  border-left: 4px solid var(--green);
}

.stat-danger {
  border-left: 4px solid var(--red);
}

.stat-purple {
  border-left: 4px solid var(--purple);
}

.stat-muted {
  border-left: 4px solid #64748b;
}

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

.narrow-panel {
  max-width: 860px;
}

.panel-header {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.panel-header h2,
.detail-title h2,
.login-card h2 {
  margin: 0;
  font-size: 21px;
  line-height: 1.2;
}

.panel-header p,
.workflow-row p,
.form-intro {
  margin: 4px 0 0;
  color: var(--muted);
}

.workflow-row {
  display: grid;
  gap: 12px;
}

.workflow-row > div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

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

.mini-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  padding: 12px;
}

.mini-list a:hover {
  border-color: #b7c7d7;
  background: #f8fafc;
}

.mini-list a > span {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.mini-list strong {
  color: var(--brand-dark);
}

.step-number {
  display: inline-grid;
  width: 28px;
  height: 28px;
  margin-bottom: 8px;
  place-items: center;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 800;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
}

.btn-primary:hover {
  background: var(--brand-dark);
  color: #fff;
}

.btn-dark {
  background: #111827;
  color: #fff;
}

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

.btn-danger:hover {
  background: #8f1d15;
  color: #fff;
}

.btn-light {
  border-color: var(--line);
  background: #fff;
  color: #111827;
}

.btn-small {
  min-height: 36px;
  padding: 7px 11px;
}

.btn-full {
  width: 100%;
}

.btn:disabled,
button:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.alert {
  margin-bottom: 14px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 12px 14px;
  font-weight: 650;
}

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

.alert-success {
  border-color: #bbf7d0;
  background: #ecfdf3;
  color: var(--green);
}

.alert-warning {
  border-color: #fed7aa;
  background: #fff7ed;
  color: var(--yellow);
}

.filter-bar,
.request-form {
  display: grid;
  gap: 12px;
}

.filter-bar {
  display: none;
  margin-bottom: 18px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fafc;
  padding: 12px;
}

.filter-bar.is-open {
  display: grid;
}

.filter-toggle {
  width: 100%;
  margin-bottom: 12px;
}

label span,
.field span {
  display: block;
  margin-bottom: 6px;
  color: #344054;
  font-size: 13px;
  font-weight: 800;
}

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

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(23, 107, 135, 0.16);
}

.is-invalid {
  border-color: var(--red);
}

.field-error {
  display: block;
  margin-top: 6px;
  color: var(--red);
  font-weight: 700;
}

.field small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

.field-full {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  grid-column: 1 / -1;
}

.desktop-table {
  display: none;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.request-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  background: #fff;
}

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

.request-table tbody tr {
  transition: background 150ms ease;
}

.request-table tbody tr:hover {
  background: #f8fafc;
}

.clickable-row,
.clickable-card {
  cursor: pointer;
}

.request-table th {
  color: #475467;
  font-size: 12px;
  text-transform: uppercase;
}

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

.request-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 14px;
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.request-card:hover {
  border-color: #b7c7d7;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}

.request-card-head,
.badge-row,
.request-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.request-card-head {
  justify-content: space-between;
}

.request-card h3 {
  margin: 10px 0 8px;
  font-size: 17px;
}

.request-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.badge-row {
  margin-top: 10px;
}

.badge {
  max-width: 100%;
  background: #eef2f7;
  color: #334155;
  white-space: normal;
}

.badge-low,
.badge-completed,
.badge-approved {
  background: #dcfce7;
  color: #166534;
}

.badge-medium,
.badge-pending,
.badge-pending-approval,
.badge-need-clarification,
.badge-need-cost-estimation {
  background: #fef3c7;
  color: #92400e;
}

.badge-high,
.badge-in-progress,
.badge-testing,
.badge-waiting-for-clarification,
.badge-waiting-for-approval {
  background: #dbeafe;
  color: #1e40af;
}

.badge-critical,
.badge-critical-bug,
.badge-rejected {
  background: #fee2e2;
  color: #991b1b;
}

.badge-on-hold,
.badge-deferred-to-next-phase,
.badge-archived {
  background: #f1f5f9;
  color: #475569;
}

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

.empty-state strong {
  display: block;
  color: var(--ink);
  font-size: 18px;
}

.empty-state p {
  margin: 8px auto 16px;
  max-width: 420px;
}

.compact-empty {
  padding: 16px;
  text-align: left;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.pagination a {
  display: inline-grid;
  min-width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  font-weight: 800;
}

.pagination a.active {
  background: var(--brand);
  color: #fff;
}

.detail-layout {
  display: grid;
  gap: 14px;
}

.detail-title {
  display: grid;
  gap: 12px;
  align-items: start;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.serial-chip {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 800;
}

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

.detail-section p {
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.detail-section h3,
.detail-side h3,
.detail-history h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.attachment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.attachment-card {
  display: grid;
  gap: 8px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  padding: 10px;
}

.attachment-card:hover {
  border-color: #b7c7d7;
  background: #f8fafc;
}

.attachment-card img,
.file-preview {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 6px;
  background: #eef2f7;
  object-fit: cover;
}

.file-preview {
  display: grid;
  place-items: center;
  color: var(--red);
  font-weight: 900;
}

.attachment-card strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.status-list {
  display: grid;
  gap: 12px;
  margin: 0;
}

.status-helper {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.status-list div {
  display: grid;
  grid-template-columns: minmax(110px, 0.8fr) minmax(0, 1.2fr);
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.status-list dt {
  color: var(--muted);
  font-weight: 700;
}

.status-list dd {
  margin: 0;
  text-align: right;
  min-width: 0;
}

.workflow-form,
.inline-upload-form {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

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

.timeline {
  display: grid;
  gap: 0;
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 10px;
  padding-bottom: 16px;
}

.timeline-item > span {
  position: relative;
  z-index: 1;
  width: 10px;
  height: 10px;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--brand);
}

.timeline-item:not(:last-child)::before {
  position: absolute;
  top: 15px;
  bottom: 0;
  left: 4px;
  width: 2px;
  background: var(--line);
  content: "";
}

.timeline-item small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.compact-header {
  margin-bottom: 12px;
}

.app-footer {
  display: grid;
  gap: 4px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  padding: 16px;
}

.login-body {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 16px;
  background: #edf3f7;
}

.login-shell {
  display: grid;
  width: min(1040px, 100%);
  overflow: hidden;
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow);
}

.login-brand-panel {
  display: none;
  min-height: 560px;
  flex-direction: column;
  justify-content: space-between;
  background: #123645;
  color: #fff;
  padding: 34px;
}

.login-brand-panel .muted-label,
.login-brand-panel p,
.login-brand-panel small {
  color: rgba(255, 255, 255, 0.76);
}

.login-brand-panel h1,
.login-brand-panel h2 {
  margin: 0;
}

.login-copy h2 {
  margin-top: 16px;
  font-size: 34px;
  line-height: 1.08;
}

.login-copy p {
  max-width: 470px;
  font-size: 16px;
}

.client-strip {
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius);
  padding: 14px;
}

.client-strip small {
  display: block;
}

.login-card {
  border: 0;
  box-shadow: none;
  padding: 26px 18px;
}

.mobile-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
}

.stacked-form {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.login-hint {
  margin-top: 16px;
  color: var(--muted);
  font-size: 12px;
}

@media (min-width: 720px) {
  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .panel-header {
    grid-template-columns: 1fr auto;
    align-items: center;
  }

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

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

  .filter-toggle {
    display: none;
  }

  .sticky-filters {
    position: sticky;
    top: 66px;
    z-index: 6;
  }

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

  .detail-layout {
    grid-template-columns: minmax(0, 1fr) 340px;
  }

  .detail-history {
    grid-column: 1 / -1;
  }

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

  .inline-upload-form {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .login-shell {
    grid-template-columns: 1.1fr 0.9fr;
  }

  .login-brand-panel {
    display: flex;
  }

  .login-card {
    padding: 52px 42px;
  }

  .mobile-brand {
    display: none;
  }
}

@media (min-width: 1024px) {
  .sidebar {
    width: 280px;
    transform: none;
  }

  .sidebar-backdrop,
  .sidebar-open .sidebar-backdrop {
    display: none;
  }

  .main-shell {
    margin-left: 280px;
  }

  .sidebar-toggle {
    display: none;
  }

  .topbar-actions {
    display: flex;
  }

  .topbar-actions > .env-badge,
  .topbar-actions > .btn {
    display: inline-flex;
  }

  .topbar-actions > .user-chip {
    display: flex;
  }

  .topbar h1 {
    font-size: 20px;
  }

  .page-content {
    padding: 24px;
  }

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

  .filter-bar {
    grid-template-columns: minmax(180px, 1.4fr) repeat(5, minmax(122px, 1fr)) auto;
  }

  .desktop-table {
    display: block;
  }

  .mobile-request-list {
    display: none;
  }

  .app-footer {
    margin-left: 0;
    grid-template-columns: 1fr auto;
  }
}
