/* Greenix support — public form and admin share this sheet. */

:root {
  --bg: #f7f6f1;
  --surface: #ffffff;
  --ink: #1b2420;
  --muted: #5d6b64;
  --line: #dcdcd2;
  --accent: #0a6b45;
  --accent-ink: #ffffff;
  --error: #9b2226;
  --error-bg: #fdf0ef;
  --ok: #0a6b45;
  --ok-bg: #eef6f1;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(27, 36, 32, .06), 0 8px 24px rgba(27, 36, 32, .05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap { width: 100%; max-width: 720px; margin: 0 auto; padding: 0 20px; }
.wrap--wide { max-width: 1080px; }

/* ------------------------------------------------------------- masthead */

.masthead {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 18px 0;
  margin-bottom: 40px;
}
.masthead .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { font-weight: 650; letter-spacing: -.01em; }
.masthead nav { display: flex; gap: 18px; align-items: center; }
.masthead a { color: var(--muted); text-decoration: none; font-size: 14px; }
.masthead a:hover { color: var(--ink); }

/* ------------------------------------------------------------- typography */

h1 { font-size: 28px; line-height: 1.25; letter-spacing: -.02em; margin: 0 0 12px; }
h2 { font-size: 19px; margin: 32px 0 10px; }
.lede { color: var(--muted); margin: 0 0 32px; max-width: 60ch; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .9em; background: #eeeee6; padding: 1px 5px; border-radius: 4px;
}

/* ----------------------------------------------------------------- panels */

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin: 0 0 28px;
  background: var(--surface);
}
.panel--error { border-color: #e7c3c1; background: var(--error-bg); color: var(--error); }
.panel--error ul { margin: 8px 0 0; padding-left: 20px; }
.panel--ok { border-color: #bcd9c9; background: var(--ok-bg); }
.panel--ok h1 { color: var(--ok); }
.panel .ref { font-size: 15px; color: var(--muted); }

/* ------------------------------------------------------------------ form */

form { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow); }

.field { margin-bottom: 22px; }

/* Two fields on one line — first and last name. Collapses on a phone, where
   side-by-side inputs get too narrow to type into comfortably. */
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 560px) { .field-row { grid-template-columns: 1fr; } }
label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.req { color: var(--error); }

input[type="text"], input[type="email"], input[type="password"], input[type="search"],
select, textarea {
  width: 100%;
  padding: 11px 13px;
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(10, 107, 69, .15);
}
textarea { resize: vertical; min-height: 150px; }
input[type="file"] { width: 100%; padding: 10px 0; font-size: 14px; }

.hint { font-size: 13px; color: var(--muted); margin: 6px 0 0; }
.fineprint { font-size: 13px; color: var(--muted); margin: 18px 0 0; }

/* Off-screen rather than display:none — some bots skip hidden fields. */
.trap {
  position: absolute; left: -9999px; width: 1px; height: 1px;
  overflow: hidden;
}

/* -------------------------------------------- client-side validation state */

.field-error {
  color: var(--error);
  font-size: 13px;
  margin: 6px 0 0;
  font-weight: 500;
}

.field.has-error input,
.field.has-error select,
.field.has-error textarea { border-color: var(--error); }

.field.has-error input:focus,
.field.has-error select:focus,
.field.has-error textarea:focus {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(155, 34, 38, .13);
}

.counter { text-align: right; }
.counter--over { color: var(--error); font-weight: 600; }

/* ----------------------------------------------------------- file previews */

/* minmax(0, 1fr) rather than the default: a grid track sizes to its content
   unless told otherwise, so one long filename pushed the whole row past the
   edge of the form and the ellipsis below never got a chance to apply. */
.preview {
  list-style: none; margin: 14px 0 0; padding: 0;
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px;
}

.preview__item {
  display: flex; align-items: center; gap: 12px;
  min-width: 0;              /* same reason, one level down */
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; background: #fdfdfa;
}

.preview__thumb {
  width: 48px; height: 48px; flex: 0 0 48px;
  object-fit: cover; border-radius: 6px;
  border: 1px solid var(--line); background: #fff;
}
.preview__thumb--file {
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .03em;
}

