/* Companion Administration: Academic research aesthetic matching the customer portal, with a deep forest sidebar */

.admin-app {
  --green: #1a4f35;
  --green-dark: #123926;
  --green-deeper: #0c271a;
  --green-light: #ebf4e9;
  --green-subtle: #f4f8f2;
  --green-border: #d4e3d1;
  --green-border-strong: #cadcc6;
  --green-text-accent: #245e3d;
  --ink: #162f22;
  --ink-secondary: #3b5446;
  --muted: #5e796c;
  --line: #d8e5d6;
  --line-light: #e8f0e6;
  --paper: #f8faf6;
  --surface: #ffffff;
  --danger: #b34535;
  --danger-hover: #9c2e20;
  --danger-bg: #fdf5f4;
  --danger-border: #ead1ca;
  --warning-bg: #fcf8ed;
  --warning-border: #ebdcb9;
  --warning-text: #876d3b;

  min-height: 100vh;
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 92% 8%, #e8f2e4 0%, transparent 45%),
    radial-gradient(circle at 8% 92%, #ebf4e7 0%, transparent 40%),
    linear-gradient(180deg, #f9fbf8 0%, #f4f7f2 100%);
  background-attachment: fixed;
  background-repeat: no-repeat;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, Tahoma, sans-serif;
  line-height: 1.6;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

.admin-app h1,
.admin-app h2,
.admin-app h3,
.admin-app button,
.admin-app a,
.admin-app input,
.admin-app select,
.admin-app textarea {
  font-family: inherit;
}

.admin-app .layout {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

/* Sidebar: Dignified Deep Forest Academic Tone */
.admin-app aside {
  position: sticky;
  top: 0;
  height: 100vh;
  background: linear-gradient(175deg, #123926 0%, #0c271a 100%);
  padding: 30px 18px 24px;
  gap: 8px;
  border-right: 1px solid #1a4f35;
  overflow-y: auto;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.admin-app .companion-brand {
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
}

.admin-app .companion-brand-symbol {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  border: 1px solid rgba(182, 217, 180, 0.25);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: #c5e5c3;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.1);
}

.admin-app .companion-brand-symbol svg {
  width: 24px;
  height: 24px;
}

.admin-app .companion-brand .brand {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 2.2px;
  color: #ffffff;
}

.admin-app .companion-brand .subtitle {
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 1.6px;
  color: #a4cca1;
  text-transform: uppercase;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.admin-app aside button[data-screen] {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  border: 1px solid transparent;
  padding: 10px 14px;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 500;
  color: #bed5c5;
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all 160ms ease;
  text-align: left;
}

.admin-app .nav-glyph {
  display: grid;
  place-items: center;
  width: 20px;
  color: #8bb69c;
  flex-shrink: 0;
}

.admin-app aside button[data-screen]:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.admin-app aside button[data-screen].active {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  box-shadow: inset 3px 0 #7da672;
  font-weight: 600;
}

.admin-app aside button[data-screen].active .nav-glyph {
  color: #c5e5c3;
}

.admin-app .aside-note {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 14px 14px;
  margin-top: auto;
}

.admin-app .side-foot-label {
  display: block;
  font-size: 8px;
  letter-spacing: 1.6px;
  font-weight: 700;
  color: #a4cca1;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.admin-app .aside-note p {
  font-size: 10.5px;
  line-height: 1.7;
  margin: 0;
  color: #9cbca7;
}

.admin-app .aside-note small {
  display: block;
  margin-top: 10px;
  font-size: 8px;
  color: #7a9e86;
  letter-spacing: 0.5px;
}

/* Main Area & Sticky Topbar */
.admin-app .main {
  padding: 0 36px 48px;
  max-width: 1340px;
  min-width: 0;
  width: 100%;
  margin: 0 auto;
}

.admin-app .topbar {
  height: 70px;
  position: sticky;
  top: 0;
  z-index: 5;
  margin-bottom: 30px;
  background: rgba(248, 250, 246, 0.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 12.5px;
  color: var(--muted);
  margin-inline: -36px;
  padding-inline: 36px;
}

.admin-app .topbar > span {
  font-weight: 500;
  color: var(--muted);
}

.admin-app .session-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-app .session-actions .app-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  min-height: 36px;
  padding: 0 14px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--green-border-strong);
  background: var(--green-light);
  border-radius: 20px;
  color: #215437;
  box-shadow: 0 1px 3px rgba(18, 48, 32, 0.03);
}

.admin-app .status-dot {
  width: 6px;
  height: 6px;
  flex: 0 0 6px;
  border-radius: 50%;
  background: #25814a;
  box-shadow: 0 0 0 2px rgba(37, 129, 74, 0.16);
}

.admin-app .session-actions .logout-button {
  height: 36px;
  min-height: 36px;
  padding: 0 16px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid #cadcc6;
  background: #ffffff;
  color: #1c5235;
  cursor: pointer;
  transition: all 160ms ease;
  box-shadow: 0 1px 3px rgba(18, 48, 32, 0.03);
}

.admin-app .session-actions .logout-button:hover:not(:disabled) {
  background: #eff6ec;
  border-color: #9cb895;
  color: #133f28;
}

/* Heading & Eyebrow */
.admin-app .heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 24px;
  border-bottom: 1px solid #dfe8df;
  margin-bottom: 26px;
}

.admin-app .heading .eyebrow {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--green-text-accent);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.admin-app .heading h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.6px;
  margin: 0;
  color: #163825;
  line-height: 1.25;
}

.admin-app .heading p {
  font-size: 13.5px;
  color: #557262;
  line-height: 1.6;
  margin: 6px 0 0;
}

/* Buttons */
.admin-app button,
.admin-app a {
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.admin-app button:not(.primary):not(.danger):not(.logout-button):not([data-screen]):not(.tab):not([data-project-group]):not(.buyer-permission-switch):not(.sepay-key-toggle):not(.sepay-delete-transaction) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid #cadcc6;
  background: #ffffff;
  color: #1c5235;
  min-height: 38px;
  box-shadow: 0 1px 3px rgba(18, 48, 32, 0.03);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.admin-app button:not(.primary):not(.danger):not(.logout-button):not([data-screen]):not(.tab):not([data-project-group]):not(.buyer-permission-switch):not(.sepay-key-toggle):not(.sepay-delete-transaction):hover:not(:disabled) {
  background: #eff6ec;
  border-color: #9cb895;
  color: #133f28;
  box-shadow: 0 2px 7px rgba(18, 48, 32, 0.08);
}

.admin-app button.primary,
.admin-app .primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #194e33 !important;
  border: 1px solid #133f29 !important;
  color: #ffffff !important;
  box-shadow: 0 2px 6px rgba(18, 48, 32, 0.16) !important;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 9px 18px;
  min-height: 38px;
  cursor: pointer;
}

.admin-app button.primary:hover:not(:disabled),
.admin-app .primary:hover:not(:disabled) {
  background: #14402a !important;
  border-color: #0e2d1d !important;
  box-shadow: 0 4px 12px rgba(18, 48, 32, 0.22) !important;
  transform: translateY(-1px);
  color: #ffffff !important;
}

.admin-app button.primary:active:not(:disabled),
.admin-app .primary:active:not(:disabled) {
  background: #103422 !important;
  transform: translateY(0);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2) !important;
}

.admin-app button.danger,
.admin-app .danger,
.admin-app .key-delete,
.admin-app .sepay-delete-transaction {
  background: #ffffff;
  color: var(--danger);
  border: 1px solid var(--danger-border);
  font-weight: 600;
}

.admin-app button.danger:hover:not(:disabled),
.admin-app .danger:hover:not(:disabled),
.admin-app .key-delete:hover:not(:disabled),
.admin-app .sepay-delete-transaction:hover {
  background: var(--danger-bg);
  border-color: #d98b8b;
  color: var(--danger-hover);
  box-shadow: 0 2px 6px rgba(179, 69, 53, 0.08);
}

/* Cards & Settings Containers */
.admin-app .card {
  background: #ffffff;
  border: 1px solid #dbe6da;
  border-radius: 14px;
  padding: 28px 30px;
  margin-bottom: 22px;
  box-shadow: 0 2px 8px rgba(18, 48, 32, 0.03), 0 8px 24px rgba(18, 48, 32, 0.02);
}

.admin-app .card h2 {
  font-size: 19px;
  font-weight: 700;
  color: #163825;
  letter-spacing: -0.4px;
  margin: 0 0 16px;
}

.admin-app .card h3 {
  font-size: 16.5px;
  font-weight: 700;
  color: #163825;
  letter-spacing: -0.3px;
  margin: 0 0 16px;
}

.admin-app .card form > h3:first-child {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-app .card form > h3:first-child::before {
  content: '';
  width: 4px;
  height: 18px;
  border-radius: 2px;
  background: #1a4f35;
  flex-shrink: 0;
}

/* Rows in Repository & Shares */
.admin-app .rows .row {
  display: flex;
  align-items: center;
  padding: 18px 0;
  border-top: 1px solid #ebf2e8;
  gap: 16px;
  transition: all 160ms ease;
}

.admin-app .rows .row:first-child {
  border-top: 0;
  padding-top: 4px;
}

.admin-app .rows .row:last-child {
  padding-bottom: 4px;
}

.admin-app .row h3 {
  font-size: 15px;
  font-weight: 600;
  color: #163825;
  letter-spacing: -0.2px;
  margin: 0 0 4px;
  overflow-wrap: anywhere;
}

.admin-app .row small {
  font-size: 12px;
  line-height: 1.5;
  color: #5e796c;
  font-variant-numeric: tabular-nums;
  display: block;
}

.admin-app .file-type {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  width: 46px;
  height: 50px;
  padding: 0;
  background: #eef6ec;
  border: 1px solid #d6e5d3;
  border-radius: 10px;
  color: #235838;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.admin-app .row .actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-app .row .actions button {
  padding: 7px 13px;
  min-height: 36px;
  font-size: 12px;
}

.admin-app .link {
  color: #1a4f35;
  font-size: 12.5px;
  font-weight: 600;
  margin: 4px 0 8px;
  text-decoration: none;
  display: block;
  overflow-wrap: anywhere;
}

.admin-app .link:hover {
  text-decoration: underline;
  color: #123926;
}

/* Tabs & Workspace Groups */
.admin-app .tabs,
.admin-app .workspace-groups {
  display: inline-flex;
  align-items: center;
  background: #eaf1e8;
  border: 1px solid #d5e3d2;
  border-radius: 10px;
  padding: 4px;
  gap: 4px;
  width: fit-content;
  max-width: 100%;
  margin: 20px 0 24px;
}

.admin-app .tabs button,
.admin-app .workspace-groups button {
  border: 1px solid transparent;
  background: transparent;
  padding: 8px 16px;
  font-size: 12.5px;
  font-weight: 600;
  color: #4f6d5c;
  border-radius: 7px;
  min-height: 36px;
  cursor: pointer;
  transition: all 160ms ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.admin-app .tabs button:hover:not(.active),
.admin-app .workspace-groups button:hover:not(.active) {
  background: rgba(255, 255, 255, 0.45);
  color: #245838;
}

.admin-app .tabs button.active,
.admin-app .workspace-groups button.active {
  background: #ffffff;
  border-color: #cadcc6;
  color: #163825;
  box-shadow: 0 2px 5px rgba(18, 48, 32, 0.05);
}

.admin-app .workspace-groups small {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid #d0e2cc;
  background: #eef6ec;
  color: #235b3a;
  font-variant-numeric: tabular-nums;
  margin: 0;
}

.admin-app .workspace-groups button.active small {
  background: #ebf4e9;
  border-color: #9cb895;
  color: #14402a;
}

/* Form Controls */
.admin-app label {
  font-size: 12px;
  font-weight: 600;
  color: #3b5446;
  margin: 18px 0 8px;
  display: block;
  letter-spacing: 0.2px;
}

.admin-app input:not([type="checkbox"]):not([type="radio"]),
.admin-app select,
.admin-app textarea {
  font-size: 13px;
  padding: 10px 14px;
  border: 1px solid #cad7c7;
  border-radius: 8px;
  background: #f9fbf8;
  color: var(--ink);
  min-height: 40px;
  box-sizing: border-box;
  min-width: 0;
  transition: all 160ms ease;
}

.admin-app input[readonly] {
  background: #f1f6f0;
  border-color: #d6e2d4;
  color: #3b5446;
}

.admin-app input:hover:not(:disabled):not([readonly]),
.admin-app select:hover:not(:disabled),
.admin-app textarea:hover:not(:disabled) {
  border-color: #9cb895;
}

.admin-app input:focus-visible,
.admin-app select:focus-visible,
.admin-app textarea:focus-visible {
  outline: 0;
  border-color: #25814a;
  box-shadow: 0 0 0 3px rgba(37, 129, 74, 0.16);
  background: #ffffff;
}

.admin-app input[type=checkbox] {
  accent-color: #1a4f35;
}

.admin-app small {
  font-size: 11px;
  line-height: 1.65;
  color: #5e796c;
}

.admin-app p {
  font-size: 13px;
  color: #557262;
  line-height: 1.65;
}

/* Notices & Alerts */
.admin-app .notice {
  background: #eef6ec;
  border: 1px solid #cfe2cd;
  color: #265939;
  border-radius: 9px;
  padding: 13px 18px;
  font-size: 12.5px;
  line-height: 1.65;
}

.admin-app .notice.warning {
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  color: var(--warning-text);
}

.admin-app .sepay-toggle-status {
  background: #eef6ec;
  border: 1px solid #cfe2cd;
  color: #265939;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 12.5px;
}

.admin-app .empty {
  border: 1px dashed #d6e2d3;
  background: #fafcf8;
  color: #5e796c;
  border-radius: 12px;
  padding: 36px 24px;
  font-size: 13px;
  line-height: 1.7;
  text-align: center;
}

/* Login Card: Dignified academic aesthetic */
.admin-app .login {
  margin: 8vh auto 40px;
  padding: 40px 36px;
  max-width: 520px;
  background: #ffffff;
  border: 1px solid #dbe6da;
  border-radius: 16px;
  box-shadow: 0 12px 36px rgba(18, 48, 32, 0.07), 0 2px 8px rgba(18, 48, 32, 0.03);
  text-align: center;
}

.admin-app .login-symbol {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  background: #eef6ec;
  border: 1px solid #d6e5d3;
  border-radius: 14px;
  color: #1a4f35;
  margin: 0 auto 20px;
  box-shadow: 0 2px 6px rgba(18, 48, 32, 0.04);
}

.admin-app .login-symbol svg {
  width: 24px;
  height: 24px;
  stroke: #1a4f35;
}

.admin-app .login .eyebrow {
  font-size: 10px;
  letter-spacing: 2px;
  font-weight: 700;
  color: #245e3d;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.admin-app .login h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: #163825;
  margin: 0 0 10px;
  line-height: 1.3;
}

.admin-app .login p {
  font-size: 13.5px;
  color: #557262;
  line-height: 1.6;
  margin: 0 0 24px;
}

.admin-app .login label {
  text-align: left;
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #3b5446;
  margin-bottom: 8px;
}

.admin-app .login input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13.5px;
  padding: 12px 14px;
  border: 1px solid #cad7c7;
  border-radius: 8px;
  background: #f9fbf8;
  color: #162f22;
  text-align: center;
  letter-spacing: 0.5px;
}

.admin-app .login input:focus-visible {
  border-color: #25814a;
  box-shadow: 0 0 0 3px rgba(37, 129, 74, 0.16);
  background: #ffffff;
}

.admin-app .login .form-error {
  margin: 12px 0 0;
  color: #b34535;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.5;
}

.admin-app .login .primary {
  width: 100%;
  margin-top: 22px;
  min-height: 42px;
  font-size: 13px;
}

.admin-app .storage-directory {
  display: block;
  overflow-wrap: anywhere;
  font-weight: 600;
  color: #235838;
  margin: 8px 0;
}

.admin-app .sepay-profile-toolbar {
  display: flex;
  align-items: stretch;
  gap: 12px;
  margin: 18px 0;
}
.admin-app .sepay-profile-toolbar select {
  flex: 1;
  min-width: 0;
  margin: 0;
}
.admin-app .sepay-profile-toolbar button {
  flex-shrink: 0;
  white-space: nowrap;
}

/* Toast Notification */
.admin-app #toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: 420px;
  background: #143826;
  color: #f4fbf1;
  border: 1px solid #285b3f;
  border-radius: 10px;
  padding: 14px 22px;
  box-shadow: 0 10px 30px rgba(16, 44, 28, 0.25);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
  display: none;
  z-index: 99999;
}

/* Eye visibility toggle for secrets */
.sepay-key-field {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}
.sepay-key-field input {
  padding-right: 50px;
  margin: 0;
  width: 100%;
}
.sepay-key-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #5e796c;
  cursor: pointer;
  transition: all 160ms ease;
}
.sepay-key-toggle:hover {
  background: #eef6ec;
  color: #1a4f35;
}
.sepay-key-toggle:focus-visible {
  outline: 2px solid #25814a;
  outline-offset: 2px;
}
.sepay-eye-slash[hidden] {
  display: none;
}

/* Numeric inputs typed manually */
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input:disabled,
select:disabled {
  background: #edf0ed !important;
  color: #94a098 !important;
  opacity: 0.65;
  cursor: not-allowed;
  box-shadow: none !important;
}

/* Shared Payment History Card Layout */
#sepayHistory .sepay-history-heading {
  margin: 28px 0 16px;
  font-size: 16px;
  font-weight: 700;
  color: #163825;
}
#sepayHistory .row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 34px;
  align-items: center;
  gap: 18px;
  min-height: 86px;
  padding: 18px 22px;
  margin: 12px 0 0;
  border: 1px solid #dbe6da;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(18, 48, 32, 0.02);
}
#sepayHistory .detail {
  min-width: 0;
}
#sepayHistory .detail strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.5;
  color: #163825;
  overflow-wrap: anywhere;
}
#sepayHistory .detail small {
  display: block;
  margin-top: 6px;
  font-size: 11.5px;
  line-height: 1.6;
  color: #5e796c;
}
#sepayHistory .row > span {
  font-size: 15px;
  font-weight: 700;
  color: #145231;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.heading-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

