/* Ensure [hidden] always hides elements (badges etc.) */
[hidden] { display: none !important; }

/* Dark theme and layout styles */
html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background-color: #121212;
    color: #e0e0e0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow-x: hidden; /* Prevent page-wide horizontal scrolling */
}

.app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    box-sizing: border-box;
}


/* Top bar (title + tabs) fixed */
.topbar{
    position: sticky;
    top: 0;
    z-index: 100;
    background: #05070a;
    padding-top: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid #333;
}
.app-main{
    padding-top: 12px;
}
/* Header styling */
.app-header {
    text-align: center;
    margin-bottom: 1rem;
}

.app-title-img {
    display: block;
    margin: 0 auto;
    width: 92%;
    max-width: 560px;
    height: auto;
}
.title-line1 {
    margin: 0;
    font-size: 2rem;
    color: #00ffc8;
}
.title-line2 {
    margin: 0;
    font-size: 1.2rem;
    color: #00ffc8;
    font-weight: normal;
}

/* Tabs navigation */
.tabs {
    display: flex;
    border-bottom: 1px solid #333;
    margin-bottom: 1rem;
}
.tab-button {
    flex: 1;
    padding: 0.75rem;
    background: none;
    border: none;
    cursor: pointer;
    color: #e0e0e0;
    font-size: 1rem;
    white-space: nowrap; /* prevent emoji+label from wrapping on small screens */
    border-bottom: 3px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}

/* Mobile: tabs can get tight, so slightly reduce padding/font to keep one-line labels */
@media (max-width: 420px) {
  .tab-button {
    padding: 0.65rem 0.45rem;
    font-size: 0.92rem;
  }
}
.tab-button:hover {
    color: #00ffc8;
}
.tab-button.active {
    color: #00ffc8;
    border-color: #00ffc8;
}

/* Tab content */
.tab-content {
    display: none;
}
.tab-content.active {
    display: block;
}

/* Form sections */
.form-section {
    margin-top: 1rem;
}
.form-columns {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}
.form-column {
    flex: 1;
    min-width: 240px;
    box-sizing: border-box;
}

.form-column h3 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    color: #00ffc8;
    font-size: 1.1rem;
}

label {
    display: flex;
    flex-direction: row;   /* ← 横並び */
    flex-wrap: wrap;       /* ← 折り返し */
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    gap: 6px;              /* ← 「エントリー日時」と「必須」の間隔 */
}

/* Entry 編集中UI */
.section-header{
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 0.75rem;
}

.section-header.stack{
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.section-header h2{
  margin: 0;
}

.edit-badge{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.15rem 0.55rem;
  border: 1px solid #00ffc8;
  border-radius: 999px;
  color: #00ffc8;
  font-size: 0.8rem;
  line-height: 1.2;
}

.edit-badge::before{
  content: "●";
  font-size: 0.7rem;
}

/* 入力欄だけ次の行に落とす */
label > input,
label > select,
label > textarea {
  flex: 1 1 100%;
}

input[type="text"],
input[type="number"],
input[type="datetime-local"],
input[type="date"],
select {
    margin-top: 0.2rem;
    padding: 0.4rem 0.5rem;
    border: 1px solid #444;
    border-radius: 4px;
    background-color: #1e1e1e;
    color: #e0e0e0;
    font-size: 0.9rem;
}

select {
    appearance: none;
    -moz-appearance: none;
    -webkit-appearance: none;
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}
.button-row button {
    padding: 0.6rem 1rem;
    border: 1px solid #00ffc8;
    background-color: transparent;
    color: #00ffc8;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    flex: none;
}
.button-row button:hover {
    background-color: #00ffc8;
    color: #121212;
}

/* Error message */
.error-message {
    color: #ff6b6b;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
}

/* Analysis result card */
.analysis-result {
    border: 1px solid #00ffc8;
    border-radius: 6px;
    padding: 1rem;
    margin-top: 1rem;
}
.analysis-result h3 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    color: #00ffc8;
}
.analysis-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.5rem 1rem;
}
.analysis-grid .label {
    color: #00ffc8;
    margin-right: 0.25rem;
}
.confidence-bar-wrap {
    grid-column: span 2;
    width: 100%;
    background-color: #333;
    border-radius: 4px;
    height: 8px;
    margin-top: 0.5rem;
    overflow: hidden;
}
.confidence-bar {
    height: 100%;
    background-color: #00ffc8;
    width: 0%;
    transition: width 0.4s;
}

