:root {
  --bg: #f6f4f1;
  --panel: #ffffff;
  --ink: #191919;
  --muted: #68635d;
  --line: #ded7cf;
  --brand: #ff6a00;
  --brand-2: #ff9f1c;
  --accent: #2a2928;
  --danger: #b42318;
  --ok: #087443;
  --warn: #a15c07;
  --shadow: 0 12px 30px rgba(25, 25, 25, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  background: #0c0c0c;
}

.login-panel {
  background: var(--panel);
  padding: 42px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 22px;
}

.login-stack {
  background: var(--panel);
  display: grid;
  align-content: center;
  max-height: 100vh;
  overflow: auto;
}

.login-stack .login-panel {
  min-height: auto;
  box-shadow: none;
}

.reset-panel {
  border-top: 1px solid var(--line);
  padding-top: 28px;
}

.login-art {
  min-height: 100vh;
  display: flex;
  align-items: end;
  padding: 54px;
  color: #fff;
  background:
    linear-gradient(120deg, rgba(10, 10, 10, 0.46), rgba(255, 106, 0, 0.55)),
    url("https://images.unsplash.com/photo-1551434678-e076c223a692?auto=format&fit=crop&w=1600&q=80") center/cover;
}

.login-art h1 {
  max-width: 780px;
  font-size: clamp(38px, 6vw, 78px);
  line-height: 0.98;
  margin: 0;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  font-size: 19px;
  min-width: 0;
}

.brand-logo {
  width: 44px;
  height: 44px;
  object-fit: contain;
  flex: 0 0 auto;
}

.brand-logo.full {
  width: min(280px, 100%);
  height: auto;
  display: block;
}

.brand-text {
  line-height: 1.05;
}

.brand-text small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0;
  margin-top: 3px;
}

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

.field span {
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: #fff;
  color: var(--ink);
}

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

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  min-height: 40px;
  padding: 9px 13px;
  border-radius: 8px;
  font-weight: 700;
}

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

.btn.danger {
  border-color: #f4c7c3;
  color: var(--danger);
}

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

