:root {
  --asc-red: #c8102e;
  --asc-black: #1a1a1a;
  --ink: #222;
  --line: #c9c9c9;
  --bg: #f4f4f4;
  --paper: #ffffff;
  --accent: var(--asc-red);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

a { color: var(--asc-black); }

.topbar {
  background: var(--asc-black);
  color: #fff;
  padding: 0.6rem 1.2rem;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  row-gap: 0.4rem;
  column-gap: 1rem;
}
.brand { display: flex; align-items: center; gap: 0.6rem; color: #fff; text-decoration: none; font-weight: bold; white-space: nowrap; }
.brand img { height: 32px; flex-shrink: 0; }

.test-banner {
  background: #7a5b00;
  color: #fff3cd;
  text-align: center;
  font-size: 0.82rem;
  font-weight: bold;
  padding: 0.45rem 1rem;
  letter-spacing: 0.01em;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem 1rem;
}
.test-banner-link {
  color: #fff;
  text-decoration: underline;
  white-space: nowrap;
}
.test-banner-link:hover { color: #fff3cd; }

.feedback-banner {
  background: #f2f2f2;
  color: var(--asc-black);
  text-align: center;
  font-size: 0.82rem;
  padding: 0.4rem 1rem;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.4rem 0.8rem;
}
.feedback-banner-link {
  color: var(--asc-red);
  font-weight: bold;
  text-decoration: underline;
  white-space: nowrap;
}
.feedback-banner-link:hover { color: var(--asc-black); }

.topbar-right { display: flex; align-items: center; gap: 0.6rem 0.8rem; flex-wrap: wrap; margin-left: auto; justify-content: flex-end; }
.signed-in-as { font-size: 0.82rem; color: #ddd; white-space: nowrap; }
.signed-in-as.dev-warning { color: #ffcf5c; font-weight: bold; }

.btn {
  display: inline-block;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--asc-black);
  background: #fff;
  color: var(--asc-black);
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.9rem;
  text-decoration: none;
}
.btn-accent {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: bold;
}

.page { max-width: 1400px; margin: 1.2rem auto 3rem; padding: 0 1rem; }

.flash-stack { margin-bottom: 1rem; }
.flash { padding: 0.6rem 1rem; border-radius: 3px; margin-bottom: 0.4rem; }
.flash-success { background: #e6f6ea; border: 1px solid #2e7d32; }
.flash-error { background: #fdecea; border: 1px solid #c62828; }

.tab-row { display: flex; gap: 0.4rem; margin-bottom: 1rem; border-bottom: 2px solid var(--line); }
.tab-link {
  display: inline-block;
  padding: 0.5rem 0.9rem;
  color: #666;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: bold;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
}
.tab-link.is-active { color: var(--asc-black); border-bottom-color: var(--accent); }
.tab-link:hover { color: var(--asc-black); }

.dashboard-filters { display: flex; align-items: flex-end; gap: 0.8rem; flex-wrap: wrap; margin-bottom: 1rem; }
.dashboard-filters label { margin: 0 0 0.15rem; }
.dashboard-filters input, .dashboard-filters select { min-width: 12rem; }
.dashboard-filters > div { display: flex; flex-direction: column; }

.list-table { width: 100%; border-collapse: collapse; background: #fff; }
.list-table th, .list-table td { border: 1px solid var(--line); padding: 0.5rem 0.6rem; text-align: left; font-size: 0.92rem; }
.list-table th { background: #eee; }
.list-table tr.inactive-row { opacity: 0.55; }
.sort-link { color: var(--asc-black); text-decoration: none; white-space: nowrap; }
.sort-link:hover { text-decoration: underline; }
.empty-row { text-align: center; color: #777; font-style: italic; }

.status-pill { display: inline-block; padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.78rem; font-weight: bold; text-transform: uppercase; letter-spacing: 0.02em; }
.status-draft { background: #ececec; color: #555; }
.status-pending_dept, .status-pending_capital, .status-pending_cfo { background: #fff3cd; color: #7a5b00; }
.status-approved { background: #d9f2df; color: #1b5e20; }

.pr-sheet {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 1.4rem 1.6rem;
  margin-bottom: 1rem;
}

.pr-head { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; border-bottom: 3px solid var(--asc-black); padding-bottom: 0.6rem; margin-bottom: 1rem; }
.pr-logo { height: 54px; }
.pr-head h1 { flex: 1; font-size: 1.35rem; margin: 0; letter-spacing: 0.03em; text-wrap: balance; }
.pr-page { font-size: 0.85rem; color: #555; }
.pr-company { display: flex; align-items: center; gap: 0.6rem; }
.pr-company-text { font-size: 0.72rem; line-height: 1.35; color: #444; white-space: normal; }
.pr-company-text strong { display: block; font-size: 0.8rem; color: var(--asc-black); }

.pr-notice-box { border: 1px solid var(--line); padding: 0.5rem 0.7rem; margin-bottom: 0.6rem; }
.pr-terms { font-weight: bold; font-size: 0.85rem; margin: 0 0 0.3rem; }
.pr-notice-box label { margin-top: 0.2rem; }

label { display: block; font-size: 0.72rem; font-weight: bold; text-transform: uppercase; letter-spacing: 0.03em; color: #555; margin: 0.5rem 0 0.15rem; }
input[type=text], input:not([type]), input[type=date], input[type=number], input[type=url], textarea {
  width: 100%;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  font-family: inherit;
  font-size: 0.92rem;
}
textarea { resize: vertical; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; margin-bottom: 0.6rem; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 0.6rem; }
.readonly .f-label { font-weight: bold; text-transform: uppercase; font-size: 0.72rem; color: #555; margin-right: 0.35rem; }
.readonly > div { margin-bottom: 0.3rem; font-size: 0.92rem; }
.pre { white-space: pre-wrap; font-size: 0.92rem; }

.checkbox-row { display: flex; align-items: center; gap: 0.5rem; font-weight: normal; text-transform: none; font-size: 0.92rem; }
.checkbox-row input { width: auto; }

h2 { font-size: 1rem; border-bottom: 2px solid var(--asc-black); padding-bottom: 0.3rem; margin-top: 1.6rem; }

.table-scroll {
  overflow-x: auto;
  scrollbar-width: auto;
  scrollbar-color: #999 #e4e4e4;
  padding-bottom: 4px;
}
.table-scroll::-webkit-scrollbar { height: 12px; }
.table-scroll::-webkit-scrollbar-track { background: #e4e4e4; border-radius: 6px; }
.table-scroll::-webkit-scrollbar-thumb { background: #999; border-radius: 6px; }
.table-scroll::-webkit-scrollbar-thumb:hover { background: #777; }

.scroll-hint { color: #666; font-size: 0.8rem; margin: 0.4rem 0 0; }
.items-table { min-width: 75em; border-collapse: collapse; margin-top: 0.5rem; table-layout: fixed; }
.items-table th, .items-table td { border: 1px solid var(--line); padding: 0.3rem 0.4rem; font-size: 0.85rem; }
.items-table th { background: #eee; text-transform: uppercase; font-size: 0.7rem; }
.items-table input { border: none; padding: 0.15rem; font-size: 0.85rem; }
.price-cell { display: flex; align-items: center; gap: 0.15rem; }
.price-cell .price-sign { color: #777; font-size: 0.8rem; }
.price-cell input { flex: 1; min-width: 0; }

.link-cell { display: flex; align-items: center; gap: 0.3rem; }
.link-cell .link-input { flex: 1; min-width: 0; }
.link-badge {
  background: #2563eb;
  color: #fff;
  font-size: 0.7rem;
  font-weight: bold;
  letter-spacing: 0.03em;
  padding: 0.2rem 0.55rem;
  border-radius: 3px;
  text-decoration: none;
  text-transform: uppercase;
  white-space: nowrap;
}
.link-badge:hover { background: #1d4ed8; }
.link-badge-empty {
  background: #e0e0e0;
  color: #999;
  cursor: default;
  pointer-events: none;
}
.link-badge-empty:hover { background: #e0e0e0; }
.link-edit-btn {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.1rem 0.25rem;
  color: #777;
  flex-shrink: 0;
}
.link-edit-btn:hover { color: #222; }
.row-remove {
  border: none;
  background: none;
  color: var(--asc-red);
  font-size: 1.1rem;
  cursor: pointer;
  min-width: 2.2rem;
  min-height: 2.2rem;
  padding: 0.3rem;
}

#add-row { margin-top: 0.5rem; }

.form-actions { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; margin-top: 1rem; }

.view-toolbar { display: flex; align-items: center; gap: 0.7rem 1rem; margin-bottom: 1rem; flex-wrap: wrap; }

.btn-danger { border-color: var(--asc-red); color: var(--asc-red); }
.btn-danger:hover { background: var(--asc-red); color: #fff; }
.btn-small { padding: 0.25rem 0.6rem; font-size: 0.82rem; }
.row-actions { display: flex; gap: 0.4rem; align-items: center; }
.deleted-banner { background: #fdecea; border: 1px solid var(--asc-red); padding: 0.6rem 0.8rem; border-radius: 4px; display: flex; align-items: center; gap: 0.75rem; }

.sig-blocks { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-top: 0.6rem; }
.sig-block { border: 1px solid var(--line); padding: 0.6rem; min-height: 190px; display: flex; flex-direction: column; }
.sig-title { font-weight: bold; font-size: 0.8rem; text-transform: uppercase; margin-bottom: 0.4rem; color: #555; }
.sig-image { max-width: 100%; border-bottom: 1px solid var(--asc-black); }
.sig-meta { font-size: 0.78rem; color: #444; margin-top: 0.3rem; }
.sig-mode-toggle { display: flex; gap: 0.4rem; margin-bottom: 0.4rem; }
.sig-mode-btn {
  flex: 1;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 3px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  cursor: pointer;
}
.sig-mode-btn.is-active { background: var(--accent); color: #fff; border-color: var(--accent); }
.sig-canvas { border: 1px dashed #999; background: #fdfdfd; width: 100%; touch-action: none; }
.sig-canvas-locked { background: #f0efec; touch-action: auto; }
.sig-type-input { font-style: italic; font-size: 1.05rem; margin-top: 0.4rem; }
.sig-pad-controls { display: flex; gap: 0.4rem; margin-top: 0.4rem; flex-wrap: wrap; }
.signer-name-input { flex: 1 1 100%; }
.sig-placeholder { color: #999; font-style: italic; font-size: 0.85rem; margin: auto; }
.print-only { display: none; }

.escalate-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--line);
}
.escalate-form label { flex: 1 1 100%; margin: 0; }
.escalate-form select { flex: 1 1 auto; min-width: 9rem; }
.escalate-form input { flex: 1 1 auto; min-width: 9rem; }

.mono { font-family: "Courier New", monospace; }
.small { font-size: 0.8rem; }
.hint { color: #666; font-size: 0.85rem; }
.hint code { font-family: "Courier New", monospace; background: #eee; padding: 0.05rem 0.3rem; border-radius: 2px; font-size: 0.82rem; }
#assigned-to-feedback.resolved-ok { color: #1b5e20; font-weight: bold; }
#assigned-to-feedback.resolved-bad { color: #c62828; font-weight: bold; }
.login-box { max-width: 380px; margin: 4rem auto; text-align: center; }
.login-logo { height: 90px; margin-bottom: 1rem; }
.login-box h1 { font-size: 1.15rem; margin: 0 0 0.5rem; }
.login-btn { display: inline-block; margin-top: 1rem; }
.quick-add-box { border: 1px dashed var(--line); border-radius: 4px; padding: 0.75rem; margin-top: 0.5rem; background: #fafafa; }
.quick-add-title { font-weight: bold; margin: 0 0 0.5rem 0; font-size: 0.9rem; }
.quick-add-similar { color: #8a6d00; }
.quick-add-error { color: #c62828; }

.chain-status { padding: 0.6rem 1rem; border-radius: 3px; margin-bottom: 1rem; font-weight: bold; }
.chain-ok { background: #d9f2df; color: #1b5e20; }
.chain-broken { background: #fdecea; color: #c62828; }

@media print {
  .no-print { display: none !important; }
  .print-only { display: block !important; }
  body { background: #fff; }
  .page { max-width: 800px; padding: 0; }
  .pr-sheet { border: none; }
  .sig-block { break-inside: avoid; }
  .items-table { min-width: 0; }
  .table-scroll { overflow: visible; }
}

@media (max-width: 520px) {
  .pr-sheet { padding: 0.9rem; }
}
