:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface2: #293548;
  --border: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --primary: #6366f1;
  --primary-h: #4f46e5;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #38bdf8;
  --radius: 10px;
  --sidebar: 220px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); height: 100vh; overflow: hidden; }

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

/* Sidebar */
.sidebar { width: var(--sidebar); background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 16px 0; flex-shrink: 0; }
.logo { font-size: 1.1rem; font-weight: 700; padding: 0 16px 20px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.nav-item { display: block; padding: 10px 16px; color: var(--muted); text-decoration: none; border-radius: 8px; margin: 2px 8px; cursor: pointer; font-size: 0.9rem; transition: background 0.15s, color 0.15s; }
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--primary); color: #fff; }

/* Content */
.content { flex: 1; overflow-y: auto; padding: 24px; }
.section { display: flex; flex-direction: column; gap: 16px; }
.section.hidden { display: none; }
.section-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.section-header h2 { font-size: 1.3rem; font-weight: 700; }
h2 { font-size: 1.3rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 600; color: var(--muted); }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }

/* Stats grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat-card .stat-val { font-size: 1.8rem; font-weight: 700; }
.stat-card .stat-label { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }
.stat-card.primary .stat-val { color: var(--primary); }
.stat-card.success .stat-val { color: var(--success); }
.stat-card.warning .stat-val { color: var(--warning); }
.stat-card.info .stat-val { color: var(--info); }

/* Tools grid */
.tools-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.tool-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; cursor: pointer; transition: border-color 0.15s, transform 0.1s; }
.tool-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.tool-card .tool-img { width: 100%; height: 150px; object-fit: cover; background: var(--surface2); display: flex; align-items: center; justify-content: center; font-size: 2.5rem; color: var(--muted); }
.tool-card img.tool-img { display: block; }
.tool-card .tool-info { padding: 12px; }
.tool-card .tool-name { font-weight: 600; font-size: 0.95rem; }
.tool-card .tool-cat { font-size: 0.75rem; color: var(--muted); margin: 2px 0 8px; }
.tool-card .tool-prices { font-size: 0.82rem; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.tool-card .tool-prices span { background: var(--surface2); padding: 2px 8px; border-radius: 99px; }

/* Clients list */
.client-row { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; align-items: center; gap: 12px; cursor: pointer; transition: border-color 0.15s; margin-bottom: 8px; }
.client-row:hover { border-color: var(--primary); }
.client-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1rem; flex-shrink: 0; }
.client-info { flex: 1; }
.client-name { font-weight: 600; }
.client-meta { font-size: 0.8rem; color: var(--muted); display: flex; gap: 12px; margin-top: 2px; }

/* Rentals */
.rental-row { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; align-items: flex-start; gap: 12px; margin-bottom: 8px; cursor: pointer; transition: border-color 0.15s; }
.rental-row:hover { border-color: var(--primary); }
.rental-info { flex: 1; }
.rental-title { font-weight: 600; }
.rental-meta { font-size: 0.8rem; color: var(--muted); display: flex; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 0.75rem; font-weight: 600; }
.badge-confirmed { background: rgba(99,102,241,0.2); color: var(--primary); }
.badge-ongoing { background: rgba(34,197,94,0.2); color: var(--success); }
.badge-returned { background: rgba(148,163,184,0.15); color: var(--muted); }
.badge-cancelled { background: rgba(239,68,68,0.15); color: var(--danger); }

