:root {
  --tmm-font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --tmm-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --tmm-bg: var(--tmv2-surface, #ffffff);
  --tmm-text: var(--tmv2-text, #0f172a);
  --tmm-muted: var(--tmv2-muted, #64748b);
  --tmm-faint: #94a3b8;
  --tmm-line: var(--tmv2-line-2, #e7ebf1);
  --tmm-panel: var(--tmv2-surface-muted, #f8fafc);
  --tmm-shadow: 0 24px 64px rgba(15, 23, 42, .24), 0 4px 12px rgba(15, 23, 42, .08);
  --tmm-backdrop-bg: rgba(15, 23, 42, .46);
  --tmm-info: #0175e4;
  --tmm-danger: #ef4444;
  --tmm-success: #10b981;
  --tmm-warning: #f59e0b;
  --tmm-neutral: #64748b;
}

.tmm-backdrop,
.tmm-backdrop * {
  box-sizing: border-box;
}

.tmm-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--tm-z-modal, 1065);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  font-family: var(--tmm-font);
  background: transparent;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  overflow: auto;
  transition: opacity 240ms ease, background-color 240ms ease, backdrop-filter 240ms ease, visibility 0s linear 300ms;
}

.tmm-backdrop.is-rendered {
  visibility: visible;
}

.tmm-backdrop.is-open {
  background: var(--tmm-backdrop-bg);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 1;
  pointer-events: auto;
  transition-delay: 0s;
}

.tmm {
  --tmm-accent: var(--tmm-info);
  width: min(100%, 600px);
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  color: var(--tmm-text);
  background: var(--tmm-bg);
  border: 1px solid var(--tmm-line);
  border-radius: 16px;
  box-shadow: var(--tmm-shadow);
  opacity: 0;
  transform: translateY(10px) scale(.982);
  transition: transform 240ms cubic-bezier(.2, .8, .2, 1), opacity 220ms ease;
}

.tmm.sm { width: min(100%, 440px); }
.tmm.md { width: min(100%, 680px); }
.tmm.lg { width: min(100%, 920px); }
.tmm.xl { width: min(100%, 1080px); }

.tmm.info { --tmm-accent: var(--tmm-info); --tmm-accent-soft: rgba(1, 117, 228, .1); }
.tmm.danger { --tmm-accent: var(--tmm-danger); --tmm-accent-soft: rgba(239, 68, 68, .1); }
.tmm.success { --tmm-accent: var(--tmm-success); --tmm-accent-soft: rgba(16, 185, 129, .1); }
.tmm.warning { --tmm-accent: var(--tmm-warning); --tmm-accent-soft: rgba(245, 158, 11, .13); }
.tmm.neutral { --tmm-accent: var(--tmm-neutral); --tmm-accent-soft: rgba(100, 116, 139, .12); }

.tmm-backdrop.is-open .tmm {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.tmm.anim-slide {
  transform: translateY(22px);
}

.tmm.anim-fade {
  transform: none;
}

.tmm-backdrop.is-open .tmm.anim-slide,
.tmm-backdrop.is-open .tmm.anim-fade {
  transform: translateY(0);
}

.tmm-accentbar {
  height: 3px;
  flex: 0 0 auto;
  background: var(--tmm-accent);
}

.tmm-head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 18px 18px 15px 20px;
  border-bottom: 1px solid var(--tmm-line);
}

.tmm-ic {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  color: var(--tmm-accent);
  background: var(--tmm-accent-soft);
}

.tmm-ic svg,
.tmm-ic i[data-lucide],
.tmm-x svg,
.tmm-x i[data-lucide],
.tmm-sec-title svg,
.tmm-sec-title i[data-lucide] {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
}

.tmm-heading {
  min-width: 0;
  flex: 1 1 auto;
}

.tmm-title {
  margin: 0;
  color: var(--tmm-text);
  font-size: 16px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: 0;
}

.tmm-sub {
  margin: 4px 0 0;
  color: var(--tmm-faint);
  font-size: 12.5px;
  line-height: 1.35;
  font-weight: 500;
}

.tmm-x {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  color: #94a3b8;
  background: transparent;
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease;
}

.tmm-x:hover,
.tmm-x:focus-visible {
  color: var(--tmm-text);
  background: #f1f5f9;
  outline: none;
}

.tmm-body {
  padding: 6px 20px 18px;
  overflow: auto;
  min-height: 0;
}

.tmm--center .tmm-body {
  padding: 26px 24px 22px;
  text-align: center;
}

.tmm-sec {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--tmm-panel);
}

.tmm-sec:first-child {
  margin-top: 10px;
}

.tmm-sec-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  color: var(--tmm-text);
  font-size: 13px;
  line-height: 1.2;
  font-weight: 700;
}

.tmm-sec-title svg,
.tmm-sec-title i[data-lucide] {
  color: var(--tmm-accent);
}

.tmm-grid {
  display: grid;
  gap: 10px 16px;
}

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

.tmm-kv {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.tmm-k {
  color: var(--tmm-muted);
  font-size: 12.5px;
  line-height: 1.35;
  font-weight: 600;
}

.tmm-v {
  min-width: 0;
  color: var(--tmm-text);
  font-size: 13px;
  line-height: 1.35;
  font-weight: 700;
  text-align: right;
  overflow-wrap: anywhere;
}

.tmm-money {
  font-family: var(--tmm-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.tmm-v.is-pos { color: #059669; }
.tmm-v.is-neg { color: #e11d48; }
.tmm-v.is-info { color: var(--tmm-info); }

.tmm-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 20px;
  padding: 3px 9px;
  border-radius: 999px;
  color: #047857;
  background: #d1fae5;
  font-size: 11px;
  line-height: 1.2;
  font-weight: 800;
}

.tmm-chip.danger {
  color: #b91c1c;
  background: #fee2e2;
}

.tmm-callout {
  padding: 12px 14px;
  border-radius: 12px;
  color: #7f1d1d;
  background: #fef2f2;
  border: 1px solid #fecaca;
  font-size: 13px;
  line-height: 1.45;
  font-weight: 600;
}

.tmm-callout.danger {
  color: #7f1d1d;
  background: #fef2f2;
  border-color: #fecaca;
}

.tmm-form {
  display: grid;
  gap: 14px;
  padding-top: 8px;
}

.tmm-field {
  display: grid;
  gap: 7px;
  color: var(--tmm-muted);
  font-size: 12.5px;
  font-weight: 700;
}

.tmm-input {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid var(--tmm-line);
  border-radius: 10px;
  color: var(--tmm-text);
  background: var(--tmm-bg);
  font: 500 13px/1.35 var(--tmm-font);
  outline: none;
}

.tmm-input:focus {
  border-color: var(--tmm-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tmm-accent) 16%, transparent);
}

.tmm-foot {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--tmm-line);
  background: var(--tmm-bg);
}

.tmm-btn {
  min-height: 36px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font: 700 13px/1.2 var(--tmm-font);
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, background-color 140ms ease, border-color 140ms ease;
}

.tmm-btn:hover {
  transform: translateY(-1px);
}

.tmm-btn:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--tmm-accent) 22%, transparent);
  outline-offset: 2px;
}

