@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap");

:root {
  color-scheme: light;
  --app-bg: #f7f8fb;
  --surface: #ffffff;
  --border: #e2e5eb;
  --sidebar: #2b5797;
  --sidebar-soft: rgba(255, 255, 255, 0.18);
  --sidebar-text: #ffffff;
  --sidebar-muted: rgba(255, 255, 255, 0.6);
  --panel: var(--surface);
  --text: #1a1d26;
  --muted: #9198a5;
  --text2: #5c6170;
  --line: var(--border);
  --line-strong: #cdd2db;
  --primary: #2b5797;
  --primary-hover: #1e4278;
  --primary-light: #e8eef6;
  --attention: #d97706;
  --attention-bg: #fffbeb;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.1);
  --radius: 10px;
  --radius-sm: 6px;
  --font: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}


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

button {
  cursor: pointer;
}

.auth-mode-switch {
  display: block;
  margin: 14px auto 0;
  padding: 4px;
  border: 0;
  background: transparent;
  color: var(--primary);
  text-decoration: underline;
}

.auth-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #21477f 0%, #2b5797 55%, #3970b9 100%);
}

.auth-card {
  width: min(430px, 100%);
  overflow: hidden;
  border-radius: 16px;
  background: var(--primary);
  box-shadow: 0 24px 70px rgba(10, 28, 58, 0.3);
}

.auth-logo {
  display: block;
  width: 160px;
  margin: 24px auto;
}

.auth-card-body {
  padding: 30px 36px 36px;
  background: #fff;
}

.auth-kicker {
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.auth-card h1 {
  margin: 8px 0 6px;
  font-size: 28px;
}

.auth-card p {
  margin: 0 0 22px;
  color: var(--text2);
}

.auth-form {
  display: grid;
  gap: 16px;
}

.auth-form label {
  display: grid;
  gap: 7px;
  color: var(--text2);
  font-weight: 600;
}

.auth-form input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
}

.auth-form input:focus {
  outline: 3px solid rgba(43, 87, 151, .13);
  border-color: var(--primary);
}

.auth-role {
  padding: 11px 13px;
  border-radius: 8px;
  background: var(--primary-light);
  color: var(--primary);
}

.auth-error {
  margin: 0 !important;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--danger-bg);
  color: var(--danger) !important;
}

.auth-submit {
  width: 100%;
  min-height: 44px;
  justify-content: center;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  color: var(--sidebar-text);
  border-right: 1px solid rgba(24, 54, 94, 0.24);
}

.brand {
  display: block;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-logo {
  display: block;
  width: 140px;
  height: auto;
}

.brand span,
.profile span,
.side-section span {
  color: var(--sidebar-muted);
  display: block;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.3px;
  margin-top: 8px;
  text-transform: uppercase;
}

.side-nav {
  display: grid;
  gap: 2px;
  padding: 12px 10px;
}

.side-link {
  width: 100%;
  min-height: 38px;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 8px;
  padding: 10px 12px;
  color: rgba(255, 255, 255, 0.75);
  background: transparent;
  text-align: left;
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.15s;
}

.side-link:hover,
.side-link.active {
  color: #fff;
  background: var(--sidebar-soft);
  font-weight: 600;
}

.side-link b {
  min-width: 26px;
  padding: 1px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.2);
  text-align: center;
  font-size: 11px;
  font-weight: 700;
}

.side-section {
  display: grid;
  gap: 0;
  margin-top: 8px;
  padding: 6px 10px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.side-section span {
  margin: 0;
  padding: 10px 12px 6px;
  color: rgba(255, 255, 255, 0.45);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
}

.side-section a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.75);
  text-decoration: none;
  font-size: 13px;
  transition: all 0.15s;
}

