@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display&display=swap');

:root {
  color-scheme: light;
  --paper: #f4f4ee;
  --surface: #fffefa;
  --ink: #202823;
  --muted: #68716a;
  --line: #d8ddd4;
  --accent: #bc573d;
  --accent-dark: #963e2a;
  --green: #567b62;
  --error: #9b342b;
  font-family: 'Source Sans 3', 'Trebuchet MS', sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background-color: var(--paper);
  background-image: linear-gradient(90deg, transparent 0 49.9%, rgba(46, 70, 52, .045) 50%, transparent 50.1%), repeating-linear-gradient(0deg, transparent 0 47px, rgba(46, 70, 52, .035) 48px, transparent 49px);
}

a { color: inherit; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #c37551; outline-offset: 3px; }

.site-header, .site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(100% - 56px, 1200px);
  margin-inline: auto;
}
.site-header { min-height: 82px; border-bottom: 1px solid rgba(32, 40, 35, .15); }
.site-logo { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.site-logo img { display: block; width: 150px; height: auto; }
.logo-icon { width: 26px; height: 26px; flex: 0 0 auto; overflow: visible; }
.logo-icon path, .logo-icon rect { fill: currentColor; }
.logo-icon path { fill: none; }
.logo-outline-large { stroke: currentColor; stroke-width: 8; }
.logo-outline-small, .logo-layer-small { display: none; }
.logo-outline-small { stroke: currentColor; stroke-width: 10; }
.logo-wordmark { width: 119.595px; height: 17px; flex: 0 0 auto; fill: currentColor; }
.back-link { color: var(--muted); font-size: 15px; text-decoration-thickness: 1px; text-underline-offset: 4px; }
.back-link:hover { color: var(--ink); }

.auth-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 430px);
  align-items: center;
  gap: clamp(48px, 9vw, 140px);
  width: min(100% - 56px, 1080px);
  min-height: calc(100vh - 150px);
  margin: 0 auto;
  padding: 58px 0 76px;
}
.intro { max-width: 540px; animation: arrive .55s ease-out both; }
.eyebrow { margin: 0; color: var(--green); font-size: 12px; font-weight: 700; letter-spacing: 0; }
.intro h1 { max-width: 530px; margin: 18px 0 16px; font-family: 'DM Serif Display', Georgia, serif; font-size: 56px; font-weight: 400; line-height: 1.02; }
.intro-copy { max-width: 400px; margin: 0; color: var(--muted); font-size: 19px; line-height: 1.55; }
.privacy-note { display: flex; align-items: center; gap: 10px; margin-top: 42px; color: var(--muted); font-size: 14px; }
.status-dot { width: 9px; height: 9px; flex: 0 0 9px; border-radius: 50%; background: #6d906f; box-shadow: 0 0 0 4px rgba(109, 144, 111, .13); }

.auth-panel {
  min-height: 400px;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 22px 60px rgba(38, 49, 40, .08);
  animation: arrive .55s .08s ease-out both;
}
.panel-topline { display: flex; align-items: center; justify-content: space-between; margin-bottom: 34px; }
.panel-mark { display: grid; width: 36px; height: 36px; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--accent); font-size: 11px; font-weight: 700; }
.auth-panel h2 { margin: 0; font-family: 'DM Serif Display', Georgia, serif; font-size: 32px; font-weight: 400; line-height: 1.15; }
.panel-copy { margin: 9px 0 24px; color: var(--muted); font-size: 15px; line-height: 1.5; }
.auth-form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; color: #343d36; font-size: 14px; font-weight: 600; }
.field input { width: 100%; min-height: 48px; padding: 10px 12px; border: 1px solid #cbd1c9; border-radius: 3px; color: var(--ink); background: #fff; font-size: 16px; }
.field input::placeholder { color: #929a93; }
.field input:focus { border-color: var(--green); outline: 2px solid rgba(86, 123, 98, .2); }
.primary-button { min-height: 48px; margin-top: 3px; padding: 11px 18px; border: 0; border-radius: 3px; color: #fff; background: var(--accent); font-size: 16px; font-weight: 700; cursor: pointer; transition: background-color .16s ease, transform .16s ease; }
.primary-button:hover:not(:disabled) { transform: translateY(-1px); background: var(--accent-dark); }
.primary-button:disabled { cursor: wait; opacity: .65; }
.text-button { padding: 0; border: 0; color: var(--accent-dark); background: none; font-size: 14px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.text-button:hover { color: var(--ink); }
.form-links { display: flex; justify-content: space-between; gap: 12px; margin-top: 4px; }
.mode-switch { margin: 22px 0 0; color: var(--muted); font-size: 14px; }
.mode-switch .text-button { margin-left: 4px; }
.feedback { margin: 18px 0 0; padding: 10px 12px; border-left: 3px solid var(--error); color: var(--error); background: #fbefec; font-size: 14px; line-height: 1.45; }
.feedback.success { border-color: var(--green); color: #365942; background: #edf4eb; }
.loading-state { margin: 42px 0; color: var(--muted); }
.account-email { overflow-wrap: anywhere; color: var(--green); font-weight: 600; }
.account-state { display: flex; align-items: center; gap: 11px; margin: 28px 0; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.account-state .status-dot { background: var(--green); }
.account-actions { display: grid; gap: 18px; margin-top: 28px; }
.site-footer { min-height: 68px; border-top: 1px solid rgba(32, 40, 35, .15); color: var(--muted); font-size: 13px; }
.footer-brand img { display: block; width: 140px; height: auto; }

@keyframes arrive { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 760px) {
  .site-header, .site-footer { width: min(100% - 36px, 560px); }
  .site-header { min-height: 68px; }
  .site-logo { gap: 9px; }
  .site-logo img { width: 132px; }
  .logo-icon { width: 20px; height: 20px; }
  .logo-outline-large, .logo-layer-large { display: none; }
  .logo-outline-small, .logo-layer-small { display: initial; }
  .logo-wordmark { width: 91.455px; height: 13px; }
  .auth-layout { grid-template-columns: 1fr; gap: 30px; width: min(100% - 36px, 500px); min-height: auto; padding: 44px 0 56px; }
  .intro h1 { max-width: 430px; font-size: 44px; }
  .intro-copy { font-size: 17px; }
  .privacy-note { margin-top: 20px; }
  .auth-panel { min-height: 0; padding: 25px 22px; }
  .panel-topline { margin-bottom: 26px; }
  .site-footer { min-height: 58px; }
}

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

.auth-layout.is-dashboard {
  display: block;
  width: min(100% - 56px, 1200px);
  min-height: 0;
  padding: 38px 0 64px;
}
.auth-layout.is-dashboard .intro,
.auth-layout.is-dashboard .panel-topline { display: none; }
.auth-layout.is-dashboard .auth-panel {
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  animation: none;
}
.manage-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; padding-bottom: 27px; border-bottom: 1px solid var(--line); }
.manage-heading h2 { margin: 7px 0 5px; font-family: 'DM Serif Display', Georgia, serif; font-size: 36px; font-weight: 400; line-height: 1.1; }
.manage-heading p, .section-heading p { margin: 0; color: var(--muted); font-size: 15px; }
.manage-account-line { display: flex; justify-content: space-between; gap: 16px; padding: 14px 0; color: var(--muted); font-size: 13px; }
.manage-account-line strong { color: var(--ink); font-weight: 600; }
.manage-account-line code, .system-entry code { color: var(--ink); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }
.manage-tabs { display: flex; gap: 28px; border-bottom: 1px solid var(--line); }
.manage-tabs button { display: flex; align-items: center; gap: 9px; min-height: 50px; padding: 0 2px; border: 0; border-bottom: 3px solid transparent; color: var(--muted); background: transparent; font-weight: 600; cursor: pointer; }
.manage-tabs button.is-selected { border-bottom-color: var(--accent); color: var(--ink); }
.manage-tabs button span { display: grid; min-width: 22px; height: 22px; place-items: center; padding: 0 6px; border-radius: 12px; color: var(--muted); background: #e9ece6; font-size: 12px; }
.manage-section { padding-top: 28px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.section-heading h3 { margin: 0 0 5px; color: var(--ink); font-family: 'DM Serif Display', Georgia, serif; font-size: 27px; font-weight: 400; }
.primary-button, .secondary-button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 9px 15px; border: 1px solid transparent; border-radius: 3px; font-size: 14px; font-weight: 700; text-decoration: none; cursor: pointer; transition: background-color .16s ease, border-color .16s ease; }
.primary-button { color: #fff; background: var(--accent); }
.primary-button:hover:not(:disabled) { background: var(--accent-dark); }
.secondary-button { border-color: var(--line); color: var(--ink); background: #fffefa; }
.secondary-button:hover:not(:disabled) { border-color: #9ea99e; background: #f5f6f1; }
.primary-button:disabled, .secondary-button:disabled { cursor: wait; opacity: .6; }
.sign-out-button { flex: 0 0 auto; }
.manage-table-wrap { overflow-x: auto; border-top: 1px solid var(--line); }
.manage-table { width: 100%; border-collapse: collapse; text-align: left; }
.manage-table th { padding: 12px 14px; color: var(--muted); background: rgba(255,255,255,.5); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.manage-table td { padding: 16px 14px; border-top: 1px solid var(--line); color: var(--ink); font-size: 14px; }
.manage-table td strong { font-weight: 600; overflow-wrap: anywhere; }
.manage-status { display: inline-flex; align-items: center; min-height: 24px; padding: 2px 9px; border-radius: 12px; font-size: 12px; font-weight: 700; }
.manage-status.is-active { color: #365942; background: #e6efe6; }
.manage-status.is-inactive { color: #68716a; background: #eceeea; }
.manage-row-actions { display: flex; flex-wrap: wrap; gap: 14px; }
.icon-action, .text-button { padding: 0; border: 0; color: var(--accent-dark); background: none; font-size: 13px; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.icon-action:hover, .text-button:hover { color: var(--ink); }
.manage-empty { padding: 34px 0; border-top: 1px solid var(--line); color: var(--muted); }
.manage-empty h3, .system-empty h3, .system-entry h3 { margin: 0 0 7px; color: var(--ink); font-family: 'DM Serif Display', Georgia, serif; font-size: 24px; font-weight: 400; }
.manage-empty p, .system-empty p { margin: 0; font-size: 14px; }
.system-limit-label { color: var(--muted); font-size: 13px; }
.system-empty, .system-entry { display: flex; align-items: center; justify-content: space-between; gap: 26px; padding: 25px; border: 1px solid var(--line); background: rgba(255,254,250,.78); }
.system-empty .eyebrow, .system-entry .eyebrow { display: block; margin-bottom: 8px; }
.system-entry { align-items: stretch; justify-content: flex-start; }
.system-entry-image { display: grid; width: 190px; min-height: 145px; flex: 0 0 190px; place-items: center; overflow: hidden; background: #e9ece6; color: var(--green); font-size: 20px; font-weight: 700; }
.system-entry-image img { width: 100%; height: 100%; min-height: 145px; object-fit: cover; }
.system-entry-details { flex: 1 1 auto; min-width: 0; padding: 5px 0; }
.system-entry-details h3 { overflow-wrap: anywhere; }
.system-entry-details > a { display: inline-block; max-width: 100%; overflow-wrap: anywhere; color: var(--green); font-size: 14px; text-underline-offset: 3px; }
.system-entry-details p { margin: 13px 0 0; color: var(--muted); font-size: 13px; }
.system-entry-details .tunnel-status { margin-top: 5px; }
.tunnel-status-error { display: block; margin-top: 3px; color: var(--error); font-size: 12px; overflow-wrap: anywhere; }
.tunnel-status-error[hidden] { display: none; }
.system-entry-actions { display: flex; flex: 0 0 auto; flex-direction: column; align-items: flex-end; justify-content: center; gap: 13px; }
.manage-notice, .manage-error { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 14px 0; padding: 12px 14px; border-left: 3px solid var(--green); color: #365942; background: #edf4eb; font-size: 14px; }
.manage-error { border-color: var(--error); color: var(--error); background: #fbefec; }
.manage-error p { flex: 1; margin: 0; }
.notice-dismiss { display: grid; width: 30px; height: 30px; flex: 0 0 auto; place-items: center; padding: 0; border: 0; color: var(--muted); background: transparent; font-size: 22px; line-height: 1; cursor: pointer; }
.loading-state { text-align: center; }
.manage-modal { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; overflow-y: auto; padding: 24px; background: rgba(24, 31, 26, .55); }
.manage-dialog { width: min(100%, 520px); max-height: min(90vh, 860px); overflow-y: auto; padding: 28px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); box-shadow: 0 24px 70px rgba(22, 30, 24, .24); animation: arrive .18s ease-out both; }
.manage-dialog-wide { width: min(100%, 840px); }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.dialog-heading h2 { margin: 6px 0 0; font-family: 'DM Serif Display', Georgia, serif; font-size: 30px; font-weight: 400; line-height: 1.1; }
.manage-form { display: grid; gap: 17px; }
.manage-form label { display: grid; gap: 6px; color: #343d36; font-size: 13px; font-weight: 700; }
.manage-form input:not([type="checkbox"]), .manage-form select { width: 100%; min-height: 44px; padding: 9px 11px; border: 1px solid #cbd1c9; border-radius: 3px; color: var(--ink); background: #fff; font-size: 15px; font-weight: 400; }
.manage-form input:disabled, .manage-form input[readonly] { color: var(--muted); background: #f1f2ed; }
.manage-form small { color: var(--muted); font-size: 12px; font-weight: 400; line-height: 1.4; }
.manage-form .check-field { display: flex; align-items: center; gap: 9px; font-weight: 500; }
.manage-form .check-field input, .manage-permissions input { width: 16px; height: 16px; accent-color: var(--green); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px 18px; }
.manage-permissions { margin: 0; padding: 14px; border: 1px solid var(--line); }
.manage-permissions legend { padding: 0 6px; color: var(--ink); font-size: 13px; font-weight: 700; }
.manage-permissions > div { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.manage-permissions label { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 500; text-transform: capitalize; }
.system-mode { padding: 12px; background: #eef1eb; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 17px; border-top: 1px solid var(--line); }
.modal-feedback { display: none; margin: 0; padding: 10px 12px; border-left: 3px solid var(--error); color: var(--error); background: #fbefec; font-size: 13px; line-height: 1.45; }
.modal-feedback:not(:empty) { display: block; }

@media (max-width: 760px) {
  .auth-layout.is-dashboard { width: min(100% - 36px, 560px); padding: 28px 0 48px; }
  .manage-heading h2 { font-size: 32px; }
  .manage-account-line { flex-direction: column; gap: 6px; }
  .section-heading { align-items: flex-start; }
  .manage-table thead { display: none; }
  .manage-table, .manage-table tbody, .manage-table tr, .manage-table td { display: block; width: 100%; }
  .manage-table tr { padding: 12px 0; border-top: 1px solid var(--line); }
  .manage-table td { display: flex; justify-content: space-between; gap: 12px; padding: 6px 2px; border: 0; text-align: right; }
  .manage-table td::before { content: attr(data-label); flex: 0 0 auto; color: var(--muted); font-size: 12px; }
  .manage-row-actions { justify-content: flex-end; }
  .system-entry { flex-wrap: wrap; padding: 16px; }
  .system-entry-image { width: 100%; min-height: 170px; flex-basis: 100%; }
  .system-entry-image img { min-height: 170px; }
  .system-entry-actions { flex-direction: row; align-items: center; justify-content: flex-start; }
  .form-grid { grid-template-columns: 1fr; }
  .manage-dialog { padding: 21px 18px; }
  .manage-permissions > div { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 420px) {
  .manage-heading { align-items: center; gap: 10px; }
  .manage-heading p { max-width: 230px; }
  .sign-out-button { padding-inline: 10px; }
  .manage-notice { align-items: flex-start; flex-wrap: wrap; }
  .system-empty { align-items: flex-start; flex-direction: column; padding: 19px; }
}
