/* ============================
   CSS Variables & Base
   ============================ */
:root {
  --sidebar-w: 260px;
  --sidebar-bg: #1a2e4a;
  --sidebar-hover: rgba(255,255,255,0.08);
  --sidebar-active: rgba(59,130,246,0.25);
  --sidebar-active-border: #3b82f6;
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #fff;
  --topbar-h: 56px;
  --primary: #1a2e4a;
  --accent: #3b82f6;
  --body-bg: #f1f5f9;
  --card-radius: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -1px rgba(0,0,0,0.04);
}

* { box-sizing: border-box; }

body {
  font-family: 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', 'Meiryo', sans-serif;
  background: var(--body-bg);
  margin: 0;
  font-size: 0.9rem;
  color: #1e293b;
}

/* ============================
   Login Page
   ============================ */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #1a2e4a 0%, #1e40af 50%, #0f172a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-container {
  width: 100%;
  max-width: 420px;
}

.login-card {
  border: none;
  border-radius: 20px;
  overflow: hidden;
}

.org-logo {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, #1a2e4a, #3b82f6);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  box-shadow: 0 8px 24px rgba(59,130,246,0.4);
}

.org-logo i {
  font-size: 32px;
  color: white;
}

.org-name {
  font-size: 1.15rem;
  font-weight: 800;
  color: #1a2e4a;
  letter-spacing: 0.02em;
}

/* ============================
   Sidebar
   ============================ */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  overflow: hidden;
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
}

.sidebar-header {
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}

.sidebar-icon-wrap {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.sidebar-icon-wrap i { color: white; font-size: 18px; }

.sidebar-title {
  font-size: 1rem;
  font-weight: 700;
  color: white;
  line-height: 1.2;
}

.sidebar-subtitle {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.45);
  line-height: 1.2;
}

.sidebar-nav {
  padding: 12px 8px;
  overflow-y: auto;
  flex: 1;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.nav-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.3);
  padding: 8px 10px 4px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  color: var(--sidebar-text);
  text-decoration: none;
  border-radius: 8px;
  border-left: 3px solid transparent;
  margin-bottom: 2px;
  font-size: 0.875rem;
  transition: all 0.2s;
  white-space: nowrap;
}

.sidebar-link i {
  font-size: 1.05rem;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: white;
}

.sidebar-link.active {
  background: var(--sidebar-active);
  color: var(--sidebar-text-active);
  border-left-color: var(--sidebar-active-border);
  font-weight: 600;
}

/* Sidebar submenu (dropdown) */
.sidebar-submenu {
  display: none;
  padding-left: 18px;
}
.sidebar-submenu.open {
  display: block;
}
.sidebar-sublink {
  font-size: 0.82rem !important;
  padding: 7px 12px !important;
}
.sidebar-parent .sidebar-chevron {
  transition: transform 0.2s;
}
.sidebar-parent.open .sidebar-chevron {
  transform: rotate(180deg);
}

.sidebar-footer {
  padding: 14px 12px;
  border-top: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 2px;
}

.user-avatar {
  width: 32px; height: 32px;
  background: rgba(255,255,255,0.12);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.user-avatar i { color: rgba(255,255,255,0.7); font-size: 16px; }
.user-name { font-size: 0.85rem; color: rgba(255,255,255,0.85); font-weight: 600; line-height: 1.2; }
.user-role { font-size: 0.7rem; color: rgba(255,255,255,0.4); }

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

.topbar {
  height: var(--topbar-h);
  background: white;
  border-bottom: 1px solid #e2e8f0;
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 990;
}

.topbar-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--primary);
}

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

/* Sidebar Overlay */
.sidebar-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 999;
  backdrop-filter: blur(2px);
}

/* ============================
   Page Structure
   ============================ */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
  margin: 0;
  line-height: 1.2;
}

.page-subtitle {
  font-size: 0.82rem;
  color: #64748b;
  margin: 3px 0 0;
}

/* ============================
   Cards
   ============================ */