/* Exit tab */
.exit-select-wrap label {
    font-size: 0.9rem;
}
.exit-details {
    margin-top: 1rem;
}
.exit-details .label {
    color: #00ffc8;
    margin-right: 0.25rem;
}

/* Stats */
.stats-filters {
    border: 1px solid #333;
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
}
.stats-filters h3 {
    margin-top: 0;
    color: #00ffc8;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}
.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.5rem 1rem;
}
.filter-buttons {
    margin-top: 0.5rem;
}
.import-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.import-label button {
    margin-left: 0.5rem;
}
.import-result {
    font-size: 0.8rem;
    color: #00ffc8;
    margin-top: 0.5rem;
}

.stats-summary {
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: #e0e0e0;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid #333;
    border-radius: 4px;
    margin-bottom: 1rem;
}
table {
    width: 100%;
    border-collapse: collapse;
    min-width: 900px;
}
thead {
    background-color: #00ffc8;
    color: #121212;
}
th, td {
    padding: 0.5rem;
    border: 1px solid #333;
    text-align: center;
    white-space: nowrap;
    font-size: 0.85rem;
}
tbody tr:nth-child(even) {
    background-color: #1f1f1f;
}
tbody tr:nth-child(odd) {
    background-color: #151515;
}
.chart-wrap {
    width: 100%;
    margin-bottom: 1rem;
}

/* Footer */
.app-footer {
    margin-top: 2rem;
    padding: 1rem 0;
    text-align: center;
    font-size: 0.75rem;
    color: #888;
    line-height: 1.4;
}

/* Responsive behaviour */
@media (max-width: 480px) {
    .form-column {
        flex-basis: 100%;
    }
    .button-row button {
        flex: 1 1 100%;
        width: 100%;
    }
    .app-footer {
        font-size: 0.68rem;
    }
}

