:root {
  color-scheme: light;
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    "Segoe UI",
    sans-serif;
  background: #f5f7fb;
  color: #17202a;
  --panel: #ffffff;
  --panel-strong: #f8fafc;
  --line: #dbe3ec;
  --muted: #667789;
  --text: #17202a;
  --accent: #18b77a;
  --accent-2: #f2b84b;
  --danger: #ff7d6e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #f5f7fb;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select,
input[type="range"] {
  cursor: pointer;
}

.app-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.app-frame {
  display: flex;
  width: 100%;
  min-height: 100vh;
  margin: 0;
  padding: 0;
}

.sidebar {
  position: sticky;
  top: 0;
  width: 280px;
  height: 100vh;
  flex: 0 0 280px;
  overflow-y: auto;
  border-right: 1px solid #13283a;
  background: #001526;
  color: #d8e7f5;
  transition:
    width 0.2s ease,
    flex-basis 0.2s ease;
}

.sidebar.collapsed {
  width: 76px;
  flex-basis: 76px;
}

.sidebar-brand,
.nav-group-title,
.nav-item {
  display: flex;
  align-items: center;
}

.sidebar-brand {
  gap: 10px;
  min-height: 68px;
  padding: 0 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.icon-button {
  width: 40px;
  min-height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: transparent;
  color: #d8e7f5;
  padding: 0;
}

.sidebar-nav {
  display: grid;
  gap: 6px;
  padding: 14px 10px 24px;
}

.nav-group {
  display: grid;
  gap: 4px;
  margin-top: 8px;
}

.nav-group-title,
.nav-item {
  min-height: 44px;
  gap: 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #d8e7f5;
  text-align: left;
}

.nav-group-title {
  padding: 0 14px;
  color: #92a8bc;
  font-size: 14px;
}

.nav-item {
  width: 100%;
  padding: 0 14px;
  font-weight: 600;
}

.nav-item:hover,
.nav-item.active {
  background: #06253c;
  color: #29a8ff;
}

.sub-item {
  padding-left: 36px;
  font-size: 14px;
}

.nav-icon {
  width: 22px;
  flex: 0 0 22px;
  text-align: center;
}

.sidebar.collapsed .nav-text {
  display: none;
}

.sidebar.collapsed .sub-item {
  padding-left: 14px;
}

.main-area {
  flex: 1;
  min-width: 0;
  padding: 22px 26px 40px;
  background: #f5f7fb;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: -22px -26px 22px;
  padding: 14px 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
}

.page-view {
  display: none;
}

.page-view.active {
  display: block;
}

.auth-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(460px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 24px 90px rgba(30, 48, 72, 0.16);
  padding: 28px;
}

.auth-card h1 {
  margin-bottom: 12px;
  font-size: 40px;
}

.auth-card .primary-button {
  width: 100%;
}

.auth-error {
  margin-bottom: 14px;
  color: var(--danger);
}

[hidden] {
  display: none !important;
}

.topbar,
.section-title,
.filters,
.actions,
.user-area {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 3.2vw, 42px);
  line-height: 1.05;
}

h2 {
  margin-bottom: 8px;
  font-size: 20px;
}

p {
  color: var(--muted);
  line-height: 1.7;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--muted);
  white-space: nowrap;
}

.status-pill span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 18px var(--accent);
}

.user-area {
  gap: 10px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 0.95fr) minmax(280px, 0.9fr) minmax(340px, 1.35fr);
  gap: 16px;
  align-items: stretch;
}

.control-panel,
.prompt-panel,
.result-panel,
.library-section,
.template-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 50px rgba(30, 48, 72, 0.08);
}

.template-section {
  margin-bottom: 16px;
  padding: 20px;
}

.ai-template-strip {
  padding: 16px 18px;
}

.ai-template-strip .section-title {
  margin-bottom: 12px;
}

.ai-template-strip .section-title p {
  margin-bottom: 0;
}

.ai-template-strip .template-grid {
  grid-template-columns: repeat(6, minmax(120px, 1fr));
}

.ai-template-strip .template-card {
  min-height: 88px;
  align-content: start;
  gap: 6px;
  padding: 12px;
}

.ai-template-strip .template-preview {
  display: none;
}

.ai-template-strip .template-card small {
  font-size: 12px;
}

.ai-workspace {
  grid-template-columns: 1fr;
  max-width: 1180px;
  margin: 0 auto;
}

