:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #667085;
  --line: #dce3ef;
  --soft: #f4f7fc;
  --panel: #ffffff;
  --primary: #3157d8;
  --primary-dark: #2446bd;
  --accent: #7357e8;
  --success: #13795b;
  --warning: #a15c00;
  --danger: #b42318;
  --shadow: 0 24px 70px rgba(29, 45, 90, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 8% 5%, rgba(78, 116, 239, 0.12), transparent 30rem),
    linear-gradient(180deg, #f8faff 0%, #eef3fb 100%);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.shell { min-height: 100vh; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 0 4vw;
  border-bottom: 1px solid rgba(190, 203, 226, 0.72);
  background: rgba(248, 250, 255, 0.88);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  font-size: 1.08rem;
  font-weight: 750;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--primary), var(--accent));
  box-shadow: 0 8px 24px rgba(49, 87, 216, 0.3);
}

.brand-mark svg {
  width: 32px;
  height: 32px;
  overflow: visible;
}

.logo-frame,
.logo-landscape,
.logo-spark {
  fill: none;
  stroke: white;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.logo-frame { stroke-width: 3.2; opacity: 0.92; }
.logo-landscape { stroke-width: 3; }
.logo-spark { stroke-width: 3.4; }
.logo-sun { fill: #fff; }

.brand:hover .brand-mark { transform: translateY(-1px); box-shadow: 0 10px 28px rgba(49, 87, 216, 0.36); }
.brand-mark { transition: transform 160ms ease, box-shadow 160ms ease; }

.account { display: flex; align-items: center; gap: 14px; }
.account-name { color: var(--muted); font-size: 0.92rem; }

.quiet-button, .icon-button, .replace-button {
  border: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 700;
}
.quiet-button:hover, .replace-button:hover { color: var(--primary-dark); }

main { width: min(1240px, 92vw); margin: 0 auto; padding: 48px 0 70px; }

.login-card {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  width: min(880px, 100%);
  margin: 7vh auto 0;
  overflow: hidden;
  border: 1px solid rgba(188, 201, 227, 0.78);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-copy {
  padding: 56px;
  color: white;
  background:
    radial-gradient(circle at 15% 15%, rgba(255, 255, 255, 0.2), transparent 20rem),
    linear-gradient(145deg, #243c91, #513bb0 82%);
}
.login-copy h1 { max-width: 9ch; margin: 10px 0 18px; font-size: clamp(2rem, 4vw, 3.2rem); line-height: 1.03; }
.login-copy p:last-child { max-width: 37ch; color: rgba(255, 255, 255, 0.78); }

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.login-copy .eyebrow { color: #c9d3ff; }

.login-form { display: flex; flex-direction: column; justify-content: center; gap: 18px; padding: 50px; }
label > span, .prompt-field > span { display: block; margin-bottom: 8px; font-weight: 700; }
input, textarea, select {
  width: 100%;
  border: 1px solid #cfd8e8;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
input, select { min-height: 46px; padding: 0 14px; }
textarea { resize: vertical; min-height: 108px; padding: 12px 14px; }
input:focus, textarea:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(49, 87, 216, 0.12); }

.primary-button {
  min-height: 50px;
  border: 0;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--primary), #5b52df);
  color: white;
  font-weight: 800;
  box-shadow: 0 10px 26px rgba(49, 87, 216, 0.26);
  transition: transform 160ms ease, box-shadow 160ms ease;
}
.primary-button:hover { transform: translateY(-1px); box-shadow: 0 14px 30px rgba(49, 87, 216, 0.3); }
.primary-button:disabled { cursor: wait; opacity: 0.68; transform: none; }
.form-error { min-height: 1.4em; margin: 0; color: var(--danger); font-size: 0.9rem; }

.workspace-heading { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin-bottom: 28px; }
.workspace-heading h1 { margin: 0; font-size: clamp(1.85rem, 4vw, 3rem); line-height: 1.1; letter-spacing: -0.035em; }
.workspace-tabs { display: inline-flex; gap: 5px; margin-bottom: 28px; padding: 5px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255, 255, 255, 0.72); }
.workspace-tab { min-height: 40px; padding: 0 16px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-weight: 750; }
.workspace-tab.active { background: var(--panel); color: var(--primary); box-shadow: 0 5px 16px rgba(42, 57, 96, 0.12); }
.summary { display: flex; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: rgba(255, 255, 255, 0.78); }
.summary div { min-width: 92px; padding: 12px 18px; border-left: 1px solid var(--line); text-align: center; }
.summary div:first-child { border-left: 0; }
.summary strong, .summary span { display: block; }
.summary strong { font-size: 1.28rem; }
.summary span { color: var(--muted); font-size: 0.76rem; }

.work-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(310px, 0.85fr); gap: 24px; align-items: start; }
.editor-card, .history-card { border: 1px solid var(--line); border-radius: 22px; background: var(--panel); box-shadow: 0 18px 50px rgba(42, 57, 96, 0.08); }
.editor-card { padding: 26px; }
.history-card { position: sticky; top: 20px; max-height: calc(100vh - 40px); padding: 24px; overflow: auto; }

.dropzone {
  position: relative;
  min-height: 210px;
  overflow: hidden;
  border: 1.5px dashed #b9c6dd;
  border-radius: 18px;
  background: linear-gradient(145deg, #f8faff, #f2f5fb);
  transition: border-color 160ms ease, background 160ms ease;
}
.dropzone.dragover { border-color: var(--primary); background: #eef2ff; }
.dropzone > input { position: absolute; z-index: 2; inset: 0; width: 100%; height: 100%; cursor: pointer; opacity: 0; }
.dropzone-empty { display: flex; min-height: 210px; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 28px; text-align: center; }
.dropzone-empty span:last-child { max-width: 42ch; color: var(--muted); font-size: 0.9rem; }
.upload-icon { position: relative; width: 46px; height: 46px; margin-bottom: 4px; border-radius: 14px; background: #e6ebff; }
.upload-icon::before { position: absolute; top: 13px; left: 15px; width: 14px; height: 14px; border-left: 2px solid var(--primary); border-top: 2px solid var(--primary); content: ""; transform: rotate(45deg); }
.upload-icon::after { position: absolute; left: 22px; bottom: 11px; width: 2px; height: 18px; background: var(--primary); content: ""; }
.image-preview { position: relative; min-height: 210px; padding: 16px; }
.preview-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.preview-item { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.preview-item img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; background: #e7ebf3; }
.preview-item span { display: block; overflow: hidden; padding: 7px 8px; color: #566179; font-size: 0.72rem; text-overflow: ellipsis; white-space: nowrap; }
.preview-footer { position: relative; z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 13px; }
.preview-footer strong { color: #4b5871; font-size: 0.86rem; }
.image-preview .replace-button { flex: 0 0 auto; }

.preset-fieldset { margin: 27px 0 0; padding: 0; border: 0; }
.preset-fieldset legend { margin-bottom: 12px; font-weight: 800; }
.preset-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.preset-card { position: relative; display: flex; min-height: 88px; align-items: center; gap: 11px; padding: 13px; border: 1px solid var(--line); border-radius: 15px; cursor: pointer; transition: border-color 150ms ease, background 150ms ease, transform 150ms ease; }
.preset-card:hover { transform: translateY(-1px); border-color: #aab9d8; }
.preset-card:has(input:checked) { border-color: var(--primary); background: #f0f3ff; box-shadow: inset 0 0 0 1px var(--primary); }
.preset-card input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.preset-card strong, .preset-card small { display: block; }
.preset-card strong { font-size: 0.92rem; }
.preset-card small { margin-top: 2px; color: var(--muted); font-size: 0.75rem; line-height: 1.3; }
.preset-icon { flex: 0 0 auto; width: 32px; height: 32px; border: 1px solid #d7dff0; border-radius: 9px; background: linear-gradient(135deg, #e8edff, #d8e2ff); }
.preset-icon.bg-white { background: linear-gradient(135deg, #fff 48%, #cfd8ee 49% 53%, #f2f5fb 54%); }
.preset-icon.bg-transparent { background-color: #fff; background-image: linear-gradient(45deg,#dce2ec 25%,transparent 25%),linear-gradient(-45deg,#dce2ec 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#dce2ec 75%),linear-gradient(-45deg,transparent 75%,#dce2ec 75%); background-position: 0 0,0 8px,8px -8px,-8px 0; background-size: 16px 16px; }
.preset-icon.clean { background: linear-gradient(145deg, #d6f3e9, #7dd3b4); }
.preset-icon.remove { background: linear-gradient(135deg, #ffe5e0 46%, #ce5547 47% 54%, #fff4f2 55%); }
.preset-icon.restore { background: linear-gradient(135deg, #f4e7c5, #c89d48); }
.preset-icon.custom { background: linear-gradient(145deg, #e8defc, #8d6cda); }

.prompt-field { display: block; margin-top: 24px; }
.prompt-field small { color: var(--muted); font-weight: 500; }
.settings-panel { margin-top: 15px; border: 1px solid var(--line); border-radius: 14px; }
.settings-panel summary { padding: 13px 15px; cursor: pointer; color: #4b5871; font-weight: 700; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 0 15px 15px; }
.settings-grid label > span { color: var(--muted); font-size: 0.86rem; }
.process-button { display: flex; width: 100%; align-items: center; justify-content: center; gap: 10px; margin-top: 2px; }
.button-loader { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.42); border-top-color: white; border-radius: 50%; animation: spin 800ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.history-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 15px; }
.history-heading h2 { margin: 0; font-size: 1.42rem; }
.icon-button { display: grid; width: 38px; height: 38px; place-items: center; border: 1px solid var(--line); border-radius: 11px; font-size: 1.3rem; }
.history-list { display: grid; gap: 10px; }
.history-item { display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: #fbfcff; }
.history-thumb { position: relative; display: grid; width: 54px; height: 54px; place-items: center; overflow: hidden; border-radius: 11px; background: #e9eef7; color: #70809e; font-size: 1.35rem; }
.history-thumb img { width: 100%; height: 100%; object-fit: cover; }
.history-info { min-width: 0; }
.history-title-row { display: flex; align-items: start; justify-content: space-between; gap: 8px; }
.history-info strong { display: block; overflow: hidden; font-size: 0.9rem; text-overflow: ellipsis; white-space: nowrap; }
.history-meta { display: flex; flex-wrap: wrap; gap: 5px 9px; margin-top: 4px; color: var(--muted); font-size: 0.74rem; }
.history-prompt { display: -webkit-box; margin: 5px 0 0; overflow: hidden; color: #566179; font-size: 0.78rem; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.status { flex: 0 0 auto; border-radius: 999px; padding: 3px 7px; font-size: 0.68rem; font-weight: 800; }
.status-completed { background: #dff5ec; color: var(--success); }
.status-processing, .status-queued { background: #fff0d5; color: var(--warning); }
.status-failed { background: #fde5e2; color: var(--danger); }
.result-link { display: inline-flex; margin-top: 8px; color: var(--primary); font-size: 0.8rem; font-weight: 800; text-decoration: none; }
.result-link:hover { color: var(--primary-dark); text-decoration: underline; }
.empty-state { padding: 45px 18px; color: var(--muted); text-align: center; }
.empty-state span { display: block; width: 54px; height: 44px; margin: 0 auto 13px; border: 2px solid #c9d3e5; border-radius: 12px; box-shadow: 7px 7px 0 #e6ebf4; }
.empty-state strong { display: block; color: var(--ink); }
.empty-state p { margin: 5px 0 0; font-size: 0.88rem; }

.statistics-view { display: grid; gap: 22px; }
.statistics-heading { display: flex; align-items: start; justify-content: space-between; gap: 24px; }
.statistics-heading h1 { margin: 0; font-size: clamp(1.8rem, 4vw, 2.7rem); line-height: 1.1; }
.statistics-heading p:last-child { margin: 9px 0 0; color: var(--muted); }
.employee-stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 13px; }
.employee-stat-card { padding: 18px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); color: var(--ink); text-align: left; box-shadow: 0 12px 34px rgba(42, 57, 96, 0.07); transition: transform 150ms ease, border-color 150ms ease; }
.employee-stat-card:hover { transform: translateY(-2px); border-color: #aab9d8; }
.employee-stat-card > div:first-child { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.employee-stat-card > div:first-child span { color: var(--muted); font-size: 0.78rem; }
.employee-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin-top: 16px; }
.employee-metrics span { padding: 8px 3px; border-radius: 9px; background: var(--soft); text-align: center; }
.employee-metrics b, .employee-metrics small { display: block; }
.employee-metrics b { font-size: 1.08rem; }
.employee-metrics small { color: var(--muted); font-size: 0.65rem; }
.employee-activity { display: block; margin-top: 12px; color: var(--muted); font-size: 0.73rem; }
.audit-section { padding: 24px; border: 1px solid var(--line); border-radius: 22px; background: var(--panel); box-shadow: 0 18px 50px rgba(42, 57, 96, 0.08); }
.audit-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 22px; margin-bottom: 18px; }
.audit-toolbar h2 { margin: 0; font-size: 1.45rem; }
.employee-filter { width: min(260px, 100%); }
.employee-filter > span { margin-bottom: 5px; color: var(--muted); font-size: 0.78rem; }
.audit-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.audit-card { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 17px; background: #fbfcff; }
.audit-card-header { display: flex; align-items: start; justify-content: space-between; gap: 12px; padding: 13px 14px; }
.audit-card-header strong, .audit-card-header span { display: block; }
.audit-card-header > div > span { margin-top: 2px; color: var(--muted); font-size: 0.76rem; }
.audit-comparison { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; background: var(--line); }
.audit-comparison figure { min-width: 0; margin: 0; background: #eef2f8; }
.audit-comparison figcaption { padding: 7px 10px; background: #f7f9fd; color: #526078; font-size: 0.72rem; font-weight: 750; }
.audit-comparison a { display: block; }
.audit-comparison img, .audit-image-empty { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.audit-image-empty { display: grid; place-items: center; padding: 12px; color: var(--muted); font-size: 0.78rem; text-align: center; }
.audit-card-footer { padding: 12px 14px 14px; color: var(--muted); font-size: 0.77rem; }
.audit-card-footer > span { display: block; overflow: hidden; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.audit-card-footer p { margin: 6px 0 0; color: #526078; }
.audit-card-footer .audit-error { color: var(--danger); }

.toast { position: fixed; right: 22px; bottom: 22px; z-index: 10; max-width: min(380px, calc(100vw - 44px)); padding: 13px 16px; border-radius: 13px; background: #172033; color: white; box-shadow: 0 18px 45px rgba(16, 24, 40, 0.28); }

@media (max-width: 900px) {
  main { width: min(94vw, 720px); padding-top: 32px; }
  .login-card { grid-template-columns: 1fr; margin-top: 2vh; }
  .login-copy { padding: 38px; }
  .login-copy h1 { max-width: none; }
  .login-form { padding: 36px; }
  .workspace-heading { align-items: start; flex-direction: column; }
  .work-grid { grid-template-columns: 1fr; }
  .history-card { position: static; max-height: none; }
  .audit-list { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .topbar { min-height: 64px; padding: 0 18px; }
  .account-name { display: none; }
  main { width: 100%; padding: 24px 14px 48px; }
  .login-card { border-radius: 20px; }
  .login-copy, .login-form { padding: 28px 24px; }
  .summary { width: 100%; }
  .summary div { min-width: 0; flex: 1; padding: 10px 8px; }
  .workspace-tabs { display: flex; width: 100%; }
  .workspace-tab { min-width: 0; flex: 1; padding: 0 8px; font-size: 0.84rem; }
  .editor-card, .history-card { padding: 17px; border-radius: 18px; }
  .preset-grid { grid-template-columns: 1fr 1fr; }
  .preset-card { min-height: 82px; }
  .image-preview { min-height: 160px; padding: 12px; }
  .preview-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
  .preview-footer { align-items: stretch; flex-direction: column; }
  .image-preview .replace-button { width: 100%; }
  .settings-grid { grid-template-columns: 1fr; }
  .statistics-heading, .audit-toolbar { align-items: stretch; flex-direction: column; }
  .employee-filter { width: 100%; }
  .audit-section { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