/* Payment History Dialog & Summary */
#paymentHistoryDialog {
  max-width: 95vw;
  width: 1000px;
  max-height: 90vh;
  overflow: auto;
  border: 1px solid #d4e2d8;
  border-radius: 16px;
  padding: 0;
  color: #162f22;
  background: #ffffff;
}
#paymentHistoryDialog::backdrop {
  background: rgba(14, 41, 27, 0.45);
  backdrop-filter: blur(4px);
}
.payment-history-dialog {
  padding: 28px 30px;
}
.payment-history-dialog > h2 {
  margin: 0 0 22px;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: #163825;
}
.payment-history-summary {
  display: grid;
  grid-template-columns: 1fr 1fr 1.5fr;
  gap: 14px;
  margin-bottom: 22px;
}
.payment-history-summary > div {
  border: 1px solid #dbe6da;
  background: #fafcf8;
  border-radius: 12px;
  padding: 16px 20px;
  box-shadow: 0 1px 3px rgba(18, 48, 32, 0.02);
}
.payment-history-summary small {
  display: block;
  color: #5e796c;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.payment-history-summary strong {
  font-size: 22px;
  font-weight: 700;
  color: #145231;
  font-variant-numeric: tabular-nums;
}
.payment-history-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.payment-history-toolbar input {
  min-width: 0;
  flex: 1;
  margin: 0;
}
.payment-history-toolbar button {
  flex: none;
  margin: 0;
  white-space: nowrap;
}
.payment-history-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 36px;
  align-items: center;
  gap: 18px;
  padding: 18px 22px;
  border: 1px solid #dbe6da;
  border-radius: 12px;
  background: #ffffff;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(18, 48, 32, 0.02);
}
.payment-history-detail {
  min-width: 0;
}
.payment-history-detail > strong,
.payment-history-detail > span,
.payment-history-detail > small {
  display: block;
  overflow-wrap: anywhere;
}
.payment-history-detail > strong {
  font-size: 14.5px;
  font-weight: 600;
  color: #163825;
  margin-bottom: 5px;
}
.payment-history-detail > span {
  margin-top: 4px;
}
.payment-history-detail > small {
  font-size: 11.5px;
  line-height: 1.6;
  color: #5e796c;
}
.payment-history-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  font-size: 11px;
  font-weight: 600;
  border-radius: 8px;
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  color: var(--warning-text);
  padding: 3px 8px;
}
.payment-history-badge.confirmed {
  background: #eef6ec;
  border-color: #cfe2cd;
  color: #175a34;
}
.payment-history-amount {
  white-space: nowrap;
  font-size: 16px;
  font-weight: 700;
  color: #145231;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.payment-history-delete {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  min-height: 36px;
  width: 36px;
  height: 36px;
  padding: 0 !important;
  color: var(--danger) !important;
  border: 1px solid var(--danger-border) !important;
  border-radius: 8px !important;
  background: #ffffff !important;
  cursor: pointer;
  transition: all 160ms ease;
}
.payment-history-delete:hover {
  background: var(--danger-bg) !important;
  border-color: #d98b8b !important;
  color: var(--danger-hover) !important;
}
.payment-history-pages {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  color: #5e796c;
  font-size: 12.5px;
}
.payment-history-pages button {
  flex: none;
}
.payment-history-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 24px;
}

