/* ===========================
   三星商会 AIプラットフォーム
   スタイルシート
   =========================== */

:root {
  --navy: #1a2744;
  --navy-dark: #111b33;
  --navy-mid: #223060;
  --navy-light: #2d3f6e;
  --gold: #f5a623;
  --gold-light: #fbbf46;
  --gold-pale: rgba(245, 166, 35, 0.12);
  --white: #ffffff;
  --bg: #f0f2f8;
  --surface: #ffffff;
  --border: #e2e6f0;
  --text: #1a2744;
  --text-sub: #607090;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --insight: #8b5cf6;
  --sidebar-w: 240px;
  --header-h: 60px;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(26,39,68,0.10);
  --shadow-md: 0 4px 24px rgba(26,39,68,0.14);
}

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

html, body {
  height: 100%;
  font-family: 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', 'Noto Sans JP', 'Yu Gothic', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

a { text-decoration: none; color: inherit; }

/* ===== LAYOUT ===== */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ===== SIDEBAR ===== */
#sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--navy-dark) 0%, var(--navy) 100%);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-logo {
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.logo-main {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-light) 100%);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(245,166,35,0.4);
}

.logo-text {
  line-height: 1.2;
}

.logo-company {
  font-size: 13px;
  font-weight: 700;
  color: var(--white);
  letter-spacing: 0.02em;
}

.logo-sub {
  font-size: 10px;
  color: rgba(255,255,255,0.5);
  letter-spacing: 0.04em;
}

.logo-badge {
  display: inline-block;
  margin-top: 6px;
  font-size: 9px;
  color: var(--gold);
  border: 1px solid rgba(245,166,35,0.4);
  border-radius: 4px;
  padding: 1px 6px;
  letter-spacing: 0.06em;
}

.sidebar-nav {
  padding: 12px 0;
  flex: 1;
}

.nav-section-label {
  font-size: 9px;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.35);
  padding: 8px 18px 4px;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  cursor: pointer;
  border-radius: 0;
  transition: all 0.15s;
  position: relative;
  color: rgba(255,255,255,0.65);
  font-size: 13px;
  font-weight: 500;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.9);
}

.nav-item.active {
  background: rgba(245,166,35,0.15);
  color: var(--gold);
  border-left-color: var(--gold);
}

.nav-item .nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 11px;
  color: rgba(255,255,255,0.35);
}

.sidebar-footer .sys-name {
  font-weight: 600;
  color: rgba(255,255,255,0.5);
  margin-bottom: 2px;
}

/* ===== MAIN ===== */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ===== HEADER ===== */
#header {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(26,39,68,0.06);
}

.header-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--navy);
  flex: 1;
}

.header-title span {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-sub);
  margin-left: 8px;
}

.branch-switcher {
  display: flex;
  background: var(--bg);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}

.branch-btn {
  padding: 5px 14px;
  border-radius: 6px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-sub);
  transition: all 0.15s;
}

.branch-btn.active {
  background: var(--navy);
  color: var(--white);
  box-shadow: 0 1px 4px rgba(26,39,68,0.3);
}

.notif-btn {
  position: relative;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--bg);
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  transition: background 0.15s;
}

.notif-btn:hover { background: var(--border); }

.notif-dot {
  position: absolute;
  top: 5px; right: 5px;
  width: 8px; height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid white;
}

.user-avatar {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 100%);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--gold);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

/* ===== CONTENT ===== */
#content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ===== TABS ===== */
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ===== KPI CARDS ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  transition: transform 0.15s, box-shadow 0.15s;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--gold), var(--gold-light));
}

.kpi-label {
  font-size: 11px;
  color: var(--text-sub);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.kpi-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--navy);
  line-height: 1;
  margin-bottom: 4px;
}

.kpi-unit {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-sub);
}

.kpi-change {
  font-size: 11px;
  color: var(--success);
  font-weight: 600;
}

.kpi-change.down { color: var(--danger); }

.kpi-icon {
  position: absolute;
  top: 14px; right: 16px;
  font-size: 28px;
  opacity: 0.15;
}

/* ===== GRID 2-col ===== */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

/* ===== CARD ===== */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--navy);
  display: flex;
  align-items: center;
  gap: 7px;
}

.card-body { padding: 18px 20px; }

/* ===== ALERTS ===== */
.alert-list { display: flex; flex-direction: column; gap: 10px; }

