/* ===================================
   Dashboard CSS — Notion-inspired
   視認性改善版
   =================================== */

:root {
  --bg: #ffffff;
  --bg-secondary: #f7f7f5;
  --bg-hover: #efefed;
  --text: #37352f;
  --text-secondary: #6b6b68;
  --text-tertiary: #a0a09c;
  --border: #e3e3e0;
  --accent: #2eaadc;
  --accent-bg: #e8f4f8;
  --green: #0f7b6c;
  --green-bg: #e6f4f1;
  --red: #e03e3e;
  --red-bg: #fbe4e4;
  --orange: #c77a10;
  --orange-bg: #fbecdb;
  --sidebar-width: 250px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif;
  --radius: 6px;
}

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

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--text); text-decoration: none; }

/* ========== Layout ========== */

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: 16px 10px;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 100;
}

.main {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bg);
}

.content {
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 48px;
}

/* ========== Sidebar ========== */

.sidebar-brand {
  padding: 8px 12px 12px;
  margin-bottom: 4px;
}

.sidebar-brand strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-brand small {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.sidebar-nav { list-style: none; }

.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text-secondary);
  transition: background 0.1s, color 0.1s;
  margin-bottom: 1px;
}

.sidebar-nav li a:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.sidebar-nav li a.active {
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 600;
}

.sidebar-nav li a .nav-icon {
  width: 18px;
  height: 18px;
  opacity: 0.6;
  flex-shrink: 0;
}

.sidebar-nav li a.active .nav-icon { opacity: 1; }

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 10px 12px;
}

.badge-count {
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  margin-left: auto;
  min-width: 20px;
  text-align: center;
}

/* ========== Page Header ========== */

.page-header {
  margin-bottom: 32px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.page-header h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.page-header p {
  margin-top: 6px;
  color: var(--text-secondary);
  font-size: 14px;
}

/* ========== Metric Cards ========== */

.metric-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 40px;
}

.metric-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: box-shadow 0.15s;
}

.metric-card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.metric-card .mc-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.metric-card .mc-sublabel {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-bottom: 12px;
}

.metric-card .mc-value {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: 6px;
  color: var(--text);
}

.metric-card .mc-change {
  font-size: 13px;
  font-weight: 600;
}

.mc-change.up { color: var(--green); }
.mc-change.down { color: var(--red); }
.mc-change.neutral { color: var(--text-tertiary); }

/* ========== Section Blocks ========== */

.section-block {
  margin-bottom: 40px;
}

.section-block h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ========== Table ========== */

.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  padding: 10px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tbody td {
  padding: 12px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  line-height: 1.5;
}

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

tbody tr:hover { background: #fafaf9; }

/* ========== Status badges ========== */

.status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

.status-pending { background: var(--orange-bg); color: var(--orange); }
.status-approved { background: var(--green-bg); color: var(--green); }
.status-rejected { background: var(--red-bg); color: var(--red); }
.status-unread { background: var(--accent-bg); color: #1a8fb4; }

/* ========== Buttons ========== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 7px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background 0.1s, box-shadow 0.1s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: #2596c4; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

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

.btn-success {
  background: var(--green);
  color: #fff;
}
.btn-success:hover { background: #0a6b5e; }

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

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
}

/* ========== Toggle Switch ========== */

.toggle {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: #ccc;
  border-radius: 11px;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle-slider::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle input:checked + .toggle-slider {
  background: var(--accent);
}

.toggle input:checked + .toggle-slider::after {
  transform: translateX(18px);
}

.toggle input:disabled + .toggle-slider {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ========== Section list ========== */

.section-list-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

.section-list-item:hover { background: #fafaf9; }
.section-list-item:last-child { border-bottom: none; }

.section-list-item .section-name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
}

.section-list-item .section-name .locked-hint {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-left: 8px;
  font-weight: 400;
}

/* ========== Forms ========== */

.form-group {
  margin-bottom: 24px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

.form-control::placeholder {
  color: var(--text-tertiary);
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

/* ========== Stars ========== */

.stars {
  color: #f5c518;
  letter-spacing: 2px;
  font-size: 14px;
}

/* ========== Empty state ========== */

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-tertiary);
}

.empty-state p {
  font-size: 14px;
  margin-bottom: 16px;
  line-height: 1.6;
}

/* ========== Login ========== */

.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-secondary);
}

.login-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}

.login-box h1 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 28px;
  text-align: center;
}

.login-box .form-control {
  padding: 11px 14px;
  font-size: 15px;
}

.login-box .btn {
  width: 100%;
  padding: 11px;
  font-size: 15px;
  justify-content: center;
}

.login-error {
  background: var(--red-bg);
  color: var(--red);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 16px;
}

/* ========== Info box ========== */

.info-box {
  background: var(--accent-bg);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 24px;
  font-size: 13px;
  color: #1a6b7a;
  line-height: 1.5;
}

/* ========== AI Assist Button ========== */

.btn-ai {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  border: 1px solid #d4b8f0;
  background: #f8f0ff;
  color: #7c3aed;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.btn-ai:hover {
  background: #ede5ff;
  border-color: #a78bfa;
}

.form-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.form-label-row label {
  margin-bottom: 0;
}

/* ========== Cards ========== */

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

.card-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card-list .card {
  padding: 16px 20px;
}

/* ========== Extra form helpers ========== */

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.page-subtitle {
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 13px;
}

/* ========== Button variants ========== */

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

/* ========== Tabs ========== */

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
}

.tab-item {
  padding: 10px 20px;
  font-size: 14px;
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}

.tab-item:hover {
  color: var(--text);
}

.tab-item.active {
  color: var(--text);
  font-weight: 600;
  border-bottom-color: var(--accent);
}

/* ========== Responsive ========== */

@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .content { padding: 20px 16px; }
  .metric-cards { grid-template-columns: repeat(2, 1fr); }
}
