@font-face {
  font-family: 'Inter';
  src: url('../fonts/Inter-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('../fonts/Inter-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Newsreader';
  src: url('../fonts/Newsreader-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Newsreader';
  src: url('../fonts/Newsreader-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f5f6f8;
  --card-bg: #ffffff;
  --border: #e0e2e7;
  --text: #171713;
  --muted: #6b7280;
  --primary: #2526b3;
  --primary-hover: #1d1e8f;
  --gold: #ffc83a;
  --gold-hover: #f0b520;
  --danger: #d63b3b;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

body { margin: 0; background: var(--bg); color: var(--text); }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; background: #fff; border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(23, 23, 19, 0.03);
}
.topbar-logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.topbar-logo img { height: 24px; display: block; }
.topbar-divider { width: 1px; height: 20px; background: var(--border); }
.topbar-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar-actions .muted { font-size: 13px; }

.page { max-width: 1100px; margin: 0 auto; padding: 24px 20px 60px; }

.page-loading, .centered-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 60vh; color: var(--muted);
}

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-header h1 { font-size: 22px; margin: 0; }
.header-actions { display: flex; gap: 8px; }

.card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px; margin-bottom: 24px;
}

.login-card { width: 320px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 12px 32px rgba(23, 23, 19, 0.08); }
.login-page { min-height: 100vh; background: linear-gradient(180deg, #f5f6f8 0%, #eceeff 100%); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; }
.login-logo img { height: 30px; display: block; }
.login-subtitle { margin: 0; }

label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }

input, select, textarea {
  padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; color: var(--text); background: #fff;
}
textarea { resize: vertical; font-family: inherit; line-height: 1.45; }
input[type="color"] { padding: 2px; height: 36px; }

.btn {
  border: none; border-radius: 8px; padding: 9px 16px; font-size: 14px;
  font-weight: 600; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-accent { background: var(--gold); color: #171713; }
.btn-accent:hover { background: var(--gold-hover); }
.btn-secondary { background: #eef0f4; color: var(--text); }
.btn-secondary:hover { background: #e2e5eb; }
.btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-danger { background: #fce9e9; color: var(--danger); }
.btn-danger:hover { background: #f8d5d5; }
.form-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.error-text { color: var(--danger); font-size: 13px; margin: 4px 0; }
.muted { color: var(--muted); font-size: 13px; }

.form-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.template-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px;
}
.template-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden; color: inherit;
}
.template-card-link { text-decoration: none; transition: box-shadow 0.15s; display: block; }
.template-card-link:hover { box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08); }
.template-card img { width: 100%; height: 140px; object-fit: cover; display: block; background: #f0f0f0; }
.template-card-body { padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.template-card-actions { display: flex; gap: 8px; margin-top: 8px; }

.editor-toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }

.editor-layout { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }

.editor-canvas {
  position: relative; border: 1px solid var(--border); border-radius: 8px;
  overflow: hidden; background: #eee; flex-shrink: 0;
}
.editor-canvas img { display: block; user-select: none; pointer-events: none; }
.editor-sidebar { width: 260px; flex-shrink: 0; }

.placeholder-box {
  position: absolute; border: 2px dashed rgba(37, 38, 179, 0.5);
  background: rgba(37, 38, 179, 0.04); cursor: move; overflow: hidden;
}
.placeholder-box.placeholder-selected { border-color: #ffc83a; box-shadow: 0 0 0 2px rgba(255, 200, 58, 0.35); z-index: 5; }
.placeholder-box.placeholder-image { border-color: rgba(126, 0, 255, 0.5); background: rgba(126, 0, 255, 0.06); }
.placeholder-box.placeholder-cta { border-color: rgba(214, 59, 59, 0.5); }

.placeholder-label {
  position: absolute; top: 0; left: 0; font-size: 10px; text-transform: uppercase; font-weight: 700; color: var(--text);
  background: rgba(255, 255, 255, 0.85); padding: 2px 5px; border-radius: 0 0 4px 0;
  display: inline-block; pointer-events: none; user-select: none; z-index: 2;
}

.placeholder-preview-text {
  position: absolute; inset: 0; display: flex; align-items: flex-start; overflow: hidden;
  white-space: pre-wrap; word-break: break-word; pointer-events: none; line-height: 1.25;
}
.placeholder-preview-image {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 28px; color: rgba(126, 0, 255, 0.35); pointer-events: none;
}

.template-title-input {
  font-size: 22px; font-weight: 700; border: 1px solid transparent; border-radius: 8px;
  padding: 4px 8px; margin: -4px -8px; background: transparent; color: var(--text);
  min-width: 200px;
}
.template-title-input:hover, .template-title-input:focus { border-color: var(--border); background: #fff; outline: none; }

.resize-handle {
  position: absolute; right: -6px; bottom: -6px; width: 14px; height: 14px;
  background: #fff; border: 2px solid rgba(37, 38, 179, 0.9); border-radius: 50%;
  cursor: nwse-resize;
}

.customize-layout { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.customize-form { width: 280px; flex-shrink: 0; display: flex; flex-direction: column; gap: 14px; }
.customize-preview { flex: 1; min-width: 300px; display: flex; justify-content: center; }
.preview-canvas { max-width: 100%; border: 1px solid var(--border); border-radius: 8px; background: #fff; }

.header-actions .muted { align-self: center; }

.dashboard-welcome { margin: 0 0 20px; }
.dashboard-welcome h1 { margin: 0 0 4px; font-size: 24px; }
.dashboard-welcome p { margin: 0; color: var(--muted); }

.module-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px;
}
.module-card {
  position: relative; background: var(--card-bg); border: 1px solid var(--border); border-radius: 14px;
  padding: 22px; text-decoration: none; color: inherit; overflow: hidden;
  transition: box-shadow 0.15s, transform 0.15s;
}
.module-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--gold);
}
.module-card:not(.module-card-disabled):hover { box-shadow: 0 8px 20px rgba(23, 23, 19, 0.1); transform: translateY(-2px); }
.module-card-icon {
  width: 40px; height: 40px; border-radius: 10px; background: rgba(37, 38, 179, 0.08);
  color: var(--primary); display: flex; align-items: center; justify-content: center; margin-bottom: 14px;
}
.module-card-icon svg { width: 20px; height: 20px; }
.module-card h2 { margin: 0 0 6px; font-size: 17px; }
.module-card p { margin: 0; color: var(--muted); font-size: 13.5px; }
.module-card-disabled { opacity: 0.6; cursor: not-allowed; }
.module-card-disabled::before { background: var(--border); }
.module-card-disabled .module-card-icon { background: #eef0f4; color: var(--muted); }
.module-card-badge {
  position: absolute; top: 14px; right: 14px; font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.03em; background: #eef0f4; color: var(--muted); padding: 3px 8px; border-radius: 999px;
}

.qr-preview-image { max-width: 100%; border: 1px solid var(--border); border-radius: 8px; }

.signature-template-textarea {
  width: 100%; min-height: 260px; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12.5px; padding: 12px; border: 1px solid var(--border); border-radius: 8px;
  margin-bottom: 12px; resize: vertical;
}
.customize-preview-stacked { flex-direction: column; align-items: stretch; gap: 8px; }
.signature-preview-frame {
  width: 100%; min-height: 200px; border: 1px solid var(--border); border-radius: 8px; background: #fff;
}
.checkbox-row { display: flex; align-items: center; gap: 8px; flex-direction: row; }
.checkbox-row input { width: auto; }

.icon-live-preview {
  width: 240px; height: 240px; padding: 24px; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 8px; background:
    linear-gradient(45deg, #f0f0f0 25%, transparent 25%), linear-gradient(-45deg, #f0f0f0 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f0f0f0 75%), linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
  background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

.icon-search {
  width: 100%; max-width: 320px; padding: 9px 10px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; margin-bottom: 14px; display: block;
}
.icon-letter-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.icon-letter-tabs .btn { padding: 6px 12px; font-size: 13px; }
.icon-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px;
}
.icon-card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
  color: inherit; text-decoration: none;
}
.icon-card img { width: 48px; height: 48px; object-fit: contain; }
.icon-edit-form { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.icon-edit-form input[type="text"] { width: 100%; }
.icon-card-tags { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.icon-card-tag { font-size: 11px; background: #eef0f4; color: var(--muted); padding: 2px 7px; border-radius: 999px; }
.icon-card-file-badge {
  width: 48px; height: 48px; display: flex; align-items: center; justify-content: center;
  background: #eef0f4; color: var(--muted); font-size: 11px; font-weight: 700; border-radius: 6px;
}
.icon-card span { font-size: 13px; font-weight: 600; word-break: break-word; }

.user-table { width: 100%; border-collapse: collapse; background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.user-table th, .user-table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 14px; }
.user-table th { background: #f0f1f4; font-size: 12px; text-transform: uppercase; color: var(--muted); }
.user-table tr:last-child td { border-bottom: none; }

.request-grid { display: grid; grid-template-columns: minmax(280px, 420px) 1fr; gap: 18px; align-items: start; }
.request-panel h2 { margin-top: 0; }
.stack-form { display: flex; flex-direction: column; gap: 14px; }
.request-toolbar { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 18px; }
.request-toolbar label { min-width: 220px; flex: 1; }
.request-list { display: flex; flex-direction: column; gap: 14px; }
.request-card {
  border: 1px solid var(--border); border-radius: 12px; background: #fff; padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.request-card-header { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.request-card h3 { margin: 0 0 6px; font-size: 17px; }
.request-meta { margin: 0; color: var(--muted); font-size: 12px; }
.request-detail { margin: 0; white-space: pre-wrap; line-height: 1.5; }
.request-note { margin: 0; padding: 10px 12px; border-radius: 10px; background: #f5f6f8; line-height: 1.45; }
.request-admin-controls { display: flex; flex-direction: column; gap: 12px; }
.status-pill {
  border-radius: 999px; padding: 5px 10px; font-size: 12px; font-weight: 700; white-space: nowrap;
  background: #eef0f4; color: var(--muted);
}
.status-open { background: #fff3d8; color: #8a5b00; }
.status-reviewing { background: #e7efff; color: #2450a8; }
.status-resolved { background: #e8f7ed; color: #1f7a3b; }
.status-closed { background: #eceff3; color: #5d6673; }

@media (max-width: 900px) {
  .request-grid { grid-template-columns: 1fr; }
  .request-card-header { flex-direction: column; }
}

.tool-feedback-trigger {
  position: fixed; right: 20px; bottom: 20px; z-index: 80;
  border: none; border-radius: 999px; padding: 12px 18px;
  background: var(--primary); color: #fff; font-weight: 700; cursor: pointer;
  box-shadow: 0 10px 26px rgba(37, 38, 179, 0.28);
}
.tool-feedback-trigger:hover { background: var(--primary-hover); }
.tool-feedback-backdrop {
  position: fixed; inset: 0; z-index: 90; display: flex; justify-content: flex-end; align-items: flex-end;
  padding: 20px; background: rgba(23, 23, 19, 0.28);
}
.tool-feedback-backdrop[hidden] { display: none; }
.tool-feedback-dialog {
  position: relative; width: min(420px, 100%); background: #fff; border-radius: 16px;
  padding: 22px; box-shadow: 0 18px 50px rgba(23, 23, 19, 0.22);
}
.tool-feedback-dialog h2 { margin: 0 34px 6px 0; font-size: 20px; }
.tool-feedback-form { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }
.tool-feedback-close {
  position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; border: none;
  border-radius: 50%; background: #eef0f4; color: var(--text); font-size: 22px; line-height: 1; cursor: pointer;
}
.tool-feedback-close:hover { background: #e2e5eb; }

@media (max-width: 700px) {
  .tool-feedback-trigger { right: 14px; bottom: 14px; }
  .tool-feedback-backdrop { padding: 12px; }
}