.ai-console {
  display: grid;
  gap: 16px;
}

.ai-console .panel-heading {
  max-width: 720px;
}

.ai-param-bar {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(220px, 1.1fr) minmax(180px, 0.9fr) minmax(160px, 0.75fr);
  gap: 12px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.ai-param-bar .field,
.ai-composer .field,
.ai-prompt-field {
  margin-bottom: 0;
}

.custom-size-fields {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 12px;
}

.custom-size-fields[hidden] {
  display: none;
}

.ai-composer {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}

.ai-reference-field {
  min-width: 0;
}

.ai-reference-field .upload-box {
  min-height: 170px;
}

.ai-brief-field textarea,
.ai-prompt-field textarea {
  min-height: 190px;
}

.ai-prompt-field textarea {
  background: #fbfdff;
}

.strategy-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  margin-right: 8px;
}

.strategy-option {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.strategy-option.active[data-strategy-mode="strict"] {
  color: #0f5132;
  border-color: rgba(24, 183, 122, 0.46);
  background: rgba(24, 183, 122, 0.14);
}

.strategy-option.active[data-strategy-mode="balanced"] {
  color: #0f3d72;
  border-color: rgba(96, 165, 250, 0.46);
  background: rgba(96, 165, 250, 0.14);
}

.strategy-option.active[data-strategy-mode="inspired"] {
  color: #8a5200;
  border-color: rgba(242, 184, 75, 0.58);
  background: rgba(242, 184, 75, 0.2);
}

.ai-actions {
  justify-content: flex-end;
}

.quota-pill {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  margin-right: auto;
  border: 1px solid rgba(24, 183, 122, 0.28);
  border-radius: 999px;
  padding: 0 12px;
  background: rgba(24, 183, 122, 0.08);
  color: #0f8a5a;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.ai-actions .secondary-button,
.ai-actions .primary-button {
  flex: 0 0 auto;
  min-width: 132px;
}

.ai-result-panel {
  min-height: 260px;
}

.design-note-panel {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.design-note-content {
  display: grid;
  gap: 8px;
}

.design-note-item {
  padding: 10px 12px;
  border: 1px solid rgba(15, 138, 90, 0.12);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  line-height: 1.65;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 12px;
}

.template-card {
  display: grid;
  gap: 9px;
  min-height: 190px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #ffffff;
  color: var(--text);
  text-align: left;
}

.template-card.active,
.template-card:hover {
  border-color: rgba(73, 230, 162, 0.72);
  box-shadow: 0 0 0 3px rgba(73, 230, 162, 0.12);
}

.template-card strong {
  font-size: 15px;
}

.template-card small {
  color: var(--muted);
  line-height: 1.5;
}

.template-preview {
  display: block;
  min-height: 92px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(135deg, rgba(73, 230, 162, 0.9), rgba(243, 199, 95, 0.72)),
    #171812;
}

.preview-business {
  background:
    linear-gradient(90deg, transparent 0 12%, rgba(255,255,255,0.18) 12% 14%, transparent 14%),
    linear-gradient(135deg, #10100f, #49e6a2);
}

.preview-report {
  background:
    radial-gradient(circle at 78% 28%, rgba(243, 199, 95, 0.9) 0 16%, transparent 17%),
    linear-gradient(135deg, #161009, #b84c36);
}

.preview-promo {
  background:
    linear-gradient(90deg, rgba(255,255,255,0.18) 0 28%, transparent 28%),
    linear-gradient(135deg, #2b1128, #f3c75f);
}

.preview-outdoor {
  background:
    linear-gradient(0deg, rgba(255,255,255,0.16) 0 18%, transparent 18%),
    linear-gradient(135deg, #050505, #49e6a2 48%, #f3c75f);
}

.preview-social {
  background:
    radial-gradient(circle at 34% 28%, rgba(73, 230, 162, 0.8) 0 18%, transparent 19%),
    linear-gradient(135deg, #10100f, #2d6cdf);
}

.preview-hiring {
  background:
    linear-gradient(120deg, rgba(255,255,255,0.18) 0 34%, transparent 34%),
    linear-gradient(135deg, #102019, #49e6a2);
}

.control-panel,
.prompt-panel,
.result-panel {
  padding: 20px;
}

.panel-heading p {
  margin-bottom: 20px;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.field span {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.field-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.voice-input-button {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
  font-size: 13px;
}

.voice-input-button.active {
  border-color: var(--accent);
  background: rgba(24, 183, 122, 0.12);
  color: #08734a;
}

textarea,
select,
input[type="email"],
input[type="password"],
input[type="text"],
input[type="number"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  outline: none;
}

textarea {
  min-height: 120px;
  padding: 12px;
  resize: vertical;
  line-height: 1.65;
}

textarea:focus,
select:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="text"]:focus,
input[type="number"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(73, 230, 162, 0.14);
}

select,
input[type="email"],
input[type="password"],
input[type="text"],
input[type="number"] {
  min-height: 42px;
  padding: 0 12px;
}

.size-row {
  display: grid;
  grid-template-columns: 1fr 1fr 0.75fr;
  gap: 10px;
}

.size-row .field {
  margin-bottom: 18px;
}

.upload-box {
  display: grid;
  gap: 6px;
  min-height: 104px;
  place-items: center;
  padding: 18px;
  border: 1px dashed #a8b4c1;
  border-radius: 8px;
  background: #f8fafc;
  text-align: center;
}

.upload-box input {
  display: none;
}

.upload-box strong {
  color: var(--text);
}

.upload-box small {
  color: var(--muted);
}

.reference-preview {
  width: 100%;
  max-height: 180px;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f8fafc;
  cursor: zoom-in;
}

.style-reference-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.style-reference-toggle input {
  accent-color: var(--accent);
}

.reference-library-button {
  width: 100%;
}

.selected-reference-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.selected-reference-pill,
.reference-empty-text {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  color: var(--muted);
  font-size: 12px;
}

.reference-picker {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(12, 21, 32, 0.48);
}

.reference-picker[hidden] {
  display: none;
}

.reference-picker-panel {
  width: min(860px, 100%);
  max-height: min(720px, 90vh);
  overflow: auto;
  padding: 18px;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24);
}

.reference-picker-heading,
.reference-picker-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.reference-picker-heading h2 {
  margin: 0;
  font-size: 20px;
}

.reference-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.reference-picker-item {
  display: grid;
  gap: 8px;
  height: auto;
  min-height: 0;
  padding: 8px;
  border: 2px solid var(--line);
  background: #ffffff;
  color: var(--text);
  text-align: left;
}

.reference-picker-item.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(24, 183, 122, 0.12);
}

.reference-picker-item img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 6px;
  background: #f8fafc;
}

.reference-preview:focus-visible,
.final-image:focus-visible {
  outline: 3px solid rgba(73, 230, 162, 0.58);
  outline-offset: 3px;
}

input[type="range"] {
  accent-color: var(--accent);
}

output {
  color: var(--accent-2);
  font-weight: 700;
}

.actions {
  gap: 10px;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  color: #072016;
  font-weight: 800;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

button[aria-disabled="true"] {
  cursor: wait;
  opacity: 0.82;
}

.primary-button {
  flex: 1;
  background: var(--accent);
}

.secondary-button {
  background: var(--accent-2);
}

.design-wait-dialog {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(12, 21, 32, 0.42);
}

.design-wait-dialog[hidden] {
  display: none;
}

.design-wait-panel {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid rgba(216, 227, 236, 0.88);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
  text-align: center;
}

.design-wait-spinner {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  border: 4px solid #dbe3ec;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: design-wait-spin 0.8s linear infinite;
}

.design-wait-panel h2 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 22px;
}

.design-wait-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

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

.ghost-button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.design-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.design-image-wrap {
  position: relative;
  background: #f8fafc;
}

.design-image-button {
  display: block;
  width: 100%;
  height: 150px;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: #f8fafc;
  cursor: zoom-in;
}

.design-image {
  display: block;
  width: 100%;
  height: 150px;
  object-fit: contain;
  background: #f8fafc;
}

.download-original-button {
  position: absolute;
  top: 8px;
  right: 8px;
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(207, 216, 226, 0.9);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 8px 20px rgba(12, 27, 54, 0.12);
}

.download-original-button:hover {
  color: var(--accent);
}

.design-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
}

.design-card-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.icon-mini-button {
  display: inline-grid;
  width: 30px;
  min-height: 30px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0;
  background: #ffffff;
  color: var(--accent);
  font-size: 18px;
  line-height: 1;
}

.download-link {
  color: var(--accent);
  font-weight: 700;
  text-decoration: none;
}

.library-section {
  margin-top: 16px;
  padding: 20px;
}

.standalone-section {
  margin-top: 0;
}

.final-upload-panel {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #f8fafc;
}

.final-upload-panel .field {
  margin-bottom: 0;
}

.final-upload-panel .field {
  grid-column: span 3;
}

.final-upload-panel .field:nth-child(4),
.final-upload-panel .field:nth-child(6) {
  grid-column: span 4;
}

.final-upload-panel .final-checkbox {
  grid-column: span 2;
}

.final-upload-panel .compact-button {
  grid-column: span 2;
}

.compact-upload {
  min-height: 72px;
  padding: 12px;
}

.final-upload-preview {
  width: 100%;
  max-height: 120px;
  object-fit: contain;
  border-radius: 6px;
  background: #ffffff;
}

.compact-upload:has(.final-upload-preview:not([hidden])) strong,
.compact-upload:has(.final-upload-preview:not([hidden])) small {
  display: none;
}

.final-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
}

.final-checkbox input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.final-image {
  width: 100%;
  height: auto;
  object-fit: contain;
  border-radius: 6px;
  margin-bottom: 0;
  background: #f8fafc;
  cursor: zoom-in;
}

.image-viewer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.86);
}

.image-viewer-panel {
  position: relative;
  display: grid;
  max-width: min(1180px, 96vw);
  max-height: 92vh;
  place-items: center;
}

.image-viewer-img {
  display: block;
  max-width: min(1180px, 96vw);
  max-height: 92vh;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #050505;
  object-fit: contain;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.58);
}

.image-viewer-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  min-height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 8px;
  padding: 0;
  background: rgba(7, 7, 7, 0.74);
  color: var(--text);
  font-size: 28px;
  line-height: 1;
}

.viewer-open {
  overflow: hidden;
}

.employee-modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.52);
}

