*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #2e7d32;
  --primary-dark: #1b5e20;
  --primary-light: #e8f5e9;
  --accent: #ff7043;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --sidebar-w: 220px;
  --header-h: 56px;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.1), 0 2px 4px rgba(0,0,0,.06);
}
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', sans-serif; background: var(--gray-100); color: var(--gray-800); font-size: 14px; line-height: 1.5; overflow-x: hidden; }
a { color: var(--primary); text-decoration: none; }
button { cursor: pointer; border: none; font-family: inherit; font-size: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }

/* Login */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1b5e20 0%, #2e7d32 100%); }
.login-card { background: #fff; border-radius: 16px; padding: 40px; width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-card .login-logo { text-align: center; margin-bottom: 32px; }
.login-card .login-logo .logo-icon { width: 64px; height: 64px; background: var(--primary); border-radius: 16px; display: inline-flex; align-items: center; justify-content: center; font-size: 32px; color: #fff; margin-bottom: 12px; }
.login-card .login-logo h2 { font-size: 22px; color: var(--gray-800); }
.login-card .login-logo p { font-size: 13px; color: var(--gray-500); margin-top: 4px; }

/* Layout */
.app { display: flex; min-height: 100vh; }
.app.hidden { display: none; }
.sidebar { width: var(--sidebar-w); background: var(--gray-900); color: #fff; position: fixed; top: 0; left: 0; bottom: 0; z-index: 100; display: flex; flex-direction: column; transition: transform .3s; }
.sidebar.closed { transform: translateX(-100%); }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 99; }
.sidebar-overlay.show { display: block; }
.sidebar-logo { padding: 16px 20px; font-size: 16px; font-weight: 700; border-bottom: 1px solid var(--gray-700); display: flex; align-items: center; gap: 10px; }
.sidebar-logo .logo-icon { width: 32px; height: 32px; background: var(--primary); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 16px; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.nav-section { padding: 12px 20px 4px; font-size: 11px; text-transform: uppercase; color: var(--gray-400); letter-spacing: .5px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 9px 20px; color: var(--gray-300); transition: all .15s; cursor: pointer; border: none; background: none; width: 100%; text-align: left; font-size: 14px; text-decoration: none; }
.nav-item:hover { background: var(--gray-800); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item .icon { width: 20px; text-align: center; font-size: 16px; }
.sidebar-footer { padding: 12px 20px; border-top: 1px solid var(--gray-700); font-size: 12px; color: var(--gray-500); }

/* Main */
.main { flex: 1; margin-left: var(--sidebar-w); overflow-x: auto; min-width: 0; }
.header { height: var(--header-h); background: #fff; border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; padding: 0 24px; gap: 16px; position: sticky; top: 0; z-index: 50; }
.header .menu-btn { display: none; background: none; border: none; font-size: 20px; color: var(--gray-600); }
.header-title { font-size: 18px; font-weight: 600; }
.header-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.user-info { display: flex; align-items: center; gap: 8px; padding: 6px 12px; background: var(--gray-50); border-radius: 6px; font-size: 13px; cursor: pointer; border: 1px solid var(--gray-200); }
.user-info:hover { background: var(--gray-100); }
.user-info .user-avatar { width: 28px; height: 28px; background: var(--primary); color: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; }
.user-dropdown { position: absolute; top: 50px; right: 16px; background: #fff; border: 1px solid var(--gray-200); border-radius: 8px; box-shadow: var(--shadow-md); min-width: 200px; display: none; z-index: 90; }
.user-dropdown.show { display: block; }
.dropdown-item { padding: 10px 16px; cursor: pointer; display: flex; align-items: center; gap: 8px; color: var(--gray-700); text-decoration: none; }
.dropdown-item:hover { background: var(--gray-50); }
.dropdown-divider { height: 1px; background: var(--gray-200); }

.content { padding: 24px; overflow-x: auto; }

/* Cards */
.card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card-header { padding: 14px 20px; border-bottom: 1px solid var(--gray-100); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-header h3 { font-size: 16px; font-weight: 600; }
.card-body { padding: 20px; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: #fff; border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 14px; }
.stat-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.stat-icon.green { background: #dcfce7; color: #16a34a; }
.stat-icon.blue { background: #dbeafe; color: #2563eb; }
.stat-icon.yellow { background: #fef3c7; color: #d97706; }
.stat-icon.red { background: #fee2e2; color: #dc2626; }
.stat-icon.purple { background: #f3e8ff; color: #9333ea; }
.stat-icon.orange { background: #ffedd5; color: #ea580c; }
.stat-info h4 { font-size: 22px; font-weight: 700; }
.stat-info p { font-size: 12px; color: var(--gray-500); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 6px; font-weight: 500; transition: all .15s; border: 1px solid transparent; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline { background: #fff; border: 1px solid var(--gray-300); color: var(--gray-700); }
.btn-outline:hover { background: var(--gray-50); }
.btn-import { color: #c2410c; border: 1px solid #fb923c; background: #fff7ed; }
.btn-import:hover { background: #ffedd5; }
.btn-export { color: #15803d; border: 1px solid #86efac; background: #f0fdf4; }
.btn-export:hover { background: #dcfce7; }
.btn:disabled { background: var(--gray-200) !important; color: var(--gray-400) !important; border-color: var(--gray-300) !important; cursor: not-allowed; opacity: .7; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-icon { padding: 6px 8px; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-block { width: 100%; justify-content: center; }

/* Modal */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 200; align-items: center; justify-content: center; padding: 16px; }
.modal-overlay.show { display: flex; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-lg { max-width: 800px; }
.modal-header { padding: 14px 20px; border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 18px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 22px; color: var(--gray-400); }
.modal-body { padding: 20px; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--gray-200); display: flex; justify-content: flex-end; gap: 8px; }

/* Form */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; margin-bottom: 4px; font-weight: 500; font-size: 13px; color: var(--gray-700); }
.form-control { width: 100%; padding: 8px 12px; border: 1px solid var(--gray-300); border-radius: 6px; outline: none; transition: border-color .2s; background: #fff; }
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(46,125,50,.1); }
select.form-control { appearance: auto; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* Toast */
#toastContainer { position: fixed; top: 16px; right: 16px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 20px; border-radius: 8px; color: #fff; font-weight: 500; box-shadow: var(--shadow-md); animation: slideIn .3s; }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--info); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Badge */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 500; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-gray { background: var(--gray-100); color: var(--gray-700); }

/* Filter bar */
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px 20px; background: var(--gray-50); border-bottom: 1px solid var(--gray-100); }
.filter-bar input, .filter-bar select { padding: 6px 10px; border: 1px solid var(--gray-300); border-radius: 6px; font-size: 13px; background: #fff; }
.filter-bar .spacer { flex: 1; }

/* Loading */
.loading-overlay { position: fixed; inset: 0; background: rgba(255,255,255,.7); z-index: 9000; display: none; align-items: center; justify-content: center; }
.loading-overlay.show { display: flex; }
.spinner { width: 36px; height: 36px; border: 3px solid var(--gray-200); border-top-color: var(--primary); border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Empty */
.empty-state { padding: 40px; text-align: center; color: var(--gray-500); }
.empty-state .icon { font-size: 48px; margin-bottom: 12px; opacity: .4; }

/* 商品画像サムネ */
.product-thumb { width: 32px; height: 32px; border-radius: 4px; object-fit: cover; vertical-align: middle; background: var(--gray-100); }
.product-thumb-placeholder { width: 32px; height: 32px; border-radius: 4px; background: var(--gray-100); display: inline-flex; align-items: center; justify-content: center; color: var(--gray-400); font-size: 14px; }

/* Pagination */
.pagination { display: flex; gap: 4px; justify-content: center; padding: 16px; align-items: center; }
.page-btn { padding: 6px 12px; border: 1px solid var(--gray-300); background: #fff; border-radius: 4px; min-width: 36px; }
.page-btn:hover { background: var(--gray-50); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:disabled { color: var(--gray-300); cursor: not-allowed; }
.page-info { padding: 0 12px; color: var(--gray-600); font-size: 13px; }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .header .menu-btn { display: block; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
}
