:root {
  color-scheme: light;
  --ink: #1b2925;
  --muted: #6c7772;
  --paper: #f4f1e9;
  --panel: #fffdf8;
  --line: #d8ddd8;
  --green: #225f51;
  --green-dark: #173f36;
  --green-soft: #dfece6;
  --gold: #b18134;
  --danger: #a43f3f;
  --danger-soft: #f8e1df;
  --shadow: 0 18px 42px rgb(24 48 40 / 12%);
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 12% 10%, rgb(177 129 52 / 9%), transparent 30rem),
    var(--paper);
  color: var(--ink);
}

body {
  min-width: 320px;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

button, input, textarea { font: inherit; }
button, .upload-button { touch-action: manipulation; }
button { cursor: pointer; }

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px clamp(16px, 3vw, 36px);
  color: #fff;
  background: rgb(23 63 54 / 96%);
  border-bottom: 1px solid rgb(255 255 255 / 12%);
  backdrop-filter: blur(12px);
}

.brand, .topbar-actions, .editor-actions, .button-group,
.dialog-actions, .panel-heading, .section-heading, .editor-heading {
  display: flex;
  align-items: center;
}

.brand { gap: 11px; }
.brand img { border-radius: 12px; background: #fff; }
.brand div { display: grid; gap: 2px; }
.brand strong { font-size: 1.05rem; letter-spacing: .02em; }
.brand span { color: rgb(255 255 255 / 72%); font-size: .75rem; }
.topbar-actions, .button-group, .editor-actions, .dialog-actions { gap: 8px; }

.app-shell {
  display: grid;
  grid-template-columns: minmax(300px, 390px) minmax(0, 1fr);
  gap: 18px;
  min-height: calc(100vh - 118px);
  padding: 18px clamp(16px, 3vw, 36px) 28px;
}

.orders-panel, .workspace-panel {
  min-width: 0;
  border: 1px solid rgb(34 95 81 / 12%);
  border-radius: 22px;
  background: rgb(255 253 248 / 93%);
  box-shadow: var(--shadow);
}

.orders-panel {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 104px);
  padding: 18px;
  position: sticky;
  top: 86px;
}