.employee-dialog {
  width: min(760px, 96vw);
  max-height: 92vh;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 28px 90px rgba(15, 23, 42, 0.24);
  padding: 22px;
}

.employee-close {
  color: var(--text);
}

.employee-photo-box {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  margin-bottom: 18px;
}

.employee-photo-preview {
  display: grid;
  width: 128px;
  aspect-ratio: 1;
  place-items: center;
  border: 1px dashed #a8b4c1;
  border-radius: 8px;
  background: #f8fafc center / cover no-repeat;
  color: var(--muted);
  font-size: 42px;
}

.employee-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.employee-checkbox {
  margin: 6px 18px 0 0;
}

.employee-dialog-actions {
  justify-content: flex-end;
  margin-top: 18px;
}

.admin-panel {
  width: min(1120px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 50px rgba(30, 48, 72, 0.08);
  padding: 24px;
}

.admin-form {
  display: grid;
  gap: 4px;
}

.prompt-template-panel {
  margin-top: 20px;
}

.template-variable-help {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 14px 16px;
  margin-bottom: 10px;
}

.template-variable-help strong {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
}

.template-variable-help p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  word-break: break-all;
}

.template-variable-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.template-variable-chip {
  border: 1px solid #b6d4fe;
  background: #eff6ff;
  color: #2563eb;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}

.template-variable-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  color: var(--muted);
  line-height: 1.6;
}

