@import url('https://cdn.jsdelivr.net/npm/@dawod/thmanyah-font-web/sans.css');

:root {
    --background: #ffffff;
    --foreground: #0f172a;
    --card: #ffffff;
    --card-foreground: #0f172a;
    --primary: #0f172a;
    --primary-foreground: #f8fafc;
    --secondary: #f1f5f9;
    --secondary-foreground: #0f172a;
    --muted: #f8fafc;
    --muted-foreground: #64748b;
    --accent: #f1f5f9;
    --accent-foreground: #0f172a;
    --destructive: #ef4444;
    --border: #e2e8f0;
    --input: #e2e8f0;
    --ring: #94a3b8;
    --radius: 0.625rem;
    --header-height: 4.4rem;
}

body.sys-app,
body.sys-app button,
body.sys-app input,
body.sys-app select,
body.sys-app textarea,
.sa-auth,
.sa-auth button,
.sa-auth input,
.sa-portal {
    font-family: "Thmanyah Sans", system-ui, sans-serif;
}

body.sys-app {
    margin: 0;
    background: var(--muted) !important;
    color: var(--foreground);
    text-align: right;
    padding-top: calc(var(--header-height) + 1.5rem);
}

.sa-navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 40;
    height: var(--header-height);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1.25rem;
    background: #fff;
    border: 0;
}

.sa-side {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 0;
}

.sa-side-left {
    justify-self: start;
}

.sa-menu {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    border: 0;
}

.sa-brand {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.sa-logo {
    width: 2.7rem;
    height: 2.7rem;
    object-fit: contain;
    display: block;
}

.sa-auth-logo {
    width: 4.5rem;
    height: 4.5rem;
    margin-bottom: 0.6rem;
}

.sa-navbtn,
.sa-menu > .sa-link {
    display: inline-flex;
    align-items: center;
    height: 2.6rem;
    padding: 0 0.9rem;
    border: 0;
    border-radius: calc(var(--radius) - 2px);
    background: transparent;
    color: var(--foreground);
    font: inherit;
    font-size: 1.28rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}

.sa-navbtn::after {
    content: "";
    width: 0.4rem;
    height: 0.4rem;
    margin-right: 0.35rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg) translateY(-2px);
}

.sa-navbtn:hover,
.sa-menu > .sa-link:hover,
.sa-menu > .sa-link.is-active,
.sa-drop:hover > .sa-navbtn,
.sa-drop:focus-within > .sa-navbtn {
    background: transparent;
    color: var(--foreground);
}

.sa-drop {
    position: relative;
}

.sa-side-left .sa-drop-panel {
    right: auto;
    left: 0;
}

.sa-drop-panel {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 50;
    min-width: 230px;
    padding: 0.35rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 12px 28px rgb(15 23 42 / 0.1);
}

.sa-drop-wide {
    display: none;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    gap: 0.35rem;
    min-width: min(760px, 80vw);
}

.sa-drop:hover > .sa-drop-panel,
.sa-drop:focus-within > .sa-drop-panel {
    display: block;
}

.sa-drop:hover > .sa-drop-wide,
.sa-drop:focus-within > .sa-drop-wide {
    display: grid;
}

.sa-drop-label {
    padding: 0.35rem 0.7rem 0.15rem;
    color: var(--muted-foreground);
    font-size: 0.75rem;
    font-weight: 700;
}

.sa-link {
    display: block;
    margin: 0.1rem 0;
    padding: 0.5rem 0.8rem;
    border-radius: calc(var(--radius) - 2px);
    color: var(--foreground);
    text-decoration: none;
    font-size: 1.08rem;
}

.sa-link:hover,
.sa-link.is-active {
    background: var(--accent);
    color: var(--accent-foreground);
}

.sa-header-tools {
    justify-self: end;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
}

.sa-navbar select {
    width: 6.5rem;
    min-height: 2.25rem;
}

.sa-search {
    position: relative;
    width: min(280px, 40vw);
}

.sa-search-results {
    position: absolute;
    top: calc(100% + 0.35rem);
    right: 0;
    left: 0;
    z-index: 50;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 10px 20px rgb(15 23 42 / 0.08);
    max-height: 18rem;
    overflow: auto;
}

.sa-search-results:empty {
    display: none;
}

.sa-search-results a {
    display: block;
    padding: 0.55rem 0.75rem;
    color: var(--foreground);
    text-decoration: none;
}

.sa-search-results a:hover {
    background: var(--accent);
}

html:has(body.sa-is-home:not(:has(table))),
body.sa-is-home:not(:has(table)) {
    height: 100%;
    overflow: hidden;
}

.sa-home {
    width: min(1100px, calc(100% - 2rem));
    height: calc(100vh - var(--header-height) - 1.5rem);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: transparent;
    border: 0;
    box-shadow: none;
    padding: 1rem;
    box-sizing: border-box;
    overflow: hidden;
}