.workspace-panel { overflow: hidden; }
.panel-heading, .section-heading, .editor-heading { justify-content: space-between; gap: 14px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 1.35rem; }
h2 { margin-bottom: 0; font-size: 1.25rem; }
h3 { margin-bottom: 0; font-size: 1.05rem; }
.eyebrow { margin-bottom: 4px; color: var(--green); font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.muted { color: var(--muted); font-size: .84rem; }

.button {
  min-height: 42px;
  padding: 9px 14px;
  color: var(--ink);
  background: #e8ece8;
  border: 1px solid transparent;
  border-radius: 12px;
  font-weight: 700;
}

.button:hover { filter: brightness(.97); }
.button:focus-visible, .filter:focus-visible, input:focus, textarea:focus, button:focus-visible {
  outline: 3px solid rgb(177 129 52 / 42%);
  outline-offset: 2px;
}

.button.primary { color: #fff; background: var(--green); }
.button.ghost { color: inherit; background: transparent; border-color: rgb(108 119 114 / 30%); }
.button.danger { color: var(--danger); }
.topbar .button { color: #fff; background: rgb(255 255 255 / 12%); }
.topbar .button.ghost { border-color: rgb(255 255 255 / 24%); }
.icon-button { min-width: 44px; padding-inline: 11px; font-size: 1.05rem; }

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  padding: 0 12px;
  background: #f1f2ed;
  border: 1px solid var(--line);
  border-radius: 13px;
}

.search-box span { color: var(--muted); font-size: 1.5rem; }
input, textarea {
  width: 100%;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 11px;
}

input { min-height: 44px; padding: 9px 11px; }
textarea { min-height: 128px; padding: 12px; resize: vertical; line-height: 1.45; }
.search-box input { padding-inline: 0; background: transparent; border: 0; }
.search-box input:focus { outline: 0; }

.filter-row {
  display: flex;
  gap: 7px;
  margin: 12px 0;
  padding-bottom: 3px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.filter {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 6px 11px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: .82rem;
  font-weight: 700;
}

.filter.active { color: #fff; background: var(--green); border-color: var(--green); }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.summary-grid article {
  min-width: 0;
  padding: 10px;
  background: var(--green-soft);
  border-radius: 12px;
}

.summary-grid span { display: block; color: var(--muted); font-size: .7rem; }
.summary-grid strong { display: block; margin-top: 4px; font-size: .95rem; overflow-wrap: anywhere; }

.list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  color: var(--muted);
  font-size: .8rem;
}

.text-button {
  min-height: 34px;
  padding: 4px 8px;
  color: var(--green);
  background: transparent;
  border: 0;
  font-weight: 800;
}

.orders-list {
  display: grid;
  gap: 9px;
  margin-top: 8px;
  padding-right: 4px;
  overflow-y: auto;
}

.order-card {
  width: 100%;
  padding: 13px;
  text-align: left;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-left: 5px solid var(--green);
  border-radius: 14px;
}

.order-card:hover { transform: translateY(-1px); }
.order-card.selected { background: #eaf3ef; border-color: var(--green); box-shadow: 0 8px 20px rgb(34 95 81 / 14%); }
.order-card.overdue { border-left-color: var(--danger); }
.order-card.soon { border-left-color: var(--gold); }
.order-card-top, .order-card-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.order-card-top strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.order-card-bottom { margin-top: 8px; color: var(--muted); font-size: .78rem; }
.status-badge { flex: 0 0 auto; padding: 4px 8px; color: var(--green-dark); background: var(--green-soft); border-radius: 999px; font-size: .7rem; font-weight: 800; }
.order-card.overdue .status-badge { color: #7f2929; background: var(--danger-soft); }

.empty-state {
  display: grid;
  min-height: 70vh;
  place-content: center;
  justify-items: center;
  padding: 32px;
  text-align: center;
}

.empty-state img { margin-bottom: 14px; border-radius: 22px; box-shadow: var(--shadow); }
.empty-state p { max-width: 520px; color: var(--muted); line-height: 1.55; }
.empty-list { padding: 30px 12px; color: var(--muted); text-align: center; line-height: 1.5; }

.order-editor { padding: clamp(18px, 3vw, 30px); }
.editor-heading { margin-bottom: 22px; }
.editor-heading .muted { display: block; margin-top: 6px; }

.stepper {
  display: grid;
  grid-template-columns: repeat(6, minmax(72px, 1fr));
  margin: 0 0 24px;
  overflow-x: auto;
}

.step {
  position: relative;
  min-height: 64px;
  padding: 8px 6px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-bottom: 4px solid var(--line);
  font-size: .78rem;
  font-weight: 800;
}

.step::before {
  content: "";
  display: block;
  width: 12px;
  height: 12px;
  margin: 0 auto 7px;
  background: #c4ccc7;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--line);
}

.step.reached { color: var(--green-dark); border-color: var(--green); }
.step.reached::before { background: var(--green); box-shadow: 0 0 0 1px var(--green); }
.step.current { background: var(--green-soft); border-radius: 10px 10px 0 0; }

.form-grid, .brief-grid, .settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid label, .settings-grid label, .text-card {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: .79rem;
  font-weight: 750;
}

.input-action { display: grid; grid-template-columns: minmax(0, 1fr) 44px; }
.input-action input { border-radius: 11px 0 0 11px; }
.input-action button {
  background: var(--green-soft);
  border: 1px solid var(--line);
  border-left: 0;
  border-radius: 0 11px 11px 0;
}

.brief-section, .gallery-section { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--line); }
.section-heading { margin-bottom: 14px; align-items: flex-start; }
.brief-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.text-card {
  padding: 12px;
  background: #f5f5f0;
  border: 1px solid var(--line);
  border-radius: 15px;
}

.text-card textarea { min-height: 220px; border: 0; background: #fff; }
.label-row { display: flex; min-height: 24px; align-items: center; justify-content: space-between; }
.label-row button { padding: 2px 5px; background: transparent; border: 0; }
.upload-button { display: inline-flex; align-items: center; cursor: pointer; }
.upload-button input { display: none; }

.file-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.file-card {
  display: grid;
  gap: 9px;
  min-width: 0;
  padding: 9px;
  color: var(--ink);
  text-decoration: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.file-card img, .file-placeholder {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #e9eae5;
  border-radius: 10px;
}

.file-placeholder { display: grid; place-items: center; font-size: 2rem; }
.file-card span { overflow: hidden; font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
.upload-progress { margin: 12px 0; padding: 10px 12px; color: var(--green-dark); background: var(--green-soft); border-radius: 10px; }

dialog {
  width: min(720px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  padding: 0;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 30px 80px rgb(0 0 0 / 30%);
}

dialog::backdrop { background: rgb(13 32 27 / 66%); backdrop-filter: blur(5px); }
dialog form { padding: 24px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.notice { margin: 16px 0; padding: 11px; color: #67501d; background: #fff2cf; border-radius: 10px; font-size: .78rem; line-height: 1.45; }
.dialog-actions { justify-content: flex-end; flex-wrap: wrap; }

footer { padding: 10px 20px 18px; color: var(--muted); text-align: center; font-size: .78rem; }

.toast {
  position: fixed;
  z-index: 100;
  right: 20px;
  bottom: 20px;
  max-width: min(430px, calc(100vw - 40px));
  padding: 13px 16px;
  color: #fff;
  background: var(--green-dark);
  border-radius: 13px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: .2s ease;
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #8f3434; }

.busy-overlay {
  position: fixed;
  z-index: 90;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  color: #fff;
  background: rgb(13 32 27 / 68%);
  backdrop-filter: blur(3px);
}

.spinner { width: 38px; height: 38px; border: 4px solid rgb(255 255 255 / 28%); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }

@media (max-width: 1040px) {
  .app-shell { grid-template-columns: 320px minmax(0, 1fr); padding-inline: 12px; }
  .brief-grid { grid-template-columns: 1fr; }
  .text-card textarea { min-height: 150px; }
}

@media (max-width: 760px) {
  .topbar { align-items: flex-start; }
  .brand strong { font-size: .92rem; }
  .topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
  .app-shell { grid-template-columns: 1fr; padding: 10px; }
  .orders-panel { position: static; max-height: none; }
  .orders-list { max-height: 380px; }
  .workspace-panel { min-height: 50vh; }
  .form-grid, .settings-grid { grid-template-columns: 1fr; }
  .editor-heading, .section-heading { align-items: stretch; flex-direction: column; }
  .editor-actions { justify-content: flex-end; }
  .stepper { grid-template-columns: repeat(6, 92px); }
  .summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  dialog form { padding: 18px; }
}

@media (max-width: 480px) {
  .brand img { width: 36px; height: 36px; }
  #signInButton { width: 100%; }
  .summary-grid { grid-template-columns: 1fr; }
  .summary-grid article { display: flex; align-items: center; justify-content: space-between; }
  .summary-grid strong { margin-top: 0; }
  .editor-actions .button { flex: 1; }
  .upload-button { justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