.template-variable-list strong {
  color: var(--text);
}

.industry-manager-row {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.usage-manager-row {
  grid-template-columns: minmax(180px, 220px) minmax(320px, 1fr) auto;
}

.industry-manager-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.industry-manager-item {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: #ffffff;
}

#usageManagerList .industry-manager-item {
  grid-template-columns: minmax(160px, 220px) minmax(260px, 1fr) auto auto;
}

.industry-manager-item span {
  color: var(--text);
  font-weight: 600;
}

.industry-manager-item small {
  color: var(--muted);
  line-height: 1.5;
}

.industry-manager-item .ghost-button,
.industry-manager-item .secondary-button {
  min-width: 72px;
}

.left-actions {
  justify-content: flex-start;
}

.compact-button {
  flex: 0 0 auto;
  min-width: 110px;
  padding: 0 12px;
  font-size: 14px;
  white-space: nowrap;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

#companyPage .table-wrap {
  position: relative;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
  color: var(--text);
  text-align: left;
  white-space: nowrap;
}

#companyPage th:last-child,
#companyPage td:last-child {
  position: sticky;
  right: 0;
  z-index: 2;
  min-width: 128px;
  box-shadow: -10px 0 14px rgba(255, 255, 255, 0.82);
}

th {
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
}

td {
  background: #ffffff;
}