.preview__meta { flex: 1; min-width: 0; }
.preview__name {
  display: block; font-size: 14px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.preview__size { display: block; font-size: 12px; color: var(--muted); }

.preview__remove {
  flex: 0 0 auto;
  font: inherit; font-size: 13px; font-weight: 600;
  color: var(--error); background: none;
  border: 1px solid transparent; border-radius: 6px;
  padding: 5px 10px; cursor: pointer;
}
.preview__remove:hover { border-color: #e7c3c1; background: var(--error-bg); }

input[type="file"]:disabled { opacity: .5; cursor: not-allowed; }

/* --------------------------------------------------------------- buttons */

.btn {
  display: inline-block;
  padding: 12px 22px;
  font: inherit; font-weight: 600;
  color: var(--accent-ink);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  transition: opacity .15s, transform .15s;
}
.btn:hover { opacity: .9; }
.btn:active { transform: translateY(1px); }
.btn--quiet { background: transparent; color: var(--accent); }
.btn--small { padding: 7px 14px; font-size: 14px; }
/* Not :disabled — disabling the button would cancel the POST it belongs to. */
.btn.is-busy { opacity: .65; pointer-events: none; }

/* ---------------------------------------------------------------- tables */

table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: top; }
th { background: #f2f1ea; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafaf6; }
td a { color: var(--accent); text-decoration: none; font-weight: 600; }
td a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- status */

.tag {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 650; letter-spacing: .01em; white-space: nowrap;
}
.tag--new      { background: #e4f0ff; color: #14508c; }
.tag--open     { background: #fff2d9; color: #8a5a00; }
.tag--waiting  { background: #f0ecf9; color: #59409c; }
.tag--resolved { background: var(--ok-bg); color: var(--ok); }
.tag--closed   { background: #ececec; color: #555; }

/* ----------------------------------------------------------------- admin */

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 20px; }
.toolbar form { padding: 0; border: 0; background: none; box-shadow: none; display: flex; gap: 8px; flex-wrap: wrap; }
.toolbar select, .toolbar input[type="search"] { width: auto; min-width: 180px; }

.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.filters a {
  padding: 6px 13px; border-radius: 999px; font-size: 13px; font-weight: 600;
  text-decoration: none; color: var(--muted); border: 1px solid var(--line); background: var(--surface);
}
.filters a.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }

.meta { display: grid; grid-template-columns: 150px 1fr; gap: 8px 16px; font-size: 14px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; word-break: break-word; }

.message-body {
  white-space: pre-wrap; word-break: break-word;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; font-size: 15px;
}

.attachments { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.attachments li {
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
  padding: 10px 14px; font-size: 14px;
  /* Merchants upload files with very long names. Cap the tile and break the
     name rather than letting one attachment widen the whole page. */
  max-width: 100%; min-width: 0; overflow-wrap: anywhere;
}
.attachments .size { color: var(--muted); font-size: 12px; display: block; }

.note { background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 8px; padding: 12px 15px; margin-bottom: 10px; font-size: 14px; }
.note .by { color: var(--muted); font-size: 12px; margin-top: 6px; }

/* ------------------------------------------------------- reply / timeline */

label.inline { display: flex; align-items: center; gap: 9px; font-weight: 500; }
label.inline input[type="checkbox"] { width: auto; margin: 0; }

.timeline { display: grid; gap: 12px; }

.entry {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 14px;
}
/* A reply left the building; a note did not. The left edge says which. */
.entry--reply  { border-left: 3px solid var(--accent); }
.entry--note   { border-left: 3px dashed var(--muted); background: #fbfbf6; }
.entry--failed { border-left-color: var(--error); background: var(--error-bg); }

.entry__head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.entry__body { white-space: pre-wrap; word-break: break-word; }
.entry__error { color: var(--error); font-size: 13px; margin: 8px 0 0; font-weight: 500; }
.entry .by { color: var(--muted); font-size: 12px; margin-top: 8px; }

.pager { display: flex; gap: 10px; justify-content: center; margin: 24px 0; }
.pager a, .pager span { padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); text-decoration: none; color: var(--ink); font-size: 14px; }
.pager span { color: var(--muted); }

.empty { text-align: center; color: var(--muted); padding: 50px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }

.login-card { max-width: 380px; margin: 60px auto; }

/* ---------------------------------------------------------------- footer */

.footer { margin: 60px 0 40px; color: var(--muted); font-size: 13px; }

@media (max-width: 640px) {
  h1 { font-size: 23px; }
  form { padding: 20px; }
  .meta { grid-template-columns: 1fr; gap: 2px 0; }
  .meta dd { margin-bottom: 10px; }
  table { display: block; overflow-x: auto; }
}