.alert-item {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  border-left: 4px solid;
  transition: transform 0.1s;
}

.alert-item:hover { transform: translateX(2px); }

.alert-item.warning {
  background: rgba(245, 158, 11, 0.08);
  border-left-color: var(--warning);
}

.alert-item.info {
  background: rgba(59,130,246,0.08);
  border-left-color: var(--info);
}

.alert-item.insight {
  background: rgba(139,92,246,0.08);
  border-left-color: var(--insight);
}

.alert-icon { font-size: 20px; flex-shrink: 0; margin-top: 1px; }

.alert-content { flex: 1; min-width: 0; }

.alert-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 2px;
}

.alert-msg {
  font-size: 12px;
  color: var(--text-sub);
  line-height: 1.5;
}

.alert-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
}

.alert-time { font-size: 10px; color: var(--text-sub); }

.alert-action {
  font-size: 11px;
  color: var(--gold);
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
}

.alert-action:hover { text-decoration: underline; }

/* ===== TABLES ===== */
.table-wrap { overflow-x: auto; }

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

th {
  background: var(--bg);
  color: var(--text-sub);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 9px 12px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(26,39,68,0.025); }

/* ===== BADGES / STATUS ===== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-success { background: rgba(34,197,94,0.12); color: #16a34a; }
.badge-warning { background: rgba(245,158,11,0.12); color: #d97706; }
.badge-info    { background: rgba(59,130,246,0.12);  color: #2563eb; }
.badge-danger  { background: rgba(239,68,68,0.12);   color: #dc2626; }
.badge-purple  { background: rgba(139,92,246,0.12);  color: #7c3aed; }
.badge-gray    { background: rgba(100,116,139,0.12); color: #475569; }
.badge-gold    { background: rgba(245,166,35,0.15);  color: #b45309; }

.channel-badge { display: inline-flex; align-items: center; gap: 4px; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 7px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.15s;
  white-space: nowrap;
  font-family: inherit;
}

.btn-primary {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(26,39,68,0.25);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(26,39,68,0.35);
}

.btn-gold {
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-light) 100%);
  color: var(--navy-dark);
  box-shadow: 0 2px 8px rgba(245,166,35,0.35);
}

.btn-gold:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(245,166,35,0.5);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-outline:hover { border-color: var(--navy); color: var(--navy); }

.btn-danger { background: var(--danger); color: white; }
.btn-success { background: var(--success); color: white; }

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 6px;
}

/* ===== UPLOAD AREA ===== */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg);
}

.upload-area:hover, .upload-area.dragover {
  border-color: var(--gold);
  background: var(--gold-pale);
}

.upload-icon { font-size: 40px; margin-bottom: 12px; }
.upload-title { font-size: 15px; font-weight: 700; color: var(--navy); margin-bottom: 6px; }
.upload-sub { font-size: 12px; color: var(--text-sub); }

/* ===== OCR RESULT ===== */
.ocr-section { margin-top: 20px; }

.ocr-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.ocr-info {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.ocr-info-item {
  background: var(--bg);
  border-radius: 8px;
  padding: 10px 14px;
}

.ocr-info-label { font-size: 10px; color: var(--text-sub); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; margin-bottom: 3px; }
.ocr-info-val { font-size: 14px; font-weight: 700; color: var(--navy); }

.confidence-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.confidence-track {
  flex: 1;
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.confidence-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--success), #4ade80);
  border-radius: 3px;
  transition: width 0.8s ease;
}

.confidence-val { font-size: 11px; font-weight: 700; color: var(--success); }

/* ===== LOADING ANIMATION ===== */
.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(17,27,51,0.55);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 20px;
}

.loading-overlay.active { display: flex; }

.spinner {
  width: 56px; height: 56px;
  border: 5px solid rgba(245,166,35,0.2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
  color: white;
  font-size: 15px;
  font-weight: 600;
  text-align: center;
}

.loading-sub {
  color: rgba(255,255,255,0.6);
  font-size: 12px;
  text-align: center;
}

/* ===== PROGRESS BAR ===== */
.progress-wrap {
  background: var(--border);
  border-radius: 8px;
  height: 14px;
  overflow: hidden;
  margin: 8px 0;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--navy), var(--gold));
  border-radius: 8px;
  width: 0%;
  transition: width 0.3s ease;
  position: relative;
}

