:root {
	--brand-primary: #1a6b3c;
	--brand-primary-dark: #124d2b;
	--brand-ink: #1a1a1a;
	--brand-bg: #f4f6f5;
	--brand-border: #d8ddda;
}

* { box-sizing: border-box; }

body {
	font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
	background: var(--brand-bg);
	color: var(--brand-ink);
	margin: 0;
}

/* ---- Login page ---- */
.login-body {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 100vh;
	min-height: 100dvh;
	padding: 1rem;
}

.login-card {
	background: #fff;
	border: 1px solid var(--brand-border);
	border-radius: 8px;
	padding: 2rem;
	width: 100%;
	max-width: 360px;
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
}

.paused-card { text-align: center; }
.paused-card p { color: #555; line-height: 1.5; margin: 0; }

@media (max-width: 480px) {
	.login-body { padding: 0; align-items: stretch; }
	.login-card {
		max-width: none;
		min-height: 100vh;
		min-height: 100dvh;
		border-radius: 0;
		border: none;
		justify-content: center;
		padding: 2rem 1.5rem;
	}
}

.login-card h1 { font-size: 1.25rem; margin: 0 0 0.5rem; text-align: center; }
.login-logo {
	display: block;
	max-width: 160px;
	max-height: 100px;
	margin: 0 auto 0.5rem;
}
.login-card input {
	padding: 0.5rem;
	border: 1px solid var(--brand-border);
	border-radius: 4px;
}
.login-card button,
.app-shell button {
	background: var(--brand-primary);
	color: #fff;
	border: none;
	border-radius: 4px;
	padding: 0.5rem 1rem;
	cursor: pointer;
}
.login-card button:hover,
.app-shell button:hover { background: var(--brand-primary-dark); }
.error { color: #b3261e; margin: 0; }

/* ---- App shell ---- */
.app-shell {
	max-width: 1100px;
	margin: 0 auto;
	padding: 1.5rem;
}

.app-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 1.5rem;
}

.app-header h1 { font-size: 1.4rem; margin: 0; }
.app-header a { color: var(--brand-primary); text-decoration: none; }

.panel {
	background: #fff;
	border: 1px solid var(--brand-border);
	border-radius: 8px;
	padding: 1rem 1.25rem;
	margin-bottom: 1.25rem;
}

.panel h2 { font-size: 1rem; margin: 0 0 0.75rem; }

.row { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; }
.row > * { flex: 1 1 160px; }

select, input, textarea {
	width: 100%;
	padding: 0.4rem 0.5rem;
	border: 1px solid var(--brand-border);
	border-radius: 4px;
	font-size: 0.9rem;
}

/* ---- Calendar ---- */
.calendar-nav {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 0.75rem;
}
.calendar-nav button { padding: 0.3rem 0.75rem; }

.calendar-grid {
	display: grid;
	grid-template-columns: repeat(7, 1fr);
	gap: 4px;
}

.calendar-grid .dow {
	font-size: 0.75rem;
	font-weight: 600;
	text-align: center;
	color: #666;
	padding: 0.25rem 0;
}

.calendar-day {
	min-height: 84px;
	border: 1px solid var(--brand-border);
	border-radius: 6px;
	padding: 0.3rem;
	background: #fafbfa;
	cursor: pointer;
	display: flex;
	flex-direction: column;
	gap: 2px;
}
.calendar-day.empty { background: transparent; border: none; cursor: default; }
.calendar-day:hover:not(.empty) { border-color: var(--brand-primary); }
.calendar-day .day-num { font-size: 0.75rem; font-weight: 600; }
.calendar-day .entry-chip {
	font-size: 0.65rem;
	background: #e5f0e9;
	border-radius: 3px;
	padding: 1px 4px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* ---- Day editor (inline panel) ---- */
#day-editor { display: none; }
#day-editor.open { display: block; }
.entry-list { list-style: none; margin: 0.5rem 0; padding: 0; }
.entry-list li {
	display: flex;
	justify-content: space-between;
	gap: 0.5rem;
	padding: 0.25rem 0;
	border-bottom: 1px solid var(--brand-border);
	font-size: 0.85rem;
}
.entry-list button { background: none; color: #b3261e; padding: 0 0.4rem; }

/* ---- Summary ---- */
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--brand-border); }
tfoot td { font-weight: 700; }

.msg { font-size: 0.85rem; margin-top: 0.5rem; }
.msg.error { color: #b3261e; }
.msg.ok { color: var(--brand-primary); }

/* ---- Manual invoice modal ---- */
.modal-overlay {
	display: none;
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.45);
	align-items: center;
	justify-content: center;
	z-index: 100;
	padding: 1.5rem;
}
.modal-overlay.open { display: flex; }

.modal {
	background: #fff;
	border-radius: 8px;
	width: 100%;
	max-width: 680px;
	max-height: 90vh;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.modal-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 1rem 1.25rem;
	border-bottom: 1px solid var(--brand-border);
}
.modal-header h2 { margin: 0; font-size: 1.1rem; }

.icon-btn {
	font-size: 1.4rem;
	line-height: 1;
	padding: 0 0.25rem;
}

.modal-body {
	padding: 1.25rem;
	overflow-y: auto;
}

.mi-fieldset {
	border: 1px solid var(--brand-border);
	border-radius: 6px;
	padding: 0.75rem;
	margin: 0 0 1rem;
}
.mi-fieldset legend { padding: 0 0.4rem; font-size: 0.8rem; font-weight: 600; color: #555; }

#mi-items-table th, #mi-items-table td { border-bottom: 1px solid var(--brand-border); padding: 0.3rem; }
#mi-items-table input { padding: 0.3rem; font-size: 0.85rem; }
.mi-remove-item { background: none; color: #b3261e; padding: 0 0.4rem; }

.mi-total { text-align: right; margin-top: 0.6rem; font-size: 0.95rem; }

.modal-footer {
	padding: 0.9rem 1.25rem;
	border-top: 1px solid var(--brand-border);
}

.modal button {
	background: var(--brand-primary);
	color: #fff;
	border: none;
	border-radius: 4px;
	padding: 0.5rem 1rem;
	cursor: pointer;
}
.modal button:hover { background: var(--brand-primary-dark); }
.modal .icon-btn,
.modal .mi-remove-item {
	background: none;
	color: var(--brand-ink);
	padding: 0 0.4rem;
}
.modal .mi-remove-item { color: #b3261e; }
.modal .icon-btn:hover,
.modal .mi-remove-item:hover { background: none; color: #b3261e; }

.hidden { display: none !important; }

/* ---- Support ticket thread (chat) ---- */
.ticket-list-item {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 0.65rem 0.75rem;
	border: 1px solid var(--brand-border);
	border-radius: 6px;
	margin-bottom: 0.5rem;
	cursor: pointer;
}
.ticket-list-item:hover { background: #f7f7f7; }
.ticket-list-item .ticket-subject { font-weight: 600; font-size: 0.9rem; }
.ticket-list-item .ticket-meta { font-size: 0.75rem; color: #777; margin-top: 0.15rem; }
.ticket-status-badge {
	font-size: 0.7rem;
	padding: 0.15rem 0.5rem;
	border-radius: 999px;
	text-transform: uppercase;
	font-weight: 600;
}
.ticket-status-badge.open { background: #e6f4ea; color: #1e7e34; }
.ticket-status-badge.closed { background: #eee; color: #777; }

.ticket-thread-messages {
	display: flex;
	flex-direction: column;
	gap: 0.6rem;
	max-height: 45vh;
	overflow-y: auto;
	padding: 0.25rem 0;
}
.ticket-bubble {
	max-width: 80%;
	padding: 0.5rem 0.75rem;
	border-radius: 10px;
	font-size: 0.9rem;
	white-space: pre-wrap;
}
.ticket-bubble.client { align-self: flex-end; background: var(--brand-primary); color: #fff; }
.ticket-bubble.admin { align-self: flex-start; background: #eee; color: var(--brand-ink); }
.ticket-bubble .ticket-bubble-meta { font-size: 0.7rem; opacity: 0.75; margin-top: 0.25rem; }
.ticket-bubble img { max-width: 100%; border-radius: 6px; margin-top: 0.4rem; display: block; }

/* ---- Mobile responsiveness ---- */
@media (max-width: 640px) {
	.app-shell { padding: 0.85rem; }
	.app-header {
		flex-wrap: wrap;
		gap: 0.5rem;
	}
	.app-header h1 { font-size: 1.15rem; }
	.panel { padding: 0.85rem; overflow-x: auto; }
	.row > * { flex: 1 1 100%; }
	table { font-size: 0.8rem; }
	th, td { padding: 0.3rem 0.4rem; }
	.calendar-day { min-height: 56px; padding: 0.2rem; }
	.calendar-day .entry-chip { font-size: 0.6rem; }
	.calendar-grid { gap: 2px; }
	.modal-overlay { padding: 0; }
	.modal { max-height: 100vh; max-height: 100dvh; border-radius: 0; }
	.modal-body { padding: 1rem; }
	.ticket-bubble { max-width: 92%; }
}