body.sa-is-home:not(:has(table)) > .w3-row {
    display: none !important;
}

body.sa-is-home:has(table) {
    height: auto;
    overflow: auto;
}

body.sa-is-home:has(table) .sa-home {
    height: auto;
    overflow: visible;
    padding-bottom: 0.5rem;
}

.sa-home-title {
    margin: 0.6rem 0 0;
    font-size: 1.85rem;
    font-weight: 700;
}

.sa-home-logo {
    width: 10rem;
    height: 10rem;
    object-fit: contain;
}

.sa-home-find {
    width: min(760px, 100%);
    margin-top: 1.35rem;
    display: flex;
    direction: rtl;
    justify-content: center;
    align-items: center;
    gap: 0.6rem;
}

.sa-home-find select,
.sa-home-find input {
    direction: ltr;
    text-align: right;
}

.sa-home-find select {
    width: 7.5rem;
}

.sa-home-find .sa-search {
    width: min(560px, 100%);
}

.sa-home-detail,
body.sys-app .sa-home-detail {
    margin-top: 0.95rem;
    min-height: 2.7rem;
    padding: 0 1.5rem;
    border: 0 !important;
    border-radius: calc(var(--radius) - 2px);
    background: var(--primary) !important;
    color: var(--primary-foreground) !important;
    font: inherit;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
}

.sa-home-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.35rem 0.8rem;
    margin-top: 1rem;
    color: var(--muted-foreground);
    font-size: 0.92rem;
}

.sa-home-meta b {
    color: var(--foreground);
    font-weight: 700;
}

body.sa-is-home > .w3-row .w3-card-4:has(> h4:only-child),
body.sa-is-home > .w3-row .w3-card-4:has(form),
body.sa-is-home > .w3-row .w3-container:has(form) {
    display: none !important;
}

.sa-modal {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: grid;
    place-items: center;
    padding: 1.25rem;
    background: rgb(15 23 42 / 0.45);
}

.sa-modal[hidden] {
    display: none;
}

.sa-modal-card {
    width: min(640px, 100%);
    max-height: min(86vh, 760px);
    overflow: auto;
    background: var(--card);
    border-radius: calc(var(--radius) + 4px);
    padding: 1rem 1.15rem 1.25rem;
    box-shadow: 0 20px 40px rgb(15 23 42 / 0.16);
}

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

.sa-modal-head h3 {
    margin: 0;
    font-size: 1.25rem;
}

.sa-modal-close,
body.sys-app .sa-modal-close {
    width: 2.2rem;
    height: 2.2rem;
    border: 0 !important;
    border-radius: calc(var(--radius) - 2px);
    background: var(--secondary) !important;
    color: var(--foreground) !important;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}

#sa-detail {
    direction: rtl;
}

#sa-detail .w3-row-padding {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

#sa-detail .w3-row-padding > .w3-third {
    order: -1;
}

#sa-detail .w3-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.3rem;
    width: 100%;
    margin: 0;
}

#sa-detail .w3-third,
#sa-detail .w3-twothird {
    width: 100% !important;
    float: none !important;
    padding: 0 !important;
    min-width: 0;
}

#sa-detail .w3-third {
    order: -1;
}

#sa-detail .w3-third h4,
#sa-detail .w3-third h5 {
    margin: 0;
    font-size: 1rem;
    text-align: right;
}

#sa-detail .w3-row .w3-row {
    display: flex;
    justify-content: flex-start;
}

#sa-detail .w3-row .w3-row .w3-third {
    display: none;
}

#sa-detail select {
    direction: ltr;
    width: 100%;
    box-sizing: border-box;
    text-align: right;
}

#sa-detail button,
body.sys-app #sa-detail button {
    background: var(--primary) !important;
    color: var(--primary-foreground) !important;
    border: 0 !important;
}

@media (max-width: 720px) {
    .sa-home-find {
        flex-direction: column;
    }

    .sa-home-find .sa-search,
    .sa-home-find select {
        width: 100%;
    }
}

body.sys-app > .w3-row {
    width: min(1100px, calc(100% - 2rem));
    margin: 1.75rem auto 2rem !important;
    float: none !important;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
}

body.sys-app .w3-card-4:has(> h3:only-child),
body.sys-app .w3-card-4:has(> h4:only-child),
body.sys-app .w3-card-2:has(> h3:only-child),
body.sys-app .w3-card-2:has(> h4:only-child),
body.sys-app .w3-border:has(> h3:only-child),
body.sys-app .w3-border:has(> h4:only-child) {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 0.4rem 0 0.2rem !important;
    margin-top: 0.5rem;
}

body.sys-app .w3-card-4:has(> h4:only-child) h4,
body.sys-app .w3-card-4:has(> h3:only-child) h3,
body.sys-app .w3-border:has(> h4:only-child) h4,
body.sys-app .w3-border:has(> h3:only-child) h3 {
    margin: 0;
    text-align: right;
    font-size: 1.55rem;
    font-weight: 700;
}

body.sys-app > .w3-row > .w3-col[style*="width:15%"],
body.sys-app > .w3-row > .w3-col[style*="width:10%"],
body.sys-app > .w3-row > .w3-col[style*="width:8%"],
body.sys-app > .w3-row > .w3-col[style*="width:6%"],
body.sys-app > .w3-row > .w3-col[style*="width:5%"] {
    display: none !important;
}

body.sys-app > .w3-row > .w3-col[style*="width:70%"],
body.sys-app > .w3-row > .w3-col[style*="width:80%"],
body.sys-app > .w3-row > .w3-col[style*="width:84%"],
body.sys-app > .w3-row > .w3-col[style*="width:64%"] {
    width: 100% !important;
    float: none !important;
    margin: 0 auto !important;
}

body.sys-app .w3-card,
body.sys-app .w3-card-2,
body.sys-app .w3-card-4,
body.sys-app .w3-border.w3-padding {
    background: var(--card);
    border: 1px solid var(--border) !important;
    border-radius: var(--radius);
    box-shadow: 0 1px 2px rgb(15 23 42 / 0.05);
}

body.sys-app .w3-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

body.sys-app .w3-table th {
    background: var(--muted);
    color: var(--muted-foreground);
    font-weight: 600;
    font-size: 0.8rem;
}

body.sys-app .w3-table td,
body.sys-app .w3-table th {
    border-color: var(--border) !important;
    padding: 0.7rem 0.6rem;
}

body.sys-app .w3-input,
body.sys-app .w3-select,
body.sys-app select.w3-select,
body.sys-app input[type="text"],
body.sys-app input[type="password"],
body.sys-app input[type="number"],
body.sys-app select,
body.sys-app textarea {
    border: 1px solid var(--input) !important;
    border-radius: calc(var(--radius) - 2px) !important;
    background: var(--background) !important;
    color: var(--foreground) !important;
    min-height: 2.4rem;
    padding: 0.4rem 0.7rem !important;
    box-shadow: none;
}

body.sys-app input:focus,
body.sys-app select:focus,
body.sys-app textarea:focus {
    outline: 2px solid var(--ring);
    outline-offset: 1px;
}

body.sys-app .w3-btn,
body.sys-app .w3-button,
body.sys-app button,
body.sys-app .sa-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.25rem;
    padding: 0.35rem 0.9rem;
    border-radius: calc(var(--radius) - 2px) !important;
    border: 1px solid var(--border);
    background: var(--background);
    color: var(--foreground);
    font-family: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

body.sys-app .sa-navbtn,
body.sys-app .sa-menu > .sa-link {
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    min-height: 2.25rem;
}

body.sys-app .w3-theme,
body.sys-app .w3-theme-d3,
body.sys-app .w3-btn.w3-theme,
body.sys-app .w3-button.w3-theme,
body.sys-app .sa-btn-primary {
    background: var(--primary) !important;
    color: var(--primary-foreground) !important;
    border-color: var(--primary) !important;
}

body.sys-app button.w3-btn:not(.w3-pale-red):not(.w3-white),
body.sys-app a.w3-btn.w3-theme,
body.sys-app a.w3-btn.w3-theme-d1,
body.sys-app a.w3-btn.w3-theme-d3,
body.sys-app .sa-home-detail,
body.sys-app #sa-detail button,
body.sys-app .imp-submit {
    background: var(--primary) !important;
    color: var(--primary-foreground) !important;
    border: 0 !important;
}

body.sys-app .w3-hover-red,
body.sys-app .w3-pale-red,
body.sys-app .sa-btn-danger {
    background: #fff !important;
    color: var(--destructive) !important;
    border-color: #fecaca !important;
}

body.sys-app .w3-modal {
    background: rgb(15 23 42 / 0.45) !important;
}

body.sys-app .w3-modal-content {
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: 0 20px 40px rgb(15 23 42 / 0.16);
    overflow: hidden;
}

body.sys-app h3,
body.sys-app h4,
body.sys-app h5 {
    font-weight: 700;
    letter-spacing: 0;
}

.sa-auth,
.sa-portal {
    min-height: 100vh;
    margin: 0;
    background: var(--muted);
    color: var(--foreground);
    font-family: "Thmanyah Sans", system-ui, sans-serif;
}

.sa-auth {
    display: grid;
    place-items: center;
    padding: 1.5rem;
}

.sa-auth-card,
.sa-portal-card {
    width: min(420px, 100%);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) + 4px);
    box-shadow: 0 10px 30px rgb(15 23 42 / 0.06);
    padding: 1.5rem;
}

.sa-auth-card h1,
.sa-portal h1 {
    margin: 0.4rem 0 0.2rem;
    font-size: 1.35rem;
}

.sa-muted {
    color: var(--muted-foreground);
    margin: 0 0 1rem;
}

.sa-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 0.85rem;
    text-align: right;
}

.sa-field input,
.sa-search input,
.sa-auth-card input {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--input);
    border-radius: calc(var(--radius) - 2px);
    min-height: 2.5rem;
    padding: 0.45rem 0.75rem;
    font: inherit;
    background: #fff;
}

.sa-auth-card button,
.sa-portal-card {
    font: inherit;
}

.sa-auth-card button {
    width: 100%;
    min-height: 2.5rem;
    border: 0;
    border-radius: calc(var(--radius) - 2px);
    background: var(--primary);
    color: var(--primary-foreground);
    font-weight: 700;
    cursor: pointer;
}

.sa-back {
    display: inline-block;
    margin-bottom: 0.8rem;
    color: var(--muted-foreground);
    text-decoration: none;
    font-size: 0.9rem;
}

.sa-alert {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    border-radius: calc(var(--radius) - 2px);
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.8rem;
    font-size: 0.9rem;
}

.sa-portal {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1rem;
}

.sa-portal-wrap {
    width: min(760px, 100%);
    text-align: center;
}

.sa-portal-logo {
    width: 148px;
    height: 148px;
    object-fit: contain;
    margin-bottom: 0.4rem;
}

.sa-portal-wrap h1 {
    font-size: 2rem;
    font-weight: 700;
}

.sa-portal-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.85rem;
    margin-top: 1.5rem;
    text-align: center;
}

.sa-portal-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-height: 7.5rem;
    text-align: center;
    text-decoration: none;
    color: var(--foreground);
}

.sa-portal-card strong {
    font-size: 1.05rem;
}

.sa-portal-card span {
    color: var(--muted-foreground);
    font-size: 0.9rem;
    font-weight: 400;
}

.sa-portal-card:hover {
    background: var(--accent);
}

@media (max-width: 720px) {
    .sa-portal-list {
        grid-template-columns: 1fr;
    }
}

.imp-title {
    margin: 0.4rem 0 0.35rem;
    text-align: right;
    font-size: 1.7rem;
    font-weight: 700;
}

.imp-lead {
    margin: 0 0 1.25rem;
    color: var(--muted-foreground);
    text-align: right;
}

.imp-form {
    direction: rtl;
    margin-bottom: 1.5rem;
    padding: 1.2rem 1.3rem 1.15rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) + 4px);
    box-shadow: 0 8px 24px rgb(15 23 42 / 0.04);
    text-align: right;
}

body.sys-app .imp-submit {
    background: var(--primary) !important;
    color: var(--primary-foreground) !important;
    border: 0 !important;
}

.imp-form select,
.imp-form input {
    direction: ltr;
    width: 100%;
    box-sizing: border-box;
    text-align: right;
}

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

.imp-submit {
    margin-top: 0.4rem;
    min-height: 2.6rem;
    padding: 0 1.4rem;
    border: 0;
    border-radius: calc(var(--radius) - 2px);
    background: var(--primary);
    color: var(--primary-foreground);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.imp-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin: 0.5rem 0 0.75rem;
}

.imp-stats div {
    padding: 0.9rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-align: center;
    background: #fff;
}

.imp-stats b {
    display: block;
    font-size: 1.25rem;
}

.imp-stats span,
.imp-meta {
    color: var(--muted-foreground);
    font-size: 0.9rem;
}

.imp-section {
    margin: 1.25rem 0 0.5rem;
    text-align: right;
}

.imp-alert {
    margin: 0.75rem 0;
    padding: 0.75rem 0.9rem;
    border-radius: var(--radius);
}

.imp-alert-ok {
    background: #f0fdf4;
    color: #166534;
}

.imp-alert-bad {
    background: #fef2f2;
    color: #b91c1c;
}

@media (max-width: 720px) {
    .imp-grid,
    .imp-stats {
        grid-template-columns: 1fr;
    }
}

.sa-portal-foot {
    margin-top: 1.2rem;
    text-align: center;
    color: var(--muted-foreground);
    font-size: 0.8rem;
}

@media (max-width: 980px) {
    .sa-navbar {
        height: auto;
        grid-template-columns: 1fr;
        justify-items: center;
        padding: 0.45rem 0.75rem 0.7rem;
    }

    .sa-side-left,
    .sa-header-tools {
        justify-self: center;
    }

    body.sys-app {
        padding-top: 7.5rem;
    }

    .sa-drop-wide {
        grid-template-columns: 1fr;
        min-width: 240px;
    }
}
