/* ─────────────────────────────────────────────────────────────────
   AIO TOOL — CSS
   Same design language as existing Toolbox tools
───────────────────────────────────────────────────────────────── */

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

:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface2: #f1efe8;
  --border: rgba(0,0,0,0.12);
  --border-strong: rgba(0,0,0,0.25);
  --text: #1a1a18;
  --text-muted: #5f5e5a;
  --text-hint: #888780;
  --green-bg: #EAF3DE; --green-text: #3B6D11; --green-dot: #639922;
  --red-bg: #FCEBEB;   --red-text: #A32D2D;   --red-dot: #E24B4A;
  --yellow-bg: #FFF8DC; --yellow-text: #7A5C00;
  --blue-bg: #E8F0FE;  --blue-text: #1A56A0;
  --accent: #378ADD;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SFMono-Regular', 'Consolas', 'Liberation Mono', monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1c1a;
    --surface: #252523;
    --surface2: #2c2c2a;
    --border: rgba(255,255,255,0.1);
    --border-strong: rgba(255,255,255,0.22);
    --text: #f0ede6;
    --text-muted: #b4b2a9;
    --text-hint: #888780;
    --green-bg: #173404; --green-text: #C0DD97; --green-dot: #97C459;
    --red-bg: #501313;   --red-text: #F7C1C1;   --red-dot: #F09595;
    --yellow-bg: #3a2e00; --yellow-text: #f0d060;
    --blue-bg: #0d1f3c;  --blue-text: #90b8f8;
  }
}

/* ── Base ── */
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
}

.content { padding: 1.5rem 1rem 2rem; }

/* ── Header ── */
header { text-align: center; margin-bottom: 1.2rem; }
header h1 {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}
header p { font-size: 14px; color: var(--text-muted); }

@media (max-width: 480px)  { header h1 { font-size: 20px; } }
@media (min-width: 1200px) { header h1 { font-size: 30px; } .card { padding: 1.8rem; } }

/* ── Back link ── */
.back-link {
  align-self: flex-start;
  font-size: 13px;
  color: var(--text-hint);
  text-decoration: none;
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: color 0.15s;
}
.back-link:hover { color: var(--text-muted); }

/* ── Container ── */
.container { width: 100%; max-width: 900px; }

/* ── Card ── */
.card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.2rem;
  margin-bottom: 1rem;
}

.section-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-hint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.optional-label {
  font-size: 10px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-hint);
  opacity: 0.7;
}

.card-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 10px;
  line-height: 1.5;
}

/* ── Upload zone ── */
.upload-zone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 2rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}

.upload-zone-sm {
  padding: 1rem 1.5rem;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent);
  background: var(--blue-bg);
}

.upload-zone input[type=file] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.upload-zone-text { font-size: 14px; color: var(--text-muted); }
.upload-zone-text strong {
  display: block;
  font-size: 15px;
  color: var(--text);
  font-weight: 500;
  margin-bottom: 4px;
}

/* ── File loaded ── */
.file-loaded {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--green-bg);
  border-radius: var(--radius-md);
  margin-top: 10px;
  font-size: 13px;
  color: var(--green-text);
}
.file-loaded.show { display: flex; }
.file-loaded-name { font-weight: 500; }
.file-loaded-meta {
  color: var(--green-text);
  opacity: 0.8;
  font-family: var(--font-mono);
  font-size: 12px;
}

/* ── Selectors ── */
.selector-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}
@media (max-width: 560px) { .selector-row { grid-template-columns: 1fr; } }

.selector-group label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-hint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

select {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 14px;
  background: var(--surface2);
  border: 0.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 0 12px;
  height: 42px;
  color: var(--text);
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888780' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(55,138,221,0.15);
}

/* ── Mode Tabs ── */
.mode-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 1rem;
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 5px;
  overflow-x: auto;
  scrollbar-width: none;
}
.mode-tabs::-webkit-scrollbar { display: none; }

.mode-tab {
  flex: 1;
  min-width: 120px;
  height: 38px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-sans);
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  padding: 0 12px;
}

.mode-tab:hover {
  background: var(--surface2);
  color: var(--text);
}

.mode-tab.active {
  background: var(--text);
  color: var(--bg);
}

/* ── Buttons ── */
button.btn-primary {
  padding: 0 20px;
  height: 42px;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-sans);
  white-space: nowrap;
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
button.btn-primary:hover { opacity: 0.85; }
button.btn-primary:active { transform: scale(0.97); }
button.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.generate-hint {
  font-size: 13px;
  color: var(--text-hint);
}

/* ── Messages ── */
.msg {
  font-size: 13px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  margin-top: 10px;
  display: none;
}
.msg.show  { display: block; }
.msg.error { background: var(--red-bg);    color: var(--red-text); }
.msg.warn  { background: var(--yellow-bg); color: var(--yellow-text); max-height: 80px; overflow-y: auto; }
.msg.info  { background: var(--blue-bg);   color: var(--blue-text); }

/* ── Stats grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  margin-bottom: 1.25rem;
}

.stat-box {
  background: var(--surface2);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
}
.stat-box .stat-val {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.02em;
  display: block;
  margin-bottom: 2px;
}
.stat-box .stat-lbl {
  font-size: 11px;
  color: var(--text-hint);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 500;
}

/* ── Results header ── */
.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 1rem;
}
.results-title {
  font-size: 15px;
  font-weight: 600;
}

/* ── Table ── */
.table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 600px;
  border-radius: var(--radius-md);
  border: 0.5px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

thead th {
  background: var(--surface2);
  padding: 9px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-hint);
  white-space: nowrap;
  border-bottom: 0.5px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
}

tbody tr {
  border-bottom: 0.5px solid var(--border);
  transition: background 0.1s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }
tbody td { padding: 9px 12px; vertical-align: middle; }

/* ── Table cell types ── */
.td-mono  { font-family: var(--font-mono); font-size: 12px; text-align: center; }
.td-name  { font-weight: 500; min-width: 160px; }
.td-num   { font-family: var(--font-mono); text-align: right; }
.td-center { text-align: center; }
.td-deduct { font-family: var(--font-mono); text-align: right; color: var(--red-text); }
.td-due    { font-family: var(--font-mono); text-align: right; font-weight: 600; }
.td-note   { font-size: 10px; min-width: 150px; max-width: 200px; white-space: normal; }
.td-hint   { color: var(--text-hint); font-family: var(--font-mono); font-size: 11px; }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: var(--radius-md);
  line-height: 1.6;
}
.badge-warn  { background: var(--yellow-bg); color: var(--yellow-text); }
.badge-ok    { background: var(--green-bg);  color: var(--green-text); }
.badge-info  { background: var(--blue-bg);   color: var(--blue-text); }
.badge-flag  { background: var(--red-bg);    color: var(--red-text); }

.badge-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* ── More rows ── */
.more-rows {
  text-align: center;
  padding: 10px;
  font-size: 12px;
  color: var(--text-hint);
  font-family: var(--font-mono);
  border-top: 0.5px solid var(--border);
}

/* ── Footer ── */
footer {
  margin-top: 3rem;
  text-align: center;
  font-size: 13px;
  color: var(--text-hint);
  line-height: 1.8;
}

/* ── Mobile overlay ── */
.mobile-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
}
