/* CAU Accounting System — 主样式 */

:root {
  --primary:    #1a56db;
  --primary-d:  #1341a3;
  --success:    #057a55;
  --warning:    #c27803;
  --danger:     #c81e1e;
  --info:       #1c64f2;
  --bg:         #f9fafb;
  --bg-card:    #ffffff;
  --border:     #e5e7eb;
  --text:       #111827;
  --text-muted: #6b7280;
  --sidebar-w:  220px;
  --topbar-h:   56px;
}

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

body {
  font-family: 'Noto Sans JP', 'Noto Sans SC', 'PingFang SC', 'Hiragino Sans',
               system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

/* 2026-05-28: フォントサイズ 全 UI 等比拡大 (高齢者向け) */
/* Chrome/Edge は zoom native、Firefox は transform: scale + min-width fallback */
body.font-small  { zoom: 0.9; }
body.font-normal { zoom: 1.0; }
body.font-large  { zoom: 1.15; }
body.font-xl     { zoom: 1.3; }
body.font-xxl    { zoom: 1.5; }

/* font-size 切替 button (topbar 内) */
.font-size-picker {
  display: inline-flex;
  gap: 2px;
  margin-right: 8px;
  background: #f3f4f6;
  border-radius: 6px;
  padding: 2px;
}
.font-size-picker button {
  background: transparent;
  border: none;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 4px;
  color: #6b7280;
  font-size: 12px;
  line-height: 1;
}
.font-size-picker button:hover { background: #e5e7eb; }
.font-size-picker button.active {
  background: #1a56db;
  color: white;
  font-weight: 600;
}

/* ── Layout ── */
#app { display: flex; min-height: 100vh; }

/* Sidebar */
#sidebar {
  width: var(--sidebar-w);
  background: #1e293b;
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

#sidebar .logo {
  padding: 16px;
  font-size: 15px;
  font-weight: 700;
  border-bottom: 1px solid #334155;
  color: #f1f5f9;
}

#sidebar .logo .subtitle {
  font-size: 11px;
  color: #94a3b8;
  font-weight: 400;
  margin-top: 2px;
}

#sidebar nav { flex: 1; padding: 8px 0; }

#sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: #cbd5e1;
  text-decoration: none;
  font-size: 13px;
  border-radius: 0;
  transition: background 0.15s, color 0.15s;
}

#sidebar nav a:hover,
#sidebar nav a.active {
  background: #0f172a;
  color: #f1f5f9;
}

#sidebar nav a .icon { font-size: 16px; width: 20px; text-align: center; }

/* Main area */
#main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Topbar */
#topbar {
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky; top: 0; z-index: 90;
}

#topbar .page-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

#topbar .topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

#lang-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-muted);
}
#lang-toggle:hover { background: var(--bg); }

/* Content */
#content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
}

/* ── Page Visibility ── */
.page { display: none; }
.page.active { display: block; }

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

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

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

/* ── KPI Grid ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}

.kpi-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.kpi-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.kpi-value.profit  { color: var(--success); }
.kpi-value.loss    { color: var(--danger); }
.kpi-value.warning { color: var(--warning); }

/* ── Alerts ── */
.alert-list { display: flex; flex-direction: column; gap: 8px; }

.alert-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
}

.alert-item.critical { background: #fef2f2; border: 1px solid #fca5a5; color: #991b1b; }
.alert-item.warning  { background: #fffbeb; border: 1px solid #fcd34d; color: #92400e; }
.alert-item.info     { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }

.alert-item .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.critical .dot { background: #ef4444; }
.warning  .dot { background: #f59e0b; }
.info     .dot { background: #3b82f6; }

/* ── Tables ── */
.tbl-wrap { overflow-x: auto; }

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

thead th {
  text-align: left;
  padding: 8px 12px;
  background: #f1f5f9;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

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

tbody tr:hover { background: #f8fafc; }

tbody tr:last-child td { border-bottom: none; }

.td-amount { text-align: right; font-variant-numeric: tabular-nums; }
.td-center { text-align: center; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
}
.badge-green  { background: #d1fae5; color: #065f46; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-gray   { background: #f3f4f6; color: #374151; }
.badge-orange { background: #ffedd5; color: #9a3412; }
.badge-purple { background: #f3e8ff; color: #6b21a8; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }

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

.btn-danger  { background: var(--danger); color: #fff; }
.btn-sm      { padding: 4px 10px; font-size: 12px; }

/* ── Forms ── */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; }
.form-control {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
  color: var(--text);
  outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(26,86,219,0.15); }

select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-width='1.5' d='m6 8 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; background-size: 16px; padding-right: 28px; }

/* ── Loading ── */
.loading { text-align: center; padding: 40px; color: var(--text-muted); }

/* ── Responsive ── */
/* ── Modal ── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  max-height: 92vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close {
  background: none; border: none; font-size: 20px;
  cursor: pointer; color: var(--text-muted);
  padding: 4px 8px; border-radius: 4px;
}
.modal-close:hover { background: #f3f4f6; }
.modal-body { padding: 20px; }
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}

@media (max-width: 768px) {
  #sidebar { transform: translateX(-100%); transition: transform 0.2s; }
  #sidebar.open { transform: translateX(0); }
  #main { margin-left: 0; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
}
