* { box-sizing: border-box; }
body { font-family: system-ui, -apple-system, Segoe UI, sans-serif;
       margin: 0; background: #f5f5f7; color: #222; }
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

header { background: #1f2937; color: #fff; padding: 14px 24px; display: flex;
         align-items: center; gap: 24px; }
header h1 { margin: 0; font-size: 18px; font-weight: 600; }
header nav { display: flex; gap: 14px; flex-wrap: wrap; }
header nav a { color: #d1d5db; font-size: 14px; padding: 4px 10px;
               border-radius: 4px; }
header nav a.active { background: #2563eb; color: #fff; }
header .project-chip { margin-left: auto; font-size: 13px; color: #cbd5e1; }
header .project-chip strong { color: #fff; }

main { max-width: 960px; margin: 24px auto; padding: 0 20px; }
h2 { margin-top: 0; }
.crumbs { font-size: 13px; color: #666; margin-bottom: 12px; }

fieldset { background: #fff; border: 1px solid #ddd; border-radius: 8px;
           padding: 12px 18px 18px; margin: 14px 0; }
legend { padding: 0 8px; font-weight: 600; }
label { display: block; margin: 10px 0 4px; font-size: 13px; font-weight: 500; color: #444; }
input[type=text], input[type=number], input[type=datetime-local], select, textarea {
  width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; font: inherit;
}
textarea { min-height: 50px; resize: vertical; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 180px; }
.memo-row { display: flex; gap: 8px; margin-bottom: 6px; align-items: flex-start; }
.memo-row textarea { flex: 1; }
button { padding: 8px 16px; border-radius: 4px; border: 1px solid #999;
         background: #fff; cursor: pointer; font: inherit; }
button.primary { background: #2563eb; color: #fff; border-color: #2563eb; }
button.danger  { background: #dc2626; color: #fff; border-color: #dc2626; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.tag { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 10px;
       font-weight: 600; vertical-align: middle; margin-left: 6px; }
.tag.std  { background: #d1fae5; color: #065f46; }
.tag.cost { background: #fef3c7; color: #92400e; }

.hint { font-size: 12px; color: #777; margin-top: 2px; }
.warn { background: #fef3c7; border: 1px solid #f59e0b; padding: 10px 14px;
        border-radius: 4px; font-size: 14px; margin: 10px 0; }
.err  { background: #fee2e2; border: 1px solid #dc2626; padding: 10px 14px;
        border-radius: 4px; font-size: 14px; margin: 10px 0; }
.flash { background: #dbeafe; border: 1px solid #2563eb; padding: 8px 14px;
         border-radius: 4px; font-size: 14px; margin: 10px 0; }

table { width: 100%; border-collapse: collapse; background: #fff;
        border: 1px solid #ddd; border-radius: 6px; overflow: hidden; }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid #eee; font-size: 14px; }
th { background: #f9fafb; font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.actions { display: flex; gap: 10px; margin-top: 16px; }

#stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.stat { background: #fff; padding: 8px 12px; border-radius: 6px; border: 1px solid #ddd; }
.stat .v { font-size: 22px; font-weight: 600; }
.stat .k { font-size: 11px; color: #666; text-transform: uppercase; letter-spacing: 0.4px; }
#log { background: #111; color: #c5f1c5; padding: 12px; border-radius: 4px;
       font-family: ui-monospace, Consolas, monospace; font-size: 12px;
       height: 320px; overflow-y: auto; white-space: pre-wrap; }
.phase { display: inline-block; padding: 2px 12px; border-radius: 12px;
         font-size: 12px; font-weight: 600; margin-left: 8px; }
.phase.idle     { background: #e5e5e5; color: #555; }
.phase.scanning { background: #dbeafe; color: #1e40af; }
.phase.sending  { background: #fef3c7; color: #92400e; }
.phase.done     { background: #d1fae5; color: #065f46; }
.phase.error    { background: #fee2e2; color: #991b1b; }

.memo-card { border: 1px solid #ddd; border-radius: 6px; padding: 10px 14px;
             margin: 10px 0; background: #fafafa; transition: opacity 0.15s; }
.memo-card.disabled { opacity: 0.45; }
.memo-card.disabled .memo-card-body input,
.memo-card.disabled .memo-card-body textarea,
.memo-card.disabled .memo-card-body select { pointer-events: none; }
.memo-card-head { display: flex; align-items: center; justify-content: space-between;
                  margin-bottom: 4px; }
.memo-card-head label { margin: 0; font-size: 14px; }

tr.discount-row td { color: #065f46; font-style: italic; }

.tool-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
             gap: 14px; margin-top: 14px; }
.tool-card { background: #fff; border: 1px solid #ddd; border-radius: 8px;
             padding: 14px 16px; display: flex; flex-direction: column; }
.tool-card h3 { margin-top: 0; }
.tool-card p { flex: 1; }
.tool-card a { margin-top: 8px; }

.dh-pair { display: flex; gap: 6px; align-items: center; }
.dh-pair input { width: 70px; }
.dh-pair .sep { color: #888; font-size: 12px; }

.norms { background: #ecfdf5; border: 1px solid #10b981; border-radius: 6px;
         padding: 10px 14px 8px; font-size: 13px; margin: 10px 0 16px;
         line-height: 1.5; }
.norms .norms-head { display: flex; align-items: center; gap: 6px;
                     font-weight: 700; color: #065f46; margin-bottom: 4px; }
.norms ul { margin: 4px 0 4px 18px; padding: 0; }
.norms li { margin: 2px 0; }
.norms b { color: #065f46; }

.icon-preview { width: 80px; height: 80px; border: 1px dashed #ccc;
                border-radius: 8px; display: flex; align-items: center;
                justify-content: center; background: #fafafa; margin-top: 8px;
                overflow: hidden; font-size: 11px; color: #999; }
.icon-preview img { max-width: 100%; max-height: 100%; }
