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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f5;
    color: #333;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.layout {
    flex: 1;
    padding: 20px;
    width: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.case-constrained {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #ddd;
    margin-bottom: 24px;
}

.header .brand {
    font-size: 20px;
    font-weight: 600;
    color: #1a1a2e;
}

.header .brand span {
    color: #e2a626;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    position: relative;
}

.user-menu .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #1a1a2e;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.footer {
    text-align: center;
    padding: 16px;
    font-size: 12px;
    color: #888;
    border-top: 1px solid #ddd;
    margin-top: 32px;
}

.footer p + p {
    margin-top: 4px;
}

/* Cards */
.card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    padding: 20px;
    margin-bottom: 20px;
}

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

label {
    display: block;
    margin-bottom: 4px;
    font-weight: 500;
    font-size: 14px;
}

input[type="text"],
input[type="tel"],
input[type="email"],
input[type="password"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s;
}

input:focus {
    border-color: #1a1a2e;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    line-height: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    text-decoration: none;
    box-sizing: border-box;
    height: 40px;
}

.btn-primary {
    background: #1a1a2e;
    color: #fff;
}

.btn-primary:hover {
    background: #2d2d4a;
}

.btn-danger {
    background: #dc3545;
    color: #fff;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-secondary {
    background: #6c757d;
    color: #fff;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-success {
    background: #28a745;
    color: #fff;
}

.btn-success:hover {
    background: #218838;
}

.btn-warning {
    background: #ffc107;
    color: #333;
}

.btn-warning:hover {
    background: #e0a800;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Tables */
table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 14px;
}

th, td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

th {
    background: #f8f9fa;
    font-weight: 600;
    color: #555;
}

tr:hover {
    background: #f0f4ff;
}

tr.selected {
    background: #dbeafe;
}

/* Page title */
.page-title {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 20px;
    flex-shrink: 0;
}

/* Case view - two-column layout */
.case-view {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

.case-main {
    display: flex;
    gap: 20px;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

.case-left,
.case-right {
    width: 50%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.card-fill {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    margin-bottom: 0;
}

.card-fill h3 {
    flex-shrink: 0;
    margin-bottom: 12px;
}

.table-scroll {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* Resize handle */
.resize-handle {
    flex: 0 0 8px;
    background: #e0e0e0;
    border-radius: 4px;
    cursor: row-resize;
    margin: 8px 0;
    position: relative;
    transition: background 0.2s;
    flex-shrink: 0;
}

.resize-handle:hover {
    background: #1a1a2e;
}

.resize-handle::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 3px;
    background: #bbb;
    border-radius: 2px;
}

.resize-handle:hover::after {
    background: #fff;
}

.resize-handle.dragging {
    background: #1a1a2e;
}

.resize-handle.dragging::after {
    background: #fff;
}

/* PDF button */
.btn-pdf {
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid #1a1a2e;
    border-radius: 4px;
    background: #fff;
    color: #1a1a2e;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-pdf:hover {
    background: #1a1a2e;
    color: #fff;
}

/* PDF Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
}

.modal-content {
    position: relative;
    width: 90%;
    height: 90%;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid #eee;
    font-weight: 600;
    font-size: 16px;
    flex-shrink: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 26px;
    cursor: pointer;
    color: #888;
    padding: 0 6px;
    line-height: 1;
    transition: color 0.2s;
}

.modal-close:hover {
    color: #333;
}

.modal-content iframe {
    flex: 1;
    width: 100%;
    border: none;
}

/* -- Comments -- */
.btn-light-border {
    background: #fff;
    color: #333;
    border: 1px solid #333;
}
.btn-light-border:hover {
    background: #f0f0f0;
}

.btn-has-comments {
    background: #bbb;
    color: #fff;
    border: 1px solid #999;
}
.btn-has-comments:hover {
    background: #999;
}

.comments-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding: 0 4px;
}

.comment-item {
    padding: 10px 8px;
    border-bottom: 1px solid #f0f0f0;
}
.comment-item:last-child {
    border-bottom: none;
}

.comment-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.comment-author {
    font-weight: 600;
    font-size: 13px;
    color: #1a1a2e;
}

.comment-date {
    font-size: 11px;
    color: #999;
}

.comment-edited {
    font-size: 11px;
    color: #999;
    font-style: italic;
    margin-top: 2px;
}

.comment-text {
    font-size: 14px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
    color: #333;
}

.comment-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.comment-btn {
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px;
    transition: opacity 0.2s;
}
.comment-btn:hover {
    opacity: 0.8;
}
.comment-btn img {
    width: 16px;
    height: 16px;
    display: block;
}

.comment-btn-edit,
.comment-btn-del {
    background: #fff;
    border: 1px solid #aaa;
}
.comment-btn-edit:hover,
.comment-btn-del:hover {
    background: #f0f0f0;
}

.comment-input-area {
    padding: 10px 8px;
    border-top: 1px solid #eee;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}
.comment-input-area textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    min-height: 50px;
    outline: none;
    box-sizing: border-box;
}
.comment-input-area textarea:focus {
    border-color: #1a1a2e;
}
.comment-input-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}
.comment-input-actions .btn img {
    width: 16px;
    height: 16px;
    margin-right: 4px;
    vertical-align: middle;
}

.comment-edit-textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    min-height: 50px;
    outline: none;
    box-sizing: border-box;
    margin-bottom: 4px;
}
.comment-edit-textarea:focus {
    border-color: #1a1a2e;
}

.comment-edit-actions {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

#comments-card {
    flex: none;
    margin-top: 12px;
}
#comments-card .btn img {
    width: 16px;
    height: 16px;
    vertical-align: middle;
    margin-right: 4px;
}