@media (max-width: 650px) {
  .payment-history-summary {
    grid-template-columns: 1fr 1fr;
  }
  .payment-history-summary > div:last-child {
    grid-column: 1 / -1;
  }
  .payment-history-toolbar {
    flex-wrap: wrap;
  }
  .payment-history-toolbar input {
    flex-basis: 100%;
  }
  .payment-history-row {
    grid-template-columns: minmax(0, 1fr) 36px;
    gap: 12px;
    padding: 16px;
  }
  .payment-history-detail {
    grid-column: 1;
  }
  .payment-history-amount {
    grid-column: 1;
    grid-row: 2;
  }
  .payment-history-delete {
    grid-column: 2;
    grid-row: 1 / 3;
    align-self: center;
  }
  .payment-history-dialog {
    padding: 20px 16px;
  }
}

/* Market Buyers Dialog & Actions */
#marketBuyersDialog {
  max-width: 94vw;
  width: 750px;
  max-height: 85vh;
  overflow: auto;
  border: 1px solid #d4e2d8;
  border-radius: 16px;
  color: var(--ink);
  background: #ffffff;
}
#marketBuyersDialog::backdrop {
  background: rgba(14, 41, 27, 0.45);
  backdrop-filter: blur(4px);
}
.market-dialog-body {
  padding: 26px 28px;
}
.market-dialog-body > h2 {
  margin: 0 0 16px;
  font-size: 20px;
  font-weight: 700;
  color: #163825;
}
.market-dialog-body p {
  color: #557262;
  font-size: 13px;
  line-height: 1.65;
  margin: 0 0 16px;
}
.market-buyer {
  display: flex;
  align-items: center;
  gap: 16px;
  background: #ffffff;
  border: 1px solid #dbe6da;
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 10px;
}
.market-buyer .detail {
  min-width: 0;
  flex: 1;
}
.market-buyer strong {
  font-size: 14px;
  font-weight: 600;
  color: #163825;
  overflow-wrap: anywhere;
  display: block;
}
.market-buyer small {
  display: block;
  margin-top: 4px;
  font-size: 11.5px;
  color: #5e796c;
}
.market-buyer-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.market-buyer-actions [data-delete-buyer] {
  color: var(--danger);
  border-color: var(--danger-border);
}

