:root {
    --ink: #18221c;
    --muted: #69736c;
    --line: #d7ddd8;
    --paper: #fbfcfa;
    --wash: #eef2ed;
    --green: #1f6b49;
    --green-dark: #155039;
    --lime: #c9e265;
    --danger: #a43e36;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-width: 320px;
    min-height: 100vh;
    color: var(--ink);
    background:
        linear-gradient(rgba(255,255,255,.48), rgba(255,255,255,.48)),
        repeating-linear-gradient(135deg, transparent 0 18px, rgba(31,107,73,.035) 18px 19px),
        var(--wash);
    font-family: "IBM Plex Sans Thai", sans-serif;
}

button, input { font: inherit; }

.shell { width: min(1180px, calc(100% - 48px)); margin: 0 auto; }

.topbar {
    height: 94px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(24,34,28,.16);
}

.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; color: white; background: var(--green); border-radius: 7px; }
.brand-mark svg { width: 25px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.brand strong, .brand small { display: block; letter-spacing: 0; }
.brand strong { font: 700 17px/1.1 Manrope, sans-serif; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 12px; }
.connection { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; }
.connection i { width: 8px; height: 8px; background: #3aa96d; border-radius: 50%; box-shadow: 0 0 0 4px rgba(58,169,109,.12); }

.workspace { min-height: calc(100vh - 154px); display: grid; grid-template-columns: .85fr 1.15fr; gap: clamp(56px, 9vw, 130px); align-items: center; padding: 56px 0; }
.intro { align-self: center; }
.eyebrow { margin: 0 0 20px; color: var(--green); font: 700 11px/1 Manrope, sans-serif; letter-spacing: 2px; }
h1 { margin: 0; max-width: 510px; font-size: clamp(42px, 5vw, 68px); line-height: 1.08; letter-spacing: 0; font-weight: 700; }
.lead { max-width: 470px; margin: 25px 0 34px; color: var(--muted); font-size: 17px; line-height: 1.75; }
.destination { display: flex; gap: 42px; margin: 0; padding-top: 21px; border-top: 1px solid var(--line); }
.destination div { min-width: 130px; }
.destination dt { color: var(--muted); font-size: 11px; }
.destination dd { margin: 5px 0 0; font: 600 13px/1.4 Manrope, sans-serif; }

.upload-panel { padding: clamp(25px, 4vw, 42px); background: rgba(251,252,250,.94); border: 1px solid var(--line); border-top: 4px solid var(--green); box-shadow: 0 20px 55px rgba(28,47,35,.09); }
.credentials { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.connector-info { display: flex; align-items: center; gap: 11px; padding: 12px 14px; color: var(--green-dark); background: #edf4ee; border-left: 3px solid var(--green); }
.connector-info > span:last-child, .connector-info strong, .connector-info small { display: block; }
.connector-info strong { font-size: 12px; }
.connector-info small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.connector-icon { width: 27px; height: 27px; display: grid; flex: 0 0 auto; place-items: center; color: white; background: var(--green); border-radius: 50%; font-size: 12px; font-weight: 700; }
label > span:first-child, .file-heading { display: block; margin-bottom: 7px; color: #3f4943; font-size: 12px; font-weight: 600; }
label small { color: #8a938d; font-weight: 400; }
input[type="text"], input[type="password"] { width: 100%; height: 46px; padding: 0 13px; color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 4px; outline: none; transition: border-color .18s, box-shadow .18s; }
input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(31,107,73,.1); }
.password-wrap { position: relative; display: block; }
.password-wrap input { padding-right: 44px; }
.reveal { position: absolute; top: 4px; right: 4px; width: 38px; height: 38px; padding: 9px; color: var(--muted); background: transparent; border: 0; cursor: pointer; }
.reveal svg { width: 100%; fill: none; stroke: currentColor; stroke-width: 1.7; }
.folder-field { display: block; margin: 18px 0; }
.folder-input { display: flex; align-items: center; height: 46px; background: white; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.folder-input:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px rgba(31,107,73,.1); }
.folder-input b { height: 100%; display: flex; align-items: center; padding-left: 13px; color: var(--muted); background: #f5f7f4; font: 500 12px Manrope, sans-serif; }
.folder-input input { min-width: 0; border: 0; box-shadow: none; }
.folder-input button { align-self: stretch; flex: 0 0 auto; padding: 0 13px; color: var(--green); background: #edf3ed; border: 0; border-left: 1px solid var(--line); font-size: 11px; font-weight: 600; cursor: pointer; }
.folder-input button:hover { background: #e1ece2; }

.drop-zone { position: relative; min-height: 226px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 28px; text-align: center; background: #f5f8f4; border: 1px dashed #aebbb2; border-radius: 6px; transition: background .18s, border-color .18s, transform .18s; }
.drop-zone.dragging { background: #edf5e4; border-color: var(--green); transform: translateY(-2px); }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-icon { width: 48px; height: 48px; display: grid; place-items: center; margin-bottom: 13px; color: var(--green); background: #e5eddf; border-radius: 50%; }
.upload-icon svg { width: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.drop-zone > strong { font-size: 16px; }
.drop-zone p { margin: 5px 0 13px; color: var(--muted); font-size: 13px; }
.drop-zone p button, .file-heading button { padding: 0; color: var(--green); background: none; border: 0; font-weight: 600; cursor: pointer; }
.drop-zone > small { color: #8b958e; font-size: 11px; }

.file-section { margin-top: 18px; }
.file-heading { display: flex; justify-content: space-between; }
#fileList, .result-list { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; }
#fileList li, .result-list li { display: flex; align-items: center; gap: 11px; min-width: 0; padding: 10px 12px; background: #f4f7f3; border-left: 3px solid var(--green); }
#fileList li div, .result-list li div { min-width: 0; flex: 1; }
#fileList strong, .result-list strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
#fileList small, .result-list small { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; }
.file-badge, .result-list > li > span { width: 28px; height: 28px; display: grid; flex: 0 0 auto; place-items: center; color: var(--green); background: #e2ebe3; border-radius: 4px; font-size: 10px; font-weight: 700; }
.result-list { margin-bottom: 18px; }
.result-list .failed { border-color: var(--danger); }
.result-list .failed > span { color: var(--danger); background: #f4e4e2; }

.submit-button { width: 100%; height: 52px; display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 22px; color: white; background: var(--green); border: 0; border-radius: 4px; font-weight: 600; cursor: pointer; transition: background .18s, transform .18s; }
.submit-button:hover { background: var(--green-dark); transform: translateY(-1px); }
.submit-button:disabled { opacity: .65; cursor: wait; transform: none; }
.submit-button svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.notice { display: grid; gap: 2px; margin-bottom: 18px; padding: 12px 14px; color: #7e312d; background: #f9e9e7; border-left: 3px solid var(--danger); font-size: 12px; }
.notice.success { color: var(--green-dark); background: #e8f2eb; border-color: var(--green); }
.notice.warning { color: #79560d; background: #fff5d8; border-color: #c99624; }
.notice span { opacity: .86; }
footer { height: 60px; display: flex; justify-content: space-between; align-items: center; color: #7c877f; border-top: 1px solid rgba(24,34,28,.12); font-size: 10px; letter-spacing: .5px; }

.folder-dialog { width: min(620px, calc(100% - 28px)); max-height: min(720px, calc(100vh - 40px)); padding: 0; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-top: 4px solid var(--green); box-shadow: 0 28px 80px rgba(18,42,26,.24); }
.folder-dialog::backdrop { background: rgba(18,31,23,.54); backdrop-filter: blur(2px); }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; padding: 24px 26px 18px; border-bottom: 1px solid var(--line); }
.dialog-heading .eyebrow { margin-bottom: 8px; }
.dialog-heading h2 { margin: 0; font-size: 21px; }
.dialog-heading > button { width: 32px; height: 32px; color: var(--muted); background: transparent; border: 1px solid var(--line); border-radius: 3px; font-size: 20px; cursor: pointer; }
.folder-breadcrumb { min-height: 48px; display: flex; align-items: center; gap: 7px; padding: 10px 26px; overflow-x: auto; background: #f3f6f2; border-bottom: 1px solid var(--line); white-space: nowrap; }
.folder-breadcrumb button { padding: 3px; color: var(--muted); background: none; border: 0; font-size: 12px; cursor: pointer; }
.folder-breadcrumb button[aria-current="page"] { color: var(--ink); font-weight: 600; }
.folder-breadcrumb span { color: #a1aaa4; }
.folder-loading, .folder-error { margin: 25px; padding: 26px; text-align: center; color: var(--muted); background: #f4f7f3; font-size: 12px; }
.folder-error { color: var(--danger); background: #f9e9e7; }
.folder-list { min-height: 190px; max-height: 360px; margin: 0; padding: 10px 18px; overflow-y: auto; list-style: none; }
.folder-list li button, .folder-list li .browser-file { width: 100%; min-height: 49px; display: grid; grid-template-columns: 31px 1fr auto; align-items: center; gap: 10px; padding: 7px 10px; color: var(--ink); text-align: left; background: transparent; border: 0; border-bottom: 1px solid #e7ebe8; }
.folder-list li button { cursor: pointer; }
.folder-list li button:hover { background: #f0f5ef; }
.folder-list strong, .folder-list small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-list strong { font-size: 13px; }
.folder-list small { margin-top: 2px; color: var(--muted); font-size: 9px; }
.folder-icon { width: 29px; height: 27px; display: grid; place-items: center; color: var(--green); background: #e2ece3; border-radius: 3px; font-size: 13px; }
.folder-icon.file { color: #59645d; background: #e9edea; font: 700 7px Manrope, sans-serif; }
.browser-file > span:last-child { color: var(--green); font-weight: 700; }
.empty-folder { padding: 70px 20px; color: var(--muted); text-align: center; font-size: 12px; }
.dialog-actions { min-height: 77px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 13px 26px; border-top: 1px solid var(--line); }
.dialog-actions > span { min-width: 0; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; font: 500 11px Manrope, sans-serif; }
.dialog-actions .submit-button { width: auto; min-width: 145px; height: 43px; margin: 0; padding: 0 15px; }

@media (max-width: 860px) {
    .workspace { grid-template-columns: 1fr; gap: 40px; padding-top: 40px; }
    .intro { text-align: center; }
    .lead { margin-left: auto; margin-right: auto; }
    .destination { justify-content: center; }
}

@media (max-width: 560px) {
    .shell { width: min(100% - 28px, 1180px); }
    .topbar { height: 76px; }
    .connection { font-size: 0; }
    h1 { font-size: 39px; }
    .workspace { min-height: auto; padding: 36px 0; }
    .credentials { grid-template-columns: 1fr; }
    .upload-panel { padding: 22px 17px; }
    .destination { gap: 16px; }
    .destination div { min-width: 120px; }
    .folder-input b { display: none; }
    .folder-input button { padding: 0 9px; font-size: 10px; }
    .dialog-heading, .folder-breadcrumb, .dialog-actions { padding-right: 16px; padding-left: 16px; }
    .dialog-actions { align-items: stretch; flex-direction: column; }
    .dialog-actions .submit-button { width: 100%; }
    footer { height: 55px; }
}

@media (prefers-reduced-motion: no-preference) {
    .intro > *, .upload-panel { animation: reveal .55s both; }
    .intro > *:nth-child(2) { animation-delay: .07s; }
    .intro > *:nth-child(3) { animation-delay: .14s; }
    .intro > *:nth-child(4) { animation-delay: .21s; }
    .upload-panel { animation-delay: .12s; }
    @keyframes reveal { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
}

/* Authentication and application shell */
.auth-page { display: grid; min-height: 100vh; place-items: center; padding: 32px; }
.auth-shell { width: min(960px, 100%); min-height: 610px; display: grid; grid-template-columns: .9fr 1.1fr; background: var(--paper); border: 1px solid var(--line); box-shadow: 0 28px 70px rgba(25,49,34,.13); }
.auth-aside { display: flex; flex-direction: column; justify-content: space-between; padding: 48px; color: white; background: var(--green); }
.auth-aside .brand { color: white; }
.auth-aside .brand-mark { color: var(--green); background: var(--lime); font: 700 19px Manrope, sans-serif; }
.auth-aside .brand small, .auth-aside > small { color: rgba(255,255,255,.65); }
.auth-aside .eyebrow { color: var(--lime); }
.auth-aside h1 { font-size: clamp(39px, 4vw, 55px); }
.auth-aside p:not(.eyebrow) { max-width: 360px; margin: 22px 0 0; color: rgba(255,255,255,.74); line-height: 1.75; }
.auth-form { display: flex; flex-direction: column; justify-content: center; padding: clamp(35px, 6vw, 72px); }
.auth-form form { display: grid; gap: 18px; }
.auth-form label { display: grid; }
.auth-form input:not([type="checkbox"]):not([type="radio"]) { width: 100%; height: 46px; padding: 0 13px; border: 1px solid var(--line); border-radius: 4px; outline: none; }
.auth-form input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(31,107,73,.1); }
.form-title { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 30px; }
.form-title > span { width: 31px; height: 31px; display: grid; flex: 0 0 auto; place-items: center; color: var(--green); background: #e7eee8; border-radius: 4px; font: 700 11px Manrope, sans-serif; }
.form-title h2 { margin: 0; font-size: 24px; }
.form-title p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.form-title.divider { margin: 10px 0 0; padding-top: 25px; border-top: 1px solid var(--line); }
.field-help { display: block; margin-top: 5px; color: #8a938d; font-size: 10px; }
.setup-shell { width: min(1120px, 100%); grid-template-columns: .72fr 1.28fr; }
.setup-form { padding-top: 45px; padding-bottom: 45px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid.three { grid-template-columns: 1fr 95px 1fr; }
.compact-shell { min-height: 570px; }

.app-header { width: min(1240px, calc(100% - 48px)); height: 82px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin: 0 auto; border-bottom: 1px solid var(--line); }
.app-header nav, .upload-nav { display: flex; align-items: stretch; height: 100%; gap: 32px; }
.app-header nav a, .upload-nav a { position: relative; display: flex; align-items: center; color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 600; }
.app-header nav a.active, .upload-nav a.active { color: var(--ink); }
.app-header nav a.active::after, .upload-nav a.active::after { content: ""; position: absolute; right: 0; bottom: -1px; left: 0; height: 3px; background: var(--green); }
.account { display: flex; justify-self: end; align-items: center; gap: 14px; }
.account > span, .account > a { color: inherit; text-align: right; text-decoration: none; }
.account strong, .account small { display: block; }
.account strong { font-size: 12px; }
.account small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.account form { margin: 0; }
.icon-button { width: 36px; height: 36px; color: var(--muted); background: transparent; border: 1px solid var(--line); border-radius: 4px; cursor: pointer; }
.icon-button:hover { color: var(--danger); border-color: #dfbbb7; }
.topbar { gap: 25px; }
.topbar .upload-nav { margin-left: auto; }
.topbar .account { flex: 0 0 auto; }

.management-shell { width: min(1240px, calc(100% - 48px)); margin: 0 auto; padding: 54px 0 70px; }
.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 30px; }
.page-heading h1 { font-size: 43px; }
.page-heading p:last-child { margin: 8px 0 0; color: var(--muted); }
.primary-link { height: 44px; display: inline-flex; align-items: center; padding: 0 17px; color: white; background: var(--green); border-radius: 4px; text-decoration: none; font-size: 13px; font-weight: 600; }
.stat-strip { display: flex; gap: 0; margin: 34px 0 24px; border: 1px solid var(--line); background: rgba(251,252,250,.7); }
.stat-strip div { min-width: 175px; padding: 18px 24px; border-right: 1px solid var(--line); }
.stat-strip strong { margin-right: 7px; font: 700 25px Manrope, sans-serif; }
.stat-strip span { color: var(--muted); font-size: 11px; }
.management-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; align-items: start; gap: 22px; }
.user-table-panel, .user-form-panel { background: var(--paper); border: 1px solid var(--line); }
.panel-heading { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 17px 20px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 0; font-size: 16px; }
.panel-heading .eyebrow { margin-bottom: 6px; }
.panel-heading > a { color: var(--muted); text-decoration: none; font-size: 22px; }
.search-field { width: min(240px, 48%); position: relative; }
.search-field > span { position: absolute; top: 10px; left: 11px; color: var(--muted); }
.search-field input { width: 100%; height: 38px; padding: 0 10px 0 32px; border: 1px solid var(--line); border-radius: 4px; outline: none; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 16px; text-align: left; border-bottom: 1px solid #e7ebe8; white-space: nowrap; }
th { color: #778079; background: #f5f7f4; font-size: 10px; font-weight: 600; text-transform: uppercase; }
td { font-size: 12px; }
tbody tr:last-child td { border-bottom: 0; }
.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell > span { width: 34px; height: 34px; display: grid; place-items: center; color: var(--green); background: #e5eee5; border-radius: 4px; font-weight: 700; }
.user-cell strong, .user-cell small { display: block; }
.user-cell small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.role-badge, .status-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 7px; border-radius: 3px; font-size: 10px; }
.role-badge { color: #41534a; background: #e9eeea; }
.role-badge.admin { color: #755708; background: #f6edce; }
.status-badge i { width: 6px; height: 6px; background: #aeb6b0; border-radius: 50%; }
.status-badge.active { color: var(--green); }
.status-badge.active i { background: #37a168; }
.date-cell { color: var(--muted); font-size: 10px; }
.row-actions { display: flex; justify-content: end; gap: 5px; }
.row-actions form { display: flex; gap: 5px; }
.row-actions a, .row-actions button { width: 28px; height: 28px; display: grid; place-items: center; color: var(--muted); background: transparent; border: 1px solid var(--line); border-radius: 3px; text-decoration: none; cursor: pointer; }
.row-actions .danger-action:hover { color: var(--danger); border-color: #dca9a4; }
.user-form-panel { position: sticky; top: 18px; }
.user-form-panel form { display: grid; gap: 16px; padding: 20px; }
.user-form-panel input[type="text"], .user-form-panel input[type="password"] { width: 100%; }
.user-form-panel fieldset { display: grid; gap: 7px; margin: 0; padding: 0; border: 0; }
.user-form-panel legend { margin-bottom: 7px; color: #3f4943; font-size: 12px; font-weight: 600; }
.choice { display: flex; gap: 10px; padding: 10px; border: 1px solid var(--line); cursor: pointer; }
.choice input { accent-color: var(--green); }
.choice span, .choice strong, .choice small { display: block; }
.choice strong { font-size: 12px; }
.choice small { margin-top: 2px; color: var(--muted); font-size: 9px; }
.switch-row { display: flex; justify-content: space-between; align-items: center; }
.switch-row span, .switch-row strong, .switch-row small { display: block; }
.switch-row strong { font-size: 12px; }
.switch-row small { color: var(--muted); font-size: 9px; }
.switch-row input { width: 38px; height: 20px; accent-color: var(--green); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

@media (max-width: 980px) {
    .management-grid { grid-template-columns: 1fr; }
    .user-form-panel { position: static; }
    .topbar .upload-nav { display: none; }
}

@media (max-width: 720px) {
    .auth-page { display: block; padding: 0; }
    .auth-shell, .setup-shell { min-height: 100vh; grid-template-columns: 1fr; }
    .auth-aside { min-height: 300px; padding: 30px 25px; }
    .auth-form { padding: 35px 24px; }
    .form-grid, .form-grid.three { grid-template-columns: 1fr; }
    .app-header { width: calc(100% - 28px); grid-template-columns: 1fr auto; }
    .app-header nav { position: fixed; z-index: 5; right: 0; bottom: 0; left: 0; height: 55px; justify-content: center; gap: 55px; background: var(--paper); border-top: 1px solid var(--line); }
    .app-header .account > span { display: none; }
    .management-shell { width: calc(100% - 28px); padding-top: 36px; padding-bottom: 90px; }
    .page-heading { align-items: flex-start; }
    .page-heading h1 { font-size: 35px; }
    .page-heading p:last-child { font-size: 13px; }
    .primary-link { font-size: 0; width: 42px; padding: 0; justify-content: center; }
    .primary-link::after { content: "+"; font-size: 22px; }
    .stat-strip div { min-width: 0; flex: 1; padding: 14px 10px; text-align: center; }
    .stat-strip strong, .stat-strip span { display: block; margin: 0; }
    .panel-heading { align-items: flex-start; flex-direction: column; }
    .user-form-panel .panel-heading { flex-direction: row; }
    .search-field { width: 100%; }
    .topbar .account strong { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}