/* ================================================
   PROCS 案件管理システム - メインスタイルシート
   ================================================ */

:root {
  --primary: #0A0F1E;
  --primary-light: #1a2235;
  --accent: #3B82F6;
  --accent-hover: #2563EB;
  --accent-light: rgba(59, 130, 246, 0.1);
  --success: #10B981;
  --success-light: rgba(16, 185, 129, 0.1);
  --warning: #F59E0B;
  --warning-light: rgba(245, 158, 11, 0.1);
  --danger: #EF4444;
  --danger-light: rgba(239, 68, 68, 0.1);
  --surface: #FFFFFF;
  --surface-2: #F8FAFC;
  --border: #E2E8F0;
  --border-strong: #CBD5E1;
  --text-primary: #0F172A;
  --text-secondary: #64748B;
  --text-muted: #94A3B8;
  --sidebar-w: 240px;
  --topbar-h: 60px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.14);
  --font-sans: 'DM Sans', 'Noto Sans JP', sans-serif;
}

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

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

/* ===================== Layout ===================== */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

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

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.logo-mark {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
}

.logo-main { display: block; font-weight: 700; font-size: 14px; letter-spacing: 2px; }
.logo-sub  { display: block; font-size: 10px; color: rgba(255,255,255,0.5); letter-spacing: 1px; }

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

.nav-section { margin-bottom: 8px; }

.nav-label {
  display: block;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  padding: 8px 20px 4px;
}

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

.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 400;
  border-radius: 0;
  transition: all 0.15s ease;
  border-left: 3px solid transparent;
}

.sidebar-nav li a:hover,
.sidebar-nav li.active a {
  background: rgba(255,255,255,0.07);
  color: #fff;
}

.sidebar-nav li.active a {
  border-left-color: var(--accent);
  background: rgba(59, 130, 246, 0.12);
}

.nav-icon { font-size: 15px; width: 20px; text-align: center; }

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

.sidebar-footer a {
  color: rgba(255,255,255,0.5);
  text-decoration: none;
  font-size: 13px;
  transition: color 0.15s;
}
.sidebar-footer a:hover { color: #fff; }

/* ===================== Main Content ===================== */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.top-bar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
}

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

.top-bar-actions { display: flex; gap: 10px; align-items: center; }

.content-body { padding: 28px; flex: 1; }

/* ===================== Cards ===================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 16px;
  letter-spacing: 0.5px;
}

/* ===================== KPI Cards ===================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent);
}

.kpi-card.success::before { background: var(--success); }
.kpi-card.warning::before { background: var(--warning); }

.kpi-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}

.kpi-sub {
  font-size: 12px;
  color: var(--text-muted);
}

/* ===================== Dashboard Grid ===================== */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

/* ===================== Table ===================== */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

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

thead th {
  background: var(--surface-2);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

tbody td {
  padding: 12px 16px;
  color: var(--text-primary);
  vertical-align: middle;
}

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

.amount-cell {
  font-weight: 500;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* ===================== Badges ===================== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-blue    { background: var(--accent-light);   color: var(--accent); }
.badge-green   { background: var(--success-light);  color: var(--success); }
.badge-yellow  { background: var(--warning-light);  color: #D97706; }
.badge-red     { background: var(--danger-light);   color: var(--danger); }
.badge-gray    { background: var(--surface-2);      color: var(--text-secondary); border: 1px solid var(--border); }

.billing-invoice { background: #EEF2FF; color: #4F46E5; }
.billing-paid    { background: var(--success-light); color: var(--success); }

/* ===================== Buttons ===================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: all 0.15s ease;
  white-space: nowrap;
}

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

.btn-secondary {
  background: var(--surface);
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--surface-2); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #DC2626; }

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

/* ===================== Form ===================== */
.form-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
}

.form-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }

label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.3px;
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="date"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 13.5px;
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

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

.error-message {
  font-size: 12px;
  color: var(--danger);
  margin-top: 3px;
}

/* ===================== Flash Messages ===================== */
.message {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 13.5px;
  font-weight: 500;
}

.message.success { background: var(--success-light); color: #065F46; border: 1px solid #A7F3D0; }
.message.error   { background: var(--danger-light);  color: #991B1B; border: 1px solid #FECACA; }
.message.warning { background: var(--warning-light); color: #92400E; border: 1px solid #FDE68A; }

/* ===================== Monthly Revenue Table ===================== */
.revenue-month-table { font-size: 12.5px; }

.revenue-month-table th:first-child,
.revenue-month-table td:first-child {
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-secondary);
  width: 60px;
  text-align: center;
}

.revenue-input {
  width: 100%;
  border: 1px solid transparent;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 12.5px;
  text-align: right;
  background: transparent;
  transition: all 0.15s;
  font-variant-numeric: tabular-nums;
}

.revenue-input:hover { border-color: var(--border-strong); background: var(--surface); }
.revenue-input:focus { border-color: var(--accent); background: var(--surface); outline: none; box-shadow: 0 0 0 2px rgba(59,130,246,0.1); }

/* ===================== Pagination ===================== */
.pagination {
  display: flex;
  gap: 4px;
  justify-content: center;
  margin-top: 24px;
}

.pagination .page { display: flex; gap: 4px; }

.pagination a, .pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  font-size: 13px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.15s;
}

.pagination a:hover { background: var(--surface-2); border-color: var(--border-strong); }
.pagination .current span {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ===================== Search / Filter Bar ===================== */
.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 20px;
}

.filter-bar input,
.filter-bar select { width: auto; min-width: 160px; flex: 1; }

/* ===================== Status Colors ===================== */
.status-proposal    { color: #7C3AED; background: #EDE9FE; }
.status-contracted  { color: #1D4ED8; background: #DBEAFE; }
.status-in_progress { color: #D97706; background: #FEF3C7; }
.status-completed   { color: #059669; background: #D1FAE5; }
.status-cancelled   { color: #6B7280; background: #F3F4F6; }

/* ===================== Utilities ===================== */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.fw-600 { font-weight: 600; }
.mb-0 { margin-bottom: 0; }
.mb-4 { margin-bottom: 4px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.gap-8 { gap: 8px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.num { font-variant-numeric: tabular-nums; }

/* マトリクス ヘッダー固定 */
.mx thead th {
    position: sticky !important;
    top: 0 !important;
    z-index: 20 !important;
}
.mx thead tr:nth-child(2) th {
    top: 37px !important;
}