.progress-bar::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.2) 50%, transparent 100%);
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ===== QUOTE / ESTIMATE ===== */
.quote-header-box {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy) 100%);
  color: white;
  border-radius: var(--radius) var(--radius) 0 0;
}

.quote-company { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.quote-tagline { font-size: 11px; color: rgba(255,255,255,0.6); }

.quote-meta { text-align: right; }
.quote-no { font-size: 18px; font-weight: 700; color: var(--gold); }
.quote-date { font-size: 11px; color: rgba(255,255,255,0.6); margin-top: 4px; }

.quote-to-section {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.quote-to-label { font-size: 11px; color: var(--text-sub); font-weight: 600; margin-bottom: 4px; }
.quote-to-name { font-size: 18px; font-weight: 700; color: var(--navy); }
.quote-to-sub { font-size: 12px; color: var(--text-sub); }

.quote-total-section {
  padding: 16px 24px;
  background: var(--gold-pale);
  border-top: 1px solid rgba(245,166,35,0.2);
  display: flex;
  justify-content: flex-end;
  gap: 24px;
}

.quote-total-item { text-align: right; }
.quote-total-label { font-size: 11px; color: var(--text-sub); margin-bottom: 2px; }
.quote-total-val { font-size: 22px; font-weight: 800; color: var(--navy); }
.quote-total-val.grand { color: var(--gold); font-size: 26px; }

/* ===== FANOUT ===== */
.fanout-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.fanout-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  transition: all 0.15s;
}

.fanout-card.sent {
  border-color: rgba(34,197,94,0.4);
  background: rgba(34,197,94,0.04);
}

.fanout-maker {
  font-size: 13px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.fanout-items { font-size: 12px; color: var(--text-sub); margin-bottom: 10px; }
.fanout-item-row { padding: 3px 0; border-bottom: 1px dashed var(--border); }
.fanout-item-row:last-child { border-bottom: none; }

.fanout-email {
  font-size: 11px;
  color: var(--text-sub);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ===== MASTER TABLE ===== */
.change-up { color: var(--danger); font-weight: 700; }
.change-neutral { color: var(--text-sub); }

/* ===== CANVAS CHART ===== */
.chart-wrap {
  position: relative;
  padding: 0;
}

/* ===== STATUS DOT ===== */
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 5px;
}

.dot-success { background: var(--success); box-shadow: 0 0 4px var(--success); }
.dot-warning { background: var(--warning); box-shadow: 0 0 4px var(--warning); }
.dot-info    { background: var(--info);    box-shadow: 0 0 4px var(--info); }
.dot-danger  { background: var(--danger);  box-shadow: 0 0 4px var(--danger); }

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--navy);
  color: white;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  border-left: 4px solid var(--gold);
  animation: slideIn 0.3s ease;
  max-width: 320px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast.success { border-left-color: var(--success); }
.toast.danger  { border-left-color: var(--danger); }

@keyframes slideIn {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
  from { transform: translateX(0); opacity: 1; }
  to   { transform: translateX(120%); opacity: 0; }
}

.toast.hiding { animation: slideOut 0.3s ease forwards; }

/* ===== MISC ===== */
.section-gap { margin-bottom: 16px; }
.mb-4 { margin-bottom: 4px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }

.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }

.text-right { text-align: right; }
.text-center { text-align: center; }
.font-bold { font-weight: 700; }
.font-mono { font-family: 'Courier New', monospace; font-size: 12px; }
.text-sub { color: var(--text-sub); }
.text-gold { color: var(--gold); }
.text-navy { color: var(--navy); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

.hannari-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: linear-gradient(90deg, rgba(26,39,68,0.06), rgba(245,166,35,0.08));
  border: 1px solid rgba(245,166,35,0.3);
  border-radius: 5px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 700;
  color: var(--navy);
}

.ai-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(139,92,246,0.1);
  border: 1px solid rgba(139,92,246,0.25);
  border-radius: 5px;
  padding: 2px 7px;
  font-size: 10px;
  font-weight: 700;
  color: #6d28d9;
}

.pulse {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 800px) {
  #sidebar { width: 60px; }
  .logo-text, .logo-badge, .nav-section-label, .nav-item span, .sidebar-footer { display: none; }
  .nav-item { justify-content: center; padding: 12px; border-left: none; border-bottom: 3px solid transparent; }
  .nav-item.active { border-bottom-color: var(--gold); border-left: none; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
}
