/* Miles2Smile File Transfer — Production Design System */
:root {
  color-scheme: light;
  --canvas: #f7f6ef;
  --paper: #fffefa;
  --ink: #242a20;
  --muted: #50594b;
  --line: #dcded1;
  --green: #294733;
  --green-light: #edf2e8;
  --yellow: #f7e5a5;
  --error: #8c382a;
  --error-light: #fbefe9;
  --radius: 20px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  overflow-x: hidden;
  max-width: 100%;
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

button, select {
  cursor: pointer;
}

button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible, main:focus-visible {
  outline: 3px solid #9b5c17;
  outline-offset: 4px;
}

.header-inner, .shell, .footer-inner {
  width: min(1080px, calc(100% - 56px));
  margin: auto;
  max-width: 100%;
}

/* Header */
.header {
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  width: 100%;
}

.header-inner {
  min-height: 87px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 750;
  letter-spacing: -0.035em;
  font-size: 21px;
  color: var(--ink);
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--yellow);
  font-size: 25px;
  color: var(--green);
  line-height: 1;
  flex-shrink: 0;
}

.header-caption {
  font-size: 14px;
  color: var(--muted);
  font-weight: 550;
  white-space: nowrap;
}

/* Main Shell */
.shell {
  padding: 60px 0 55px;
  flex: 1;
}

.intro {
  margin-bottom: 33px;
  max-width: 100%;
}

h1, h2, h3, p {
  margin: 0;
}

h1 {
  font-size: clamp(34px, 6.5vw, 70px);
  line-height: 1.06;
  font-weight: 720;
  letter-spacing: -0.06em;
  overflow-wrap: break-word;
  word-break: break-word;
}

.intro p {
  margin-top: 14px;
  color: var(--muted);
  font-size: 17px;
  max-width: 58ch;
  overflow-wrap: break-word;
}

/* Layout */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 2.1fr) minmax(245px, 1fr);
  gap: 25px;
  align-items: start;
  max-width: 100%;
}

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 30px;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: break-word;
}

.card h2 {
  font-size: 25px;
  letter-spacing: -0.04em;
  line-height: 1.22;
  margin-bottom: 9px;
  overflow-wrap: break-word;
}

.card p {
  color: var(--muted);
}

.card .description {
  max-width: 48ch;
  overflow-wrap: break-word;
}

/* Guidance Sidebar */
.aside {
  background: var(--green-light);
  padding: 27px;
}

.aside h2 {
  font-size: 21px;
  margin-bottom: 15px;
  color: var(--green);
  overflow-wrap: break-word;
}

.aside ul {
  margin: 0;
  list-style: none;
  padding: 0;
  display: grid;
  gap: 14px;
}

.aside li {
  display: grid;
  grid-template-columns: 21px 1fr;
  gap: 9px;
  color: #394b3c;
  font-size: 14px;
  overflow-wrap: break-word;
}

.aside li span {
  color: var(--green);
  font-weight: 700;
}

/* File Box */
.file-zone {
  margin-top: 21px;
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 18px;
  border: 1px solid var(--line);
  background: #f8f9f2;
  border-radius: 13px;
  max-width: 100%;
}

.file-zone.empty {
  border: 1px dashed #899b86;
}

.file-icon, .status-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 37px;
  height: 37px;
  background: var(--green-light);
  color: var(--green);
  border-radius: 9px;
  font-size: 21px;
  font-weight: 650;
}