@media (max-width: 600px) {
  .market-buyer {
    flex-wrap: wrap;
  }
  .market-buyer-actions {
    width: 100%;
  }
  .market-buyer-actions button {
    flex: 1;
  }
}

/* Buyer Permissions Switch */
.buyer-permission-row {
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 0;
  border-bottom: 1px solid #ebf2e8;
}
.buyer-permission-row span {
  min-width: 0;
}
.buyer-permission-row strong {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: #163825;
}
.buyer-permission-row small {
  display: block;
  margin-top: 5px;
  line-height: 1.6;
  color: #5e796c;
  font-size: 11.5px;
}
.buyer-permission-row .buyer-permission-switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: 0 0 44px;
  width: 44px;
  height: 25px;
  min-height: 25px;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 20px;
  background: #d4e0d2;
  cursor: pointer;
  transition: background-color 160ms ease;
}
.buyer-permission-switch::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(18, 48, 32, 0.2);
  transition: transform 160ms ease;
}
.buyer-permission-row .buyer-permission-switch:checked {
  background: #1a4f35;
}
.buyer-permission-switch:checked::before {
  transform: translateX(19px);
}
.buyer-permission-row .buyer-permission-switch:focus-visible {
  outline: 2px solid #25814a;
  outline-offset: 3px;
}
#buyerPermissionsForm p {
  margin: 0 0 14px;
  line-height: 1.65;
  color: #557262;
  font-size: 13px;
}
.buyer-permission-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* Responsive Rules */
@media (max-width: 1100px) {
  .admin-app .layout {
    grid-template-columns: 220px minmax(0, 1fr);
  }
  .admin-app .main {
    padding: 0 28px 40px;
  }
  .admin-app aside {
    padding: 26px 14px;
  }
  .admin-app .heading h1 {
    font-size: 25px;
  }
  .admin-app .row .actions {
    gap: 6px;
  }
}

