* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand: #006356;
  --brand-dark: #004d43;
  --brand-soft: rgba(0, 99, 86, 0.08);
  --accent: #FF601B;
  --bg: #f4fbf9;
  --text: #1a1a1a;
  --muted: #6b7280;
  --border: #e5e7eb;
  --danger: #dc2626;
  --success: #059669;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(135deg, #f0f8ff 0%, #e6f7ff 50%, #f6ffed 100%);
  color: var(--text);
  min-height: 100vh;
  padding: 32px 16px;
}

.container {
  max-width: 880px;
  margin: 0 auto;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  overflow: hidden;
}

.header {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: #fff;
  padding: 28px 32px;
}
.header h1 { font-size: 22px; font-weight: 600; margin-bottom: 6px; }
.header .sub { font-size: 13px; opacity: 0.9; }

.body { padding: 32px; }

.doc-info {
  background: var(--brand-soft);
  border-left: 3px solid var(--brand);
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.doc-info .name { font-weight: 600; color: var(--brand-dark); }
.doc-info .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.doc-info a {
  color: var(--brand); text-decoration: none; font-size: 13px; font-weight: 500;
}
.doc-info a:hover { text-decoration: underline; }

.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab {
  padding: 12px 20px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
}
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.pad-wrap {
  border: 2px solid var(--brand-soft);
  border-radius: 12px;
  background: linear-gradient(180deg, #fbfffe 0%, #ffffff 100%);
  box-shadow: inset 0 1px 0 rgba(0, 99, 86, 0.06);
  overflow: hidden;
}

canvas {
  width: 100%; height: 220px; cursor: crosshair;
  touch-action: none; display: block; background: #fff;
}

.toolbar {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 14px; font-size: 13px; color: var(--muted);
}

.upload-drop {
  border: 2px dashed var(--brand);
  border-radius: 12px;
  background: linear-gradient(180deg, #f8fffd 0%, #f4fbf9 100%);
  padding: 44px 16px;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s;
}
.upload-drop:hover { background: #e9f7f4; }
.upload-drop.dragover { background: #d1f0e8; border-color: var(--brand-dark); }
.upload-drop svg { margin-bottom: 12px; }
.upload-drop .title { font-weight: 600; margin-bottom: 4px; }
.upload-drop .hint { font-size: 13px; color: var(--muted); }

.preview-wrap {
  border: 2px solid var(--brand-soft);
  border-radius: 12px; background: #fff;
  padding: 24px; text-align: center;
}
.preview-wrap img { max-height: 180px; max-width: 100%; object-fit: contain; }

.btn {
  border: none; cursor: pointer; font-size: 14px; font-weight: 500;
  padding: 10px 18px; border-radius: 8px; transition: all 0.15s;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--brand); color: #fff;
}
.btn-primary:hover:not([disabled]) { background: var(--brand-dark); }

.btn-ghost {
  background: transparent; color: var(--brand); border: 1px solid var(--brand);
}
.btn-ghost:hover:not([disabled]) { background: var(--brand-soft); }

.btn-link {
  background: transparent; color: var(--muted); padding: 6px 10px;
}
.btn-link:hover { color: var(--brand); }

.actions {
  display: flex; justify-content: flex-end; gap: 12px;
  margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border);
}

.banner {
  padding: 12px 16px; border-radius: 8px; margin-bottom: 20px;
  font-size: 14px;
}
.banner-error { background: #fef2f2; color: var(--danger); border-left: 3px solid var(--danger); }
.banner-success { background: #ecfdf5; color: var(--success); border-left: 3px solid var(--success); }

.center {
  text-align: center; padding: 60px 20px; color: var(--muted);
}

.spinner {
  display: inline-block; width: 36px; height: 36px;
  border: 3px solid var(--brand-soft); border-top-color: var(--brand);
  border-radius: 50%; animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }
