:root {
    --bg: #f3f6f4;
    --panel: #ffffff;
    --ink: #12231c;
    --muted: #5b6f66;
    --accent: #0d8a68;
    --accent-hover: #0b7458;
    --accent-soft: #e7f6f0;
    --line: #dce7e1;
    --danger: #c81e4a;
    --danger-hover: #a8183e;
    --secondary: #3d5a4f;
    --secondary-hover: #31483f;
    --header: rgba(255, 255, 255, 0.86);
    --shadow: 0 1px 2px rgba(18, 35, 28, 0.04), 0 10px 28px rgba(18, 35, 28, 0.06);
    --radius: 16px;
    --radius-sm: 10px;
    --shell-width: 1180px;
    --shell-gutter: 1.25rem;
}

* { box-sizing: border-box; }

html { color-scheme: light; }

body {
    margin: 0;
    font-family: Inter, "Segoe UI", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(900px 420px at -10% -20%, #d7efe4 0, transparent 55%),
        radial-gradient(700px 360px at 110% -10%, #e8f2ec 0, transparent 50%),
        var(--bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.45;
}

.shell,
.container {
    width: min(calc(100% - (var(--shell-gutter) * 2)), var(--shell-width));
    margin-left: auto;
    margin-right: auto;
}

.topbar {
    width: 100%;
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--header);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(16px);
}

.topbar-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    min-height: 4rem;
}

.brand {
    display: inline-flex;
    align-items: center;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--ink);
    font-size: 1.05rem;
    text-decoration: none;
}

.brand:hover {
    color: var(--ink);
}

.brand::before {
    content: "";
    width: 1.4rem;
    height: 1.4rem;
    margin-right: 0.6rem;
    border-radius: 7px;
    background: linear-gradient(135deg, #1ec99a 0%, var(--accent) 100%);
    box-shadow: 0 6px 14px rgba(13, 138, 104, 0.28);
}

.nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.35rem;
    align-items: center;
}

.nav-item {
    display: inline-flex;
    align-items: center;
    height: 2.25rem;
    line-height: 1;
}

.nav a, .linkish {
    color: var(--muted);
    text-decoration: none;
    background: none;
    border: none;
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    padding: 0.4rem 0.7rem;
    margin: 0;
    border-radius: 999px;
}

.nav a:hover, .linkish:hover {
    color: var(--accent);
    background: var(--accent-soft);
}

.nav-logout { margin: 0; }

.nav-dropdown { position: relative; }

.nav-dropdown-toggle {
    color: var(--muted);
    background: none;
    border: none;
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    padding: 0.4rem 0.7rem;
    margin: 0;
    height: 2.25rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border-radius: 999px;
}

.nav-dropdown-toggle::after {
    content: "";
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid currentColor;
}

.nav-dropdown-toggle:hover {
    color: var(--accent);
    background: var(--accent-soft);
}

.user-menu-toggle {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    height: 2.25rem;
    display: inline-flex;
    align-items: center;
}

.user-avatar {
    width: 2.15rem;
    height: 2.15rem;
    border-radius: 50%;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
    border: 2px solid #cdeadf;
    flex-shrink: 0;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.user-avatar-letter { text-transform: uppercase; }

.user-avatar-lg {
    width: 96px;
    height: 96px;
    font-size: 2.2rem;
    border-width: 3px;
}

.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 13rem;
    margin-top: 0.45rem;
    padding: 0.4rem;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
    z-index: 30;
}

.nav-dropdown-end .nav-dropdown-menu {
    left: auto;
    right: 0;
}

.nav-dropdown-menu a,
.nav-menu-button {
    display: block;
    width: 100%;
    padding: 0.55rem 0.75rem;
    white-space: nowrap;
    color: var(--ink);
    text-decoration: none;
    background: none;
    border: none;
    font: inherit;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    border-radius: 8px;
}

.nav-dropdown-menu a:hover,
.nav-menu-button:hover {
    background: var(--accent-soft);
    color: var(--accent);
}

.nav-dropdown-label {
    padding: 0.45rem 0.75rem 0.6rem;
    color: var(--muted);
    font-size: 0.8rem;
    border-bottom: 1px solid var(--line);
    margin-bottom: 0.3rem;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-menu-form { margin: 0; }

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu {
    display: block;
}

.avatar-preview-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1rem 0;
}

.cropper-panel { margin-top: 1rem; }

.cropper-stage {
    width: 100%;
    max-width: 420px;
    height: 320px;
    background: #163127;
    border-radius: 14px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.cropper-stage img {
    display: block;
    max-width: 100%;
}

.cropper-stage .cropper-view-box,
.cropper-stage .cropper-face {
    border-radius: 50%;
}

.cropper-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.profile-layout { align-items: start; }

.container {
    flex: 1 0 auto;
    margin-top: 1.75rem;
    margin-bottom: 2rem;
    padding: 0;
}

.site-footer {
    width: 100%;
    flex-shrink: 0;
    border-top: 1px solid var(--line);
    background: transparent;
    color: var(--muted);
    font-size: 0.85rem;
}

.footer-inner {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.1rem 0 1.5rem;
}

.site-footer a { color: var(--muted); }

.auth-page {
    align-items: center;
    justify-content: center;
}

.auth-wrap {
    width: min(calc(100% - (var(--shell-gutter) * 2)), 440px);
    margin: 4.5rem auto;
}

.auth-kicker {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    margin: 0 0 1.1rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--ink);
}

.auth-kicker::before {
    content: "";
    width: 1.35rem;
    height: 1.35rem;
    border-radius: 7px;
    background: linear-gradient(135deg, #1ec99a 0%, var(--accent) 100%);
}

.auth-card, .panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.4rem 1.5rem 1.55rem;
    box-shadow: var(--shadow);
}

.auth-card h1 { text-align: center; }
.auth-card > .muted { text-align: center; }

.auth-card button[type=submit] {
    width: 100%;
    margin-top: 1.2rem;
}

.auth-links {
    margin-top: 1.15rem;
    text-align: center;
}

h1, h2, h3 { margin-top: 0; letter-spacing: -0.03em; }
h1 { font-size: 1.7rem; font-weight: 700; }
h2 { font-size: 1.05rem; font-weight: 600; margin-top: 1.75rem; }
h3 { font-size: 0.98rem; }

.panel > h1 + .muted,
.page-header .muted { margin-top: 0.2rem; }

.page-header {
    margin-bottom: 1.15rem;
}

.breadcrumb,
.breadcrumb a {
    color: var(--muted);
    font-size: 0.88rem;
    text-decoration: none;
    font-weight: 500;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0 0 0.45rem;
}

.breadcrumb a:hover { color: var(--accent); }

label {
    display: block;
    margin: 0.85rem 0 0.35rem;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--ink);
}

label:has(input[type=checkbox]) {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    margin-top: 1.15rem;
}

input[type=checkbox] {
    width: 1.05rem;
    height: 1.05rem;
    accent-color: var(--accent);
}

input[type=text], input[type=email], input[type=password], input[type=number], input[type=file], select, textarea {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font: inherit;
    background: #fff;
    color: var(--ink);
    transition: border-color 0.15s, box-shadow 0.15s;
}

input[type=file] {
    padding: 0.45rem;
    background: #f8fbf9;
}

textarea { min-height: 120px; resize: vertical; }

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(13, 138, 104, 0.15);
}

button, .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 0.95rem;
    padding: 0.62rem 1.05rem;
    border-radius: 999px;
    border: none;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 8px 16px rgba(13, 138, 104, 0.18);
}

button:hover, .btn:hover {
    background: var(--accent-hover);
}

button.secondary, .btn.secondary {
    background: var(--secondary);
    box-shadow: none;
}

button.secondary:hover, .btn.secondary:hover {
    background: var(--secondary-hover);
}

button.danger, .btn.danger {
    background: var(--danger);
    box-shadow: none;
}

button.danger:hover, .btn.danger:hover {
    background: var(--danger-hover);
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.35rem;
    height: 2.35rem;
    padding: 0;
    margin-top: 0.95rem;
    margin-right: 0.35rem;
    border-radius: 10px;
    border: none;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    text-decoration: none;
    vertical-align: middle;
    line-height: 0;
    box-shadow: none;
}

.icon-btn svg {
    display: block;
    pointer-events: none;
}

.icon-btn.secondary { background: var(--secondary); }
.icon-btn.danger { background: var(--danger); }
.icon-btn:hover { filter: brightness(1.08); }