@media (max-width: 850px) {
  .admin-app .layout {
    grid-template-columns: 1fr;
  }
  .admin-app aside {
    position: relative;
    height: auto;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 16px 18px;
    gap: 8px;
    overflow: visible;
  }
  .admin-app .companion-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 0 0 8px;
    padding-bottom: 12px;
    width: 100%;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }
  .admin-app .companion-brand-symbol {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    margin: 0;
  }
  .admin-app .companion-brand-symbol svg {
    width: 18px;
    height: 18px;
  }
  .admin-app .companion-brand .brand {
    font-size: 15px;
    margin: 0;
  }
  .admin-app .companion-brand .subtitle {
    display: none;
  }
  .admin-app aside button[data-screen] {
    flex: 1 1 auto;
    justify-content: center;
    font-size: 11.5px;
    padding: 8px 12px;
    min-height: 38px;
    width: auto;
  }
  .admin-app .nav-glyph {
    width: 16px;
  }
  .admin-app .nav-glyph svg {
    width: 16px;
  }
  .admin-app .aside-note {
    display: none;
  }
  .admin-app .main {
    padding: 0 22px 36px;
  }
  .admin-app .topbar {
    height: auto;
    min-height: 64px;
    padding: 12px 0;
    margin-inline: -22px;
    padding-inline: 22px;
    position: relative;
    margin-bottom: 24px;
  }
  .admin-app .card {
    padding: 22px;
  }
  .admin-app .heading h1 {
    font-size: 24px;
  }
  .admin-app .split {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 550px) {
  .admin-app aside {
    padding: 12px 10px;
  }
  .admin-app aside button[data-screen] {
    flex: 1 1 44%;
    font-size: 11px;
    gap: 6px;
    padding: 8px;
  }
  .admin-app .main {
    padding: 0 16px 30px;
  }
  .admin-app .topbar {
    margin-inline: -16px;
    padding-inline: 16px;
  }
  .admin-app .heading {
    flex-wrap: wrap;
    gap: 16px;
  }
  .admin-app .heading p {
    font-size: 12px;
  }
  .admin-app .heading h1 {
    font-size: 23px;
  }
  .admin-app .card {
    padding: 20px 16px;
  }
  .admin-app .rows .row {
    gap: 12px;
  }
  .admin-app .row .actions {
    width: 100%;
    padding-left: 58px;
  }
  .admin-app .row .actions button {
    flex: 1;
  }
  .admin-app .session-actions .app-status,
  .admin-app .session-actions .logout-button {
    height: 32px;
    min-height: 32px;
    font-size: 10px;
    padding: 0 10px;
  }
  .admin-app .topbar > span {
    font-size: 11px;
  }
  .admin-app .tabs,
  .admin-app .workspace-groups {
    width: 100%;
  }
  .admin-app .tabs button,
  .admin-app .workspace-groups button {
    flex: 1;
    padding: 8px 10px;
    font-size: 11px;
    justify-content: center;
  }
  .admin-app .file-type {
    min-width: 42px;
    width: 42px;
  }
  .admin-app .login {
    margin: 6vh 14px;
    padding: 28px 20px;
  }
  .admin-app .login h1 {
    font-size: 23px;
  }
}

