/* Reset & Base */
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
body{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans SC",sans-serif;background:#f5f6f8;color:#1a1a2e;line-height:1.6;min-height:100vh}
a{color:#2563eb;text-decoration:none}
a:hover{text-decoration:underline}

/* Navbar */
.navbar{display:flex;align-items:center;justify-content:space-between;padding:0 24px;height:52px;background:#fff;border-bottom:1px solid #e2e4e9;position:sticky;top:0;z-index:100}
.nav-brand{font-size:16px;font-weight:700;color:#1a1a2e;letter-spacing:.5px}
.nav-links{display:flex;align-items:center;gap:4px}
.nav-link{color:#64748b;padding:6px 14px;border-radius:6px;font-size:13px;transition:all .15s}
.nav-link:hover{background:#f1f5f9;color:#1a1a2e;text-decoration:none}
.nav-current{color:#1a1a2e;font-weight:600;padding:6px 14px;font-size:13px;background:#f1f5f9;border-radius:6px}

/* Container */
.container{max-width:1200px;margin:0 auto;padding:24px}

/* Page Header */
.page-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:24px;flex-wrap:wrap;gap:12px}
.page-header h2{font-size:22px;font-weight:700}
.page-header h3{font-size:18px;font-weight:600;margin:32px 0 12px}
.header-actions{display:flex;gap:8px}

/* Homepage */
.home{display:flex;flex-direction:column;align-items:center;justify-content:center;min-height:70vh;text-align:center}
.home-title{font-size:32px;font-weight:700;margin-bottom:40px;color:#1a1a2e}
.home-entrances{display:flex;gap:24px;flex-wrap:wrap;justify-content:center}
.home-card{display:flex;flex-direction:column;align-items:center;padding:32px 40px;background:#fff;border:1px solid #e2e4e9;border-radius:8px;width:280px;transition:all .2s;cursor:pointer}
.home-card:hover{border-color:#2563eb;box-shadow:0 4px 16px rgba(37,99,235,.1);transform:translateY(-2px);text-decoration:none}
.home-card-icon{font-size:40px;margin-bottom:16px}
.home-card-title{font-size:18px;font-weight:600;color:#1a1a2e;margin-bottom:8px}
.home-card-desc{font-size:13px;color:#64748b;line-height:1.5}

/* Tabs */
.tabs{display:flex;gap:0;margin-bottom:24px;border-bottom:2px solid #e2e4e9}
.tab{padding:10px 20px;font-size:14px;border:none;background:none;color:#64748b;cursor:pointer;border-bottom:2px solid transparent;margin-bottom:-2px;transition:all .15s}
.tab:hover{color:#1a1a2e}
.tab.active{color:#2563eb;border-bottom-color:#2563eb;font-weight:600}

/* Form */
.form{background:#fff;border:1px solid #e2e4e9;border-radius:8px;padding:28px}
.form-group{margin-bottom:20px}
.form-group label{display:block;font-size:13px;font-weight:600;color:#475569;margin-bottom:6px}
.form-group input[type="text"],
.form-group input[type="url"],
.form-group input[type="date"],
.form-group select,
.form-group textarea{width:100%;padding:9px 12px;border:1px solid #d1d5db;border-radius:6px;font-size:14px;font-family:inherit;transition:border-color .15s;background:#fff}
.form-group input:focus,.form-group select:focus,.form-group textarea:focus{outline:none;border-color:#2563eb;box-shadow:0 0 0 3px rgba(37,99,235,.1)}
.form-group textarea{resize:vertical;min-height:80px}
.form-group input[type="file"]{font-size:13px}
.form-row{display:flex;gap:16px}
.form-row .form-group{flex:1}
.form-group.flex-2{flex:2}
.file-hint{font-size:12px;color:#94a3b8;margin-top:4px}
.file-preview{display:flex;flex-wrap:wrap;gap:6px;margin-top:8px}
.file-tag{display:inline-block;background:#e8f0fe;color:#2563eb;padding:3px 10px;border-radius:12px;font-size:12px}
.form-msg{margin-left:12px;font-size:14px}
.form-msg.success{color:#16a34a}
.form-msg.error{color:#dc2626}
.form-actions{display:flex;align-items:center;gap:12px}

/* Buttons */
.btn{display:inline-flex;align-items:center;justify-content:center;padding:8px 16px;border-radius:6px;font-size:13px;font-weight:500;border:1px solid transparent;cursor:pointer;transition:all .15s;font-family:inherit;line-height:1.4;white-space:nowrap}
.btn:hover{text-decoration:none}
.btn-primary{background:#2563eb;color:#fff;border-color:#2563eb}
.btn-primary:hover{background:#1d4ed8}
.btn-outline{background:#fff;color:#475569;border-color:#d1d5db}
.btn-outline:hover{background:#f8fafc;border-color:#94a3b8}
.btn-danger{background:#dc2626;color:#fff;border-color:#dc2626}
.btn-danger:hover{background:#b91c1c}
.btn-warning{background:#f59e0b;color:#fff;border-color:#f59e0b}
.btn-warning:hover{background:#d97706}
.btn-sm{padding:4px 10px;font-size:12px}
.btn-lg{padding:10px 24px;font-size:15px}
.btn:disabled{opacity:.6;cursor:not-allowed}

/* Table */
.table{width:100%;background:#fff;border:1px solid #e2e4e9;border-radius:8px;overflow:hidden;border-collapse:collapse}
.table thead{background:#f8fafc}
.table th,.table td{padding:10px 14px;text-align:left;font-size:13px;border-bottom:1px solid #e2e4e9}
.table th{font-weight:600;color:#475569;font-size:12px;text-transform:none}
.table tbody tr:hover{background:#f8fafc}
.table tbody tr:last-child td{border-bottom:none}

/* Badge */
.badge{display:inline-block;background:#e2e4e9;color:#475569;padding:2px 8px;border-radius:10px;font-size:12px;margin-left:8px;font-weight:500}

/* Status */
.status{display:inline-block;padding:2px 10px;border-radius:10px;font-size:12px;font-weight:500}
.status-pending{background:#fef3c7;color:#92400e}
.status-completed{background:#d1fae5;color:#065f46}
.status-archived{background:#e2e4e9;color:#475569}

/* Text */
.text-muted{color:#94a3b8;font-size:13px}

/* Section */
.section{margin-top:28px;background:#fff;border:1px solid #e2e4e9;border-radius:8px;padding:24px}
.section h3{font-size:16px;font-weight:600;margin-bottom:16px;color:#1a1a2e}

/* Case Info */
.case-info{background:#fff;border:1px solid #e2e4e9;border-radius:8px;padding:20px 24px;margin-bottom:20px}
.info-grid{display:flex;flex-wrap:wrap;gap:16px 32px;margin-bottom:12px}
.info-item{display:flex;gap:8px;font-size:14px}
.info-label{color:#64748b;min-width:70px;flex-shrink:0}
.info-section{margin-top:8px;font-size:14px}
.ext-link{color:#2563eb;word-break:break-all;font-size:13px}

/* Image Gallery */
.image-gallery{display:flex;flex-wrap:wrap;gap:12px}
.gallery-item{width:180px;cursor:pointer;border:1px solid #e2e4e9;border-radius:6px;overflow:hidden;transition:all .15s;background:#f8fafc}
.gallery-item:hover{border-color:#2563eb;box-shadow:0 2px 8px rgba(37,99,235,.12)}
.gallery-item img{width:100%;height:140px;object-fit:cover;display:block}
.gallery-name{padding:6px 10px;font-size:13px;font-weight:600;color:#1a1a2e;text-align:center;background:#fff;border-top:1px solid #e2e4e9}

/* Existing images (edit page) */
.existing-images{display:flex;flex-wrap:wrap;gap:10px;margin-bottom:12px}
.img-thumb{position:relative;width:120px;border:1px solid #e2e4e9;border-radius:6px;overflow:hidden;background:#f8fafc}
.img-thumb img{width:100%;height:90px;object-fit:cover;display:block}
.img-name{font-size:11px;padding:3px 6px;color:#475569;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.img-del{position:absolute;top:2px;right:2px;background:rgba(220,38,38,.9);color:#fff;border:none;width:20px;height:20px;border-radius:10px;font-size:12px;line-height:1;cursor:pointer;display:flex;align-items:center;justify-content:center}
.img-del:hover{background:#dc2626}

/* Field blocks */
.field-block{margin-bottom:16px}
.field-label{font-size:12px;font-weight:600;color:#64748b;margin-bottom:4px;text-transform:none}
.field-value{font-size:14px;color:#1a1a2e;line-height:1.6;white-space:pre-wrap}

/* Diagnosis Form */
.diagnosis-form{padding-top:24px;border-top:2px dashed #e2e4e9}

/* Disk bar */
.disk-bar{display:flex;align-items:center;gap:12px;padding:10px 14px;background:#fff;border:1px solid #e2e4e9;border-radius:8px;margin-bottom:20px;font-size:13px;color:#475569}
.disk-progress{flex:1;height:8px;background:#e2e4e9;border-radius:4px;overflow:hidden;max-width:300px}
.disk-fill{height:100%;background:#2563eb;border-radius:4px;transition:width .3s}

/* Stats */
.stats-period{display:flex;align-items:center;gap:10px;margin-bottom:20px;font-size:14px}
.stats-period input[type="date"]{padding:7px 10px;border:1px solid #d1d5db;border-radius:6px;font-size:13px}
.stats-table-wrap{overflow-x:auto}
.stats-table{min-width:900px}
.stats-table th,.stats-table td{text-align:center;min-width:60px;font-size:12px}
.stats-table th:first-child,.stats-table td:first-child{text-align:left;min-width:90px}
.stats-table .total-row td,.stats-table .grand-row td{background:#fef3c7;font-weight:700}
.stats-table tfoot td{border-top:2px solid #1a1a2e}

/* Image Viewer */
.viewer-overlay{position:fixed;inset:0;background:rgba(0,0,0,.92);z-index:9999;display:flex;align-items:center;justify-content:center;flex-direction:column}
.viewer-close{position:absolute;top:20px;right:24px;font-size:36px;color:#fff;cursor:pointer;z-index:10;width:44px;height:44px;display:flex;align-items:center;justify-content:center;border-radius:22px}
.viewer-close:hover{background:rgba(255,255,255,.1)}
.viewer-nav{position:absolute;top:50%;transform:translateY(-50%);font-size:48px;color:#fff;cursor:pointer;z-index:10;padding:20px;user-select:none}
.viewer-nav:hover{color:#94a3b8}
.viewer-prev{left:20px}
.viewer-next{right:20px}
.viewer-content{display:flex;flex-direction:column;align-items:center;max-width:90vw;max-height:90vh}
#viewer-img{max-width:90vw;max-height:75vh;object-fit:contain;cursor:zoom-in;transition:transform .1s}
.viewer-filename{margin-top:16px;font-size:22px;font-weight:700;color:#fff;text-align:center}

/* Responsive */
@media(max-width:768px){
    .container{padding:12px}
    .form{padding:16px}
    .form-row{flex-direction:column;gap:0}
    .home-entrances{flex-direction:column;align-items:center}
    .home-card{width:100%;max-width:320px}
    .image-gallery{gap:8px}
    .gallery-item{width:140px}
    .gallery-item img{height:110px}
    .info-grid{flex-direction:column;gap:8px}
    .navbar{padding:0 12px}
    .nav-link,.nav-current{padding:4px 8px;font-size:12px}
    .page-header{flex-direction:column;align-items:flex-start}
}