.icon-actions {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.icon-actions .icon-btn,
.icon-actions form,
.icon-actions button {
    margin-top: 0.85rem;
}

.icon-actions form.inline { display: inline-flex; }

.form-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.form-actions button,
.form-actions .icon-btn,
.form-actions form {
    margin-top: 0;
    margin-right: 0;
}

.form-actions form.inline { display: inline-flex; }

.flash, .error, .message {
    padding: 0.8rem 0.95rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    font-weight: 500;
}

.message { background: #e5f7ec; color: #14532d; }
.error { background: #fde8ee; color: var(--danger); }

.muted { color: var(--muted); font-size: 0.92rem; }

a { color: var(--accent); }

.table-scroll { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--panel);
}

.table th, .table td {
    border-bottom: 1px solid var(--line);
    padding: 0.8rem 0.75rem;
    text-align: left;
    vertical-align: middle;
}

.table th {
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    background: #f7faf8;
    font-weight: 600;
}

.table thead th:first-child { border-top-left-radius: 10px; }
.table thead th:last-child { border-top-right-radius: 10px; }

.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover { background: #f3faf6; }
.table tr.selected { background: var(--accent-soft); }

.cell-link {
    color: inherit;
    text-decoration: none;
    display: block;
}

.table a.cell-link { font-weight: 500; }

.table-editable input,
.table-editable select {
    margin: 0;
    min-width: 0;
}

.table-editable td.cell-checkbox {
    text-align: center;
    width: 5rem;
}

.table-editable td.cell-checkbox input[type=checkbox] {
    width: 1.05rem;
    height: 1.05rem;
}

.table-editable .icon-actions button,
.table-editable .icon-actions form,
.table-editable .icon-actions .icon-btn {
    margin-top: 0;
}

button.compact, .btn.compact {
    margin-top: 0;
    padding: 0.45rem 0.85rem;
    font-size: 0.92rem;
    box-shadow: none;
}

.table .col-description {
    max-width: 16rem;
    min-width: 10rem;
}

.cell-clamp-3 {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
    white-space: normal;
    word-break: break-word;
    line-height: 1.45;
}

.thumb {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #fff;
}

.attachment {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    color: inherit;
    text-decoration: none;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.18rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.badge-OPEN { background: #e7f6f0; color: #0b7458; }
.badge-IN_PROGRESS { background: #e8eefc; color: #274690; }
.badge-RESOLVED { background: #eef6d9; color: #3f6212; }
.badge-CLOSED { background: #eef1f0; color: #495057; }
.badge-visible { background: #e7f6f0; color: #0b7458; }
.badge-hidden { background: #fde8ee; color: var(--danger); }

.log-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}

.log-card {
    display: block;
    padding: 1.2rem 1.25rem 1.3rem;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.log-card:hover {
    transform: translateY(-2px);
    border-color: #b7d8c9;
    box-shadow: 0 12px 28px rgba(18, 35, 28, 0.08);
}

.log-card h2 {
    margin: 0 0 0.35rem;
    font-size: 1.05rem;
}

.log-card p {
    margin: 0;
}

.empty-state {
    padding: 1.5rem 0.25rem;
    color: var(--muted);
}

.issue-detail .form-actions {
    padding-top: 1rem;
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
}

.modal.modal-open {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(18, 35, 28, 0.45);
    border: none;
    cursor: pointer;
}

.modal-dialog {
    position: relative;
    z-index: 1;
    width: min(100%, 32rem);
    max-height: min(92vh, 860px);
    overflow-y: auto;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 18px 48px rgba(18, 35, 28, 0.18);
    padding: 1.25rem 1.35rem 1.35rem;
}

.modal-dialog h2 {
    margin: 0 2rem 1rem 0;
    font-size: 1.15rem;
}

.modal-dialog-wide {
    width: min(100%, 56rem);
}

.modal-close {
    position: absolute;
    top: 0.85rem;
    right: 0.85rem;
    margin-top: 0;
    z-index: 2;
}

body.modal-active {
    overflow: hidden;
}

.attachment-lightbox-caption {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0 2.5rem 0.75rem 0;
    word-break: break-word;
}

.attachment-lightbox-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 12rem;
    background: #f7faf8;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.attachment-lightbox-image {
    display: block;
    max-width: 100%;
    max-height: min(70vh, 720px);
    object-fit: contain;
}

.attachment-lightbox-pdf {
    display: block;
    width: 100%;
    height: min(70vh, 720px);
    border: none;
    background: #fff;
}

.attachment-lightbox-hint {
    margin: 0.75rem 0 0;
    text-align: center;
}

.attachment-lightbox-hint a {
    font-weight: 500;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.toolbar .btn { margin-top: 0; }

.inline { display: inline; }

.stack-form > * + * { margin-top: 0.2rem; }

.field-error { color: var(--danger); font-size: 0.85rem; font-weight: 500; }

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 700px) {
    .grid-2 { grid-template-columns: 1fr; }
    h1 { font-size: 1.4rem; }
}
