/* DMST Client Tickets: client portal. Scoped to .dmst-portal so it sits inside any theme. */
.dmst-portal {
	--dmst-accent: #1d4ed8;
	--dmst-text: #111827;
	--dmst-muted: #6b7280;
	--dmst-border: #e5e7eb;
	--dmst-surface: #ffffff;
	--dmst-soft: #f9fafb;
	--dmst-radius: 12px;
	max-width: 860px;
	margin: 0 auto;
	color: var(--dmst-text);
	font-size: 16px;
	line-height: 1.55;
	box-sizing: border-box;
}
.dmst-portal *, .dmst-portal *::before, .dmst-portal *::after { box-sizing: inherit; }
.dmst-portal [hidden] { display: none !important; }
.dmst-portal h2 { font-size: 1.35em; margin: 0 0 .5em; line-height: 1.3; }
.dmst-muted { color: var(--dmst-muted); font-size: .9em; }

/* Buttons */
.dmst-portal .dmst-btn {
	display: inline-flex; align-items: center; justify-content: center; gap: .35em;
	background: var(--dmst-accent); color: #fff; border: 1px solid var(--dmst-accent);
	border-radius: 8px; padding: .6em 1.1em; font-size: .95em; font-weight: 600;
	text-decoration: none; cursor: pointer; line-height: 1.2; min-height: 44px;
	transition: filter .15s;
}
.dmst-portal .dmst-btn:hover { filter: brightness(1.1); color: #fff; }
.dmst-portal .dmst-btn:disabled { opacity: .6; cursor: wait; }
.dmst-portal .dmst-btn--ghost { background: transparent; color: var(--dmst-accent); }
.dmst-portal .dmst-btn--ghost:hover { background: var(--dmst-soft); color: var(--dmst-accent); }
.dmst-portal .dmst-link { background: none; border: 0; padding: 0; color: var(--dmst-muted); text-decoration: underline; cursor: pointer; font-size: .9em; }
.dmst-portal .dmst-link:hover { color: var(--dmst-text); }

/* Bar */
.dmst-bar {
	display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
	padding: 0 0 16px; margin-bottom: 16px; border-bottom: 1px solid var(--dmst-border);
}
.dmst-bar__home { font-weight: 700; font-size: 1.15em; color: var(--dmst-text); text-decoration: none; }
.dmst-bar__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.dmst-bar__user { color: var(--dmst-muted); font-size: .9em; }
.dmst-bar__user a { color: inherit; }

.dmst-ios-hint {
	position: relative; background: var(--dmst-soft); border: 1px solid var(--dmst-border);
	border-radius: var(--dmst-radius); padding: 12px 40px 12px 14px; margin-bottom: 16px; font-size: .92em;
}
.dmst-ios-hint__close { position: absolute; top: 6px; right: 8px; background: none; border: 0; font-size: 22px; line-height: 1; cursor: pointer; color: var(--dmst-muted); }

/* Cards and notices */
.dmst-card {
	background: var(--dmst-surface); border: 1px solid var(--dmst-border);
	border-radius: var(--dmst-radius); padding: 20px; margin-bottom: 16px;
}
.dmst-notice { border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; font-size: .95em; }
.dmst-notice--success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.dmst-notice--error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.dmst-notice--info { background: #eff6ff; color: #1e3a8a; border: 1px solid #bfdbfe; }

/* Badges */
.dmst-ref { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 600; font-size: .85em; letter-spacing: .02em; }
.dmst-ref--big { font-size: 1em; }
.dmst-badge, .dmst-pill {
	display: inline-block; border-radius: 999px; padding: .15em .65em; font-size: .78em; font-weight: 600; line-height: 1.5; white-space: nowrap;
}
.dmst-badge--open { background: #dbeafe; color: #1e40af; }
.dmst-badge--in_progress { background: #ede9fe; color: #5b21b6; }
.dmst-badge--awaiting_client { background: #fef3c7; color: #92400e; }
.dmst-badge--resolved { background: #d1fae5; color: #065f46; }
.dmst-badge--closed { background: #f3f4f6; color: #4b5563; }
.dmst-pill--new { background: var(--dmst-accent); color: #fff; }

/* Tabs */
.dmst-tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.dmst-tabs a { padding: .45em .9em; border-radius: 8px; text-decoration: none; color: var(--dmst-muted); font-weight: 600; font-size: .92em; }
.dmst-tabs a.is-current { background: var(--dmst-soft); color: var(--dmst-text); box-shadow: inset 0 0 0 1px var(--dmst-border); }

/* Ticket list */
.dmst-portal .dmst-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.dmst-portal .dmst-list li { margin: 0; }
.dmst-list__item {
	display: grid; gap: 4px; padding: 14px 16px; border: 1px solid var(--dmst-border); border-radius: var(--dmst-radius);
	background: var(--dmst-surface); color: var(--dmst-text); text-decoration: none; transition: border-color .15s, box-shadow .15s;
}
.dmst-list__item:hover { border-color: var(--dmst-accent); box-shadow: 0 2px 8px rgba(0,0,0,.05); color: var(--dmst-text); }
.dmst-list__item.is-unread { border-left: 4px solid var(--dmst-accent); }
.dmst-list__top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.dmst-list__title { font-weight: 600; font-size: 1.05em; }
.dmst-list__meta { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--dmst-muted); font-size: .85em; }
.dmst-empty { text-align: center; padding: 36px 20px; }

/* Forms */
.dmst-form .dmst-field { margin: 0 0 16px; border: 0; padding: 0; min-width: 0; }
.dmst-form label, .dmst-form legend { display: block; font-weight: 600; margin-bottom: 6px; font-size: .95em; padding: 0; }
.dmst-form input[type=text], .dmst-form input[type=url], .dmst-form select, .dmst-form textarea {
	width: 100%; max-width: 100%; border: 1px solid #d1d5db; border-radius: 8px; padding: .6em .75em; font: inherit;
	background: #fff; color: var(--dmst-text); min-height: 44px;
}
.dmst-form textarea { resize: vertical; }
.dmst-form input:focus, .dmst-form select:focus, .dmst-form textarea:focus { outline: 2px solid var(--dmst-accent); outline-offset: 1px; border-color: var(--dmst-accent); }
.dmst-form .dmst-site-other { margin-top: 8px; }
.dmst-row { display: grid; gap: 0 16px; grid-template-columns: 1fr 1fr; }
.dmst-priority { display: grid; gap: 8px; grid-template-columns: 1fr 1fr; }
.dmst-priority legend { grid-column: 1 / -1; }
.dmst-form .dmst-priority__opt {
	display: flex; gap: 8px; align-items: flex-start; font-weight: 400; margin: 0; border: 1px solid var(--dmst-border);
	border-radius: 8px; padding: 10px 12px; cursor: pointer; font-size: .9em;
}
.dmst-priority__opt input { margin-top: .3em; accent-color: var(--dmst-accent); }
.dmst-priority__opt:has(input:checked) { border-color: var(--dmst-accent); background: var(--dmst-soft); }
.dmst-priority__opt--urgent:has(input:checked) { border-color: #dc2626; background: #fef2f2; }
.dmst-form__actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

/* Upload area */
.dmst-drop { position: relative; border: 2px dashed #d1d5db; border-radius: var(--dmst-radius); padding: 16px; margin-bottom: 16px; background: var(--dmst-soft); transition: border-color .15s, background .15s; }
.dmst-drop.is-over { border-color: var(--dmst-accent); background: #eff6ff; }
.dmst-drop input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.dmst-drop input[type=file]:focus-visible + .dmst-drop__label { outline: 2px solid var(--dmst-accent); outline-offset: 4px; border-radius: 6px; }
.dmst-form .dmst-drop__label { display: grid; gap: 2px; text-align: center; cursor: pointer; font-weight: 400; margin: 0; }
.dmst-drop__label strong { color: var(--dmst-accent); }
.dmst-portal .dmst-drop__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.dmst-drop__list:not(:empty) { margin-top: 12px; }
.dmst-drop__list li { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--dmst-border); border-radius: 8px; padding: 6px 8px; font-size: .88em; margin: 0; }
.dmst-drop__list li.is-error { border-color: #fecaca; color: #991b1b; }
.dmst-drop__list img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; }
.dmst-drop__name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.dmst-drop__list button { background: none; border: 0; color: var(--dmst-muted); text-decoration: underline; cursor: pointer; font-size: .9em; padding: 4px; }

/* Ticket view */
.dmst-back { display: inline-block; color: var(--dmst-muted); text-decoration: none; font-size: .9em; margin-bottom: 8px; }
.dmst-ticket__refrow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.dmst-meta { display: flex; flex-wrap: wrap; gap: 8px 24px; margin: 8px 0 0; font-size: .9em; }
.dmst-meta dt { color: var(--dmst-muted); font-size: .85em; margin: 0; }
.dmst-meta dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

.dmst-thread { display: grid; gap: 12px; margin-bottom: 16px; }
.dmst-msg { border: 1px solid var(--dmst-border); border-radius: var(--dmst-radius); padding: 14px 16px; background: var(--dmst-surface); max-width: 92%; }
.dmst-msg.is-mine { justify-self: end; background: var(--dmst-soft); }
.dmst-msg--staff { border-left: 4px solid var(--dmst-accent); justify-self: start; }
.dmst-msg__head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; margin-bottom: 6px; font-size: .9em; }
.dmst-msg__head time { color: var(--dmst-muted); font-size: .9em; }
.dmst-msg__body { overflow-wrap: anywhere; }
.dmst-msg__body p { margin: 0 0 .7em; }
.dmst-msg__body p:last-child { margin-bottom: 0; }
.dmst-event { text-align: center; color: var(--dmst-muted); font-size: .82em; }

.dmst-files { margin-top: 10px; display: grid; gap: 8px; }
.dmst-files__images { display: flex; flex-wrap: wrap; gap: 8px; }
.dmst-thumb img { width: 110px; height: 110px; object-fit: cover; border-radius: 8px; border: 1px solid var(--dmst-border); display: block; }
.dmst-portal .dmst-file {
	display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--dmst-border); border-radius: 8px;
	text-decoration: none; color: var(--dmst-text); background: #fff; font-size: .9em; max-width: 420px;
}
.dmst-file:hover { border-color: var(--dmst-accent); }
.dmst-file__name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.dmst-file__size { color: var(--dmst-muted); font-size: .85em; white-space: nowrap; }

.dmst-closeform { text-align: center; margin: -4px 0 16px; }
.dmst-closed { text-align: center; }

/* Login */
.dmst-login { max-width: 420px; margin: 0 auto; }
.dmst-login form p { margin: 0 0 12px; }
.dmst-login label { display: block; font-weight: 600; margin-bottom: 4px; }
.dmst-login .login-remember label { display: inline; font-weight: 400; }
.dmst-login input[type=text], .dmst-login input[type=password] { width: 100%; border: 1px solid #d1d5db; border-radius: 8px; padding: .6em .75em; font: inherit; min-height: 44px; }
.dmst-login input[type=submit] { background: var(--dmst-accent); color: #fff; border: 0; border-radius: 8px; padding: .7em 1.2em; font-weight: 600; cursor: pointer; width: 100%; min-height: 44px; font-size: 1em; }
.dmst-login__links { font-size: .9em; }

/* Installed app: drop theme chrome margins a little */
@media (display-mode: standalone) {
	.dmst-portal { padding-top: env(safe-area-inset-top); }
}

@media (max-width: 600px) {
	.dmst-card { padding: 16px; }
	.dmst-row, .dmst-priority { grid-template-columns: 1fr; }
	.dmst-msg { max-width: 100%; }
	.dmst-bar__actions { width: 100%; justify-content: space-between; }
	.dmst-form__actions .dmst-btn { flex: 1; }
	.dmst-thumb img { width: 88px; height: 88px; }
}