.tmm-btn.primary,
.tmm-btn.success {
  color: #fff;
  background: var(--tmm-accent);
  box-shadow: 0 8px 18px color-mix(in srgb, var(--tmm-accent) 22%, transparent);
}

.tmm-btn.danger {
  color: #fff;
  background: var(--tmm-danger);
  box-shadow: 0 8px 18px rgba(239, 68, 68, .22);
}

.tmm-btn.ghost {
  color: var(--tmm-text);
  background: var(--tmm-bg);
  border-color: var(--tmm-line);
}

.tmm-btn.ghost:hover {
  background: #f8fafc;
}

.tmm-btn-block {
  width: 100%;
}

.tmm-center-text {
  margin: 0;
  color: var(--tmm-muted);
  font-size: 13px;
  line-height: 1.45;
}

html.dark-mode .tmm-backdrop,
body.dark-mode .tmm-backdrop {
  --tmm-bg: #0f172a;
  --tmm-text: #f8fafc;
  --tmm-muted: #cbd5e1;
  --tmm-faint: #94a3b8;
  --tmm-line: rgba(148, 163, 184, .22);
  --tmm-panel: rgba(15, 23, 42, .72);
  --tmm-shadow: 0 24px 64px rgba(0, 0, 0, .5), 0 4px 12px rgba(0, 0, 0, .28);
}

html.dark-mode .tmm-x:hover,
html.dark-mode .tmm-x:focus-visible,
body.dark-mode .tmm-x:hover,
body.dark-mode .tmm-x:focus-visible,
html.dark-mode .tmm-btn.ghost:hover,
body.dark-mode .tmm-btn.ghost:hover {
  background: rgba(148, 163, 184, .12);
}

html.dark-mode .tmm-input,
body.dark-mode .tmm-input {
  background: rgba(15, 23, 42, .72);
}

@media (max-width: 520px) {
  .tmm-backdrop {
    align-items: flex-end;
    justify-content: center;
    padding: 12px;
  }

  .tmm,
  .tmm.sm,
  .tmm.md,
  .tmm.lg,
  .tmm.xl {
    width: 100%;
    max-height: min(88vh, calc(100vh - 24px));
    border-radius: 16px 16px 12px 12px;
    transform: translateY(18px);
  }

  .tmm-head {
    min-height: 68px;
    padding: 16px 14px 13px 16px;
  }

  .tmm-body {
    padding: 6px 16px 16px;
  }

  .tmm-grid.two {
    grid-template-columns: 1fr;
  }

  .tmm-foot {
    padding: 12px 16px 16px;
    flex-wrap: wrap;
  }

  .tmm-foot .tmm-btn {
    flex: 1 1 128px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tmm-backdrop,
  .tmm {
    transition: none !important;
  }
}

@media print {
  .tmm-backdrop {
    display: none !important;
  }
}
