:root {
  color-scheme: light;
  --ink: #16363b;
  --ink-soft: #5d7376;
  --brand: #174c53;
  --brand-dark: #10383d;
  --gold: #c69d55;
  --paper: #fffefb;
  --canvas: #f2f5f3;
  --line: #dce4e1;
  --success: #2d7250;
  --warning: #a66c18;
  --danger: #a43b3b;
  --info: #2f6382;
  --shadow: 0 16px 44px rgba(21, 56, 61, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); line-height: 1.5; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button:disabled { opacity: .65; cursor: wait; }

.app-header { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; min-height: 72px; padding: 10px clamp(18px, 4vw, 56px); background: rgba(255, 254, 251, .96); border-bottom: 1px solid var(--line); backdrop-filter: blur(14px); }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand span:last-child { display: grid; }
.brand strong { font-size: 15px; }
.brand small { color: var(--ink-soft); font-size: 12px; }
.brand-mark { display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; color: white; background: linear-gradient(145deg, var(--brand), var(--brand-dark)); font-weight: 800; letter-spacing: .03em; box-shadow: 0 8px 20px rgba(23, 76, 83, .2); }
.header-user { display: flex; align-items: center; gap: 14px; color: var(--ink-soft); }
.header-user form { margin: 0; }
.app-main { width: min(1540px, calc(100% - 36px)); margin: 0 auto; padding: 34px 0 80px; }

.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.page-heading h1 { margin: 2px 0 0; font-size: clamp(28px, 4vw, 46px); line-height: 1.08; letter-spacing: -.035em; }
.eyebrow { margin: 0 0 4px; color: #887044; font-size: 11px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.muted { color: var(--ink-soft); }
.metric { min-width: 128px; padding: 14px 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--paper); text-align: right; box-shadow: var(--shadow); }
.metric strong { display: block; font-size: 24px; }
.metric span { color: var(--ink-soft); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }

.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); padding: clamp(18px, 2.4vw, 30px); }
.filter-bar { display: grid; grid-template-columns: minmax(260px, 1fr) 180px 150px auto auto; align-items: end; gap: 12px; margin-bottom: 18px; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255, 254, 251, .74); }
label { display: grid; gap: 7px; color: var(--ink-soft); font-size: 12px; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid #cbd7d3; border-radius: 10px; background: white; color: var(--ink); padding: 10px 12px; outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(23, 76, 83, .11); }
input[readonly], textarea[readonly] { background: #f4f6f5; color: #5d6f72; }
textarea { resize: vertical; min-height: 100px; }

.button { display: inline-flex; min-height: 41px; align-items: center; justify-content: center; gap: 8px; border: 1px solid #bdcbc7; border-radius: 10px; background: white; color: var(--ink); padding: 9px 15px; font-weight: 750; text-decoration: none; cursor: pointer; }
.button:hover { border-color: var(--brand); }
.button-primary, .button-start { border-color: var(--brand); background: var(--brand); color: white; }
.button-start { background: linear-gradient(135deg, #1f6b59, #174c53); }
.button-danger { border-color: #d8aaaa; color: var(--danger); background: #fff7f7; }
.button-retry { width: 100%; background: #f4f8f7; }
.button-guide { width: 100%; border-color: #d5bf8c; background: #fff8e7; color: #6d5525; }
.button-ghost { background: transparent; }
.button-small { min-height: 34px; padding: 6px 11px; font-size: 12px; }

.table-panel { padding: 4px 16px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 15px 12px; border-bottom: 1px solid #e7ecea; text-align: left; vertical-align: middle; }
th { color: var(--ink-soft); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
td { font-size: 14px; }
td small { color: var(--ink-soft); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfa; }
.empty { padding: 48px; text-align: center; color: var(--ink-soft); }

.badge { display: inline-flex; align-items: center; min-height: 25px; border-radius: 999px; padding: 4px 9px; font-size: 10px; font-weight: 850; letter-spacing: .05em; }
.badge-pending, .badge-queued { color: #775d22; background: #fff2c8; }
.badge-processing { color: #225e7c; background: #dcedf7; }
.badge-completed, .badge-sent { color: #226243; background: #dcefe5; }
.badge-error { color: #8d3030; background: #f8dddd; }
.badge-rejected, .badge-cancelled, .badge-skipped { color: #646d6e; background: #e9eeee; }
.module-dots { white-space: nowrap; }
.module-dot { display: inline-grid; place-items: center; width: 27px; height: 27px; margin-right: 3px; border-radius: 50%; background: #e8eeec; color: #637274; font-size: 11px; font-weight: 800; }
.dot-completed { background: #d7ebdf; color: #216144; }
.dot-processing { background: #d8ebf6; color: #225e7c; }
.dot-error { background: #f5d9d9; color: #8d3030; }

.pagination { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; padding: 22px 0; }
.pagination a { display: grid; place-items: center; min-width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 10px; background: white; text-decoration: none; }
.pagination a.active { background: var(--brand); color: white; border-color: var(--brand); }
.alert { margin-bottom: 18px; border-radius: 14px; padding: 14px 17px; transition: opacity .5s; }
.alert-success { color: #215a40; background: #dff0e6; border: 1px solid #b8ddc7; }
.alert-error { color: #823232; background: #fae2e2; border: 1px solid #edc2c2; }
.alert-fade { opacity: .45; }

.detail-topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.back-link { color: var(--ink-soft); text-decoration: none; font-weight: 700; }
.detail-heading { align-items: center; }
.module-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 20px; }
.module-card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 13px; min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--paper); }
.module-card > span { color: #9aa9a7; font-size: 23px; font-weight: 850; }
.module-card div { display: grid; min-width: 0; }
.module-card small { overflow: hidden; color: var(--ink-soft); text-overflow: ellipsis; white-space: nowrap; }
.state-processing { border-color: #b8d6e5; }
.state-completed { border-color: #bcdbc8; }
.state-error { border-color: #e4b9b9; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(290px, .8fr); gap: 20px; align-items: start; }
.side-column { display: grid; gap: 18px; position: sticky; top: 92px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.section-heading h2, .panel h2 { margin: 0; font-size: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.span-2 { grid-column: 1 / -1; }
.textarea-large textarea { min-height: 170px; }
.form-actions { display: flex; justify-content: flex-end; padding-top: 6px; }
.stack-form, .action-panel { display: grid; gap: 13px; }
.action-panel > form { display: grid; gap: 10px; }
.danger-zone { border-top: 1px solid #ead5d5; margin-top: 8px; padding-top: 16px; }
.success-note, .processing-note { margin: 0; border-radius: 10px; padding: 10px 12px; font-size: 12px; }
.success-note { color: var(--success); background: #e7f3ec; }
.processing-note { color: var(--info); background: #e7f1f7; }
.compact-list dl { margin: 0; }
.compact-list dt { margin-top: 12px; color: var(--ink-soft); font-size: 10px; font-weight: 850; letter-spacing: .08em; }
.compact-list dd { margin: 3px 0 0; overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11px; }
.section-block { margin-top: 20px; }
.artifact-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.artifact-card { display: grid; gap: 5px; border: 1px solid var(--line); border-radius: 13px; padding: 14px; background: #fbfcfa; text-decoration: none; }
.artifact-card:hover { border-color: var(--brand); }
.artifact-card span, .artifact-card small { color: var(--ink-soft); }
.artifact-card small { overflow-wrap: anywhere; font-family: ui-monospace, monospace; font-size: 10px; }
.timeline { display: grid; gap: 0; margin: 0; padding: 0; list-style: none; }
.timeline li { position: relative; display: grid; grid-template-columns: 20px 1fr; gap: 10px; padding: 0 0 20px; }
.timeline li:not(:last-child)::before { content: ""; position: absolute; left: 6px; top: 14px; bottom: 0; width: 1px; background: var(--line); }
.timeline-dot { position: relative; z-index: 1; width: 13px; height: 13px; margin-top: 4px; border: 3px solid #d3e3df; border-radius: 50%; background: var(--brand); }
.timeline p { margin: 2px 0 0; color: var(--ink-soft); font-size: 12px; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 10%, #e6eee9 0, transparent 38%), linear-gradient(150deg, #f8f8f3, #e9efec); }
.login-card { width: min(430px, 100%); border: 1px solid var(--line); border-radius: 24px; padding: clamp(26px, 7vw, 44px); background: rgba(255, 254, 251, .96); box-shadow: 0 24px 70px rgba(17, 55, 60, .13); }
.login-card h1 { margin: 6px 0; font-size: 31px; letter-spacing: -.03em; }
.login-card .brand-mark { margin-bottom: 24px; }

@media (max-width: 1050px) {
  .filter-bar { grid-template-columns: 1fr 1fr 1fr; }
  .filter-search { grid-column: 1 / -1; }
  .detail-grid { grid-template-columns: 1fr; }
  .side-column { grid-template-columns: repeat(2, 1fr); position: static; }
  .side-column .action-panel { grid-row: span 2; }
}

@media (max-width: 760px) {
  .app-header { min-height: 64px; padding: 9px 14px; }
  .brand strong { font-size: 13px; }
  .header-user > span { display: none; }
  .app-main { width: min(100% - 22px, 1540px); padding-top: 22px; }
  .page-heading { align-items: start; }
  .metric { min-width: 105px; padding: 11px; }
  .filter-bar { grid-template-columns: 1fr 1fr; }
  .filter-search { grid-column: 1 / -1; }
  .table-panel { padding: 6px 12px; }
  .table-panel table, .table-panel thead, .table-panel tbody, .table-panel tr, .table-panel th, .table-panel td { display: block; }
  .table-panel thead { display: none; }
  .table-panel tr { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; padding: 16px 0; border-bottom: 1px solid var(--line); }
  .table-panel td { padding: 0; border: 0; }
  .table-panel td::before { content: attr(data-label); display: block; margin-bottom: 2px; color: var(--ink-soft); font-size: 9px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
  .module-grid { grid-template-columns: 1fr; }
  .module-card small { white-space: normal; }
  .form-grid, .side-column { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .side-column .action-panel { grid-row: auto; }
}

@media (max-width: 480px) {
  .page-heading { display: grid; }
  .metric { text-align: left; }
  .filter-bar { grid-template-columns: 1fr; }
  .filter-search { grid-column: auto; }
  .panel { border-radius: 15px; }
}