.side-section a:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.profile {
  margin-top: auto;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.profile-info {
  min-width: 0;
  flex: 1;
}

.profile-logout {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: rgba(255, 255, 255, .72);
  font-size: 18px;
}

.profile-logout:hover {
  background: rgba(255, 255, 255, .12);
  color: #fff;
}

.avatar {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  font-size: 12px;
  font-weight: 700;
}

.profile strong {
  display: block;
  max-width: 174px;
  overflow: hidden;
  font-size: 12.5px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile span {
  margin-top: 0;
  font-size: 11px;
  letter-spacing: 0;
  text-transform: none;
}

.workspace {
  min-width: 0;
}

.view {
  display: none;
}

.active-view {
  display: block;
}

.page-header {
  min-height: 65px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 28px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.page-header.compact {
  justify-content: flex-start;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1.2;
}

h2 {
  font-size: 14px;
  font-weight: 700;
}

p {
  margin: 6px 0 0;
  color: var(--muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search input {
  width: min(280px, 32vw);
  padding: 7px 12px;
  font-size: 13px;
}

.search input:focus {
  width: min(380px, 36vw);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding: 24px 28px 22px;
}

.metric-card,
.form-panel,
.details-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.metric-card {
  min-height: 94px;
  padding: 16px 18px;
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.metric-card strong {
  display: block;
  margin-top: 6px;
  color: #1f2530;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.metric-card:nth-child(1) strong { color: var(--attention); }
.metric-card:nth-child(2) strong { color: #2563eb; }
.metric-card:nth-child(3) strong { color: var(--success); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  align-items: center;
  padding: 0 28px 14px;
}

.toolbar > div {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.toolbar-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.filter-btn,
.secondary-action,
.danger-action,
.back-button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  background: #fff;
  color: #303642;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.15s;
}

.filter-btn.active,
.primary-action {
  border: 0;
  background: var(--primary);
  color: #fff;
}

.primary-action {
  min-height: 34px;
  display: inline-flex;
  gap: 7px;
  align-items: center;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.15s;
  white-space: nowrap;
}

.primary-action:hover {
  background: var(--primary-hover);
}

.secondary-action:hover,
.filter-btn:hover,
.back-button:hover {
  border-color: var(--line-strong);
  background: #f8fafc;
}

.danger-action {
  color: var(--danger);
  border-color: rgba(211, 75, 75, 0.35);
}

.requests-table-wrap {
  margin: 0 28px 20px;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.requests-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}

.requests-table th {
  height: 38px;
  color: var(--muted);
  background: var(--app-bg);
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.requests-table th,
.requests-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  overflow: hidden;
}

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

.requests-table tbody tr {
  transition: background 0.12s ease;
}

.requests-table tbody tr:hover,
.requests-table tbody tr.active-row {
  background: #eef5ff;
  background: var(--primary-light);
}

.requests-table strong {
  display: block;
  margin-bottom: 3px;
}

.requests-table span {
  color: var(--muted);
  font-size: 11px;
}

.row-open {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #8c96a8;
  font-size: 26px;
  line-height: 1;
}

.row-open:hover {
  background: #e6edf8;
  color: var(--primary);
}

.detail-workspace {
  display: grid;
  gap: 20px;
  padding: 28px;
}

.status-stepper,
.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.status-stepper {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: start;
  padding: 24px 32px 20px;
}

.status-step {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 10px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
  font-weight: 700;
}

.status-step:before {
  content: "";
  position: absolute;
  top: 15px;
  left: calc(-50% + 18px);
  width: calc(100% - 36px);
  height: 3px;
  background: #dbe1ea;
}

.status-step:first-child:before {
  display: none;
}

.status-step span {
  position: relative;
  z-index: 1;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 3px solid #dbe1ea;
  border-radius: 50%;
  background: #fff;
}

.status-step.done span {
  border-color: var(--success);
  background: var(--success);
}

.status-step.done span:after {
  content: "✓";
  color: #fff;
  font-size: 18px;
  font-weight: 800;
}

.status-step.active {
  color: #2563eb;
}

.status-step.active span {
  border-color: #2563eb;
  background: #2563eb;
  box-shadow: 0 0 0 7px rgba(37, 99, 235, 0.08);
}

.status-step.active span:after {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
}

.status-step.done:before,
.status-step.active:before {
  background: var(--success);
}

.detail-card {
  padding: 20px;
}

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

.details-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 16px;
}

dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

dd {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
}

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

.detail-card .actions {
  justify-content: flex-start;
}

.approval-wait {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  margin: 0 0 14px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  color: var(--attention);
  background: var(--attention-bg);
  font-weight: 700;
}

.upload {
  display: block;
  margin: 14px 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.linklike {
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 700;
}

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

.document-version {
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.document-version:first-child {
  padding-top: 4px;
  border-top: 0;
}

.document-version-head,
.document-version-head > div {
  display: flex;
  align-items: center;
  gap: 10px;
}

.version-badge {
  padding: 5px 9px;
  border-radius: 7px;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.document-version-head {
  justify-content: space-between;
}

.document-version-head time {
  color: var(--muted);
  font-size: 13px;
}

.latest-version {
  padding: 3px 8px;
  border-radius: 7px;
  background: #e8f5ee;
  color: #168a50;
  font-size: 12px;
  font-weight: 700;
}

.version-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.docs a {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--primary);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.history {
  margin: 14px 0 0;
  padding-left: 22px;
}

.history li {
  margin-bottom: 7px;
}

.history span,
.history em,
.history small {
  display: inline-block;
  margin-right: 8px;
}

.form-panel {
  width: min(920px, calc(100% - 60px));
  margin: 24px 28px 40px;
  padding: 22px;
}

.notice-line {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  min-height: 44px;
  margin-bottom: 20px;
  padding: 10px 14px;
  background: var(--primary-light);
  border-radius: var(--radius);
  color: #42526b;
  font-weight: 600;
}

fieldset {
  border: 0;
  padding: 0;
  margin: 0 0 22px;
}

legend {
  padding: 0;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

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

.compact-grid {
  margin-top: 14px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

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

.extension-overlimit-field {
  width: min(280px, 100%);
  margin-top: 12px;
}

@media (min-width: 1100px) {
  .form-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .form-grid > label,
  .form-grid > datalist {
    grid-column: span 3;
  }

  .form-grid > .wide {
    grid-column: 1 / -1;
  }

  .form-grid > .spec-field {
    grid-column: span 2;
  }

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

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

  .form-grid.compact-grid > label {
    grid-column: span 1;
  }

  .form-grid.compact-grid > .wide {
    grid-column: 1 / -1;
  }
}

.module-fields {
  padding: 12px;
  border-top: 1px solid var(--line);
}

.module-fields + .module-fields {
  margin-top: 0;
}

.package-card {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
}

.package-card-toggle {
  width: 100%;
  min-height: 54px;
  justify-content: space-between;
  border: 0;
  border-radius: 0;
  background: #fff;
  color: var(--text);
  text-align: left;
}

.package-card-toggle span {
  font-weight: 800;
}

.package-card-toggle strong {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.package-card-body {
  padding: 0 14px 14px;
  border-top: 1px solid var(--line);
}

.package-card.collapsed .package-card-body {
  display: none;
}

.subscription-addon {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.subscription-addon label {
  flex: 0 0 auto;
  flex-direction: row;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.subscription-addon input {
  width: auto;
}

.subscription-addon span,
.payment-option-heading span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.payment-option-details {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--app-bg);
}

.payment-option-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
}

.mts-items {
  display: grid;
  gap: 12px;
}

.mts-item {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.mts-item label {
  grid-column: span 2;
}

.mts-item label:first-child {
  grid-column: 1 / -1;
}

.mts-item-remove {
  align-self: end;
  min-height: 40px;
  border-color: #fecaca;
  color: var(--danger);
}

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

.preview-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.preview-item span,
.muted-text {
  color: var(--muted);
}

.preview-item strong {
  display: block;
  margin-top: 5px;
  overflow-wrap: anywhere;
}

.approval-comment {
  margin: 14px 0 0;
  color: var(--text2);
}

.detail-card h2 {
  margin: 0 0 12px;
}

.timeline-history {
  list-style: none;
  padding-left: 18px;
  border-left: 2px solid #d9e2f0;
}

.timeline-history li {
  position: relative;
}

.timeline-history li:before {
  content: "";
  position: absolute;
  left: -25px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
}

label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: var(--text2);
  font-size: 12px;
  font-weight: 600;
}

label.wide {
  grid-column: 1 / -1;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #ccd3df;
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  background: #fff;
  color: var(--text);
  font-size: 13.5px;
  transition: border 0.15s;
  outline: none;
}

input[type="number"] {
  appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  margin: 0;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-light);
}

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

.switch-grid label {
  min-height: 40px;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.switch-grid input,
.upload input {
  width: auto;
}

.nested-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--app-bg);
}

.nested-options label {
  min-height: 36px;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 13px;
}

.nested-options input {
  width: auto;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 23px;
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
  font-size: 11.5px;
  font-weight: 600;
}

.neutral { color: #5d6a7d; background: #eef2f7; }
.attention { color: var(--attention); background: var(--attention-bg); }
.success { color: var(--success); background: var(--success-bg); }
.danger { color: var(--danger); background: var(--danger-bg); }

.warning {
  margin-top: 12px;
  color: var(--attention);
  font-weight: 700;
}

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

.manual-contract-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.manual-contract-header strong,
.manual-contract-header span {
  display: block;
}

.manual-contract-header span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.manual-contract-grid {
  margin-top: 0;
}

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

.inline-status {
  margin: 10px 0 0;
  color: var(--text2);
  font-size: 12.5px;
  font-weight: 600;
}

.empty {
  margin: 0;
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.assistant-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  padding: 22px 28px 0;
}

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

.assistant-card {
  display: grid;
  gap: 8px;
  min-height: 150px;
  padding: 20px;
}

.assistant-card strong {
  font-size: 22px;
}

.assistant-card p,
.assistant-panel p,
.page-header p {
  margin: 0;
  color: var(--muted);
}

.assistant-label {
  color: var(--text2);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.assistant-panel {
  margin: 16px 28px;
  padding: 22px;
}

.assistant-panel h2 {
  margin: 0 0 8px;
}

.assistant-panel-head,
.assistant-issue,
.assistant-issue-meta,
.assistant-issue-actions {
  display: flex;
  align-items: center;
}

.assistant-panel-head,
.assistant-issue {
  justify-content: space-between;
  gap: 18px;
}

.assistant-panel-head .secondary-action,
.assistant-issue-actions .primary-action,
.assistant-issue-actions .secondary-action {
  margin-top: 0;
}

.assistant-issues {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.assistant-issue {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--app-bg);
}

.assistant-issue-main {
  min-width: 0;
}

.assistant-issue-meta,
.assistant-issue-actions {
  gap: 10px;
}

.assistant-issue h3 {
  margin: 9px 0 6px;
}

.assistant-issue p {
  margin: 0;
}

.assistant-issue-actions .secondary-action {
  text-decoration: none;
}

.assistant-attention {
  color: var(--attention);
  font-size: 12px;
  font-weight: 700;
}

.assistant-update-notes {
  margin: 14px 0 0;
  padding-left: 20px;
  color: var(--text2);
}

.assistant-update-notes:empty {
  display: none;
}

.facsimile-settings {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px 16px;
  align-items: center;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.facsimile-settings .facsimile-file,
.facsimile-settings .inline-status {
  grid-column: 1 / -1;
}

.facsimile-settings button {
  grid-column: 1 / -1;
  justify-self: start;
  margin-top: 0;
}

.assistant-panel button {
  margin-top: 18px;
}

.assistant-panel-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.collapse-toggle {
  width: 30px;
  height: 30px;
  min-width: 30px;
  padding: 0 !important;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  margin-top: 0 !important;
  display: grid;
  place-items: center;
}

.collapse-toggle::before {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid #77849a;
  border-bottom: 2px solid #77849a;
  transform: translateY(-2px) rotate(45deg);
  transition: transform .18s ease;
}

.collapse-toggle[aria-expanded="true"]::before {
  transform: translateY(2px) rotate(225deg);
}

.collapse-toggle:hover { background: #f3f6fa; }
[data-collapse-header] { cursor: pointer; user-select: none; }
[data-collapse-header] h2,
[data-collapse-header] p { pointer-events: none; }
.assistant-collapsible-body[hidden] { display: none !important; }

[data-collapsible-panel].is-collapsed {
  padding-bottom: 18px;
}

[data-collapsible-panel].is-collapsed .assistant-panel-head {
  margin-bottom: 0;
}

.field-with-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: stretch;
}

.field-with-action .secondary-action {
  margin: 0;
  white-space: nowrap;
}

.amo-deal-candidates {
  grid-column: 1 / -1;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fafc;
}

.amo-deal-candidates > p {
  margin: 0 0 10px;
}

.amo-deal-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 12px;
  margin: 8px 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  cursor: pointer;
}

.amo-deal-option:has(input:checked) {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

.amo-deal-option input { margin-top: 4px; }
.amo-deal-option strong { display: block; }
.amo-deal-option small { display: block; margin-top: 4px; color: var(--muted); }
.amo-setup-fields { display: grid; gap: 14px; }

.assistant-ok { color: var(--success); }
.assistant-warn { color: var(--attention); }
.assistant-error { color: var(--danger) !important; }

dialog {
  width: min(420px, calc(100% - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
}

dialog::backdrop {
  background: rgba(17, 24, 39, 0.42);
}

.modal-form {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.processing-dialog {
  width: min(440px, calc(100% - 32px));
}

.processing-content {
  padding: 28px;
}

.processing-state {
  display: grid;
  justify-items: center;
  gap: 14px;
  text-align: center;
}

.processing-state h2,
.processing-state p {
  margin: 0;
}

.processing-state p {
  color: var(--muted);
}

.processing-spinner {
  width: 42px;
  height: 42px;
  border: 4px solid #dbe4f0;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: processing-spin 0.8s linear infinite;
}

.processing-success {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #18a45b;
  color: #fff;
  font-size: 26px;
  font-weight: 700;
}

.processing-error {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #fff0f0;
  color: var(--danger);
  font-size: 26px;
  font-weight: 700;
}

.processing-download {
  min-width: 180px;
  text-align: center;
  text-decoration: none;
}

.processing-downloads {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.journal-dialog {
  width: min(900px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 0;
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
}

.journal-dialog::backdrop { background: rgba(15, 23, 42, .55); }

.journal-dialog-content { padding: 24px; }
.journal-dialog-content h2 { margin: 5px 0; }

.dialog-close {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: #f0f2f6;
  color: var(--text2);
  font-size: 23px;
}

.journal-table-wrap {
  max-height: 48vh;
  overflow: auto;
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.journal-preview-table { width: 100%; border-collapse: collapse; }

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

.journal-preview-table th {
  position: sticky;
  top: 0;
  background: #f7f8fb;
  color: var(--text2);
  font-size: 11px;
  text-transform: uppercase;
}

.journal-preview-table td:first-child { width: 74px; color: var(--primary); font-weight: 800; }
.journal-preview-table td:nth-child(2) { width: 250px; color: var(--text2); }

.journal-connection-notice {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 9px;
  background: var(--attention-bg);
  color: #92400e;
}

.journal-connection-notice.success { background: var(--success-bg); color: #166534; }

.journal-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.journal-status-card { border-left: 4px solid var(--primary); }

.journal-setup-steps {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.journal-setup-steps ol {
  margin: 0;
  padding-left: 22px;
  color: var(--text2);
  line-height: 1.65;
}

.journal-setup-steps label {
  display: grid;
  gap: 7px;
  color: var(--text2);
  font-weight: 600;
}

.journal-setup-steps input,
.journal-script-code {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
}

.journal-script-code {
  min-height: 180px;
  resize: vertical;
  font: 12px/1.45 Consolas, "Courier New", monospace;
  color: #24324a;
}

.journal-secret-field input { font-family: Consolas, "Courier New", monospace; }

@keyframes processing-spin {
  to { transform: rotate(360deg); }
}

menu {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 0;
  padding: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[hidden] { display: none !important; }

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

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

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

  .requests-table {
    min-width: 840px;
  }

  .requests-table-wrap {
    overflow-x: auto;
  }

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

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

  .sidebar {
    position: static;
    height: auto;
  }

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

  .profile {
    display: none;
  }

  .page-header {
    min-height: auto;
    flex-direction: column;
    align-items: stretch;
    padding: 18px;
  }

  .header-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .search input,
  .primary-action,
  .secondary-action,
  .danger-action {
    width: 100%;
  }

  .metrics,
  .toolbar,
  .requests-table-wrap,
  .details-panel,
  .form-panel {
    margin-left: 14px;
    margin-right: 14px;
    padding-left: 0;
    padding-right: 0;
  }

  .metrics {
    grid-template-columns: 1fr;
    padding-top: 16px;
  }

  .assistant-grid {
    grid-template-columns: 1fr;
    padding: 16px 14px 0;
  }

  .assistant-panel {
    margin: 14px;
  }

  .assistant-panel-head,
  .assistant-issue,
  .assistant-issue-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .metric-card,
  .details-panel,
  .form-panel {
    padding: 16px;
  }

  .form-grid,
  .switch-grid,
  .nested-options,
  .details-grid {
    grid-template-columns: 1fr;
  }

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

  .notice-line,
  .details-head,
  .subscription-addon,
  .payment-option-heading {
    flex-direction: column;
    align-items: flex-start;
  }
}
