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

:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --shadow: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.03);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.05), 0 4px 6px -2px rgba(0,0,0,0.03);
  --radius: 8px;
  --radius-lg: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* Header */
.header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.header .logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.header .logo-icon {
  width: 28px;
  height: 28px;
  background: var(--primary);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 14px;
  font-weight: 800;
}

.header nav {
  display: flex;
  gap: 16px;
  align-items: center;
}

.header nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  padding: 6px 12px;
  border-radius: 6px;
  transition: all 0.2s;
}

.header nav a:hover {
  color: var(--primary);
  background: rgba(79, 70, 229, 0.08);
}

/* Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px;
}

/* Page Title */
.page-title {
  margin-bottom: 24px;
}

.page-title h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 6px;
}

.page-title p {
  color: var(--text-secondary);
  font-size: 14px;
}

/* Card */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 24px;
  margin-bottom: 24px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary {
  background: var(--card-bg);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg); border-color: #cbd5e1; }

.btn-success {
  background: var(--success);
  color: white;
}
.btn-success:hover { opacity: 0.9; }

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover { opacity: 0.9; }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Form elements */
textarea, input[type="text"], input[type="number"], input[type="date"], select {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  font-family: "JetBrains Mono", "Fira Code", Consolas, Monaco, monospace;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
  resize: vertical;
}

textarea:focus, input[type="text"]:focus, input[type="number"]:focus, input[type="date"]:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

textarea {
  min-height: 200px;
  line-height: 1.5;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text);
}

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

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 768px) {
  .form-row { grid-template-columns: 1fr; }
}

/* Grid layout for tool areas */
.tool-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

@media (max-width: 768px) {
  .tool-grid { grid-template-columns: 1fr; }
}

.tool-area {
  display: flex;
  flex-direction: column;
}

.tool-area label {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tool-area .count {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 400;
}

/* Toolbar */
.toolbar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
  flex-wrap: wrap;
}

.toolbar .swap-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card-bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.toolbar .swap-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(79, 70, 229, 0.05);
}

/* Status / Message */
.status-msg {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.status-msg.success { display: block; background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.status-msg.error { display: block; background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.status-msg.info { display: block; background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* Home page - category */
.category {
  margin-bottom: 32px;
}

.category-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  padding-left: 12px;
  border-left: 4px solid var(--primary);
}

.tool-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.tool-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-decoration: none;
  color: var(--text);
  transition: all 0.2s;
  display: block;
}

.tool-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.tool-card .icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(79, 70, 229, 0.1);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 12px;
}

.tool-card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

.tool-card p {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Hero */
.hero {
  text-align: center;
  padding: 48px 24px;
  margin-bottom: 32px;
}

.hero h1 {
  font-size: 36px;
  font-weight: 800;
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--primary), #ec4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  color: var(--text-secondary);
  font-size: 16px;
  max-width: 600px;
  margin: 0 auto;
}

.search-box {
  max-width: 560px;
  margin: 24px auto 0;
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 14px 20px;
  font-size: 16px;
  border: 2px solid var(--border);
  border-radius: 50px;
  background: var(--card-bg);
  color: var(--text);
  transition: all 0.2s;
  outline: none;
  box-shadow: var(--shadow);
}

.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.search-count {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg);
  padding: 2px 10px;
  border-radius: 12px;
}

.search-results {
  max-width: 560px;
  margin: 12px auto 0;
  text-align: left;
  display: none;
}

.search-results.active {
  display: block;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  color: var(--text);
}

.search-result-item:hover {
  border-color: var(--primary);
  background: rgba(79, 70, 229, 0.03);
  transform: translateX(4px);
}

.search-result-item .icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: rgba(79, 70, 229, 0.1);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.search-result-item .info {
  flex: 1;
  min-width: 0;
}

.search-result-item h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
}

.search-result-item p {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-item .cat {
  font-size: 11px;
  color: var(--primary);
  background: rgba(79, 70, 229, 0.1);
  padding: 2px 8px;
  border-radius: 10px;
  flex-shrink: 0;
}

.search-empty {
  text-align: center;
  padding: 20px;
  color: var(--text-secondary);
  font-size: 14px;
}

/* Table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th, .data-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  background: var(--bg);
  font-weight: 600;
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.data-table tr:hover td {
  background: var(--bg);
}

/* Checkbox & radio */
.checkbox-group, .radio-group {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.checkbox-item, .radio-item {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 14px;
}

.checkbox-item input, .radio-item input {
  cursor: pointer;
}

/* Color preview */
.color-preview {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 2px solid var(--border);
  display: inline-block;
  vertical-align: middle;
}

/* Gradient preview */
.gradient-preview {
  height: 80px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 16px;
}

/* Image drop zone */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg);
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--primary);
  background: rgba(79, 70, 229, 0.03);
}

.drop-zone .icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.drop-zone p {
  color: var(--text-secondary);
  font-size: 14px;
}

.drop-zone p strong {
  color: var(--primary);
}

/* Image preview */
.image-preview {
  max-width: 100%;
  max-height: 300px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.image-preview.zoomable {
  cursor: zoom-in;
  transition: transform 0.2s, box-shadow 0.2s;
}

.image-preview.zoomable:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  transform: scale(1.02);
}

/* Image lightbox / viewer */
.image-viewer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.image-viewer.active {
  opacity: 1;
  pointer-events: auto;
}

.image-viewer img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  border-radius: var(--radius);
  transition: transform 0.2s;
  user-select: none;
}

.image-viewer .viewer-close {
  position: absolute;
  top: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  transition: background 0.2s;
}

.image-viewer .viewer-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.image-viewer .viewer-toolbar {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  background: rgba(0, 0, 0, 0.6);
  padding: 8px 12px;
  border-radius: 50px;
  backdrop-filter: blur(10px);
}

.image-viewer .viewer-toolbar button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 16px;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-viewer .viewer-toolbar button:hover {
  background: rgba(255, 255, 255, 0.25);
}

.image-viewer .viewer-info {
  position: absolute;
  top: 32px;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 13px;
  background: rgba(0, 0, 0, 0.5);
  padding: 6px 14px;
  border-radius: 20px;
  backdrop-filter: blur(10px);
}

/* Stats row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat-item {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}

.stat-item .value {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
}

.stat-item .label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Footer */
.footer {
  text-align: center;
  padding: 24px;
  color: var(--text-secondary);
  font-size: 13px;
  border-top: 1px solid var(--border);
  margin-top: 48px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