#companyPage th:last-child {
  background: #f8fafc;
}

#companyPage td:last-child {
  background: #ffffff;
}

tr:last-child td {
  border-bottom: 0;
}

.table-empty {
  color: var(--muted);
  text-align: center;
}

.state-tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid rgba(73, 230, 162, 0.3);
  border-radius: 6px;
  padding: 0 9px;
  background: rgba(73, 230, 162, 0.12);
  color: var(--accent);
  font-size: 12px;
}

.danger-tag {
  border-color: rgba(255, 125, 110, 0.35);
  background: rgba(255, 125, 110, 0.12);
  color: var(--danger);
}

.department-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
}

.department-list {
  display: grid;
  gap: 10px;
  align-content: start;
}

.department-item {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #ffffff;
  cursor: pointer;
}

.department-item:hover {
  border-color: rgba(73, 230, 162, 0.45);
  background: rgba(73, 230, 162, 0.05);
}

.department-item.active {
  border-color: rgba(73, 230, 162, 0.55);
  background: rgba(73, 230, 162, 0.08);
}

.department-item span {
  color: var(--muted);
  font-size: 13px;
}

.avatar {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 999px;
  background: #3a424c;
  color: #fff;
}

.text-button {
  min-height: auto;
  padding: 0 8px 0 0;
  background: transparent;
  color: #2d9cff;
  font-weight: 700;
  pointer-events: auto;
}

.muted-button {
  color: var(--accent-2);
}

.section-title {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.filters {
  gap: 10px;
}

.history-list {
  display: grid;
  gap: 12px;
}

.history-group {
  display: grid;
  gap: 10px;
}

.history-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 4px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.history-group-title h3 {
  margin: 0;
  font-size: 15px;
}

.history-grid {
  column-count: 4;
  column-gap: 16px;
}

.history-item {
  display: inline-block;
  width: 100%;
  break-inside: avoid;
  margin: 0 0 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.history-thumb-shell {
  position: relative;
}

.history-thumb-button {
  display: block;
  width: 100%;
  padding: 10px;
  background: #ffffff;
  text-align: center;
}

.history-delete-button {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  border: 1px solid #ef4444;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  color: #dc2626;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  padding: 8px 12px;
  box-shadow: 0 8px 20px rgba(220, 38, 38, 0.12);
}

.history-delete-button:hover {
  background: #fff1f2;
}

.history-item-body {
  display: grid;
  gap: 8px;
  padding: 0 12px 12px;
}

.history-item h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.4;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 9px;
  color: var(--muted);
  font-size: 12px;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1100px) {
  .workspace,
  .department-layout,
  .final-upload-panel {
    grid-template-columns: 1fr;
  }

  .history-grid {
    column-count: 3;
  }

  .ai-template-strip .template-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .ai-param-bar,
  .ai-composer {
    grid-template-columns: 1fr 1fr;
  }

  .final-upload-panel .field,
  .final-upload-panel .field:nth-child(4),
  .final-upload-panel .field:nth-child(6),
  .final-upload-panel .final-checkbox,
  .final-upload-panel .compact-button {
    grid-column: auto;
  }

  .template-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .result-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-shell:not(.app-frame) {
    width: min(100% - 20px, 1480px);
    padding-top: 12px;
  }

  .app-frame {
    display: block;
  }

  .sidebar,
  .sidebar.collapsed {
    position: relative;
    width: 100%;
    height: auto;
    flex-basis: auto;
  }

  .sidebar.collapsed .nav-text {
    display: inline;
  }

  .main-area {
    padding: 16px 10px 32px;
  }

  .app-topbar {
    margin: -16px -10px 16px;
    padding: 16px 10px;
  }

  .topbar,
  .section-title,
  .filters,
  .actions,
  .user-area {
    align-items: stretch;
    flex-direction: column;
  }

  h1 {
    font-size: 38px;
  }

  .app-topbar {
    position: static;
  }

  textarea {
    font-size: 16px;
  }

  .reference-picker {
    padding: 10px;
  }

  .reference-picker-actions,
  .field-title-row {
    align-items: stretch;
    flex-direction: column;
  }

  .result-grid {
    grid-template-columns: 1fr;
  }

  .history-grid {
    column-count: 1;
  }

  .template-grid,
  .ai-template-strip .template-grid,
  .ai-param-bar,
  .ai-composer,
  .employee-form-grid,
  .employee-photo-box {
    grid-template-columns: 1fr;
  }
}