.sidebar {
  background: #101010;
  color: #fff3e8;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

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

.nav button {
  border: 0;
  background: transparent;
  color: #ddd4ca;
  text-align: left;
  padding: 11px 12px;
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.nav button.active,
.nav button:hover {
  background: rgba(255, 106, 0, 0.16);
  color: #fff;
}

.mobile-menu-toggle {
  display: none;
}

.workspace {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
}

.topbar {
  height: 70px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 4;
  backdrop-filter: blur(12px);
}

.topbar h1 {
  font-size: 21px;
  margin: 0;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #fff0df;
  color: var(--brand);
  display: grid;
  place-items: center;
  font-weight: 900;
}

.content {
  padding: 24px;
  display: grid;
  gap: 18px;
  align-content: start;
}

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

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

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

.grid {
  display: grid;
  gap: 14px;
}

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

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

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

.metric {
  padding: 18px;
  display: grid;
  gap: 8px;
}

.metric small {
  color: var(--muted);
  font-weight: 700;
}

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

.metric em {
  color: var(--ok);
  font-style: normal;
  font-size: 13px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

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

th {
  color: #344054;
  background: #fbf7f1;
  font-size: 12px;
  text-transform: uppercase;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  background: #fff0df;
  color: #a44700;
}

.pill.ok {
  background: #ecfdf3;
  color: var(--ok);
}

.pill.warn {
  background: #fffaeb;
  color: var(--warn);
}

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

.split {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 18px;
}

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

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

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

.panel-title h2 {
  margin: 0;
  font-size: 17px;
}

.preview {
  white-space: pre-wrap;
  line-height: 1.45;
  background: #fbfcfe;
  padding: 18px;
  min-height: 300px;
}

.letterhead-preview {
  position: relative;
  min-height: 720px;
  background: #fff;
  overflow: hidden;
}

.letterhead-preview img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.22;
  pointer-events: none;
}

.letterhead-preview .document-text {
  position: relative;
  z-index: 1;
  padding: 92px 58px 72px;
  white-space: pre-wrap;
  line-height: 1.5;
  color: #171717;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.attachment-box {
  display: grid;
  gap: 8px;
  min-width: 160px;
}

.attachment-box input[type="file"] {
  display: none;
}

.upload-control {
  width: fit-content;
}

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

.attachment-item {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.link-button {
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--brand);
  font-weight: 800;
  text-align: left;
}

.danger-text {
  color: var(--danger);
}

@media print {
  body * {
    visibility: hidden;
  }

  .print-area,
  .print-area * {
    visibility: visible;
  }

  .print-area {
    position: absolute;
    inset: 0;
    width: 100%;
  }
}

.timeline {
  padding: 14px 18px;
  display: grid;
  gap: 12px;
}

.event {
  border-left: 3px solid var(--brand);
  padding-left: 12px;
}

.event strong {
  display: block;
}

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

.locked {
  border: 1px dashed var(--line);
  background: #fff;
  padding: 30px;
  border-radius: 8px;
}

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

  .login-art {
    display: none;
  }

  .login-stack {
    min-height: 100vh;
    max-height: none;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 12px;
    gap: 12px;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .sidebar .brand-lockup {
    min-width: 0;
  }

  .sidebar .brand-text {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .nav {
    grid-column: 1 / -1;
    display: none;
    grid-template-columns: 1fr;
    gap: 8px;
    padding-top: 8px;
  }

  .sidebar.open .nav {
    display: grid;
  }

  .mobile-menu-toggle {
    width: 44px;
    height: 44px;
    display: grid;
    place-content: center;
    gap: 5px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
  }

  .mobile-menu-toggle span {
    width: 20px;
    height: 2px;
    background: #fff;
    display: block;
    border-radius: 999px;
  }

  .nav button {
    white-space: normal;
    min-height: 44px;
    padding: 10px 13px;
    background: rgba(255, 255, 255, 0.06);
  }

  .nav button span:last-child {
    display: inline;
  }

  .workspace {
    min-width: 0;
  }

  .topbar {
    height: auto;
    min-height: 62px;
    padding: 12px 14px;
    align-items: flex-start;
    gap: 10px;
  }

  .topbar h1 {
    font-size: 18px;
    padding-top: 8px;
  }

  .user-chip {
    gap: 6px;
    justify-content: flex-end;
  }

  .user-chip span {
    display: none;
  }

  .content {
    padding: 14px;
    gap: 14px;
  }

  .grid.cols-4,
  .grid.cols-3,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .toolbar,
  .toolbar-left,
  .toolbar-right {
    align-items: stretch;
    width: 100%;
  }

  .toolbar-right .btn,
  .toolbar-right select,
  .toolbar-left input,
  .toolbar-left .field {
    width: 100%;
  }

  .panel-title {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-title .toolbar-right {
    display: grid;
    grid-template-columns: 1fr;
  }

  .btn,
  .field input,
  .field select,
  .field textarea {
    min-height: 46px;
  }

  .action-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .action-row .btn {
    width: 100%;
    min-height: 42px;
    padding: 8px;
  }

  .attachment-box {
    min-width: 0;
    width: 100%;
  }

  .upload-control {
    width: 100%;
  }

  .table-wrap {
    overflow: visible;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  table {
    min-width: 0;
    border-collapse: separate;
    border-spacing: 0 12px;
  }

  thead {
    display: none;
  }

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

  td {
    border-bottom: 0;
    display: grid;
    grid-template-columns: minmax(92px, 34%) 1fr;
    gap: 10px;
    padding: 8px 12px;
    align-items: start;
    word-break: break-word;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
  }

  .letterhead-preview {
    min-height: 520px;
  }

  .letterhead-preview .document-text {
    padding: 58px 24px 46px;
    font-size: 13px;
  }

  .preview {
    max-height: 70vh;
    overflow: auto;
  }
}

@media (max-width: 560px) {
  .login-panel {
    padding: 26px 20px;
  }

  .brand-logo.full {
    width: min(230px, 100%);
  }

  .brand-lockup {
    font-size: 16px;
  }

  .metric {
    padding: 14px;
  }

  .metric strong {
    font-size: 24px;
  }

  .form-grid {
    padding: 14px;
  }

  .content {
    padding: 10px;
  }

  .card {
    border-radius: 8px;
  }

  td {
    grid-template-columns: 1fr;
    gap: 4px;
  }

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

  .letterhead-preview {
    min-height: 480px;
  }

  .letterhead-preview .document-text {
    padding: 48px 16px 40px;
    font-size: 12px;
  }
}