/* Motion Preferences */
@media (prefers-reduced-motion: reduce) {
  .admin-app *,
  .admin-app *::before,
  .admin-app *::after {
    transition: none !important;
    animation: none !important;
  }
}

/* Uploads use the existing document header/list without taking extra space. */
[data-file-drop]{transition:background-color .18s,box-shadow .18s;border-radius:14px}
[data-file-drop].file-drop-active{background-color:#eaf5ee;box-shadow:inset 0 0 0 2px #5caa80}

.login-delete{display:inline-flex;align-items:center;justify-content:center;flex:0 0 42px;width:42px;height:42px;min-width:42px;padding:0;border:1px solid #f0c9c5;border-radius:10px;background:#fff;color:#d34b43;font-size:18px;line-height:1}
.login-delete:hover{background:#fff3f1;border-color:#df9d96;color:#bb332d}

/* Match the shared button feedback while keeping a compact delete control. */
body:not(.viewer) .btn.login-delete,
.admin-app button.login-delete{background:#fff;border-color:#f0c9c5;color:#c44d43;transition:background-color 160ms ease,border-color 160ms ease,color 160ms ease,box-shadow 160ms ease}
body:not(.viewer) .btn.login-delete:hover:not(:disabled),
.admin-app button.login-delete:hover:not(:disabled){background:#fce3df !important;border-color:#dc9b93 !important;color:#ad332b !important;box-shadow:0 2px 7px rgba(173,51,43,.12)}
body:not(.viewer) .btn.login-delete:focus-visible,
.admin-app button.login-delete:focus-visible{outline:2px solid #dc9b93;outline-offset:3px}
body:not(.viewer) .btn.login-delete:active:not(:disabled),
.admin-app button.login-delete:active:not(:disabled){background:#f7d3cd !important;box-shadow:inset 0 1px 3px rgba(173,51,43,.15)}
@media(prefers-reduced-motion:reduce){body:not(.viewer) .btn.login-delete,.admin-app button.login-delete{transition:none}}

/* Buyer actions must override the general button palette on hover. */
.market-buyer-actions button{transition:background-color 160ms ease,border-color 160ms ease,color 160ms ease,box-shadow 160ms ease}
.market-buyer-actions button[data-delete-buyer]:hover:not(:disabled){background:#fce3df !important;border-color:#dc9b93 !important;color:#ad332b !important;box-shadow:0 2px 7px rgba(173,51,43,.12)}
.market-buyer-actions button[data-buyer-access][data-enable="true"]:hover:not(:disabled){background:#e5f1e7 !important;border-color:#94b69d !important;color:#245c3a !important;box-shadow:0 2px 7px rgba(36,92,58,.1)}
.market-buyer-actions button[data-buyer-access]:focus-visible,
.market-buyer-actions button[data-delete-buyer]:focus-visible{outline:2px solid #a8bda9;outline-offset:3px}
@media(prefers-reduced-motion:reduce){.market-buyer-actions button{transition:none}}


.manual-buyer-form{margin-bottom:24px;padding:18px;border:1px solid #dbe6da;border-radius:12px;background:#f6faf6}
.manual-buyer-form label{display:block;margin:0 0 10px;font-weight:600;color:#24543c}
.manual-buyer-fields{display:flex;gap:10px;align-items:center}
.manual-buyer-fields input{flex:1;min-width:0;margin:0}
.manual-buyer-fields button{flex-shrink:0}
.manual-buyer-form small{line-height:1.6;margin-top:8px}
.market-buyer-actions button[data-buyer-access]:hover:not(:disabled){background:#e5f1e7 !important;border-color:#94b69d !important;color:#245c3a !important;box-shadow:0 2px 7px rgba(36,92,58,.1)}
@media(max-width:560px){.manual-buyer-fields{flex-direction:column;align-items:stretch}.manual-buyer-fields input{width:100%}}