.file-text {
  min-width: 0;
  flex: 1;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.file-text strong {
  display: block;
  overflow-wrap: anywhere;
  word-break: break-word;
  color: var(--ink);
}

.file-text small, .meta {
  font-size: 13px;
  color: var(--muted);
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Recipients List */
.recipients {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
  max-width: 100%;
}

.recipients li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding: 14px 0;
  max-width: 100%;
}

.recipients li:first-child {
  border-top: 1px solid var(--line);
}

.recipient-meta-block {
  min-width: 0;
  flex: 1 1 180px;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.recipient-meta-block strong {
  display: block;
  font-size: 15px;
  color: var(--ink);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.rcpt-progress-box {
  width: 100%;
  margin-top: 8px;
  max-width: 100%;
}

.recipients .actions {
  margin: 0;
  flex-shrink: 0;
}

/* Actions and Buttons */
.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 23px;
  max-width: 100%;
}

.button {
  min-height: 44px;
  font-weight: 650;
  font-size: 14px;
  padding: 9px 16px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--green);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
  text-decoration: none;
  max-width: 100%;
  white-space: normal;
  text-align: center;
}

.button.primary {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.button.primary:hover:not(:disabled) {
  background: #1f3828;
}

.button.secondary:hover:not(:disabled) {
  background: var(--green-light);
}

.button.danger {
  color: var(--error);
  border-color: #fca5a5;
  background: #fff;
}

.button.danger:hover:not(:disabled) {
  background: var(--error-light);
}

.button.danger.filled {
  background: var(--error);
  color: #fff;
  border-color: var(--error);
}

.button.danger.filled:hover:not(:disabled) {
  background: #732a1e;
}

.button:disabled {
  opacity: 0.55;
  cursor: default;
}

/* Expiry Badge */
.expiry {
  display: inline-flex;
  background: var(--yellow);
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 620;
  margin-top: 13px;
  color: #3b3a16;
  max-width: 100%;
  overflow-wrap: break-word;
}

.expiry.expired {
  background: #fee2e2;
  color: #8c382a;
}

.expiry.revoked {
  background: #e5eadf;
  color: #50594b;
}

/* Link Row */
.link-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 19px;
  max-width: 100%;
}

.link-row input {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8f9f2;
  color: var(--muted);
  font: 13px ui-monospace, monospace;
}

/* Status / Notice Box */
.status-box {
  display: flex;
  gap: 13px;
  align-items: flex-start;
  padding: 15px;
  border-radius: 13px;
  background: var(--green-light);
  margin-top: 20px;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.status-box > div {
  min-width: 0;
  flex: 1;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.status-box strong {
  display: block;
  color: var(--ink);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.status-box p {
  font-size: 14px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.status-box.error {
  background: var(--error-light);
}

.status-box.error .status-icon {
  background: #f1ddd2;
  color: var(--error);
}

.status-box.warning {
  background: #fef9c3;
}

.status-box.warning .status-icon {
  background: #fef08a;
  color: #854d0e;
}

/* Progress bar */
.progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-size: 14px;
  margin-top: 20px;
  color: var(--muted);
  max-width: 100%;
}

.rcpt-progress-box .progress-meta {
  margin-top: 8px;
  font-size: 13px;
}

.progress-meta strong {
  color: var(--ink);
  overflow-wrap: break-word;
}

progress {
  width: 100%;
  max-width: 100%;
  height: 12px;
  appearance: none;
  border: 0;
  border-radius: 100px;
  overflow: hidden;
  display: block;
  margin-top: 9px;
  background: #e5eadf;
}

progress::-webkit-progress-bar {
  background: #e5eadf;
}

progress::-webkit-progress-value {
  background: var(--green);
}

progress::-moz-progress-bar {
  background: var(--green);
}

/* Feedback text */
#feedback:empty {
  display: none;
}

#feedback {
  margin-top: 12px;
  font-size: 13px;
  overflow-wrap: break-word;
}

/* Confirmation Dialog */
dialog {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
  color: var(--ink);
  padding: 25px;
  width: min(430px, calc(100% - 32px));
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  max-width: 100%;
}

dialog::backdrop {
  background: #22282088;
}

dialog h2 {
  font-size: 20px;
  margin-bottom: 8px;
  overflow-wrap: break-word;
}

dialog p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: break-word;
}

/* Footer */
footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  background: var(--canvas);
  width: 100%;
}

.footer-inner {
  padding: 17px 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.diag-link {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  text-decoration: underline;
  padding: 0;
  cursor: pointer;
}

.diag-link:hover {
  color: var(--green);
}

/* Diagnostics Modal (kept accessible separately from main UI) */
dialog.diag-dialog {
  width: min(850px, calc(100% - 32px));
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
}

.diag-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
  margin-bottom: 20px;
}

.diag-header h2 {
  font-size: 21px;
  margin: 0;
}

.diag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.diag-stat-card {
  background: #f8f9f2;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.diag-stat-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.diag-stat-val {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  margin-top: 2px;
  overflow-wrap: break-word;
}

.diag-report-text {
  width: 100%;
  min-height: 200px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  padding: 12px;
  background: #f8f9f2;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  resize: vertical;
}

.diag-config-row {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 12px;
  background: #f8f9f2;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.diag-config-row label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.diag-config-row select, .diag-config-row input {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  max-width: 100%;
}

/* Utility */
.hidden {
  display: none !important;
}

/* Responsive Media Queries */
@media (max-width: 720px) {
  .header-inner, .shell, .footer-inner {
    width: calc(100% - 32px);
  }
  .header-inner {
    min-height: 68px;
  }
  .shell {
    padding-top: 35px;
    padding-bottom: 30px;
  }
  .intro {
    margin-bottom: 23px;
  }
  .layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 15px;
  }
  .card {
    padding: 20px;
  }
  .intro p {
    font-size: 15px;
  }
  .link-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 360px) {
  .header-inner, .shell, .footer-inner {
    width: calc(100% - 24px);
  }
  .card {
    padding: 16px;
  }
  .aside {
    padding: 18px 16px;
  }
  .header-caption {
    display: none;
  }
  .brand {
    font-size: 19px;
  }
  .file-zone {
    align-items: flex-start;
    flex-wrap: wrap;
    padding: 14px;
    gap: 10px;
  }
  .file-text {
    min-width: 0;
    width: calc(100% - 47px);
  }
  .recipients .actions {
    width: 100%;
    display: flex;
    gap: 8px;
  }
  .recipients .actions .button {
    flex: 1;
    min-width: 0;
    padding: 9px 8px;
    font-size: 13px;
  }
}
