:root {
    --bg: #f4f7f5;
    --surface: #ffffff;
    --surface-soft: #f8faf9;
    --ink: #17231f;
    --muted: #66746f;
    --line: #dce5e1;
    --primary: #1f6f5c;
    --primary-dark: #155445;
    --primary-soft: #e4f2ed;
    --amber: #b7791f;
    --amber-soft: #fff5dd;
    --blue: #356a9a;
    --blue-soft: #e8f1fb;
    --red: #b54444;
    --red-soft: #fbeaea;
    --shadow: 0 18px 45px rgba(24, 52, 43, .08);
    --radius: 18px;
    --sidebar: 248px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--bg);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.muted { color: var(--muted); }
.eyebrow {
    margin: 0 0 8px;
    color: var(--primary);
    font-size: .73rem;
    font-weight: 800;
    letter-spacing: .14em;
    text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(1.7rem, 3vw, 2.25rem); letter-spacing: -.04em; }
h2 { margin-bottom: 6px; font-size: 1.12rem; }
h3 { margin-bottom: 6px; font-size: 1rem; }

.login-layout { display: grid; min-height: 100vh; grid-template-columns: minmax(360px, 1.1fr) minmax(420px, .9fr); }
.login-intro {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: clamp(48px, 8vw, 120px);
    overflow: hidden;
    color: white;
    background:
        radial-gradient(circle at 85% 20%, rgba(117, 218, 184, .3), transparent 28%),
        linear-gradient(145deg, #123f35, #1f6f5c 62%, #2d876f);
}
.login-intro::after {
    content: "";
    position: absolute;
    right: -110px;
    bottom: -110px;
    width: 360px;
    height: 360px;
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 50%;
    box-shadow: 0 0 0 55px rgba(255,255,255,.035), 0 0 0 110px rgba(255,255,255,.025);
}
.login-intro .eyebrow { margin-top: 42px; color: #a9ddcc; }
.login-intro h1 { max-width: 640px; margin-bottom: 24px; font-size: clamp(2.7rem, 6vw, 5.6rem); line-height: .98; letter-spacing: -.065em; }
.login-intro p:last-child { max-width: 590px; color: rgba(255,255,255,.78); font-size: 1.08rem; line-height: 1.7; }
.login-panel { display: grid; place-items: center; padding: 42px; background: #eef3f1; }
.login-card { width: min(100%, 430px); padding: 42px; border: 1px solid rgba(31,111,92,.12); border-radius: 24px; background: var(--surface); box-shadow: var(--shadow); }
.login-card h2 { margin-bottom: 8px; font-size: 2rem; letter-spacing: -.04em; }
.login-card form { display: grid; gap: 10px; margin-top: 30px; }
.login-card .button { margin-top: 16px; }

.brand-mark {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    border: 1px solid rgba(255,255,255,.32);
    border-radius: 17px;
    color: white;
    background: rgba(255,255,255,.12);
    font-size: 1.6rem;
    font-weight: 800;
    backdrop-filter: blur(8px);
}
.brand-mark.small { width: 40px; height: 40px; flex: 0 0 40px; border: none; border-radius: 12px; background: var(--primary); font-size: 1.1rem; }

label { display: grid; gap: 7px; color: #37453f; font-size: .86rem; font-weight: 700; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 11px;
    outline: none;
    color: var(--ink);
    background: var(--surface);
    transition: border-color .15s, box-shadow .15s;
}
input, select { min-height: 44px; padding: 0 13px; }
textarea { padding: 12px 13px; line-height: 1.55; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(31,111,92,.12); }
input::placeholder, textarea::placeholder { color: #9aa6a2; }

.button {
    min-height: 42px;
    padding: 0 17px;
    border: 1px solid transparent;
    border-radius: 11px;
    font-weight: 750;
    transition: transform .12s, background .12s, border-color .12s;
}
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: .6; transform: none; }
.button.primary { color: white; background: var(--primary); }
.button.primary:hover { background: var(--primary-dark); }
.button.secondary { border-color: var(--line); background: white; color: var(--ink); }
.button.secondary:hover { border-color: #b7c9c2; }
.button.ghost { background: transparent; color: var(--muted); }
.button.full { width: 100%; }
.text-button { padding: 0; border: 0; color: var(--primary); background: transparent; font-weight: 750; }
.icon-button { display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: white; }
.form-error { margin: 5px 0 0; color: var(--red); font-size: .86rem; }

.app-shell { min-height: 100vh; }
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    width: var(--sidebar);
    padding: 26px 18px 18px;
    border-right: 1px solid var(--line);
    background: rgba(255,255,255,.96);
}
.app-brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; color: var(--ink); text-decoration: none; }
.app-brand span:last-child { display: grid; gap: 2px; }
.app-brand strong { font-size: 1.05rem; }
.app-brand small { color: var(--muted); font-size: .7rem; }
.main-nav { display: grid; gap: 7px; margin-top: 44px; }
.nav-item { display: flex; align-items: center; gap: 12px; min-height: 45px; padding: 0 13px; border: 0; border-radius: 11px; color: #52615b; background: transparent; text-align: left; font-weight: 700; }
.nav-item span { width: 22px; color: #7b8984; font-size: 1.18rem; text-align: center; }
.nav-item:hover { background: var(--surface-soft); color: var(--ink); }
.nav-item.active { color: var(--primary); background: var(--primary-soft); }
.nav-item.active span { color: var(--primary); }
.nav-item.emphasized { margin-top: 10px; color: white; background: var(--primary); }
.nav-item.emphasized span { color: white; }
.sidebar-user { display: flex; align-items: center; gap: 10px; margin-top: auto; padding: 14px 6px 0; border-top: 1px solid var(--line); }
.avatar { display: grid; place-items: center; width: 38px; height: 38px; flex: 0 0 38px; border-radius: 50%; color: var(--primary); background: var(--primary-soft); font-weight: 800; }
.user-copy { display: grid; min-width: 0; flex: 1; }
.user-copy strong, .user-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-copy strong { font-size: .84rem; }.user-copy small { color: var(--muted); font-size: .7rem; }
.sidebar-user .icon-button { width: 34px; height: 34px; flex: 0 0 34px; border: 0; background: transparent; }
.app-content { min-height: 100vh; margin-left: var(--sidebar); }
.mobile-header { display: none; }
.page-section { max-width: 1320px; margin: 0 auto; padding: 46px clamp(28px, 4vw, 64px) 70px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 30px; }
.page-heading p:last-child { margin-bottom: 0; }
.page-heading.compact { align-items: center; }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; }
.metric-card { position: relative; min-height: 150px; padding: 22px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 8px 24px rgba(24,52,43,.04); }
.metric-card::after { content: ""; position: absolute; right: -20px; top: -20px; width: 80px; height: 80px; border-radius: 50%; background: var(--primary-soft); }
.metric-card > span { color: var(--muted); font-size: .8rem; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; }
.metric-card strong { display: block; margin: 17px 0 3px; font-size: 2.35rem; letter-spacing: -.05em; }
.metric-card small { color: var(--muted); }
.metric-card.pending::after { background: var(--amber-soft); }
.metric-card.progress::after { background: var(--blue-soft); }
.metric-card.resolved::after { background: var(--primary-soft); }

.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 8px 28px rgba(24,52,43,.045); }
.dashboard-grid { display: grid; grid-template-columns: 1.35fr .65fr; gap: 18px; margin-top: 18px; }
.dashboard-grid > .panel, .recent-panel { padding: 24px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.panel-heading p { margin: 0; color: var(--muted); font-size: .82rem; }
.ranking-list { display: grid; gap: 15px; }
.ranking-row { display: grid; grid-template-columns: minmax(110px, 1fr) 2fr 38px; align-items: center; gap: 12px; font-size: .85rem; }
.ranking-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranking-track { width: 100%; height: 8px; overflow: hidden; border: 0; border-radius: 10px; background: #edf2f0; appearance: none; }
.ranking-track::-webkit-progress-bar { border-radius: 10px; background: #edf2f0; }
.ranking-track::-webkit-progress-value { border-radius: 10px; background: var(--primary); }
.ranking-track::-moz-progress-bar { border-radius: 10px; background: var(--primary); }
.ranking-count { color: var(--muted); text-align: right; }
.attention-panel { background: linear-gradient(150deg, #173f35, #1f6f5c); color: white; border-color: transparent; }
.attention-panel .panel-heading p { color: rgba(255,255,255,.65); }
.time-metrics { display: grid; gap: 14px; }
.time-metrics div { padding: 15px; border: 1px solid rgba(255,255,255,.14); border-radius: 13px; background: rgba(255,255,255,.07); }
.time-metrics span { display: block; margin-bottom: 8px; color: rgba(255,255,255,.68); font-size: .78rem; }
.time-metrics strong { font-size: 1.45rem; }
.recent-panel { margin-top: 18px; }
.incident-list { display: grid; }
.incident-row { display: grid; grid-template-columns: 115px 1fr 150px 130px; align-items: center; gap: 14px; padding: 15px 4px; border-top: 1px solid #edf1ef; }
.incident-row:first-child { border-top: 0; }
.incident-row button { overflow: hidden; padding: 0; border: 0; color: var(--ink); background: transparent; text-align: left; text-overflow: ellipsis; white-space: nowrap; font-weight: 750; }
.incident-row small { color: var(--muted); }

.status { display: inline-flex; align-items: center; width: fit-content; min-height: 26px; padding: 0 9px; border-radius: 99px; font-size: .7rem; font-weight: 800; letter-spacing: .03em; }
.status.pending { color: #8b5a0b; background: var(--amber-soft); }
.status.in-progress { color: #285a88; background: var(--blue-soft); }
.status.resolved { color: var(--primary-dark); background: var(--primary-soft); }
.status.closed { color: #59635f; background: #ecefed; }
.priority { font-size: .72rem; font-weight: 800; }
.priority.high { color: var(--red); }

.filters { display: grid; grid-template-columns: minmax(210px, 1.7fr) repeat(3, minmax(130px, .8fr)) auto; align-items: end; gap: 12px; margin-bottom: 16px; padding: 16px; }
.filters label span { font-size: .72rem; }
.search-field input { padding-left: 14px; }
.table-panel { overflow: hidden; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 15px 18px; border-bottom: 1px solid #edf1ef; text-align: left; vertical-align: middle; }
th { color: var(--muted); background: var(--surface-soft); font-size: .71rem; letter-spacing: .05em; text-transform: uppercase; }
td { font-size: .84rem; }
td strong { display: block; max-width: 330px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td small { color: var(--muted); }
.row-action { border: 0; color: var(--primary); background: transparent; font-weight: 800; }
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 15px 18px; color: var(--muted); font-size: .8rem; }
.pagination > div { display: flex; gap: 7px; }
.empty-state { padding: 32px 16px; color: var(--muted); text-align: center; }

.incident-form { display: grid; gap: 22px; max-width: 940px; padding: clamp(22px, 4vw, 38px); }
.form-grid { display: grid; gap: 16px; }.form-grid.three { grid-template-columns: repeat(3, 1fr); }.form-grid.two { grid-template-columns: repeat(2, 1fr); }
.check-field { display: flex !important; flex-direction: row !important; align-items: center; gap: 10px; }
.check-field input { width: auto; }
.category-row { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 12px; }
.field-help { color: var(--muted); font-weight: 400; }
.upload-zone { place-items: center; min-height: 155px; padding: 22px; border: 1.5px dashed #abc5bb; border-radius: 15px; color: var(--ink); background: #f6fbf9; text-align: center; cursor: pointer; }
.upload-zone:hover { border-color: var(--primary); background: var(--primary-soft); }
.upload-zone span:not(.upload-icon) { color: var(--muted); font-size: .77rem; font-weight: 500; }
.upload-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.upload-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; color: var(--primary); background: white; font-size: 1.25rem; }
.selected-files { display: grid; gap: 7px; margin-top: -12px; }
.file-chip { display: flex; justify-content: space-between; gap: 12px; padding: 9px 12px; border-radius: 9px; background: var(--surface-soft); font-size: .78rem; }
.file-chip span:last-child { color: var(--muted); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 6px; }

.dialog { width: min(94vw, 660px); max-height: 90vh; padding: 0; overflow: hidden; border: 0; border-radius: 20px; background: white; box-shadow: 0 28px 80px rgba(12,34,27,.25); }
.dialog::backdrop { background: rgba(13,32,26,.52); backdrop-filter: blur(3px); }
.small-dialog form { display: grid; gap: 17px; padding: 26px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.dialog-heading h2 { margin-bottom: 0; font-size: 1.45rem; letter-spacing: -.03em; }
.detail-dialog { width: min(96vw, 960px); }
.dialog-heading.sticky { position: sticky; top: 0; z-index: 3; padding: 22px 26px 16px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.96); }
.detail-content { max-height: calc(90vh - 84px); padding: 24px 26px 34px; overflow-y: auto; }
.detail-meta { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 22px; }
.meta-box { padding: 12px; border-radius: 11px; background: var(--surface-soft); }
.meta-box span { display: block; margin-bottom: 5px; color: var(--muted); font-size: .69rem; font-weight: 750; text-transform: uppercase; }
.meta-box strong { font-size: .83rem; }
.detail-description { padding: 18px; border: 1px solid var(--line); border-radius: 13px; white-space: pre-wrap; line-height: 1.65; }
.resolution-confirmation { padding: 18px; border: 1px solid #b9dfd2; border-radius: 14px; background: var(--primary-soft); }
.resolution-confirmation > p { margin-top: -4px; }
.detail-section { margin-top: 26px; }
.detail-section > h3 { margin-bottom: 13px; }
.comment-list, .attachment-list, .history-list { display: grid; gap: 9px; }
.comment { padding: 13px 15px; border-left: 3px solid var(--line); border-radius: 0 10px 10px 0; background: var(--surface-soft); }
.comment.solution { border-color: var(--primary); background: var(--primary-soft); }
.comment p { margin: 5px 0 0; white-space: pre-wrap; line-height: 1.5; }
.comment small { color: var(--muted); }
.attachment { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; }
.attachment button { border: 0; color: var(--primary); background: transparent; font-weight: 750; }
.attachment small { display: block; color: var(--muted); }
.history-item { position: relative; padding: 0 0 14px 18px; border-left: 1px solid var(--line); }
.history-item::before { content: ""; position: absolute; left: -5px; top: 2px; width: 9px; height: 9px; border-radius: 50%; background: var(--primary); }
.history-item p { margin: 0 0 3px; font-size: .84rem; }.history-item small { color: var(--muted); }
.comment-form, .admin-form, .attachment-form { display: grid; gap: 11px; padding: 15px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-soft); }
.admin-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.admin-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.loading { display: flex; align-items: center; justify-content: center; gap: 5px; min-height: 150px; color: var(--muted); }
.loading span { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); animation: pulse 1s infinite alternate; }
.loading span:nth-child(2) { animation-delay: .2s; }.loading span:nth-child(3) { animation-delay: .4s; }
.loading p { margin: 0 0 0 8px; }
@keyframes pulse { to { opacity: .25; transform: translateY(-4px); } }

.toast-region { position: fixed; top: 20px; right: 20px; z-index: 100; display: grid; gap: 9px; width: min(390px, calc(100vw - 40px)); }
.toast { padding: 13px 15px; border: 1px solid var(--line); border-left: 4px solid var(--primary); border-radius: 11px; background: white; box-shadow: var(--shadow); font-size: .86rem; animation: toast-in .2s ease-out; }
.toast.error { border-left-color: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

@media (max-width: 1050px) {
    .metric-grid { grid-template-columns: repeat(2, 1fr); }
    .filters { grid-template-columns: repeat(2, 1fr); }
    .filters .search-field { grid-column: 1 / -1; }
    .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
    .login-layout { grid-template-columns: 1fr; }
    .login-intro { display: none; }
    .login-panel { min-height: 100vh; padding: 20px; }
    .login-card { padding: 30px 24px; }
    .sidebar { transform: translateX(-105%); transition: transform .2s; box-shadow: var(--shadow); }
    .sidebar.open { transform: translateX(0); }
    .app-content { margin-left: 0; }
    .mobile-header { position: sticky; top: 0; z-index: 15; display: flex; align-items: center; justify-content: space-between; height: 58px; padding: 0 14px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.94); backdrop-filter: blur(10px); }
    .mobile-header .icon-button { border: 0; }
    .page-section { padding: 28px 16px 50px; }
    .page-heading { align-items: flex-start; }
    .page-heading > .button { display: none; }
    .metric-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .metric-card { min-height: 126px; padding: 17px; }.metric-card strong { margin-top: 12px; font-size: 2rem; }
    .incident-row { grid-template-columns: 90px 1fr auto; }.incident-row > small:nth-of-type(1) { display: none; }
    .filters { grid-template-columns: 1fr; }.filters .search-field { grid-column: auto; }
    .filters .button { width: 100%; }
    .form-grid.three, .form-grid.two, .category-row, .detail-meta, .admin-grid, .admin-tools { grid-template-columns: 1fr; }
    .category-row .button { width: 100%; }
    .dialog { width: 100vw; max-width: none; height: 100vh; max-height: none; border-radius: 0; }
    .detail-content { max-height: calc(100vh - 84px); padding: 20px 16px 30px; }
    .dialog-heading.sticky { padding-inline: 16px; }
}

@media (max-width: 430px) {
    .metric-grid { grid-template-columns: 1fr; }
    .metric-card { min-height: 112px; }
    .form-actions { flex-direction: column-reverse; }.form-actions .button { width: 100%; }
}