.card {
  border: 1px solid #e2e8f0;
  border-radius: var(--card-radius);
  box-shadow: var(--shadow-sm);
}

.card-header {
  background: white;
  border-bottom: 1px solid #e2e8f0;
  padding: 14px 20px;
  font-weight: 700;
  font-size: 0.9rem;
  color: #1e293b;
  border-radius: var(--card-radius) var(--card-radius) 0 0 !important;
}

/* Stat Cards */
.stat-card {
  background: white;
  border-radius: var(--card-radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 22px;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1;
  color: var(--primary);
}

.stat-label {
  font-size: 0.78rem;
  color: #64748b;
  margin-top: 3px;
}

/* Alert Cards */
.alert-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid;
  margin-bottom: 10px;
}

.alert-item.active { background: #fff7ed; border-color: #fed7aa; }
.alert-item.upcoming { background: #fffbeb; border-color: #fde68a; }
.alert-item.info { background: #eff6ff; border-color: #bfdbfe; }

.alert-icon-wrap {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.alert-item.active .alert-icon-wrap { background: #fed7aa; color: #c2410c; }
.alert-item.upcoming .alert-icon-wrap { background: #fde68a; color: #b45309; }
.alert-item.info .alert-icon-wrap { background: #bfdbfe; color: #1d4ed8; }

.alert-title { font-weight: 700; font-size: 0.9rem; color: #1e293b; }
.alert-desc { font-size: 0.8rem; color: #64748b; margin: 2px 0 0; }

/* ============================
   Tables
   ============================ */
.table-wrap {
  background: white;
  border-radius: var(--card-radius);
  border: 1px solid #e2e8f0;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.table-wrap .table {
  margin: 0;
  font-size: 0.85rem;
}

.table thead th {
  background: #f8fafc;
  border-bottom: 2px solid #e2e8f0;
  border-top: none;
  font-weight: 700;
  color: #475569;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 14px;
  vertical-align: middle;
  text-align: center;
  white-space: nowrap;
  white-space: nowrap;
}

.table tbody td {
  padding: 11px 14px;
  vertical-align: middle;
  border-color: #f1f5f9;
}

.table tbody tr:hover { background: #f8fafc; }
.table tbody tr:last-child td { border-bottom: none; }

/* ============================
   Badges & Labels
   ============================ */
.badge-role {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-role.officer { background: #dbeafe; color: #1d4ed8; }
.badge-role.employee { background: #dcfce7; color: #15803d; }
.badge-role.candidate { background: #f3e8ff; color: #7c3aed; }

.badge-team {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
}

.badge-team.front { background: #fef3c7; color: #b45309; }
.badge-team.back { background: #e0f2fe; color: #0369a1; }

.badge-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  font-weight: 800;
  font-size: 0.8rem;
  background: var(--primary);
  color: white;
}

/* ============================
   Filter Bar
   ============================ */
.filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 16px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.filter-bar .form-select,
.filter-bar .form-control {
  font-size: 0.82rem;
  padding: 5px 10px;
  height: auto;
  border-color: #e2e8f0;
  background: white;
}

.filter-bar .form-select { max-width: 150px; }
.filter-bar .search-input { max-width: 220px; }

/* ============================
   Forms & Modals
   ============================ */
.modal-content {
  border: none;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal-header {
  background: var(--primary);
  color: white;
  border-radius: 16px 16px 0 0;
  padding: 16px 20px;
  border-bottom: none;
}

.modal-header .btn-close {
  filter: invert(1) grayscale(1) brightness(2);
}

.modal-title { font-weight: 700; font-size: 1rem; }

.modal-body { padding: 20px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
  border-radius: 0 0 16px 16px;
}

.form-label {
  font-weight: 600;
  font-size: 0.82rem;
  color: #374151;
  margin-bottom: 4px;
}

.form-control, .form-select {
  border-color: #d1d5db;
  border-radius: 8px;
  font-size: 0.875rem;
}

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

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: #1e293b;
  -webkit-box-shadow: 0 0 0 1000px #fff inset;
  transition: background-color 5000s ease-in-out 0s;
}

.nav-tabs .nav-link {
  font-size: 0.82rem;
  font-weight: 600;
  color: #64748b;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 14px;
  border-radius: 0;
}

.nav-tabs .nav-link.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: none;
}

.nav-tabs { border-bottom: 1px solid #e2e8f0; margin-bottom: 16px; }

/* ============================
   Checklist Specific
   ============================ */
.checklist-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.checklist-container .table thead th:first-child,
.checklist-container .table tbody td:first-child {
  position: sticky;
  left: 0;
  background: #f8fafc;
  z-index: 1;
  border-right: 2px solid #e2e8f0;
  min-width: 140px;
}

.checklist-container .table tbody td:first-child { background: white; }
.checklist-container .table tbody tr:hover td:first-child { background: #f8fafc; }

.check-icon {
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.check-icon.done { color: #16a34a; }
.check-icon.pending { color: #d1d5db; }

/* ============================
   Progress Bar
   ============================ */
.progress-ring {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
}

/* ============================
   Fee Calendar
   ============================ */
.fee-month-cell {
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  border-radius: 6px;
  padding: 6px 4px;
  min-width: 60px;
}

.fee-month-cell.paid {
  background: #dcfce7;
  color: #15803d;
  font-weight: 700;
}

.fee-month-cell.unpaid {
  background: #fef2f2;
  color: #dc2626;
}

.fee-month-cell.future {
  background: #f8fafc;
  color: #94a3b8;
}

/* ============================
   Document Generation
   ============================ */
.doc-card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: var(--card-radius);
  padding: 24px;
  text-align: center;
  transition: all 0.2s;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.doc-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 20px rgba(59,130,246,0.15);
  transform: translateY(-2px);
}

.doc-card-icon {
  width: 64px; height: 64px;
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px;
  font-size: 28px;
}

/* ============================
   Work Regulations
   ============================ */
.drop-zone {
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  padding: 40px 20px;
  text-align: center;
  background: #f8fafc;
  transition: all 0.2s;
  cursor: pointer;
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--accent);
  background: #eff6ff;
}

.drop-zone i { font-size: 40px; color: #94a3b8; }

.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  margin-bottom: 8px;
  transition: box-shadow 0.2s;
}

.file-item:hover { box-shadow: var(--shadow); }

.file-icon {
  width: 40px; height: 40px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.file-icon.pdf { background: #fee2e2; color: #dc2626; }
.file-icon.txt { background: #dbeafe; color: #1d4ed8; }
.file-icon.docx { background: #dbeafe; color: #2563eb; }

/* Search highlight */
.highlight { background: #fef08a; border-radius: 2px; padding: 0 1px; }

/* ============================
   Buttons
   ============================ */
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
}
.btn-primary:hover { background: #2563eb; border-color: #2563eb; }

.btn-action {
  width: 30px; height: 30px;
  padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px;
  font-size: 0.85rem;
}

/* ============================
   Utilities
   ============================ */
.text-muted { color: #94a3b8 !important; }
.border-0 { border: none !important; }

.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: #94a3b8;
}

.empty-state i { font-size: 48px; display: block; margin-bottom: 12px; }
.empty-state p { font-size: 0.9rem; margin: 0; }

/* ============================
   Print Styles
   ============================ */
@media print {
  .no-print { display: none !important; }
  body { background: white; font-size: 11pt; }
  .doc-container { padding: 0; }
}

/* ============================
   Responsive
   ============================ */
@media (max-width: 767.98px) {
  .sidebar {
    transform: translateX(-100%);
    z-index: 1001;
  }
  .sidebar.show { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .content-area { padding: 16px; }
  .page-title { font-size: 1.2rem; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 1.5rem; }
}

@media (max-width: 575.98px) {
  .page-header { flex-direction: column; align-items: stretch; }
  .page-header .btn { width: 100%; }
}