/* Filter bar */
.filter-bar { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-btn { padding: 6px 14px; border: 1px solid var(--border); border-radius: 99px; background: transparent; color: var(--muted); cursor: pointer; font-size: 0.85rem; transition: all 0.15s; }
.filter-btn.active, .filter-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Search */
.search-bar input { width: 100%; max-width: 400px; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; color: var(--text); padding: 8px 12px; font-size: 0.9rem; outline: none; }
.search-bar input:focus { border-color: var(--primary); }

/* Calendar */
.cal-nav { display: flex; align-items: center; gap: 12px; }
.cal-nav span { font-weight: 600; min-width: 140px; text-align: center; }
.cal-table { width: 100%; border-collapse: collapse; }
.cal-table th { padding: 8px; text-align: center; font-size: 0.8rem; color: var(--muted); border-bottom: 1px solid var(--border); }
.cal-table td { padding: 4px; vertical-align: top; min-width: 80px; min-height: 80px; border: 1px solid var(--border); border-radius: 4px; }
.cal-day-num { font-size: 0.8rem; color: var(--muted); padding: 2px 4px; }
.cal-day-num.today { background: var(--primary); color: #fff; border-radius: 50%; width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; }
.cal-event { font-size: 0.7rem; padding: 2px 5px; border-radius: 4px; margin-bottom: 2px; cursor: pointer; background: rgba(99,102,241,0.25); color: var(--primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-event:hover { background: rgba(99,102,241,0.45); }

/* Platforms */
.platform-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.platform-row:last-child { border-bottom: none; }
.platform-row span { flex: 1; }

/* Returning soon */
.return-row { background: var(--surface); border: 1px solid var(--warning); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 8px; display: flex; align-items: center; gap: 12px; cursor: pointer; }
.return-row:hover { border-color: var(--primary); }

/* Buttons */
.btn { padding: 8px 16px; border: none; border-radius: 8px; font-size: 0.88rem; font-weight: 600; cursor: pointer; transition: background 0.15s, opacity 0.15s; white-space: nowrap; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-h); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.85; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); }
.btn-sm { padding: 4px 10px; font-size: 0.78rem; }
.btn-icon { background: transparent; border: none; cursor: pointer; color: var(--muted); padding: 4px 6px; border-radius: 6px; }
.btn-icon:hover { background: var(--surface2); color: var(--danger); }

/* Modals */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.65); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal.hidden { display: none; }
.modal-box { width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.modal-box.wide { max-width: 800px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 8px; }

/* Forms */
label { font-size: 0.82rem; color: var(--muted); margin-top: 6px; display: flex; align-items: center; gap: 6px; }
input[type="text"], input[type="email"], input[type="number"], input[type="date"], select, textarea {
  width: 100%; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; color: var(--text); padding: 8px 12px; font-size: 0.9rem; outline: none; margin-top: 2px; font-family: inherit;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
select option { background: var(--surface); }
textarea { resize: vertical; }
input[type="checkbox"] { width: auto; margin: 0; }
input[type="file"] { padding: 6px; font-size: 0.8rem; }
.form-row { display: flex; gap: 10px; align-items: flex-start; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-col { display: flex; flex-direction: column; }
.price-hint { font-size: 0.78rem; color: var(--warning); margin-top: 4px; }

/* Images preview */
.images-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.images-preview .img-thumb { position: relative; width: 80px; height: 80px; border-radius: 8px; overflow: hidden; border: 2px solid var(--border); }
.images-preview .img-thumb img { width: 100%; height: 100%; object-fit: cover; }
.images-preview .img-thumb .img-del { position: absolute; top: 2px; right: 2px; background: rgba(0,0,0,0.7); color: #fff; border: none; border-radius: 4px; cursor: pointer; font-size: 0.7rem; padding: 1px 4px; }
.images-preview .img-thumb .img-main { position: absolute; bottom: 2px; left: 2px; background: var(--primary); color: #fff; border: none; border-radius: 4px; cursor: pointer; font-size: 0.6rem; padding: 1px 4px; }

/* Tool detail */
.tool-detail-gallery { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 12px; }
.tool-detail-gallery img { height: 180px; border-radius: 8px; object-fit: cover; cursor: pointer; border: 2px solid transparent; }
.tool-detail-gallery img.main-img { border-color: var(--primary); }
.tool-detail-info { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.detail-field label { color: var(--muted); font-size: 0.78rem; }
.detail-field .val { font-size: 0.95rem; margin-top: 2px; }
.detail-field .price { font-size: 1.2rem; font-weight: 700; color: var(--success); }

/* Client detail */
.doc-grid { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0; }
.doc-item { position: relative; }
.doc-item img, .doc-item .doc-file { width: 100px; height: 100px; border-radius: 8px; object-fit: cover; border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 2rem; background: var(--surface2); }
.doc-item .doc-del { position: absolute; top: 2px; right: 2px; background: rgba(0,0,0,0.7); color: #fff; border: none; border-radius: 4px; cursor: pointer; font-size: 0.7rem; padding: 2px 5px; }
.doc-item .doc-label { font-size: 0.7rem; color: var(--muted); text-align: center; margin-top: 4px; max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.upload-zone { border: 2px dashed var(--border); border-radius: 8px; padding: 16px; text-align: center; color: var(--muted); font-size: 0.85rem; cursor: pointer; }
.upload-zone:hover { border-color: var(--primary); color: var(--text); }

.empty-state { text-align: center; color: var(--muted); padding: 40px; }

@media (max-width: 600px) {
  .form-grid { grid-template-columns: 1fr; }
  .tool-detail-info { grid-template-columns: 1fr; }
  body { overflow: auto; }
  .layout { flex-direction: column; height: auto; }
  .sidebar { width: 100%; flex-direction: row; overflow-x: auto; padding: 8px; gap: 4px; border-right: none; border-bottom: 1px solid var(--border); }
  .nav-item { white-space: nowrap; }
  .logo { display: none; }
}