/* --- behavior/layout fixes (minimal) --- */
.req { font-size: 0.75rem; color: #00ffc8; margin-left: 6px; display: inline-block;}
.small { font-size: 0.8rem; }

/* Make cards and flex children shrink correctly to prevent horizontal overflow */
.card, .form-card { min-width: 0; }
.table-wrap { max-width: 100%; overflow-x: auto; }
.table { width: 100%; min-width: 940px; table-layout: auto; }

/* Exit layout */
.exit-layout {
  display: grid;
  grid-template-columns: 320px 1fr 1fr;
  gap: 16px;
  align-items: start;
}

.exit-details-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.exit-col-left,
.exit-col-mid,
.exit-col-right {
  min-width: 0;
}

.exit-select { width: 100%; }
.exit-details { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.exit-details .full { grid-column: 1 / -1; }

@media (max-width: 900px) {
  .exit-layout { grid-template-columns: 1fr; }
  .exit-col-mid, .exit-col-right { grid-column: auto; }
  .exit-details { grid-template-columns: 1fr; }
  .profit-wide-head { flex-direction: column; align-items: flex-start; gap: 8px; }
  .profit-wide-right { align-items: flex-start; }
}

/* Button rows: avoid overlap on mobile */
.button-row { gap: 10px; }
.button-row button { flex: 1 1 220px; }
@media (max-width: 480px) {
  .button-row button { flex: 1 1 100%; }
}

/* Disclaimer: smaller and spaced */
.app-disclaimer { font-size: 0.72rem; margin-top: 28px; padding-top: 16px; }

/* Charts */
.chart-wrap { width: 100%; overflow: hidden; }
.chart-wrap canvas { width: 100% !important; height: 260px !important; }

/* judge + stats minor styles */
.judge-grid { display:grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.judge-grid .full { grid-column: 1 / -1; }
.judge-grid strong { display:block; margin-bottom: 4px; color: #9aa4b5; font-weight: 600; }
.judge-grid .row { display:flex; align-items:center; gap: 10px; }

.judge-grid > div { min-width: 0; }
.judge-grid .row { min-width: 0; }
.bar { min-width: 0; }

.judge-split { display:grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.judge-split > div { min-width: 0; }
@media (max-width: 520px) {
  .judge-split { grid-template-columns: 1fr; }
}



/* 判定結果：推奨方向を強調 */
.reco { display:inline-block; padding: 2px 10px; border-radius: 999px; font-weight: 800; letter-spacing: 0.02em; }
.reco-long { border: 1px solid rgba(0,255,200,0.6); background: rgba(0,255,200,0.12); color: #00ffc8; }
.reco-short { border: 1px solid rgba(255,107,107,0.6); background: rgba(255,107,107,0.12); color: #ff6b6b; }
.reco-none { border: 1px solid rgba(154,164,181,0.4); background: rgba(154,164,181,0.10); color: #c7d0df; }

.bar { flex: 1; height: 10px; background: rgba(255,255,255,0.08); border-radius: 999px; overflow:hidden; }
.bar-fill { height: 100%; background: #00ffc8; border-radius: 999px; }

.stats-grid { display:grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
.stat { padding: 10px 12px; border: 1px solid #252c38; border-radius: 12px; background: #151a20; }
.stat-label { font-size: 0.8rem; color: #9aa4b5; }
.stat-value { font-size: 1.1rem; font-weight: 700; }

.row-actions { display:flex; flex-wrap: wrap; gap: 6px; }
.btn-mini { padding: 6px 10px; border-radius: 10px; border: 1px solid #252c38; background: #151a20; color: #e4e9f0; cursor: pointer; font-size: 0.82rem; }
.btn-mini:hover { border-color: #00ffc8; }
.btn-mini.danger:hover { border-color: #ff4d4d; }
.btn-mini:disabled { opacity: 0.55; cursor: not-allowed; }

.pos { color: #00ffc8; }
.neg { color: #ff7676; }

.profit-pill { display:inline-block; padding: 8px 12px; border: 1px solid #252c38; border-radius: 999px; background: rgba(0,255,200,0.08); }

/* Exit: profit banner (full width) */
.profit-wide {
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px solid #252c38;
  border-radius: 16px;
  background: #0f141a;
}

.profit-wide-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.profit-wide-title {
  font-weight: 800;
  letter-spacing: 0.02em;
}

.profit-wide-value {
  font-weight: 900;
  font-size: 2rem;
  line-height: 1.1;
  letter-spacing: 0.02em;
}

.profit-wide-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.profit-wide-duration {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.profit-wide-duration-below {
  margin-top: 10px;
}


.profit-wide-duration-label {
  font-size: 0.85rem;
  color: #9aa4b5;
}

.profit-wide-duration-value {
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}

.profit-wide-note { margin-top: 8px; }

@media (max-width: 900px) {
  .profit-wide-head { flex-direction: column; align-items: flex-start; }
  .profit-wide-value { font-size: 1.75rem; }
}

@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 480px) {
  .judge-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
}

/* Toast (popup) */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(14px);
  opacity: 0;
  pointer-events: none;
  z-index: 9999;

  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid #252c38;
  background: #0f141a;
  color: #e4e9f0;
  box-shadow: 0 10px 30px rgba(0,0,0,0.45);

  width: max-content;
  max-width: min(520px, calc(100vw - 28px));
  text-align: center;
  line-height: 1.35;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.success {
  border-color: rgba(0,255,200,0.55);
}

.toast.error {
  display: block;
margin: 0 0 10px;
  padding: 10px 12px;
  border: 1px solid #ff6b6b;
  border-radius: 12px;
  background: rgba(255, 107, 107, 0.08);
  color: #ff9c9c;
  font-size: 0.9rem;
}
.error:not(:empty) { display: block; }



.muted { opacity: 0.75; font-size: 0.85em; }

.checkline {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0 10px;
}

.checkline input[type="checkbox"],
.checkline input[type="radio"] {
  flex: 0 0 auto;
  width: auto;
  margin: 0;
  transform: translateY(1px);
}

.checkline-label {
  margin: 0;
  cursor: pointer;
  user-select: none;
  font-size: 0.9rem;
  opacity: 0.9;
}


/* Image uploader */


/* NOTE:
   max-width:1100px はスマホ(<=900px)も含むため、
   先に定義した max-width:900px の「1カラム」を上書きしてしまう。
   そのため 901px〜1100px のみ 2カラムに限定する。
*/
@media (max-width: 1100px) and (min-width: 901px) {
  .exit-layout { grid-template-columns: 320px 1fr; }
  .exit-col-mid { grid-column: 2; }
  .exit-col-right { grid-column: 2; }
}



/* Stats: filter area in 3 columns */
.filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 0.5rem 1rem;
  align-items: end;
}
.filters .button-row {
  grid-column: 1 / -1;
}

@media (max-width: 900px) {
  .filters { grid-template-columns: repeat(2, minmax(160px, 1fr)); }
}
@media (max-width: 520px) {
  .filters { grid-template-columns: 1fr; }
}


/* --- 2025-12-24 追加: TP/LS種別・決済理由(その他)入力の見た目 --- */
.subfield {
  margin-top: -6px;
  padding-left: 10px;
  border-left: 2px solid rgba(0, 255, 200, 0.35);
}


/* Button variants (match index.html classes) */
.btn-primary, button.primary {
  background: #00ffc8;
  color: #061018;
  border-color: #00ffc8;
  font-weight: 700;
}

.btn-accent {
  background: rgba(0, 255, 200, 0.10);
  color: #dffcf6;
  border-color: #00ffc8;
}

.btn-ghost, button.ghost {
  background: transparent;
  color: #d1d7e0;
  border-color: #2a3444;
}


.btn-danger {
  background: rgba(255, 73, 73, 0.10);
  color: #ffd6d6;
  border-color: rgba(255, 73, 73, 0.55);
}

.btn-danger:hover {
  filter: brightness(1.06);
}

.btn-primary:hover, button.primary:hover,
.btn-accent:hover,
.btn-ghost:hover, button.ghost:hover {
  filter: brightness(1.06);
}

/* Simple info block */
.info {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid #202a38;
  border-radius: 14px;
  background: #0f141a;
  color: #cfd6df;
  font-size: 0.9rem;
}

/* Two-column grid utility */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 720px) {
  .grid-2 { grid-template-columns: 1fr; }
}

/* Checkbox line alias */
.checkbox-line {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: nowrap;
  margin: 6px 0 10px;
  cursor: pointer;
  user-select: none;
}

.checkbox-line > input[type="checkbox"] {
  flex: 0 0 auto;
  width: auto;
  margin: 2px 0 0;
}

.checkbox-line > span {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-size: 0.9rem;
  opacity: 0.9;
  line-height: 1.3;
}

/* Judge output card */
.judge-result-card {
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px solid #1f2a39;
  border-radius: 16px;
  background: #0f141a;
}
.judge-output {
  margin-top: 8px;
  padding: 12px 14px;
  border: 1px dashed #243142;
  border-radius: 14px;
  background: #0b0f14;
  min-height: 56px;
}
.judge-output p { margin: 0; }

/* Stats charts layout */
.stats-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 900px) {
  .stats-charts { grid-template-columns: 1fr; }
}

/* Judge debug log */
details.debug {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
}
details.debug summary {
  cursor: pointer;
  user-select: none;
}


.judge-meta{ margin: 0 0 10px; }


/* Multi-select (details) — Entry Context Indicator */
.ms-wrap { margin-top: 0.25rem; }

.ms-title{
  margin: 0 0 0.2rem;
  font-size: 0.9rem;
  color: #e0e0e0;
  opacity: 0.95;
}

.ms-caret{
  color: rgba(224,224,224,0.65);
  font-size: 0.9rem;
  line-height: 1;
}
.ms-details {
  margin-top: 0.25rem;
  border: 1px solid #333;
  border-radius: 6px;
  background: rgba(255,255,255,0.02);
  padding: 0;
}
.ms-details > summary {
  cursor: pointer;
  list-style: none;
  padding: 0.6rem 0.75rem;
  margin: 0;
  color: #e0e0e0;
  font-size: 0.95rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
}
.ms-details > summary::-webkit-details-marker { display: none; }
.ms-details[open] > summary { border-bottom: 1px solid #333; }
.ms-label { color: #e0e0e0; }
.ms-summary {
  color: #00ffc8;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: calc(100% - 18px);
  text-align: left;
}
.ms-options {
  padding: 0.6rem 0.75rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.35rem;
}
.ms-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.25rem;
  border-radius: 6px;
}
.ms-option:hover { background: rgba(255,255,255,0.04); }
.ms-check { width: 18px; height: 18px; }

@media (min-width: 720px) {
  .ms-options { grid-template-columns: 1fr 1fr; }
  .ms-summary { max-width: calc(100% - 18px); }
}


.col-select {
  width: 64px;
  text-align: center;
}

.table input[type="checkbox"] {
  transform: translateY(1px);
}
