:root {
  color-scheme: dark;
  --j-bg: #080b13;
  --j-panel: #0e1421;
  --j-panel-raised: #131c2d;
  --j-line: rgba(143, 165, 211, .17);
  --j-text: #edf1fa;
  --j-muted: #929db3;
  --j-blue: #7397ff;
  --j-blue-dark: #315bc1;
  --j-gold: #e0b65c;
  --j-green: #84c9ac;
  --j-red: #e19a9b;
  --j-mono: 'DM Mono', 'SFMono-Regular', Consolas, monospace;
  --j-body: 'Sarabun', Tahoma, sans-serif;
  --j-display: 'Bebas Neue', Impact, 'Arial Narrow', sans-serif;
  --j-radius: 18px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--j-bg); }
body {
  min-height: 100dvh; margin: 0; color: var(--j-text); font-family: var(--j-body);
  background: radial-gradient(ellipse at 10% -10%, rgba(69, 99, 177, .18), transparent 34%),
    linear-gradient(180deg, #0b101b 0%, var(--j-bg) 55%);
}
button, input, select, textarea { font: inherit; }
button, input, select, textarea { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 2px solid var(--j-blue); outline-offset: 3px;
}
[hidden] { display: none !important; }

.journal-shell { width: min(1540px, calc(100% - 48px)); margin: 0 auto; padding: 28px 0 36px; }
.j-header {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 3px 0 22px; border-bottom: 1px solid var(--j-line);
}
.j-brand { color: var(--j-text); text-decoration: none; font: 1.45rem var(--j-display); letter-spacing: .1em; }
.j-brand span { color: var(--j-gold); }
.j-brandline { display: flex; align-items: center; gap: 12px; }
.j-brand-sub { color: #76839d; font: .57rem var(--j-mono); letter-spacing: .15em; }
.j-secure { display: inline-flex; align-items: center; gap: 9px; color: #9ba8c0; font: .59rem var(--j-mono); letter-spacing: .1em; }
.j-secure::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--j-green); box-shadow: 0 0 0 4px rgba(132,201,172,.1); }

.j-intro { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 380px); gap: 35px; align-items: end; padding: 31px 0 24px; }
.j-eyebrow { color: var(--j-blue); font: .61rem var(--j-mono); letter-spacing: .18em; text-transform: uppercase; }
.j-intro h1 { margin: 10px 0 8px; font: 700 clamp(2.1rem, 4vw, 3.6rem)/1.4 var(--j-body); letter-spacing: normal; }
.j-intro p { max-width: 760px; margin: 12px 0 0; color: #a6b1c7; font-size: .9rem; line-height: 1.75; }
.j-disclaimer { padding: 13px 15px; border-left: 2px solid rgba(224,182,92,.75); background: rgba(224,182,92,.055); color: #b5b2ae; font-size: .72rem; line-height: 1.75; }
.j-disclaimer strong { color: #e5c47d; }

.j-gate, .j-alert {
  border: 1px solid var(--j-line); border-radius: var(--j-radius); background: var(--j-panel);
}
.j-gate { padding: clamp(24px, 5vw, 48px); max-width: 780px; margin: 34px auto 70px; text-align: center; }
.j-gate-mark { width: 42px; height: 42px; margin: 0 auto 15px; display: grid; place-items: center; border: 1px solid rgba(115,151,255,.42); color: #a8bcff; font: 1.5rem var(--j-display); transform: skew(-5deg); }
.j-gate h2 { margin: 0 0 7px; font: 400 1.8rem var(--j-display); letter-spacing: .06em; }
.j-gate p { margin: 0 auto 20px; max-width: 35rem; color: var(--j-muted); font-size: .84rem; line-height: 1.8; }
.j-gate a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 9px 18px; border: 1px solid #4d7fff; border-radius: 11px; background: #315bc1; color: white; font-size: .81rem; font-weight: 700; text-decoration: none; }
.j-gate a:hover { background: #4073df; }

.j-statusline { display: flex; align-items: center; gap: 9px; min-height: 31px; color: var(--j-muted); font-size: .75rem; }
.j-status-dot { width: 6px; height: 6px; border-radius: 50%; background: #74809a; }
.j-statusline[data-state="dirty"] .j-status-dot { background: var(--j-gold); }
.j-statusline[data-state="saved"] .j-status-dot { background: var(--j-green); }
.j-statusline[data-state="error"] .j-status-dot { background: var(--j-red); }
.j-statusline[data-state="busy"] .j-status-dot { background: var(--j-blue); }
.j-alert { margin: 8px 0 14px; padding: 11px 14px; color: #e3b7a5; font-size: .78rem; line-height: 1.65; border-color: rgba(225,154,155,.3); background: rgba(96,32,42,.16); }

.j-top-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(370px, .95fr); gap: 16px; }
.j-hero, .j-controls, .j-panel, .j-metric {
  border: 1px solid var(--j-line); border-radius: var(--j-radius);
  background: linear-gradient(145deg, rgba(23,34,56,.86), rgba(13,19,31,.98) 65%);
  box-shadow: 0 18px 50px rgba(0,0,0,.17), inset 0 1px rgba(210,222,255,.025);
}
.j-hero { position: relative; overflow: hidden; padding: clamp(22px, 3vw, 34px); }
.j-hero::after { content: ''; position: absolute; width: 300px; height: 300px; right: -128px; top: -150px; border-radius: 50%; border: 1px solid rgba(115,151,255,.13); box-shadow: 0 0 0 26px rgba(115,151,255,.025), 0 0 0 54px rgba(115,151,255,.02); pointer-events: none; }
.j-hero h2 { position: relative; margin: 5px 0 9px; font-weight: 600; font-size: clamp(1.3rem, 2.1vw, 2rem); }
.j-moneyline { color: #a9bdff; font: clamp(1.75rem, 4vw, 3.3rem)/1.1 var(--j-display); letter-spacing: .045em; overflow-wrap: anywhere; }
.j-subline { margin-top: 10px; color: #b4bfd2; font-size: .87rem; }
.j-subline strong { color: var(--j-green); font: 500 1.1rem var(--j-mono); }
.j-quote { margin: 14px 0 0; color: #8492ac; font-size: .76rem; }
.j-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; margin-top: 25px; }
.j-metric { min-width: 0; padding: 12px; border-radius: 13px; background: rgba(6,10,18,.42); box-shadow: none; }
.j-metric small { display: block; color: #8794ad; font-size: .66rem; line-height: 1.5; }
.j-metric strong { display: block; margin-top: 6px; color: #e6ecfb; font: 1.15rem var(--j-mono); overflow-wrap: anywhere; }
.j-metric:nth-child(2) strong { color: var(--j-green); }

.j-controls { padding: 20px; }
.j-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 15px; }
.j-section-heading h2, .j-panel-head { margin: 0; font-size: .96rem; font-weight: 700; }
.j-section-heading span { color: #7f8da7; font: .56rem var(--j-mono); letter-spacing: .1em; }
.j-control-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 11px; }
.j-field { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.j-field.full { grid-column: 1 / -1; }
.j-field label { color: #c2cce0; font-size: .72rem; font-weight: 600; }
.j-field input, .j-field select, .j-table select, .j-table input {
  width: 100%; min-width: 0; min-height: 40px; padding: 8px 10px; border: 1px solid rgba(143,165,211,.2);
  border-radius: 9px; background: #090e18; color: #edf1fa; font-size: .8rem;
}
.j-field input:focus, .j-field select:focus, .j-table select:focus, .j-table input:focus { border-color: rgba(115,151,255,.75); outline: none; }
.j-field :disabled { opacity: .58; }
.j-field:has(:disabled) { opacity: .72; }
.j-action-row { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 15px; }
.j-action-row button { min-height: 42px; padding: 9px 14px; border: 1px solid rgba(115,151,255,.42); border-radius: 10px; background: #315bc1; color: white; font-size: .77rem; font-weight: 700; cursor: pointer; transition: transform .18s ease, background-color .18s ease; }
.j-action-row button:hover:not(:disabled) { background: #4073df; transform: translateY(-1px); }
.j-action-row button.secondary { border-color: rgba(143,165,211,.22); background: #111a2b; color: #bdc9e1; }
.j-action-row button.danger { border-color: rgba(225,154,155,.35); background: rgba(96,32,42,.28); color: #e9b6b7; }
.j-action-row button:disabled { opacity: .48; cursor: not-allowed; }
.j-method { margin: 13px 0 0; padding: 11px 12px; border: 1px dashed rgba(143,165,211,.2); border-radius: 10px; color: #98a5bc; font-size: .7rem; line-height: 1.7; }
.j-method strong { color: #bdc9e1; }

.j-main { display: grid; gap: 16px; margin-top: 17px; }
.j-banner { padding: 13px 16px; border: 1px solid rgba(115,151,255,.21); border-radius: 14px; background: linear-gradient(100deg, rgba(43,70,132,.57), rgba(20,31,53,.4)); color: #c2d0f0; text-align: center; font-size: .8rem; font-weight: 600; }
.j-table-wrap { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
.j-panel { min-width: 0; overflow: hidden; }
.j-panel-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 13px 15px; border-bottom: 1px solid var(--j-line); background: rgba(50,75,132,.2); }
.j-pill { padding: 4px 8px; border: 1px solid rgba(115,151,255,.23); border-radius: 30px; background: rgba(115,151,255,.08); color: #aebfff; font: .57rem var(--j-mono); white-space: nowrap; }
.j-table-scroll { overflow: auto; max-height: 690px; scrollbar-color: #394a70 #111827; }
.j-table { width: 100%; border-collapse: collapse; font-size: .68rem; }
.j-table th, .j-table td { min-width: 59px; padding: 8px 6px; border-bottom: 1px solid rgba(143,165,211,.11); text-align: center; vertical-align: middle; }
.j-table th { position: sticky; top: 0; z-index: 1; background: #131d30; color: #aab9d9; font-size: .62rem; line-height: 1.4; font-weight: 600; }
.j-table td { color: #b8c3d7; font-family: var(--j-mono); font-size: .66rem; }
.j-table tbody tr { cursor: pointer; }
.j-table tbody tr:nth-child(even) { background: rgba(255,255,255,.012); }
.j-table tbody tr.warn { background: rgba(51,94,165,.10); }
.j-table tbody tr.danger { background: rgba(51,94,165,.18); }
.j-table tbody tr.pass-row { background: rgba(39,102,78,.2); }
.j-table tbody tr.be-row { background: rgba(77,92,116,.16); }
.j-table tbody tr.loss-row { background: rgba(117,38,48,.17); }
.j-table tbody tr.pass-row td { color: #9bd7ba; }
.j-table tbody tr.pass-row td:nth-child(7) { color: #a9bdff; }
.j-table input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; accent-color: #75bd9d; cursor: pointer; }
.j-table select { min-height: 33px; padding: 5px 6px; font: .68rem var(--j-body); }
.j-table input.result-note { min-width: 112px; min-height: 33px; padding: 5px 7px; font: .68rem var(--j-body); }
.j-table th:nth-child(9), .j-table td:nth-child(9) { display: none; }
.j-table .j-day-note-button {
  appearance: none;
  border: 0;
  padding: 0;
  background: transparent;
  color: #e4eaf7;
  font: 600 .72rem/1.2 var(--j-body);
  cursor: pointer;
}
.j-table .j-day-note-button:hover { color: #aebfff; }
.j-table .j-day-note-button.has-note,
.j-table td.has-note .j-day-note-button { position: relative; }
.j-table .j-day-note-button.has-note::after,
.j-table td.has-note .j-day-note-button::after {
  content: '';
  position: absolute;
  top: -3px;
  right: -6px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--j-gold);
}
.j-note-dialog {
  width: min(520px, calc(100% - 32px));
  max-width: 520px;
  max-height: min(82dvh, 720px);
  padding: 24px;
  border: 1px solid rgba(143,165,211,.28);
  border-radius: 18px;
  background: linear-gradient(145deg, #172238, #0d131f 72%);
  color: var(--j-text);
  box-shadow: 0 24px 80px rgba(0,0,0,.55), inset 0 1px rgba(210,222,255,.04);
}
.j-note-dialog::backdrop { background: rgba(4,7,13,.76); backdrop-filter: blur(4px); }
.j-note-dialog h2 { margin: 0 0 14px; font: 400 1.45rem var(--j-display); letter-spacing: .045em; }
.j-note-dialog textarea {
  display: block;
  width: 100%;
  min-height: 210px;
  resize: vertical;
  padding: 13px 14px;
  border: 1px solid rgba(143,165,211,.27);
  border-radius: 11px;
  background: #090e18;
  color: #edf1fa;
  font: .92rem/1.75 var(--j-body);
}
.j-note-dialog p { margin: 10px 0 18px; color: var(--j-muted); font-size: .75rem; line-height: 1.7; }
.j-note-dialog button {
  min-width: 86px;
  min-height: 44px;
  padding: 9px 16px;
  border: 1px solid rgba(115,151,255,.48);
  border-radius: 10px;
  background: #315bc1;
  color: #fff;
  font-size: .8rem;
  font-weight: 700;
  cursor: pointer;
}
.j-note-dialog button:hover { background: #4073df; }
.j-bottom-grid { display: grid; grid-template-columns: 1.05fr .95fr 1fr; gap: 16px; }
.j-panel-content { padding: 16px; }
.j-guidelines { margin: 0; padding-left: 18px; color: #b3bfd3; font-size: .77rem; line-height: 1.85; }
.j-lot-table { width: 100%; border-collapse: collapse; font-size: .76rem; }
.j-lot-table th, .j-lot-table td { padding: 8px; border-bottom: 1px solid rgba(143,165,211,.11); text-align: left; }
.j-lot-table th { color: #8290aa; font-size: .67rem; font-weight: 500; }
.j-lot-table td:last-child { color: #bacaff; font-family: var(--j-mono); }
.j-summary-lines { display: grid; gap: 10px; color: #aab7cd; font-size: .77rem; }
.j-summary-lines span { display: flex; justify-content: space-between; gap: 12px; }
.j-summary-lines b:last-child { color: #dce5f7; font: 500 .75rem var(--j-mono); text-align: right; }
.j-summary-quote { margin-top: 16px; padding: 13px; border-top: 1px solid var(--j-line); color: #aab9dc; font-size: .75rem; line-height: 1.7; text-align: center; }
.j-footer { padding: 4px 0; color: #71809b; font: .56rem var(--j-mono); letter-spacing: .13em; text-align: center; }
.j-footer em { color: #a9b8db; font-style: normal; }
.j-actual-note { margin: 0; padding: 12px 15px; border: 1px solid rgba(132,201,172,.16); border-radius: 12px; background: rgba(36,89,68,.09); color: #a8b9b1; font-size: .72rem; line-height: 1.7; }
.j-actual-note strong { color: #9cd7ba; }
.j-skeleton { min-height: 160px; overflow: hidden; position: relative; border-radius: var(--j-radius); background: #111a29; }
.j-skeleton::after { content: ''; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(206,220,255,.045), transparent); animation: j-shimmer 1.5s infinite; }
@keyframes j-shimmer { to { transform: translateX(100%); } }
@keyframes j-enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.j-editor { animation: j-enter .35s ease both; }

@media (max-width: 1000px) {
  .j-top-grid { grid-template-columns: 1fr; }
  .j-table-wrap, .j-bottom-grid { grid-template-columns: 1fr; }
}
@media (max-width: 650px) {
  .journal-shell { width: calc(100% - 28px); padding-top: 17px; }
  .j-header { padding-bottom: 15px; }
  .j-brand-sub, .j-secure { font-size: .49rem; }
  .j-intro { grid-template-columns: 1fr; gap: 15px; padding: 24px 0 19px; }
  .j-intro h1 { font-size: clamp(1.75rem, 7.8vw, 2.1rem); line-height: 1.5; }
  .j-intro p { font-size: .82rem; }
  .j-summary { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .j-controls { padding: 16px; }
  .j-control-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .j-field label { min-height: 2em; }
  .j-action-row button { flex: 1 1 calc(50% - 9px); }
  .j-action-row button:first-child { flex-basis: 100%; }
}

/* Compact, complete table layout on narrow screens. */
@media (max-width: 820px) {
  .journal-shell { padding-bottom: calc(112px + env(safe-area-inset-bottom, 0px)); }
  .j-editor { animation: none; }
  .j-action-row {
    position: fixed;
    z-index: 20;
    left: 14px;
    right: 14px;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    margin: 0 auto;
    max-width: 620px;
    padding: 8px;
    gap: 6px;
    border: 1px solid var(--j-line);
    border-radius: 14px;
    background: rgba(13,19,31,.97);
    box-shadow: 0 8px 30px rgba(0,0,0,.35);
  }
  .j-action-row button,
  .j-action-row button:first-child {
    flex: 1 1 0;
    min-height: 48px;
    padding: 9px 4px;
    white-space: nowrap;
  }
  .j-table-scroll {
    max-height: none;
    overflow-x: hidden;
    overflow-y: visible;
  }
  .j-table {
    width: 100%;
    min-width: 0;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: .61rem;
  }
  .j-table th, .j-table td {
    min-width: 0;
    padding: 5px 2px;
    overflow-wrap: anywhere;
    word-break: normal;
  }
  .j-table th {
    font-size: .56rem;
    line-height: 1.3;
  }
  .j-table td {
    font-size: .58rem;
    line-height: 1.3;
  }
  .j-table th:nth-child(1), .j-table td:nth-child(1) { width: 7%; }
  .j-table th:nth-child(2), .j-table td:nth-child(2) { width: 9%; }
  .j-table th:nth-child(3), .j-table td:nth-child(3) { width: 14%; }
  .j-table th:nth-child(4), .j-table td:nth-child(4) { width: 14%; }
  .j-table th:nth-child(5), .j-table td:nth-child(5) { width: 16%; }
  .j-table th:nth-child(6), .j-table td:nth-child(6) { width: 10%; }
  .j-table th:nth-child(7), .j-table td:nth-child(7) { width: 11%; }
  .j-table th:nth-child(8), .j-table td:nth-child(8) { width: 19%; }
  .j-table input[type="checkbox"] {
    display: inline-block;
    width: 16px;
    height: 16px;
    min-height: 0;
    padding: 0;
    margin: 0;
    vertical-align: middle;
    accent-color: #75bd9d;
  }
  .j-table .j-day-note-button {
    display: inline-flex;
    width: 100%;
    min-width: 0;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    font-size: .62rem;
    white-space: normal;
  }
  .j-table select {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 4px 2px;
    border-radius: 7px;
    font: .61rem/1.2 var(--j-body);
  }
  .j-table input.result-note {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 5px 4px;
    font: .66rem/1.25 var(--j-body);
  }
  .j-note-dialog textarea { font-size: 16px; }
}

@media (max-width: 420px) {
  .j-table th, .j-table td { padding: 4px 1px; }
  .j-table th { font-size: .53rem; }
  .j-table td { font-size: .55rem; }
  .j-table select { padding-inline: 1px; font-size: .58rem; }
  .j-note-dialog { padding: 19px; }
  .j-note-dialog textarea { min-height: 190px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
